From 5ca1075b714e825006e8ba4f8e7ea5544879bb41 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 4 Apr 2019 11:45:26 -0300 Subject: Added field 'srclen' to structure 'lua_Debug' This new field gets the length of 'source' in the same structure. Unlike the other strings in that structure, 'source' can be relatively large, and Lua already has its length readily available. --- ldblib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ldblib.c') diff --git a/ldblib.c b/ldblib.c index ada35250..d045a82e 100644 --- a/ldblib.c +++ b/ldblib.c @@ -167,7 +167,8 @@ static int db_getinfo (lua_State *L) { return luaL_argerror(L, arg+2, "invalid option"); lua_newtable(L); /* table to collect results */ if (strchr(options, 'S')) { - settabss(L, "source", ar.source); + lua_pushlstring(L, ar.source, ar.srclen); + lua_setfield(L, -2, "source"); settabss(L, "short_src", ar.short_src); settabsi(L, "linedefined", ar.linedefined); settabsi(L, "lastlinedefined", ar.lastlinedefined); -- cgit v1.2.3-55-g6feb