diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
| commit | 72659a06050632da1a9b4c492302be46ac283f6b (patch) | |
| tree | bac06b4ea523ba5443564d0869e392180d4b7b77 /ltests.c | |
| parent | dfaf8c5291fa8aef5bedbfa375853475364ac76e (diff) | |
| download | lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.gz lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.bz2 lua-72659a06050632da1a9b4c492302be46ac283f6b.zip | |
no more explicit support for wide-chars; too much troble...
Diffstat (limited to 'ltests.c')
| -rw-r--r-- | ltests.c | 215 |
1 files changed, 107 insertions, 108 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 1.95 2001/10/26 17:33:30 roberto Exp $ | 2 | ** $Id: ltests.c,v 1.96 2001/11/06 21:41:43 roberto Exp $ |
| 3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -12,7 +12,6 @@ | |||
| 12 | #include <string.h> | 12 | #include <string.h> |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | #define LUA_PRIVATE | ||
| 16 | #include "lua.h" | 15 | #include "lua.h" |
| 17 | 16 | ||
| 18 | #include "lapi.h" | 17 | #include "lapi.h" |
| @@ -43,7 +42,7 @@ int islocked = 0; | |||
| 43 | 42 | ||
| 44 | 43 | ||
| 45 | 44 | ||
| 46 | static void setnameval (lua_State *L, const l_char *name, int val) { | 45 | static void setnameval (lua_State *L, const char *name, int val) { |
| 47 | lua_pushstring(L, name); | 46 | lua_pushstring(L, name); |
| 48 | lua_pushnumber(L, val); | 47 | lua_pushnumber(L, val); |
| 49 | lua_settable(L, -3); | 48 | lua_settable(L, -3); |
| @@ -139,21 +138,21 @@ void *debug_realloc (void *block, size_t oldsize, size_t size) { | |||
| 139 | */ | 138 | */ |
| 140 | 139 | ||
| 141 | 140 | ||
| 142 | static l_char *buildop (Proto *p, int pc, l_char *buff) { | 141 | static char *buildop (Proto *p, int pc, char *buff) { |
| 143 | Instruction i = p->code[pc]; | 142 | Instruction i = p->code[pc]; |
| 144 | OpCode o = GET_OPCODE(i); | 143 | OpCode o = GET_OPCODE(i); |
| 145 | const l_char *name = luaP_opnames[o]; | 144 | const char *name = luaP_opnames[o]; |
| 146 | sprintf(buff, l_s("%4d - "), pc); | 145 | sprintf(buff, "%4d - ", pc); |
| 147 | switch (getOpMode(o)) { | 146 | switch (getOpMode(o)) { |
| 148 | case iABC: | 147 | case iABC: |
| 149 | sprintf(buff+strlen(buff), l_s("%-12s%4d %4d %4d"), name, | 148 | sprintf(buff+strlen(buff), "%-12s%4d %4d %4d", name, |
| 150 | GETARG_A(i), GETARG_B(i), GETARG_C(i)); | 149 | GETARG_A(i), GETARG_B(i), GETARG_C(i)); |
| 151 | break; | 150 | break; |
| 152 | case iABc: | 151 | case iABc: |
| 153 | sprintf(buff+strlen(buff), l_s("%-12s%4d %4d"), name, GETARG_A(i), GETARG_Bc(i)); | 152 | sprintf(buff+strlen(buff), "%-12s%4d %4d", name, GETARG_A(i), GETARG_Bc(i)); |
| 154 | break; | 153 | break; |
| 155 | case iAsBc: | 154 | case iAsBc: |
| 156 | sprintf(buff+strlen(buff), l_s("%-12s%4d %4d"), name, GETARG_A(i), GETARG_sBc(i)); | 155 | sprintf(buff+strlen(buff), "%-12s%4d %4d", name, GETARG_A(i), GETARG_sBc(i)); |
| 157 | break; | 156 | break; |
| 158 | } | 157 | } |
| 159 | return buff; | 158 | return buff; |
| @@ -164,13 +163,13 @@ static int listcode (lua_State *L) { | |||
| 164 | int pc; | 163 | int pc; |
| 165 | Proto *p; | 164 | Proto *p; |
| 166 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 165 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 167 | 1, l_s("Lua function expected")); | 166 | 1, "Lua function expected"); |
| 168 | p = clvalue(luaA_index(L, 1))->l.p; | 167 | p = clvalue(luaA_index(L, 1))->l.p; |
| 169 | lua_newtable(L); | 168 | lua_newtable(L); |
| 170 | setnameval(L, l_s("maxstack"), p->maxstacksize); | 169 | setnameval(L, "maxstack", p->maxstacksize); |
| 171 | setnameval(L, l_s("numparams"), p->numparams); | 170 | setnameval(L, "numparams", p->numparams); |
| 172 | for (pc=0; pc<p->sizecode; pc++) { | 171 | for (pc=0; pc<p->sizecode; pc++) { |
| 173 | l_char buff[100]; | 172 | char buff[100]; |
| 174 | lua_pushnumber(L, pc+1); | 173 | lua_pushnumber(L, pc+1); |
| 175 | lua_pushstring(L, buildop(p, pc, buff)); | 174 | lua_pushstring(L, buildop(p, pc, buff)); |
| 176 | lua_settable(L, -3); | 175 | lua_settable(L, -3); |
| @@ -183,7 +182,7 @@ static int listk (lua_State *L) { | |||
| 183 | Proto *p; | 182 | Proto *p; |
| 184 | int i; | 183 | int i; |
| 185 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 184 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 186 | 1, l_s("Lua function expected")); | 185 | 1, "Lua function expected"); |
| 187 | p = clvalue(luaA_index(L, 1))->l.p; | 186 | p = clvalue(luaA_index(L, 1))->l.p; |
| 188 | lua_newtable(L); | 187 | lua_newtable(L); |
| 189 | for (i=0; i<p->sizek; i++) { | 188 | for (i=0; i<p->sizek; i++) { |
| @@ -199,9 +198,9 @@ static int listlocals (lua_State *L) { | |||
| 199 | Proto *p; | 198 | Proto *p; |
| 200 | int pc = luaL_check_int(L, 2) - 1; | 199 | int pc = luaL_check_int(L, 2) - 1; |
| 201 | int i = 0; | 200 | int i = 0; |
| 202 | const l_char *name; | 201 | const char *name; |
| 203 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), | 202 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), |
| 204 | 1, l_s("Lua function expected")); | 203 | 1, "Lua function expected"); |
| 205 | p = clvalue(luaA_index(L, 1))->l.p; | 204 | p = clvalue(luaA_index(L, 1))->l.p; |
| 206 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) | 205 | while ((name = luaF_getlocalname(p, ++i, pc)) != NULL) |
| 207 | lua_pushstring(L, name); | 206 | lua_pushstring(L, name); |
| @@ -215,12 +214,12 @@ static int listlocals (lua_State *L) { | |||
| 215 | 214 | ||
| 216 | static int get_limits (lua_State *L) { | 215 | static int get_limits (lua_State *L) { |
| 217 | lua_newtable(L); | 216 | lua_newtable(L); |
| 218 | setnameval(L, l_s("BITS_INT"), BITS_INT); | 217 | setnameval(L, "BITS_INT", BITS_INT); |
| 219 | setnameval(L, l_s("LFPF"), LFIELDS_PER_FLUSH); | 218 | setnameval(L, "LFPF", LFIELDS_PER_FLUSH); |
| 220 | setnameval(L, l_s("MAXLOCALS"), MAXLOCALS); | 219 | setnameval(L, "MAXLOCALS", MAXLOCALS); |
| 221 | setnameval(L, l_s("MAXPARAMS"), MAXPARAMS); | 220 | setnameval(L, "MAXPARAMS", MAXPARAMS); |
| 222 | setnameval(L, l_s("MAXSTACK"), MAXSTACK); | 221 | setnameval(L, "MAXSTACK", MAXSTACK); |
| 223 | setnameval(L, l_s("MAXUPVALUES"), MAXUPVALUES); | 222 | setnameval(L, "MAXUPVALUES", MAXUPVALUES); |
| 224 | return 1; | 223 | return 1; |
| 225 | } | 224 | } |
| 226 | 225 | ||
| @@ -241,7 +240,7 @@ static int mem_query (lua_State *L) { | |||
| 241 | 240 | ||
| 242 | static int hash_query (lua_State *L) { | 241 | static int hash_query (lua_State *L) { |
| 243 | if (lua_isnull(L, 2)) { | 242 | if (lua_isnull(L, 2)) { |
| 244 | luaL_arg_check(L, lua_tag(L, 1) == LUA_TSTRING, 1, l_s("string expected")); | 243 | luaL_arg_check(L, lua_tag(L, 1) == LUA_TSTRING, 1, "string expected"); |
| 245 | lua_pushnumber(L, tsvalue(luaA_index(L, 1))->tsv.hash); | 244 | lua_pushnumber(L, tsvalue(luaA_index(L, 1))->tsv.hash); |
| 246 | } | 245 | } |
| 247 | else { | 246 | else { |
| @@ -336,8 +335,8 @@ static int unref (lua_State *L) { | |||
| 336 | 335 | ||
| 337 | static int newuserdata (lua_State *L) { | 336 | static int newuserdata (lua_State *L) { |
| 338 | size_t size = luaL_check_int(L, 1); | 337 | size_t size = luaL_check_int(L, 1); |
| 339 | l_char *p = cast(l_char *, lua_newuserdata(L, size)); | 338 | char *p = cast(char *, lua_newuserdata(L, size)); |
| 340 | while (size--) *p++ = l_c('\0'); | 339 | while (size--) *p++ = '\0'; |
| 341 | return 1; | 340 | return 1; |
| 342 | } | 341 | } |
| 343 | 342 | ||
| @@ -383,7 +382,7 @@ static int s2d (lua_State *L) { | |||
| 383 | 382 | ||
| 384 | static int d2s (lua_State *L) { | 383 | static int d2s (lua_State *L) { |
| 385 | double d = luaL_check_number(L, 1); | 384 | double d = luaL_check_number(L, 1); |
| 386 | lua_pushlstring(L, cast(l_char *, &d), sizeof(d)); | 385 | lua_pushlstring(L, cast(char *, &d), sizeof(d)); |
| 387 | return 1; | 386 | return 1; |
| 388 | } | 387 | } |
| 389 | 388 | ||
| @@ -418,7 +417,7 @@ static int closestate (lua_State *L) { | |||
| 418 | 417 | ||
| 419 | static int doremote (lua_State *L) { | 418 | static int doremote (lua_State *L) { |
| 420 | lua_State *L1; | 419 | lua_State *L1; |
| 421 | const l_char *code = luaL_check_string(L, 2); | 420 | const char *code = luaL_check_string(L, 2); |
| 422 | int status; | 421 | int status; |
| 423 | L1 = cast(lua_State *, cast(unsigned long, luaL_check_number(L, 1))); | 422 | L1 = cast(lua_State *, cast(unsigned long, luaL_check_number(L, 1))); |
| 424 | status = lua_dostring(L1, code); | 423 | status = lua_dostring(L1, code); |
| @@ -438,7 +437,7 @@ static int doremote (lua_State *L) { | |||
| 438 | 437 | ||
| 439 | static int settagmethod (lua_State *L) { | 438 | static int settagmethod (lua_State *L) { |
| 440 | int tag = luaL_check_int(L, 1); | 439 | int tag = luaL_check_int(L, 1); |
| 441 | const l_char *event = luaL_check_string(L, 2); | 440 | const char *event = luaL_check_string(L, 2); |
| 442 | luaL_check_any(L, 3); | 441 | luaL_check_any(L, 3); |
| 443 | lua_gettagmethod(L, tag, event); | 442 | lua_gettagmethod(L, tag, event); |
| 444 | lua_pushvalue(L, 3); | 443 | lua_pushvalue(L, 3); |
| @@ -460,36 +459,36 @@ static int log2_aux (lua_State *L) { | |||
| 460 | ** ======================================================= | 459 | ** ======================================================= |
| 461 | */ | 460 | */ |
| 462 | 461 | ||
| 463 | static const l_char *const delimits = l_s(" \t\n,;"); | 462 | static const char *const delimits = " \t\n,;"; |
| 464 | 463 | ||
| 465 | static void skip (const l_char **pc) { | 464 | static void skip (const char **pc) { |
| 466 | while (**pc != l_c('\0') && strchr(delimits, **pc)) (*pc)++; | 465 | while (**pc != '\0' && strchr(delimits, **pc)) (*pc)++; |
| 467 | } | 466 | } |
| 468 | 467 | ||
| 469 | static int getnum_aux (lua_State *L, const l_char **pc) { | 468 | static int getnum_aux (lua_State *L, const char **pc) { |
| 470 | int res = 0; | 469 | int res = 0; |
| 471 | int sig = 1; | 470 | int sig = 1; |
| 472 | skip(pc); | 471 | skip(pc); |
| 473 | if (**pc == l_c('.')) { | 472 | if (**pc == '.') { |
| 474 | res = cast(int, lua_tonumber(L, -1)); | 473 | res = cast(int, lua_tonumber(L, -1)); |
| 475 | lua_pop(L, 1); | 474 | lua_pop(L, 1); |
| 476 | (*pc)++; | 475 | (*pc)++; |
| 477 | return res; | 476 | return res; |
| 478 | } | 477 | } |
| 479 | else if (**pc == l_c('-')) { | 478 | else if (**pc == '-') { |
| 480 | sig = -1; | 479 | sig = -1; |
| 481 | (*pc)++; | 480 | (*pc)++; |
| 482 | } | 481 | } |
| 483 | while (isdigit(cast(int, **pc))) res = res*10 + (*(*pc)++) - l_c('0'); | 482 | while (isdigit(cast(int, **pc))) res = res*10 + (*(*pc)++) - '0'; |
| 484 | return sig*res; | 483 | return sig*res; |
| 485 | } | 484 | } |
| 486 | 485 | ||
| 487 | static const l_char *getname_aux (l_char *buff, const l_char **pc) { | 486 | static const char *getname_aux (char *buff, const char **pc) { |
| 488 | int i = 0; | 487 | int i = 0; |
| 489 | skip(pc); | 488 | skip(pc); |
| 490 | while (**pc != l_c('\0') && !strchr(delimits, **pc)) | 489 | while (**pc != '\0' && !strchr(delimits, **pc)) |
| 491 | buff[i++] = *(*pc)++; | 490 | buff[i++] = *(*pc)++; |
| 492 | buff[i] = l_c('\0'); | 491 | buff[i] = '\0'; |
| 493 | return buff; | 492 | return buff; |
| 494 | } | 493 | } |
| 495 | 494 | ||
| @@ -501,134 +500,134 @@ static const l_char *getname_aux (l_char *buff, const l_char **pc) { | |||
| 501 | 500 | ||
| 502 | 501 | ||
| 503 | static int testC (lua_State *L) { | 502 | static int testC (lua_State *L) { |
| 504 | l_char buff[30]; | 503 | char buff[30]; |
| 505 | const l_char *pc = luaL_check_string(L, 1); | 504 | const char *pc = luaL_check_string(L, 1); |
| 506 | for (;;) { | 505 | for (;;) { |
| 507 | const l_char *inst = getname; | 506 | const char *inst = getname; |
| 508 | if EQ(l_s("")) return 0; | 507 | if EQ("") return 0; |
| 509 | else if EQ(l_s("isnumber")) { | 508 | else if EQ("isnumber") { |
| 510 | lua_pushnumber(L, lua_isnumber(L, getnum)); | 509 | lua_pushnumber(L, lua_isnumber(L, getnum)); |
| 511 | } | 510 | } |
| 512 | else if EQ(l_s("isstring")) { | 511 | else if EQ("isstring") { |
| 513 | lua_pushnumber(L, lua_isstring(L, getnum)); | 512 | lua_pushnumber(L, lua_isstring(L, getnum)); |
| 514 | } | 513 | } |
| 515 | else if EQ(l_s("istable")) { | 514 | else if EQ("istable") { |
| 516 | lua_pushnumber(L, lua_istable(L, getnum)); | 515 | lua_pushnumber(L, lua_istable(L, getnum)); |
| 517 | } | 516 | } |
| 518 | else if EQ(l_s("iscfunction")) { | 517 | else if EQ("iscfunction") { |
| 519 | lua_pushnumber(L, lua_iscfunction(L, getnum)); | 518 | lua_pushnumber(L, lua_iscfunction(L, getnum)); |
| 520 | } | 519 | } |
| 521 | else if EQ(l_s("isfunction")) { | 520 | else if EQ("isfunction") { |
| 522 | lua_pushnumber(L, lua_isfunction(L, getnum)); | 521 | lua_pushnumber(L, lua_isfunction(L, getnum)); |
| 523 | } | 522 | } |
| 524 | else if EQ(l_s("isuserdata")) { | 523 | else if EQ("isuserdata") { |
| 525 | lua_pushnumber(L, lua_isuserdata(L, getnum)); | 524 | lua_pushnumber(L, lua_isuserdata(L, getnum)); |
| 526 | } | 525 | } |
| 527 | else if EQ(l_s("isnil")) { | 526 | else if EQ("isnil") { |
| 528 | lua_pushnumber(L, lua_isnil(L, getnum)); | 527 | lua_pushnumber(L, lua_isnil(L, getnum)); |
| 529 | } | 528 | } |
| 530 | else if EQ(l_s("isnull")) { | 529 | else if EQ("isnull") { |
| 531 | lua_pushnumber(L, lua_isnull(L, getnum)); | 530 | lua_pushnumber(L, lua_isnull(L, getnum)); |
| 532 | } | 531 | } |
| 533 | else if EQ(l_s("tonumber")) { | 532 | else if EQ("tonumber") { |
| 534 | lua_pushnumber(L, lua_tonumber(L, getnum)); | 533 | lua_pushnumber(L, lua_tonumber(L, getnum)); |
| 535 | } | 534 | } |
| 536 | else if EQ(l_s("tostring")) { | 535 | else if EQ("tostring") { |
| 537 | const l_char *s = lua_tostring(L, getnum); | 536 | const char *s = lua_tostring(L, getnum); |
| 538 | lua_pushstring(L, s); | 537 | lua_pushstring(L, s); |
| 539 | } | 538 | } |
| 540 | else if EQ(l_s("tonumber")) { | 539 | else if EQ("tonumber") { |
| 541 | lua_pushnumber(L, lua_tonumber(L, getnum)); | 540 | lua_pushnumber(L, lua_tonumber(L, getnum)); |
| 542 | } | 541 | } |
| 543 | else if EQ(l_s("strlen")) { | 542 | else if EQ("strlen") { |
| 544 | lua_pushnumber(L, lua_strlen(L, getnum)); | 543 | lua_pushnumber(L, lua_strlen(L, getnum)); |
| 545 | } | 544 | } |
| 546 | else if EQ(l_s("tocfunction")) { | 545 | else if EQ("tocfunction") { |
| 547 | lua_pushcfunction(L, lua_tocfunction(L, getnum)); | 546 | lua_pushcfunction(L, lua_tocfunction(L, getnum)); |
| 548 | } | 547 | } |
| 549 | else if EQ(l_s("return")) { | 548 | else if EQ("return") { |
| 550 | return getnum; | 549 | return getnum; |
| 551 | } | 550 | } |
| 552 | else if EQ(l_s("gettop")) { | 551 | else if EQ("gettop") { |
| 553 | lua_pushnumber(L, lua_gettop(L)); | 552 | lua_pushnumber(L, lua_gettop(L)); |
| 554 | } | 553 | } |
| 555 | else if EQ(l_s("settop")) { | 554 | else if EQ("settop") { |
| 556 | lua_settop(L, getnum); | 555 | lua_settop(L, getnum); |
| 557 | } | 556 | } |
| 558 | else if EQ(l_s("pop")) { | 557 | else if EQ("pop") { |
| 559 | lua_pop(L, getnum); | 558 | lua_pop(L, getnum); |
| 560 | } | 559 | } |
| 561 | else if EQ(l_s("pushnum")) { | 560 | else if EQ("pushnum") { |
| 562 | lua_pushnumber(L, getnum); | 561 | lua_pushnumber(L, getnum); |
| 563 | } | 562 | } |
| 564 | else if EQ(l_s("pushvalue")) { | 563 | else if EQ("pushvalue") { |
| 565 | lua_pushvalue(L, getnum); | 564 | lua_pushvalue(L, getnum); |
| 566 | } | 565 | } |
| 567 | else if EQ(l_s("pushcclosure")) { | 566 | else if EQ("pushcclosure") { |
| 568 | lua_pushcclosure(L, testC, getnum); | 567 | lua_pushcclosure(L, testC, getnum); |
| 569 | } | 568 | } |
| 570 | else if EQ(l_s("pushupvalues")) { | 569 | else if EQ("pushupvalues") { |
| 571 | lua_pushupvalues(L); | 570 | lua_pushupvalues(L); |
| 572 | } | 571 | } |
| 573 | else if EQ(l_s("remove")) { | 572 | else if EQ("remove") { |
| 574 | lua_remove(L, getnum); | 573 | lua_remove(L, getnum); |
| 575 | } | 574 | } |
| 576 | else if EQ(l_s("insert")) { | 575 | else if EQ("insert") { |
| 577 | lua_insert(L, getnum); | 576 | lua_insert(L, getnum); |
| 578 | } | 577 | } |
| 579 | else if EQ(l_s("gettable")) { | 578 | else if EQ("gettable") { |
| 580 | lua_gettable(L, getnum); | 579 | lua_gettable(L, getnum); |
| 581 | } | 580 | } |
| 582 | else if EQ(l_s("settable")) { | 581 | else if EQ("settable") { |
| 583 | lua_settable(L, getnum); | 582 | lua_settable(L, getnum); |
| 584 | } | 583 | } |
| 585 | else if EQ(l_s("next")) { | 584 | else if EQ("next") { |
| 586 | lua_next(L, -2); | 585 | lua_next(L, -2); |
| 587 | } | 586 | } |
| 588 | else if EQ(l_s("concat")) { | 587 | else if EQ("concat") { |
| 589 | lua_concat(L, getnum); | 588 | lua_concat(L, getnum); |
| 590 | } | 589 | } |
| 591 | else if EQ(l_s("lessthan")) { | 590 | else if EQ("lessthan") { |
| 592 | int a = getnum; | 591 | int a = getnum; |
| 593 | if (lua_lessthan(L, a, getnum)) | 592 | if (lua_lessthan(L, a, getnum)) |
| 594 | lua_pushnumber(L, 1); | 593 | lua_pushnumber(L, 1); |
| 595 | else | 594 | else |
| 596 | lua_pushnil(L); | 595 | lua_pushnil(L); |
| 597 | } | 596 | } |
| 598 | else if EQ(l_s("equal")) { | 597 | else if EQ("equal") { |
| 599 | int a = getnum; | 598 | int a = getnum; |
| 600 | if (lua_equal(L, a, getnum)) | 599 | if (lua_equal(L, a, getnum)) |
| 601 | lua_pushnumber(L, 1); | 600 | lua_pushnumber(L, 1); |
| 602 | else | 601 | else |
| 603 | lua_pushnil(L); | 602 | lua_pushnil(L); |
| 604 | } | 603 | } |
| 605 | else if EQ(l_s("rawcall")) { | 604 | else if EQ("rawcall") { |
| 606 | int narg = getnum; | 605 | int narg = getnum; |
| 607 | int nres = getnum; | 606 | int nres = getnum; |
| 608 | lua_rawcall(L, narg, nres); | 607 | lua_rawcall(L, narg, nres); |
| 609 | } | 608 | } |
| 610 | else if EQ(l_s("call")) { | 609 | else if EQ("call") { |
| 611 | int narg = getnum; | 610 | int narg = getnum; |
| 612 | int nres = getnum; | 611 | int nres = getnum; |
| 613 | lua_call(L, narg, nres); | 612 | lua_call(L, narg, nres); |
| 614 | } | 613 | } |
| 615 | else if EQ(l_s("dostring")) { | 614 | else if EQ("dostring") { |
| 616 | lua_dostring(L, luaL_check_string(L, getnum)); | 615 | lua_dostring(L, luaL_check_string(L, getnum)); |
| 617 | } | 616 | } |
| 618 | else if EQ(l_s("settagmethod")) { | 617 | else if EQ("settagmethod") { |
| 619 | int tag = getnum; | 618 | int tag = getnum; |
| 620 | const l_char *event = getname; | 619 | const char *event = getname; |
| 621 | lua_settagmethod(L, tag, event); | 620 | lua_settagmethod(L, tag, event); |
| 622 | } | 621 | } |
| 623 | else if EQ(l_s("gettagmethod")) { | 622 | else if EQ("gettagmethod") { |
| 624 | int tag = getnum; | 623 | int tag = getnum; |
| 625 | const l_char *event = getname; | 624 | const char *event = getname; |
| 626 | lua_gettagmethod(L, tag, event); | 625 | lua_gettagmethod(L, tag, event); |
| 627 | } | 626 | } |
| 628 | else if EQ(l_s("type")) { | 627 | else if EQ("type") { |
| 629 | lua_pushstring(L, lua_type(L, getnum)); | 628 | lua_pushstring(L, lua_type(L, getnum)); |
| 630 | } | 629 | } |
| 631 | else luaL_verror(L, l_s("unknown instruction %.30s"), buff); | 630 | else luaL_verror(L, "unknown instruction %.30s", buff); |
| 632 | } | 631 | } |
| 633 | return 0; | 632 | return 0; |
| 634 | } | 633 | } |
| @@ -638,32 +637,32 @@ static int testC (lua_State *L) { | |||
| 638 | 637 | ||
| 639 | 638 | ||
| 640 | static const struct luaL_reg tests_funcs[] = { | 639 | static const struct luaL_reg tests_funcs[] = { |
| 641 | {l_s("hash"), hash_query}, | 640 | {"hash", hash_query}, |
| 642 | {l_s("limits"), get_limits}, | 641 | {"limits", get_limits}, |
| 643 | {l_s("listcode"), listcode}, | 642 | {"listcode", listcode}, |
| 644 | {l_s("listk"), listk}, | 643 | {"listk", listk}, |
| 645 | {l_s("listlocals"), listlocals}, | 644 | {"listlocals", listlocals}, |
| 646 | {l_s("loadlib"), loadlib}, | 645 | {"loadlib", loadlib}, |
| 647 | {l_s("querystr"), string_query}, | 646 | {"querystr", string_query}, |
| 648 | {l_s("querytab"), table_query}, | 647 | {"querytab", table_query}, |
| 649 | {l_s("testC"), testC}, | 648 | {"testC", testC}, |
| 650 | {l_s("ref"), tref}, | 649 | {"ref", tref}, |
| 651 | {l_s("getref"), getref}, | 650 | {"getref", getref}, |
| 652 | {l_s("unref"), unref}, | 651 | {"unref", unref}, |
| 653 | {l_s("d2s"), d2s}, | 652 | {"d2s", d2s}, |
| 654 | {l_s("s2d"), s2d}, | 653 | {"s2d", s2d}, |
| 655 | {l_s("newuserdata"), newuserdata}, | 654 | {"newuserdata", newuserdata}, |
| 656 | {l_s("newuserdatabox"), newuserdatabox}, | 655 | {"newuserdatabox", newuserdatabox}, |
| 657 | {l_s("settag"), settag}, | 656 | {"settag", settag}, |
| 658 | {l_s("udataval"), udataval}, | 657 | {"udataval", udataval}, |
| 659 | {l_s("newtag"), newtag}, | 658 | {"newtag", newtag}, |
| 660 | {l_s("doonnewstack"), doonnewstack}, | 659 | {"doonnewstack", doonnewstack}, |
| 661 | {l_s("newstate"), newstate}, | 660 | {"newstate", newstate}, |
| 662 | {l_s("closestate"), closestate}, | 661 | {"closestate", closestate}, |
| 663 | {l_s("doremote"), doremote}, | 662 | {"doremote", doremote}, |
| 664 | {l_s("settagmethod"), settagmethod}, | 663 | {"settagmethod", settagmethod}, |
| 665 | {l_s("log2"), log2_aux}, | 664 | {"log2", log2_aux}, |
| 666 | {l_s("totalmem"), mem_query} | 665 | {"totalmem", mem_query} |
| 667 | }; | 666 | }; |
| 668 | 667 | ||
| 669 | 668 | ||
| @@ -677,7 +676,7 @@ void luaB_opentests (lua_State *L) { | |||
| 677 | lua_setglobals(L); | 676 | lua_setglobals(L); |
| 678 | luaL_openl(L, tests_funcs); /* open functions inside new table */ | 677 | luaL_openl(L, tests_funcs); /* open functions inside new table */ |
| 679 | lua_setglobals(L); /* restore old table of globals */ | 678 | lua_setglobals(L); /* restore old table of globals */ |
| 680 | lua_setglobal(L, l_s("T")); /* set new table as global T */ | 679 | lua_setglobal(L, "T"); /* set new table as global T */ |
| 681 | } | 680 | } |
| 682 | 681 | ||
| 683 | #endif | 682 | #endif |
