diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-03-06 13:54:42 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-03-06 13:54:42 -0300 |
| commit | 88a2023c3285c4514519158fba90e644fc6ffca3 (patch) | |
| tree | da6611257545c486ff856dd48d66d94e056f3d66 /lbuiltin.c | |
| parent | 5ef1989c4b05aff8362a7ea6ba62aad76d4a040d (diff) | |
| download | lua-88a2023c3285c4514519158fba90e644fc6ffca3.tar.gz lua-88a2023c3285c4514519158fba90e644fc6ffca3.tar.bz2 lua-88a2023c3285c4514519158fba90e644fc6ffca3.zip | |
support for strings with '\0'
Diffstat (limited to 'lbuiltin.c')
| -rw-r--r-- | lbuiltin.c | 25 |
1 files changed, 10 insertions, 15 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbuiltin.c,v 1.24 1998/02/12 19:23:32 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.25 1998/02/12 19:27:10 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 | */ |
| @@ -47,11 +47,11 @@ static void nextvar (void) | |||
| 47 | luaL_arg_check((GCnode *)g != g->head.next, 1, "variable name expected"); | 47 | luaL_arg_check((GCnode *)g != g->head.next, 1, "variable name expected"); |
| 48 | g = (TaggedString *)g->head.next; | 48 | g = (TaggedString *)g->head.next; |
| 49 | } | 49 | } |
| 50 | while (g && g->u.globalval.ttype == LUA_T_NIL) /* skip globals with nil */ | 50 | while (g && g->u.s.globalval.ttype == LUA_T_NIL) /* skip globals with nil */ |
| 51 | g = (TaggedString *)g->head.next; | 51 | g = (TaggedString *)g->head.next; |
| 52 | if (g) { | 52 | if (g) { |
| 53 | pushstring(g); | 53 | pushstring(g); |
| 54 | luaA_pushobject(&g->u.globalval); | 54 | luaA_pushobject(&g->u.s.globalval); |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | 57 | ||
| @@ -65,12 +65,12 @@ static void foreachvar (void) | |||
| 65 | L->stack.top++; | 65 | L->stack.top++; |
| 66 | for (g = L->rootglobal.next; g; g = g->next) { | 66 | for (g = L->rootglobal.next; g; g = g->next) { |
| 67 | TaggedString *s = (TaggedString *)g; | 67 | TaggedString *s = (TaggedString *)g; |
| 68 | if (s->u.globalval.ttype != LUA_T_NIL) { | 68 | if (s->u.s.globalval.ttype != LUA_T_NIL) { |
| 69 | ttype(L->stack.stack+name) = LUA_T_STRING; | 69 | ttype(L->stack.stack+name) = LUA_T_STRING; |
| 70 | tsvalue(L->stack.stack+name) = s; /* keep s on stack to avoid GC */ | 70 | tsvalue(L->stack.stack+name) = s; /* keep s on stack to avoid GC */ |
| 71 | luaA_pushobject(&f); | 71 | luaA_pushobject(&f); |
| 72 | pushstring(s); | 72 | pushstring(s); |
| 73 | luaA_pushobject(&s->u.globalval); | 73 | luaA_pushobject(&s->u.s.globalval); |
| 74 | luaD_call((L->stack.top-L->stack.stack)-2, 1); | 74 | luaD_call((L->stack.top-L->stack.stack)-2, 1); |
| 75 | if (ttype(L->stack.top-1) != LUA_T_NIL) | 75 | if (ttype(L->stack.top-1) != LUA_T_NIL) |
| 76 | return; | 76 | return; |
| @@ -331,22 +331,17 @@ static void copytagmethods (void) | |||
| 331 | 331 | ||
| 332 | static void rawgettable (void) | 332 | static void rawgettable (void) |
| 333 | { | 333 | { |
| 334 | lua_Object t = luaL_nonnullarg(1); | 334 | lua_pushobject(luaL_nonnullarg(1)); |
| 335 | lua_Object i = luaL_nonnullarg(2); | 335 | lua_pushobject(luaL_nonnullarg(2)); |
| 336 | lua_pushobject(t); | ||
| 337 | lua_pushobject(i); | ||
| 338 | lua_pushobject(lua_rawgettable()); | 336 | lua_pushobject(lua_rawgettable()); |
| 339 | } | 337 | } |
| 340 | 338 | ||
| 341 | 339 | ||
| 342 | static void rawsettable (void) | 340 | static void rawsettable (void) |
| 343 | { | 341 | { |
| 344 | lua_Object t = luaL_nonnullarg(1); | 342 | lua_pushobject(luaL_nonnullarg(1)); |
| 345 | lua_Object i = luaL_nonnullarg(2); | 343 | lua_pushobject(luaL_nonnullarg(2)); |
| 346 | lua_Object v = luaL_nonnullarg(3); | 344 | lua_pushobject(luaL_nonnullarg(3)); |
| 347 | lua_pushobject(t); | ||
| 348 | lua_pushobject(i); | ||
| 349 | lua_pushobject(v); | ||
| 350 | lua_rawsettable(); | 345 | lua_rawsettable(); |
| 351 | } | 346 | } |
| 352 | 347 | ||
