diff options
Diffstat (limited to 'lstring.c')
-rw-r--r-- | lstring.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 1.66 2001/08/27 15:16:28 roberto Exp $ | 2 | ** $Id: lstring.c,v 1.67 2001/08/31 19:46:07 roberto Exp $ |
3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -7,7 +7,6 @@ | |||
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
10 | #define LUA_PRIVATE | ||
11 | #include "lua.h" | 10 | #include "lua.h" |
12 | 11 | ||
13 | #include "lmem.h" | 12 | #include "lmem.h" |
@@ -47,15 +46,15 @@ void luaS_resize (lua_State *L, int newsize) { | |||
47 | } | 46 | } |
48 | 47 | ||
49 | 48 | ||
50 | static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) { | 49 | static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) { |
51 | TString *ts = cast(TString *, luaM_malloc(L, sizestring(l))); | 50 | TString *ts = cast(TString *, luaM_malloc(L, sizestring(l))); |
52 | stringtable *tb; | 51 | stringtable *tb; |
53 | ts->tsv.nexthash = NULL; | 52 | ts->tsv.nexthash = NULL; |
54 | ts->tsv.len = l; | 53 | ts->tsv.len = l; |
55 | ts->tsv.hash = h; | 54 | ts->tsv.hash = h; |
56 | ts->tsv.marked = 0; | 55 | ts->tsv.marked = 0; |
57 | memcpy(getstr(ts), str, l*sizeof(l_char)); | 56 | memcpy(getstr(ts), str, l*sizeof(char)); |
58 | getstr(ts)[l] = l_c('\0'); /* ending 0 */ | 57 | getstr(ts)[l] = '\0'; /* ending 0 */ |
59 | tb = &G(L)->strt; | 58 | tb = &G(L)->strt; |
60 | h = lmod(h, tb->size); | 59 | h = lmod(h, tb->size); |
61 | ts->tsv.nexthash = tb->hash[h]; /* chain new entry */ | 60 | ts->tsv.nexthash = tb->hash[h]; /* chain new entry */ |
@@ -67,13 +66,13 @@ static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) { | |||
67 | } | 66 | } |
68 | 67 | ||
69 | 68 | ||
70 | TString *luaS_newlstr (lua_State *L, const l_char *str, size_t l) { | 69 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { |
71 | TString *ts; | 70 | TString *ts; |
72 | lu_hash h = l; /* seed */ | 71 | lu_hash h = l; /* seed */ |
73 | size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ | 72 | size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ |
74 | size_t l1; | 73 | size_t l1; |
75 | for (l1=l; l1>=step; l1-=step) /* compute hash */ | 74 | for (l1=l; l1>=step; l1-=step) /* compute hash */ |
76 | h = h ^ ((h<<5)+(h>>2)+uchar(str[l1-1])); | 75 | h = h ^ ((h<<5)+(h>>2)+(unsigned char)(str[l1-1])); |
77 | for (ts = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; | 76 | for (ts = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; |
78 | ts != NULL; | 77 | ts != NULL; |
79 | ts = ts->tsv.nexthash) { | 78 | ts = ts->tsv.nexthash) { |