aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/ltests.c b/ltests.c
index 03baa6e6..4646c5c9 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.16 2000/04/14 17:46:15 roberto Exp roberto $ 2** $Id: ltests.c,v 1.17 2000/05/08 19:32:53 roberto Exp roberto $
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*/
@@ -14,6 +14,7 @@
14 14
15#include "lapi.h" 15#include "lapi.h"
16#include "lauxlib.h" 16#include "lauxlib.h"
17#include "ldo.h"
17#include "lmem.h" 18#include "lmem.h"
18#include "lopcodes.h" 19#include "lopcodes.h"
19#include "lstate.h" 20#include "lstate.h"
@@ -193,24 +194,22 @@ static void table_query (lua_State *L) {
193 194
194 195
195static void string_query (lua_State *L) { 196static void string_query (lua_State *L) {
196 int h = luaL_check_int(L, 1) - 1; 197 stringtable *tb = (*luaL_check_string(L, 1) == 's') ? &L->strt : &L->udt;
197 int s = luaL_opt_int(L, 2, 0) - 1; 198 int s = luaL_opt_int(L, 2, 0) - 1;
198 if (s==-1) { 199 if (s==-1) {
199 if (h < NUM_HASHS) { 200 lua_pushnumber(L, tb->nuse);
200 lua_pushnumber(L, L->string_root[h].nuse); 201 lua_pushnumber(L, tb->size);
201 lua_pushnumber(L, L->string_root[h].size);
202 }
203 } 202 }
204 else { 203 else if (s < tb->size) {
205 TString *ts = L->string_root[h].hash[s]; 204 TString *ts;
206 for (ts = L->string_root[h].hash[s]; ts; ts = ts->nexthash) { 205 for (ts = tb->hash[s]; ts; ts = ts->nexthash) {
207 if (ts->constindex == -1) lua_pushstring(L, "<USERDATA>"); 206 ttype(L->top) = TAG_STRING;
208 else lua_pushstring(L, ts->str); 207 tsvalue(L->top) = ts;
208 incr_top;
209 } 209 }
210 } 210 }
211} 211}
212 212
213
214/* 213/*
215** {====================================================== 214** {======================================================
216** function to test the API with C. It interprets a kind of "assembler" 215** function to test the API with C. It interprets a kind of "assembler"