summaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/ldblib.c b/ldblib.c
index 80c49ea5..ffe781a6 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.94 2005/03/08 20:10:05 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.95 2005/05/05 20:47:02 roberto Exp roberto $
3** Interface from Lua to its debug API 3** Interface from Lua to its debug API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -77,6 +77,17 @@ static lua_State *getthread (lua_State *L, int *arg) {
77} 77}
78 78
79 79
80static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) {
81 if (L == L1) {
82 lua_pushvalue(L, -2);
83 lua_remove(L, -3);
84 }
85 else
86 lua_xmove(L1, L, 1);
87 lua_setfield(L, -2, fname);
88}
89
90
80static int db_getinfo (lua_State *L) { 91static int db_getinfo (lua_State *L) {
81 lua_Debug ar; 92 lua_Debug ar;
82 int arg; 93 int arg;
@@ -99,34 +110,25 @@ static int db_getinfo (lua_State *L) {
99 if (!lua_getinfo(L1, options, &ar)) 110 if (!lua_getinfo(L1, options, &ar))
100 return luaL_argerror(L, arg+2, "invalid option"); 111 return luaL_argerror(L, arg+2, "invalid option");
101 lua_newtable(L); 112 lua_newtable(L);
102 for (; *options; options++) { 113 if (strchr(options, 'S')) {
103 switch (*options) { 114 settabss(L, "source", ar.source);
104 case 'S': 115 settabss(L, "short_src", ar.short_src);
105 settabss(L, "source", ar.source); 116 settabsi(L, "linedefined", ar.linedefined);
106 settabss(L, "short_src", ar.short_src); 117 settabsi(L, "lastlinedefined", ar.lastlinedefined);
107 settabsi(L, "linedefined", ar.linedefined); 118 settabss(L, "what", ar.what);
108 settabsi(L, "lastlinedefined", ar.lastlinedefined); 119 }
109 settabss(L, "what", ar.what); 120 if (strchr(options, 'l'))
110 break; 121 settabsi(L, "currentline", ar.currentline);
111 case 'l': 122 if (strchr(options, 'u'))
112 settabsi(L, "currentline", ar.currentline); 123 settabsi(L, "nups", ar.nups);
113 break; 124 if (strchr(options, 'n')) {
114 case 'u': 125 settabss(L, "name", ar.name);
115 settabsi(L, "nups", ar.nups); 126 settabss(L, "namewhat", ar.namewhat);
116 break;
117 case 'n':
118 settabss(L, "name", ar.name);
119 settabss(L, "namewhat", ar.namewhat);
120 break;
121 case 'f':
122 if (L == L1)
123 lua_pushvalue(L, -2);
124 else
125 lua_xmove(L1, L, 1);
126 lua_setfield(L, -2, "func");
127 break;
128 }
129 } 127 }
128 if (strchr(options, 'L'))
129 treatstackoption(L, L1, "activelines");
130 if (strchr(options, 'f'))
131 treatstackoption(L, L1, "func");
130 return 1; /* return table */ 132 return 1; /* return table */
131} 133}
132 134