summaryrefslogtreecommitdiffstats
path: root/src/if_lua.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-07-07 23:07:41 +0200
committerBram Moolenaar <Bram@vim.org>2018-07-07 23:07:41 +0200
commitfe08df452af10db8a24dbeb1bd9ef09492a4bc66 (patch)
tree6efc248890dc4e3d4096d52d9b6eb99721e21787 /src/if_lua.c
parent2549acf794109731eab693bd396bb863d0e2cff4 (diff)
patch 8.1.0164: luaeval('vim.buffer().name') returns an errorv8.1.0164
Problem: luaeval('vim.buffer().name') returns an error. Solution: Return an empty string. (Dominique Pelle, closes #3167)
Diffstat (limited to 'src/if_lua.c')
-rw-r--r--src/if_lua.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/if_lua.c b/src/if_lua.c
index df0ef34545..f0d5a4d04d 100644
--- a/src/if_lua.c
+++ b/src/if_lua.c
@@ -1123,9 +1123,11 @@ luaV_buffer_index(lua_State *L)
{
const char *s = lua_tostring(L, 2);
if (strncmp(s, "name", 4) == 0)
- lua_pushstring(L, (char *) b->b_sfname);
+ lua_pushstring(L, (b->b_sfname == NULL)
+ ? "" : (char *) b->b_sfname);
else if (strncmp(s, "fname", 5) == 0)
- lua_pushstring(L, (char *) b->b_ffname);
+ lua_pushstring(L, (b->b_ffname == NULL)
+ ? "" : (char *) b->b_ffname);
else if (strncmp(s, "number", 6) == 0)
lua_pushinteger(L, b->b_fnum);
/* methods */