diff options
Diffstat (limited to 'src/lib_debug.c')
-rw-r--r-- | src/lib_debug.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/lib_debug.c b/src/lib_debug.c index 1487f12b..ab504de7 100644 --- a/src/lib_debug.c +++ b/src/lib_debug.c | |||
@@ -102,7 +102,7 @@ static void treatstackoption(lua_State *L, lua_State *L1, const char *fname) | |||
102 | LJLIB_CF(debug_getinfo) | 102 | LJLIB_CF(debug_getinfo) |
103 | { | 103 | { |
104 | lua_Debug ar; | 104 | lua_Debug ar; |
105 | int arg; | 105 | int arg, opt_f = 0, opt_L = 0; |
106 | lua_State *L1 = getthread(L, &arg); | 106 | lua_State *L1 = getthread(L, &arg); |
107 | const char *options = luaL_optstring(L, arg+2, "flnSu"); | 107 | const char *options = luaL_optstring(L, arg+2, "flnSu"); |
108 | if (lua_isnumber(L, arg+1)) { | 108 | if (lua_isnumber(L, arg+1)) { |
@@ -118,27 +118,34 @@ LJLIB_CF(debug_getinfo) | |||
118 | } | 118 | } |
119 | if (!lua_getinfo(L1, options, &ar)) | 119 | if (!lua_getinfo(L1, options, &ar)) |
120 | lj_err_arg(L, arg+2, LJ_ERR_INVOPT); | 120 | lj_err_arg(L, arg+2, LJ_ERR_INVOPT); |
121 | lua_createtable(L, 0, 16); | 121 | lua_createtable(L, 0, 16); /* Create result table. */ |
122 | if (strchr(options, 'S')) { | 122 | for (; *options; options++) { |
123 | settabss(L, "source", ar.source); | 123 | switch (*options) { |
124 | settabss(L, "short_src", ar.short_src); | 124 | case 'S': |
125 | settabsi(L, "linedefined", ar.linedefined); | 125 | settabss(L, "source", ar.source); |
126 | settabsi(L, "lastlinedefined", ar.lastlinedefined); | 126 | settabss(L, "short_src", ar.short_src); |
127 | settabss(L, "what", ar.what); | 127 | settabsi(L, "linedefined", ar.linedefined); |
128 | } | 128 | settabsi(L, "lastlinedefined", ar.lastlinedefined); |
129 | if (strchr(options, 'l')) | 129 | settabss(L, "what", ar.what); |
130 | settabsi(L, "currentline", ar.currentline); | 130 | break; |
131 | if (strchr(options, 'u')) | 131 | case 'l': |
132 | settabsi(L, "nups", ar.nups); | 132 | settabsi(L, "currentline", ar.currentline); |
133 | if (strchr(options, 'n')) { | 133 | break; |
134 | settabss(L, "name", ar.name); | 134 | case 'u': |
135 | settabss(L, "namewhat", ar.namewhat); | 135 | settabsi(L, "nups", ar.nups); |
136 | break; | ||
137 | case 'n': | ||
138 | settabss(L, "name", ar.name); | ||
139 | settabss(L, "namewhat", ar.namewhat); | ||
140 | break; | ||
141 | case 'f': opt_f = 1; break; | ||
142 | case 'L': opt_L = 1; break; | ||
143 | default: break; | ||
144 | } | ||
136 | } | 145 | } |
137 | if (strchr(options, 'L')) | 146 | if (opt_L) treatstackoption(L, L1, "activelines"); |
138 | treatstackoption(L, L1, "activelines"); | 147 | if (opt_f) treatstackoption(L, L1, "func"); |
139 | if (strchr(options, 'f')) | 148 | return 1; /* Return result table. */ |
140 | treatstackoption(L, L1, "func"); | ||
141 | return 1; /* return table */ | ||
142 | } | 149 | } |
143 | 150 | ||
144 | LJLIB_CF(debug_getlocal) | 151 | LJLIB_CF(debug_getlocal) |