diff options
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -262,18 +262,26 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
262 | static void funcinfo (lua_Debug *ar, Closure *cl) { | 262 | static void funcinfo (lua_Debug *ar, Closure *cl) { |
263 | if (noLuaClosure(cl)) { | 263 | if (noLuaClosure(cl)) { |
264 | ar->source = "=[C]"; | 264 | ar->source = "=[C]"; |
265 | ar->srclen = LL("=[C]"); | ||
265 | ar->linedefined = -1; | 266 | ar->linedefined = -1; |
266 | ar->lastlinedefined = -1; | 267 | ar->lastlinedefined = -1; |
267 | ar->what = "C"; | 268 | ar->what = "C"; |
268 | } | 269 | } |
269 | else { | 270 | else { |
270 | const Proto *p = cl->l.p; | 271 | const Proto *p = cl->l.p; |
271 | ar->source = p->source ? getstr(p->source) : "=?"; | 272 | if (p->source) { |
273 | ar->source = getstr(p->source); | ||
274 | ar->srclen = tsslen(p->source); | ||
275 | } | ||
276 | else { | ||
277 | ar->source = "=?"; | ||
278 | ar->srclen = LL("=?"); | ||
279 | } | ||
272 | ar->linedefined = p->linedefined; | 280 | ar->linedefined = p->linedefined; |
273 | ar->lastlinedefined = p->lastlinedefined; | 281 | ar->lastlinedefined = p->lastlinedefined; |
274 | ar->what = (ar->linedefined == 0) ? "main" : "Lua"; | 282 | ar->what = (ar->linedefined == 0) ? "main" : "Lua"; |
275 | } | 283 | } |
276 | luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); | 284 | luaO_chunkid(ar->short_src, ar->source, ar->srclen); |
277 | } | 285 | } |
278 | 286 | ||
279 | 287 | ||
@@ -750,7 +758,7 @@ const char *luaG_addinfo (lua_State *L, const char *msg, TString *src, | |||
750 | int line) { | 758 | int line) { |
751 | char buff[LUA_IDSIZE]; | 759 | char buff[LUA_IDSIZE]; |
752 | if (src) | 760 | if (src) |
753 | luaO_chunkid(buff, getstr(src), LUA_IDSIZE); | 761 | luaO_chunkid(buff, getstr(src), tsslen(src)); |
754 | else { /* no source available; use "?" instead */ | 762 | else { /* no source available; use "?" instead */ |
755 | buff[0] = '?'; buff[1] = '\0'; | 763 | buff[0] = '?'; buff[1] = '\0'; |
756 | } | 764 | } |