aboutsummaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/ldblib.c b/ldblib.c
index 73024335..906a0754 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.31 2001/01/10 16:58:11 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.32 2001/02/02 19:02:40 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*/
@@ -17,14 +17,14 @@
17 17
18 18
19 19
20static void settabss (lua_State *L, const char *i, const char *v) { 20static void settabss (lua_State *L, const l_char *i, const l_char *v) {
21 lua_pushstring(L, i); 21 lua_pushstring(L, i);
22 lua_pushstring(L, v); 22 lua_pushstring(L, v);
23 lua_settable(L, -3); 23 lua_settable(L, -3);
24} 24}
25 25
26 26
27static void settabsi (lua_State *L, const char *i, int v) { 27static void settabsi (lua_State *L, const l_char *i, int v) {
28 lua_pushstring(L, i); 28 lua_pushstring(L, i);
29 lua_pushnumber(L, v); 29 lua_pushnumber(L, v);
30 lua_settable(L, -3); 30 lua_settable(L, -3);
@@ -33,8 +33,8 @@ static void settabsi (lua_State *L, const char *i, int v) {
33 33
34static int getinfo (lua_State *L) { 34static int getinfo (lua_State *L) {
35 lua_Debug ar; 35 lua_Debug ar;
36 const char *options = luaL_opt_string(L, 2, "flnSu"); 36 const l_char *options = luaL_opt_string(L, 2, l_s("flnSu"));
37 char buff[20]; 37 l_char buff[20];
38 if (lua_isnumber(L, 1)) { 38 if (lua_isnumber(L, 1)) {
39 if (!lua_getstack(L, (int)lua_tonumber(L, 1), &ar)) { 39 if (!lua_getstack(L, (int)lua_tonumber(L, 1), &ar)) {
40 lua_pushnil(L); /* level out of range */ 40 lua_pushnil(L); /* level out of range */
@@ -43,35 +43,35 @@ static int getinfo (lua_State *L) {
43 } 43 }
44 else if (lua_isfunction(L, 1)) { 44 else if (lua_isfunction(L, 1)) {
45 lua_pushvalue(L, 1); 45 lua_pushvalue(L, 1);
46 sprintf(buff, ">%.10s", options); 46 sprintf(buff, l_s(">%.10s"), options);
47 options = buff; 47 options = buff;
48 } 48 }
49 else 49 else
50 luaL_argerror(L, 1, "function or level expected"); 50 luaL_argerror(L, 1, l_s("function or level expected"));
51 if (!lua_getinfo(L, options, &ar)) 51 if (!lua_getinfo(L, options, &ar))
52 luaL_argerror(L, 2, "invalid option"); 52 luaL_argerror(L, 2, l_s("invalid option"));
53 lua_newtable(L); 53 lua_newtable(L);
54 for (; *options; options++) { 54 for (; *options; options++) {
55 switch (*options) { 55 switch (*options) {
56 case 'S': 56 case l_c('S'):
57 settabss(L, "source", ar.source); 57 settabss(L, l_s("source"), ar.source);
58 if (ar.source) 58 if (ar.source)
59 settabss(L, "short_src", ar.short_src); 59 settabss(L, l_s("short_src"), ar.short_src);
60 settabsi(L, "linedefined", ar.linedefined); 60 settabsi(L, l_s("linedefined"), ar.linedefined);
61 settabss(L, "what", ar.what); 61 settabss(L, l_s("what"), ar.what);
62 break; 62 break;
63 case 'l': 63 case l_c('l'):
64 settabsi(L, "currentline", ar.currentline); 64 settabsi(L, l_s("currentline"), ar.currentline);
65 break; 65 break;
66 case 'u': 66 case l_c('u'):
67 settabsi(L, "nups", ar.nups); 67 settabsi(L, l_s("nups"), ar.nups);
68 break; 68 break;
69 case 'n': 69 case l_c('n'):
70 settabss(L, "name", ar.name); 70 settabss(L, l_s("name"), ar.name);
71 settabss(L, "namewhat", ar.namewhat); 71 settabss(L, l_s("namewhat"), ar.namewhat);
72 break; 72 break;
73 case 'f': 73 case l_c('f'):
74 lua_pushliteral(L, "func"); 74 lua_pushliteral(L, l_s("func"));
75 lua_pushvalue(L, -3); 75 lua_pushvalue(L, -3);
76 lua_settable(L, -3); 76 lua_settable(L, -3);
77 break; 77 break;
@@ -83,9 +83,9 @@ static int getinfo (lua_State *L) {
83 83
84static int getlocal (lua_State *L) { 84static int getlocal (lua_State *L) {
85 lua_Debug ar; 85 lua_Debug ar;
86 const char *name; 86 const l_char *name;
87 if (!lua_getstack(L, luaL_check_int(L, 1), &ar)) /* level out of range? */ 87 if (!lua_getstack(L, luaL_check_int(L, 1), &ar)) /* level out of range? */
88 luaL_argerror(L, 1, "level out of range"); 88 luaL_argerror(L, 1, l_s("level out of range"));
89 name = lua_getlocal(L, &ar, luaL_check_int(L, 2)); 89 name = lua_getlocal(L, &ar, luaL_check_int(L, 2));
90 if (name) { 90 if (name) {
91 lua_pushstring(L, name); 91 lua_pushstring(L, name);
@@ -102,7 +102,7 @@ static int getlocal (lua_State *L) {
102static int setlocal (lua_State *L) { 102static int setlocal (lua_State *L) {
103 lua_Debug ar; 103 lua_Debug ar;
104 if (!lua_getstack(L, luaL_check_int(L, 1), &ar)) /* level out of range? */ 104 if (!lua_getstack(L, luaL_check_int(L, 1), &ar)) /* level out of range? */
105 luaL_argerror(L, 1, "level out of range"); 105 luaL_argerror(L, 1, l_s("level out of range"));
106 luaL_checkany(L, 3); 106 luaL_checkany(L, 3);
107 lua_pushstring(L, lua_setlocal(L, &ar, luaL_check_int(L, 2))); 107 lua_pushstring(L, lua_setlocal(L, &ar, luaL_check_int(L, 2)));
108 return 1; 108 return 1;
@@ -111,7 +111,7 @@ static int setlocal (lua_State *L) {
111 111
112 112
113/* dummy variables (to define unique addresses) */ 113/* dummy variables (to define unique addresses) */
114static const char key1[] = "ab"; 114static const l_char key1[] = l_s("ab");
115#define KEY_CALLHOOK ((void *)key1) 115#define KEY_CALLHOOK ((void *)key1)
116#define KEY_LINEHOOK ((void *)(key1+1)) 116#define KEY_LINEHOOK ((void *)(key1+1))
117 117
@@ -150,7 +150,7 @@ static void sethook (lua_State *L, void *key, lua_Hook hook,
150 else if (lua_isfunction(L, 1)) 150 else if (lua_isfunction(L, 1))
151 (*sethookf)(L, hook); 151 (*sethookf)(L, hook);
152 else 152 else
153 luaL_argerror(L, 1, "function expected"); 153 luaL_argerror(L, 1, l_s("function expected"));
154 lua_getregistry(L); 154 lua_getregistry(L);
155 lua_pushuserdata(L, key); 155 lua_pushuserdata(L, key);
156 lua_pushvalue(L, -1); /* dup key */ 156 lua_pushvalue(L, -1); /* dup key */
@@ -174,11 +174,11 @@ static int setlinehook (lua_State *L) {
174 174
175 175
176static const luaL_reg dblib[] = { 176static const luaL_reg dblib[] = {
177 {"getlocal", getlocal}, 177 {l_s("getlocal"), getlocal},
178 {"getinfo", getinfo}, 178 {l_s("getinfo"), getinfo},
179 {"setcallhook", setcallhook}, 179 {l_s("setcallhook"), setcallhook},
180 {"setlinehook", setlinehook}, 180 {l_s("setlinehook"), setlinehook},
181 {"setlocal", setlocal} 181 {l_s("setlocal"), setlocal}
182}; 182};
183 183
184 184