From 5388aa9fc0185b5d7a852e679484e26ba53e5d4d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 30 Apr 2014 13:48:44 -0300 Subject: 'luaO_str2d' + 'luaO_str2int' replaced by 'luaO_str2num' (which converts to float or integer according to the string syntax) --- lapi.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'lapi.c') diff --git a/lapi.c b/lapi.c index 5b866885..a81d3ecc 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.205 2014/04/15 16:32:49 roberto Exp roberto $ +** $Id: lapi.c,v 2.206 2014/04/29 18:14:16 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -334,17 +334,12 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { LUA_API int lua_strtonum (lua_State *L, const char *s, size_t len) { - lua_Integer i; lua_Number n; - if (luaO_str2int(s, len, &i)) { /* try as an integer */ - setivalue(L->top, i); - } - else if (luaO_str2d(s, len, &n)) { /* else try as a float */ - setfltvalue(L->top, n); - } - else + if (!luaO_str2num(s, len, L->top)) return 0; /* conversion failed */ - api_incr_top(L); - return 1; + else { + api_incr_top(L); + return 1; + } } -- cgit v1.2.3-55-g6feb