aboutsummaryrefslogtreecommitdiff
path: root/lbuiltin.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbuiltin.c')
-rw-r--r--lbuiltin.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/lbuiltin.c b/lbuiltin.c
index ae420830..384f77c0 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.59 1999/06/17 17:04:03 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.60 1999/07/22 19:35:41 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -42,7 +42,7 @@ static void pushtagstring (TaggedString *s) {
42} 42}
43 43
44 44
45static real getsize (Hash *h) { 45static real getsize (const Hash *h) {
46 real max = 0; 46 real max = 0;
47 int i; 47 int i;
48 for (i = 0; i<nhash(h); i++) { 48 for (i = 0; i<nhash(h); i++) {
@@ -56,7 +56,7 @@ static real getsize (Hash *h) {
56} 56}
57 57
58 58
59static real getnarg (Hash *a) { 59static real getnarg (const Hash *a) {
60 TObject index; 60 TObject index;
61 TObject *value; 61 TObject *value;
62 /* value = table.n */ 62 /* value = table.n */
@@ -146,10 +146,10 @@ static void luaB_tonumber (void) {
146 else lua_pushnil(); /* not a number */ 146 else lua_pushnil(); /* not a number */
147 } 147 }
148 else { 148 else {
149 char *s = luaL_check_string(1); 149 char *s;
150 long n; 150 long n;
151 luaL_arg_check(0 <= base && base <= 36, 2, "base out of range"); 151 luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
152 n = strtol(s, &s, base); 152 n = strtol(luaL_check_string(1), &s, base);
153 while (isspace((unsigned char)*s)) s++; /* skip trailing spaces */ 153 while (isspace((unsigned char)*s)) s++; /* skip trailing spaces */
154 if (*s) lua_pushnil(); /* invalid format: return nil */ 154 if (*s) lua_pushnil(); /* invalid format: return nil */
155 else lua_pushnumber(n); 155 else lua_pushnumber(n);
@@ -162,7 +162,7 @@ static void luaB_error (void) {
162} 162}
163 163
164static void luaB_setglobal (void) { 164static void luaB_setglobal (void) {
165 char *n = luaL_check_string(1); 165 const char *n = luaL_check_string(1);
166 lua_Object value = luaL_nonnullarg(2); 166 lua_Object value = luaL_nonnullarg(2);
167 lua_pushobject(value); 167 lua_pushobject(value);
168 lua_setglobal(n); 168 lua_setglobal(n);
@@ -170,7 +170,7 @@ static void luaB_setglobal (void) {
170} 170}
171 171
172static void luaB_rawsetglobal (void) { 172static void luaB_rawsetglobal (void) {
173 char *n = luaL_check_string(1); 173 const char *n = luaL_check_string(1);
174 lua_Object value = luaL_nonnullarg(2); 174 lua_Object value = luaL_nonnullarg(2);
175 lua_pushobject(value); 175 lua_pushobject(value);
176 lua_rawsetglobal(n); 176 lua_rawsetglobal(n);
@@ -250,7 +250,7 @@ static void luaB_collectgarbage (void) {
250 250
251static void luaB_dostring (void) { 251static void luaB_dostring (void) {
252 long l; 252 long l;
253 char *s = luaL_check_lstr(1, &l); 253 const char *s = luaL_check_lstr(1, &l);
254 if (*s == ID_CHUNK) 254 if (*s == ID_CHUNK)
255 lua_error("`dostring' cannot run pre-compiled code"); 255 lua_error("`dostring' cannot run pre-compiled code");
256 if (lua_dobuffer(s, l, luaL_opt_string(2, s)) == 0) 256 if (lua_dobuffer(s, l, luaL_opt_string(2, s)) == 0)
@@ -260,7 +260,7 @@ static void luaB_dostring (void) {
260 260
261 261
262static void luaB_dofile (void) { 262static void luaB_dofile (void) {
263 char *fname = luaL_opt_string(1, NULL); 263 const char *fname = luaL_opt_string(1, NULL);
264 if (lua_dofile(fname) == 0) 264 if (lua_dofile(fname) == 0)
265 if (luaA_passresults() == 0) 265 if (luaA_passresults() == 0)
266 lua_pushuserdata(NULL); /* at least one result to signal no errors */ 266 lua_pushuserdata(NULL); /* at least one result to signal no errors */
@@ -269,8 +269,8 @@ static void luaB_dofile (void) {
269 269
270static void luaB_call (void) { 270static void luaB_call (void) {
271 lua_Object f = luaL_nonnullarg(1); 271 lua_Object f = luaL_nonnullarg(1);
272 Hash *arg = gethash(2); 272 const Hash *arg = gethash(2);
273 char *options = luaL_opt_string(3, ""); 273 const char *options = luaL_opt_string(3, "");
274 lua_Object err = lua_getparam(4); 274 lua_Object err = lua_getparam(4);
275 int narg = (int)getnarg(arg); 275 int narg = (int)getnarg(arg);
276 int i, status; 276 int i, status;
@@ -305,7 +305,7 @@ static void luaB_call (void) {
305 305
306 306
307static void luaB_nextvar (void) { 307static void luaB_nextvar (void) {
308 TObject *o = luaA_Address(luaL_nonnullarg(1)); 308 const TObject *o = luaA_Address(luaL_nonnullarg(1));
309 TaggedString *g; 309 TaggedString *g;
310 if (ttype(o) == LUA_T_NIL) 310 if (ttype(o) == LUA_T_NIL)
311 g = NULL; 311 g = NULL;
@@ -319,8 +319,8 @@ static void luaB_nextvar (void) {
319 319
320 320
321static void luaB_next (void) { 321static void luaB_next (void) {
322 Hash *a = gethash(1); 322 const Hash *a = gethash(1);
323 TObject *k = luaA_Address(luaL_nonnullarg(2)); 323 const TObject *k = luaA_Address(luaL_nonnullarg(2));
324 int i = (ttype(k) == LUA_T_NIL) ? 0 : luaH_pos(a, k)+1; 324 int i = (ttype(k) == LUA_T_NIL) ? 0 : luaH_pos(a, k)+1;
325 if (luaA_next(a, i) == 0) 325 if (luaA_next(a, i) == 0)
326 lua_pushnil(); 326 lua_pushnil();
@@ -329,7 +329,7 @@ static void luaB_next (void) {
329 329
330static void luaB_tostring (void) { 330static void luaB_tostring (void) {
331 lua_Object obj = lua_getparam(1); 331 lua_Object obj = lua_getparam(1);
332 TObject *o = luaA_Address(obj); 332 const TObject *o = luaA_Address(obj);
333 char buff[64]; 333 char buff[64];
334 switch (ttype(o)) { 334 switch (ttype(o)) {
335 case LUA_T_NUMBER: 335 case LUA_T_NUMBER:
@@ -391,7 +391,7 @@ static void luaB_assert (void) {
391 391
392 392
393static void luaB_foreachi (void) { 393static void luaB_foreachi (void) {
394 Hash *t = gethash(1); 394 const Hash *t = gethash(1);
395 int i; 395 int i;
396 int n = (int)getnarg(t); 396 int n = (int)getnarg(t);
397 TObject f; 397 TObject f;
@@ -413,13 +413,13 @@ static void luaB_foreachi (void) {
413 413
414 414
415static void luaB_foreach (void) { 415static void luaB_foreach (void) {
416 Hash *a = gethash(1); 416 const Hash *a = gethash(1);
417 int i; 417 int i;
418 TObject f; /* see comment in 'foreachi' */ 418 TObject f; /* see comment in 'foreachi' */
419 f = *luaA_Address(luaL_functionarg(2)); 419 f = *luaA_Address(luaL_functionarg(2));
420 luaD_checkstack(3); /* for f, ref, and val */ 420 luaD_checkstack(3); /* for f, ref, and val */
421 for (i=0; i<a->nhash; i++) { 421 for (i=0; i<a->nhash; i++) {
422 Node *nd = &(a->node[i]); 422 const Node *nd = &(a->node[i]);
423 if (ttype(val(nd)) != LUA_T_NIL) { 423 if (ttype(val(nd)) != LUA_T_NIL) {
424 *(L->stack.top++) = f; 424 *(L->stack.top++) = f;
425 *(L->stack.top++) = *ref(nd); 425 *(L->stack.top++) = *ref(nd);
@@ -504,7 +504,7 @@ static void swap (Hash *a, int i, int j) {
504 luaH_setint(a, j, &temp); 504 luaH_setint(a, j, &temp);
505} 505}
506 506
507static int sort_comp (lua_Object f, TObject *a, TObject *b) { 507static int sort_comp (lua_Object f, const TObject *a, const TObject *b) {
508 /* notice: the caller (auxsort) must check stack space */ 508 /* notice: the caller (auxsort) must check stack space */
509 if (f != LUA_NOOBJECT) { 509 if (f != LUA_NOOBJECT) {
510 *(L->stack.top) = *luaA_Address(f); 510 *(L->stack.top) = *luaA_Address(f);
@@ -604,7 +604,7 @@ static void query_strings (void) {
604 604
605 605
606static void countlist (void) { 606static void countlist (void) {
607 char *s = luaL_check_string(1); 607 const char *s = luaL_check_string(1);
608 GCnode *l = (s[0]=='t') ? L->roottable.next : (s[0]=='c') ? L->rootcl.next : 608 GCnode *l = (s[0]=='t') ? L->roottable.next : (s[0]=='c') ? L->rootcl.next :
609 (s[0]=='p') ? L->rootproto.next : L->rootglobal.next; 609 (s[0]=='p') ? L->rootproto.next : L->rootglobal.next;
610 int i=0; 610 int i=0;
@@ -623,7 +623,7 @@ static void testC (void) {
623 static int locks[10]; 623 static int locks[10];
624 lua_Object reg[10]; 624 lua_Object reg[10];
625 char nome[2]; 625 char nome[2];
626 char *s = luaL_check_string(1); 626 const char *s = luaL_check_string(1);
627 nome[1] = 0; 627 nome[1] = 0;
628 for (;;) { 628 for (;;) {
629 switch (*s++) { 629 switch (*s++) {
@@ -674,7 +674,7 @@ static void testC (void) {
674 674
675 675
676 676
677static struct luaL_reg builtin_funcs[] = { 677static const struct luaL_reg builtin_funcs[] = {
678#ifdef LUA_COMPAT2_5 678#ifdef LUA_COMPAT2_5
679 {"setfallback", luaT_setfallback}, 679 {"setfallback", luaT_setfallback},
680#endif 680#endif