mirror of https://github.com/rusefi/lua.git
functions should return explicit "nil"s.
This commit is contained in:
parent
9a0221ef58
commit
e869d17eb1
12
lbuiltin.c
12
lbuiltin.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbuiltin.c,v 1.30 1998/06/19 16:14:09 roberto Exp roberto $
|
** $Id: lbuiltin.c,v 1.31 1998/06/19 18:47:06 roberto Exp roberto $
|
||||||
** Built-in functions
|
** Built-in functions
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -54,6 +54,7 @@ static void nextvar (void)
|
||||||
pushstring(g);
|
pushstring(g);
|
||||||
luaA_pushobject(&g->u.s.globalval);
|
luaA_pushobject(&g->u.s.globalval);
|
||||||
}
|
}
|
||||||
|
else lua_pushnil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ static void next (void)
|
||||||
luaA_pushobject(&n->ref);
|
luaA_pushobject(&n->ref);
|
||||||
luaA_pushobject(&n->val);
|
luaA_pushobject(&n->val);
|
||||||
}
|
}
|
||||||
|
else lua_pushnil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,8 +216,8 @@ static void tonumber (void)
|
||||||
luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
|
luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
|
||||||
n = strtol(s, &s, base);
|
n = strtol(s, &s, base);
|
||||||
while (isspace(*s)) s++; /* skip trailing spaces */
|
while (isspace(*s)) s++; /* skip trailing spaces */
|
||||||
if (*s) return; /* invalid format: return nil */
|
if (*s) lua_pushnil(); /* invalid format: return nil */
|
||||||
lua_pushnumber(n);
|
else lua_pushnumber(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,8 +305,10 @@ static void luaI_call (void)
|
||||||
lua_seterrormethod();
|
lua_seterrormethod();
|
||||||
}
|
}
|
||||||
if (status != 0) { /* error in call? */
|
if (status != 0) { /* error in call? */
|
||||||
if (strchr(options, 'x'))
|
if (strchr(options, 'x')) {
|
||||||
|
lua_pushnil();
|
||||||
return; /* return nil to signal the error */
|
return; /* return nil to signal the error */
|
||||||
|
}
|
||||||
else
|
else
|
||||||
lua_error(NULL);
|
lua_error(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.15 1998/06/19 16:14:09 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.16 1998/06/24 13:33:00 roberto Exp roberto $
|
||||||
** Standard library for strings and pattern-matching
|
** Standard library for strings and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -346,6 +346,7 @@ static void str_find (void)
|
||||||
if (s2) {
|
if (s2) {
|
||||||
lua_pushnumber(s2-s+1);
|
lua_pushnumber(s2-s+1);
|
||||||
lua_pushnumber(s2-s+strlen(p));
|
lua_pushnumber(s2-s+strlen(p));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -363,6 +364,7 @@ static void str_find (void)
|
||||||
}
|
}
|
||||||
} while (s1++<cap.src_end && !anchor);
|
} while (s1++<cap.src_end && !anchor);
|
||||||
}
|
}
|
||||||
|
lua_pushnil(); /* if arives here, it didn't find */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue