From 73aa465a8ed8dee6c6a27a6f8b2f51227b70789d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 10 Mar 2000 15:37:44 -0300 Subject: some name changes --- lstring.c | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'lstring.c') diff --git a/lstring.c b/lstring.c index 7e10da33..1dd4c9b9 100644 --- a/lstring.c +++ b/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 1.32 2000/03/03 14:58:26 roberto Exp roberto $ +** $Id: lstring.c,v 1.33 2000/03/10 14:38:10 roberto Exp roberto $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -17,7 +17,7 @@ -#define gcsizestring(L, l) numblocks(L, 0, sizeof(TaggedString)+l) +#define gcsizestring(L, l) numblocks(L, 0, sizeof(TString)+l) #define gcsizeudata gcsizestring(L, 0) @@ -28,7 +28,7 @@ void luaS_init (lua_State *L) { for (i=0; istring_root[i].size = 1; L->string_root[i].nuse = 0; - L->string_root[i].hash = luaM_newvector(L, 1, TaggedString *);; + L->string_root[i].hash = luaM_newvector(L, 1, TString *);; L->string_root[i].hash[0] = NULL; } } @@ -54,14 +54,14 @@ static unsigned long hash_s (const char *s, long l) { void luaS_resize (lua_State *L, stringtable *tb, int newsize) { - TaggedString **newhash = luaM_newvector(L, newsize, TaggedString *); + TString **newhash = luaM_newvector(L, newsize, TString *); int i; for (i=0; isize; i++) { - TaggedString *p = tb->hash[i]; + TString *p = tb->hash[i]; while (p) { /* for each node in the list */ - TaggedString *next = p->nexthash; /* save next */ + TString *next = p->nexthash; /* save next */ int h = p->hash&(newsize-1); /* new position */ LUA_ASSERT(L, p->hash%newsize == (p->hash&(newsize-1)), "a&(x-1) == a%x, for x power of 2"); @@ -76,9 +76,9 @@ void luaS_resize (lua_State *L, stringtable *tb, int newsize) { } -static TaggedString *newone (lua_State *L, long l, unsigned long h) { - TaggedString *ts = (TaggedString *)luaM_malloc(L, - sizeof(TaggedString)+l*sizeof(char)); +static TString *newone (lua_State *L, long l, unsigned long h) { + TString *ts = (TString *)luaM_malloc(L, + sizeof(TString)+l*sizeof(char)); ts->marked = 0; ts->nexthash = NULL; ts->hash = h; @@ -86,9 +86,9 @@ static TaggedString *newone (lua_State *L, long l, unsigned long h) { } -static TaggedString *newone_s (lua_State *L, const char *str, +static TString *newone_s (lua_State *L, const char *str, long l, unsigned long h) { - TaggedString *ts = newone(L, l, h); + TString *ts = newone(L, l, h); memcpy(ts->str, str, l); ts->str[l] = 0; /* ending 0 */ ts->u.s.gv = NULL; /* no global value */ @@ -99,9 +99,9 @@ static TaggedString *newone_s (lua_State *L, const char *str, } -static TaggedString *newone_u (lua_State *L, void *buff, +static TString *newone_u (lua_State *L, void *buff, int tag, unsigned long h) { - TaggedString *ts = newone(L, 0, h); + TString *ts = newone(L, 0, h); ts->u.d.value = buff; ts->u.d.tag = (tag == LUA_ANYTAG) ? 0 : tag; ts->constindex = -1; /* tag -> this is a userdata */ @@ -110,7 +110,7 @@ static TaggedString *newone_u (lua_State *L, void *buff, } -static void newentry (lua_State *L, stringtable *tb, TaggedString *ts, int h) { +static void newentry (lua_State *L, stringtable *tb, TString *ts, int h) { ts->nexthash = tb->hash[h]; /* chain new entry */ tb->hash[h] = ts; tb->nuse++; @@ -119,12 +119,12 @@ static void newentry (lua_State *L, stringtable *tb, TaggedString *ts, int h) { } -TaggedString *luaS_newlstr (lua_State *L, const char *str, long l) { +TString *luaS_newlstr (lua_State *L, const char *str, long l) { unsigned long h = hash_s(str, l); stringtable *tb = &L->string_root[(l==0) ? 0 : ((unsigned int)(str[0]+str[l-1]))&(NUM_HASHSTR-1)]; int h1 = h&(tb->size-1); - TaggedString *ts; + TString *ts; for (ts = tb->hash[h1]; ts; ts = ts->nexthash) { if (ts->u.s.len == l && (memcmp(str, ts->str, l) == 0)) return ts; @@ -140,11 +140,11 @@ TaggedString *luaS_newlstr (lua_State *L, const char *str, long l) { ** uses '%' for one hashing with userdata because addresses are too regular, ** so two '&' operations would be highly correlated */ -TaggedString *luaS_createudata (lua_State *L, void *udata, int tag) { +TString *luaS_createudata (lua_State *L, void *udata, int tag) { unsigned long h = IntPoint(L, udata); stringtable *tb = &L->string_root[(h%NUM_HASHUDATA)+NUM_HASHSTR]; int h1 = h&(tb->size-1); - TaggedString *ts; + TString *ts; for (ts = tb->hash[h1]; ts; ts = ts->nexthash) { if (udata == ts->u.d.value && (tag == ts->u.d.tag || tag == LUA_ANYTAG)) return ts; @@ -156,18 +156,18 @@ TaggedString *luaS_createudata (lua_State *L, void *udata, int tag) { } -TaggedString *luaS_new (lua_State *L, const char *str) { +TString *luaS_new (lua_State *L, const char *str) { return luaS_newlstr(L, str, strlen(str)); } -TaggedString *luaS_newfixed (lua_State *L, const char *str) { - TaggedString *ts = luaS_new(L, str); +TString *luaS_newfixed (lua_State *L, const char *str) { + TString *ts = luaS_new(L, str); if (ts->marked == 0) ts->marked = FIXMARK; /* avoid GC */ return ts; } -void luaS_free (lua_State *L, TaggedString *t) { +void luaS_free (lua_State *L, TString *t) { if (t->constindex == -1) /* is userdata? */ L->nblocks -= gcsizeudata; else { /* is string */ @@ -178,11 +178,11 @@ void luaS_free (lua_State *L, TaggedString *t) { } -GlobalVar *luaS_assertglobal (lua_State *L, TaggedString *ts) { +GlobalVar *luaS_assertglobal (lua_State *L, TString *ts) { GlobalVar *gv = ts->u.s.gv; if (!gv) { /* no global value yet? */ gv = luaM_new(L, GlobalVar); - gv->value.ttype = LUA_T_NIL; /* initial value */ + gv->value.ttype = TAG_NIL; /* initial value */ gv->name = ts; gv->next = L->rootglobal; /* chain in global list */ L->rootglobal = gv; @@ -198,8 +198,8 @@ GlobalVar *luaS_assertglobalbyname (lua_State *L, const char *name) { int luaS_globaldefined (lua_State *L, const char *name) { - TaggedString *ts = luaS_new(L, name); - return ts->u.s.gv && ts->u.s.gv->value.ttype != LUA_T_NIL; + TString *ts = luaS_new(L, name); + return ts->u.s.gv && ts->u.s.gv->value.ttype != TAG_NIL; } -- cgit v1.2.3-55-g6feb