diff options
| -rw-r--r-- | lbuiltin.c | 12 | ||||
| -rw-r--r-- | lstrlib.c | 4 |
2 files changed, 11 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbuiltin.c,v 1.30 1998/06/19 16:14:09 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.31 1998/06/19 18:47:06 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 | */ |
| @@ -54,6 +54,7 @@ static void nextvar (void) | |||
| 54 | pushstring(g); | 54 | pushstring(g); |
| 55 | luaA_pushobject(&g->u.s.globalval); | 55 | luaA_pushobject(&g->u.s.globalval); |
| 56 | } | 56 | } |
| 57 | else lua_pushnil(); | ||
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | 60 | ||
| @@ -90,6 +91,7 @@ static void next (void) | |||
| 90 | luaA_pushobject(&n->ref); | 91 | luaA_pushobject(&n->ref); |
| 91 | luaA_pushobject(&n->val); | 92 | luaA_pushobject(&n->val); |
| 92 | } | 93 | } |
| 94 | else lua_pushnil(); | ||
| 93 | } | 95 | } |
| 94 | 96 | ||
| 95 | 97 | ||
| @@ -214,8 +216,8 @@ static void tonumber (void) | |||
| 214 | luaL_arg_check(0 <= base && base <= 36, 2, "base out of range"); | 216 | luaL_arg_check(0 <= base && base <= 36, 2, "base out of range"); |
| 215 | n = strtol(s, &s, base); | 217 | n = strtol(s, &s, base); |
| 216 | while (isspace(*s)) s++; /* skip trailing spaces */ | 218 | while (isspace(*s)) s++; /* skip trailing spaces */ |
| 217 | if (*s) return; /* invalid format: return nil */ | 219 | if (*s) lua_pushnil(); /* invalid format: return nil */ |
| 218 | lua_pushnumber(n); | 220 | else lua_pushnumber(n); |
| 219 | } | 221 | } |
| 220 | } | 222 | } |
| 221 | 223 | ||
| @@ -303,8 +305,10 @@ static void luaI_call (void) | |||
| 303 | lua_seterrormethod(); | 305 | lua_seterrormethod(); |
| 304 | } | 306 | } |
| 305 | if (status != 0) { /* error in call? */ | 307 | if (status != 0) { /* error in call? */ |
| 306 | if (strchr(options, 'x')) | 308 | if (strchr(options, 'x')) { |
| 309 | lua_pushnil(); | ||
| 307 | return; /* return nil to signal the error */ | 310 | return; /* return nil to signal the error */ |
| 311 | } | ||
| 308 | else | 312 | else |
| 309 | lua_error(NULL); | 313 | lua_error(NULL); |
| 310 | } | 314 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstrlib.c,v 1.15 1998/06/19 16:14:09 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.16 1998/06/24 13:33:00 roberto Exp roberto $ |
| 3 | ** Standard library for strings and pattern-matching | 3 | ** Standard library for strings and pattern-matching |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -346,6 +346,7 @@ static void str_find (void) | |||
| 346 | if (s2) { | 346 | if (s2) { |
| 347 | lua_pushnumber(s2-s+1); | 347 | lua_pushnumber(s2-s+1); |
| 348 | lua_pushnumber(s2-s+strlen(p)); | 348 | lua_pushnumber(s2-s+strlen(p)); |
| 349 | return; | ||
| 349 | } | 350 | } |
| 350 | } | 351 | } |
| 351 | else { | 352 | else { |
| @@ -363,6 +364,7 @@ static void str_find (void) | |||
| 363 | } | 364 | } |
| 364 | } while (s1++<cap.src_end && !anchor); | 365 | } while (s1++<cap.src_end && !anchor); |
| 365 | } | 366 | } |
| 367 | lua_pushnil(); /* if arives here, it didn't find */ | ||
| 366 | } | 368 | } |
| 367 | 369 | ||
| 368 | 370 | ||
