aboutsummaryrefslogtreecommitdiff
path: root/lstring.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-08-16 17:52:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-08-16 17:52:00 -0300
commitc787dccd9b5c3e55547a2c4bb598c0276de65034 (patch)
treec4cdf2f7319fee48e048472a2044119f541e8da2 /lstring.c
parentb44e35b773bcaa9891d80a117392911ab5f656e5 (diff)
downloadlua-c787dccd9b5c3e55547a2c4bb598c0276de65034.tar.gz
lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.tar.bz2
lua-c787dccd9b5c3e55547a2c4bb598c0276de65034.zip
"const" !!!
Diffstat (limited to 'lstring.c')
-rw-r--r--lstring.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lstring.c b/lstring.c
index db15fc60..3c399d5a 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.18 1999/02/08 16:28:48 roberto Exp roberto $ 2** $Id: lstring.c,v 1.19 1999/02/26 15:49:53 roberto Exp roberto $
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*/
@@ -38,7 +38,7 @@ void luaS_init (void) {
38} 38}
39 39
40 40
41static unsigned long hash_s (char *s, long l) { 41static unsigned long hash_s (const char *s, long l) {
42 unsigned long h = 0; /* seed */ 42 unsigned long h = 0; /* seed */
43 while (l--) 43 while (l--)
44 h = h ^ ((h<<5)+(h>>2)+(unsigned char)*(s++)); 44 h = h ^ ((h<<5)+(h>>2)+(unsigned char)*(s++));
@@ -83,7 +83,7 @@ static void grow (stringtable *tb) {
83} 83}
84 84
85 85
86static TaggedString *newone_s (char *str, long l, unsigned long h) { 86static TaggedString *newone_s (const char *str, long l, unsigned long h) {
87 TaggedString *ts = (TaggedString *)luaM_malloc(sizeof(TaggedString)+l); 87 TaggedString *ts = (TaggedString *)luaM_malloc(sizeof(TaggedString)+l);
88 memcpy(ts->str, str, l); 88 memcpy(ts->str, str, l);
89 ts->str[l] = 0; /* ending 0 */ 89 ts->str[l] = 0; /* ending 0 */
@@ -97,7 +97,7 @@ static TaggedString *newone_s (char *str, long l, unsigned long h) {
97 return ts; 97 return ts;
98} 98}
99 99
100static TaggedString *newone_u (char *buff, int tag, unsigned long h) { 100static TaggedString *newone_u (void *buff, int tag, unsigned long h) {
101 TaggedString *ts = luaM_new(TaggedString); 101 TaggedString *ts = luaM_new(TaggedString);
102 ts->u.d.v = buff; 102 ts->u.d.v = buff;
103 ts->u.d.tag = (tag == LUA_ANYTAG) ? 0 : tag; 103 ts->u.d.tag = (tag == LUA_ANYTAG) ? 0 : tag;
@@ -109,7 +109,7 @@ static TaggedString *newone_u (char *buff, int tag, unsigned long h) {
109 return ts; 109 return ts;
110} 110}
111 111
112static TaggedString *insert_s (char *str, long l, stringtable *tb) { 112static TaggedString *insert_s (const char *str, long l, stringtable *tb) {
113 TaggedString *ts; 113 TaggedString *ts;
114 unsigned long h = hash_s(str, l); 114 unsigned long h = hash_s(str, l);
115 int size = tb->size; 115 int size = tb->size;
@@ -172,16 +172,16 @@ TaggedString *luaS_createudata (void *udata, int tag) {
172 return insert_u(udata, tag, &L->string_root[t]); 172 return insert_u(udata, tag, &L->string_root[t]);
173} 173}
174 174
175TaggedString *luaS_newlstr (char *str, long l) { 175TaggedString *luaS_newlstr (const char *str, long l) {
176 int t = (l==0) ? 0 : ((int)((unsigned char)str[0]*l))%NUM_HASHSTR; 176 int t = (l==0) ? 0 : ((int)((unsigned char)str[0]*l))%NUM_HASHSTR;
177 return insert_s(str, l, &L->string_root[t]); 177 return insert_s(str, l, &L->string_root[t]);
178} 178}
179 179
180TaggedString *luaS_new (char *str) { 180TaggedString *luaS_new (const char *str) {
181 return luaS_newlstr(str, strlen(str)); 181 return luaS_newlstr(str, strlen(str));
182} 182}
183 183
184TaggedString *luaS_newfixedstring (char *str) { 184TaggedString *luaS_newfixedstring (const char *str) {
185 TaggedString *ts = luaS_new(str); 185 TaggedString *ts = luaS_new(str);
186 if (ts->head.marked == 0) 186 if (ts->head.marked == 0)
187 ts->head.marked = 2; /* avoid GC */ 187 ts->head.marked = 2; /* avoid GC */
@@ -282,7 +282,7 @@ void luaS_rawsetglobal (TaggedString *ts, TObject *newval) {
282} 282}
283 283
284 284
285char *luaS_travsymbol (int (*fn)(TObject *)) { 285const char *luaS_travsymbol (int (*fn)(TObject *)) {
286 TaggedString *g; 286 TaggedString *g;
287 for (g=(TaggedString *)L->rootglobal.next; g; g=(TaggedString *)g->head.next) 287 for (g=(TaggedString *)L->rootglobal.next; g; g=(TaggedString *)g->head.next)
288 if (fn(&g->u.s.globalval)) 288 if (fn(&g->u.s.globalval))
@@ -291,7 +291,7 @@ char *luaS_travsymbol (int (*fn)(TObject *)) {
291} 291}
292 292
293 293
294int luaS_globaldefined (char *name) { 294int luaS_globaldefined (const char *name) {
295 TaggedString *ts = luaS_new(name); 295 TaggedString *ts = luaS_new(name);
296 return ts->u.s.globalval.ttype != LUA_T_NIL; 296 return ts->u.s.globalval.ttype != LUA_T_NIL;
297} 297}