aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-04-30 13:48:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-04-30 13:48:44 -0300
commit5388aa9fc0185b5d7a852e679484e26ba53e5d4d (patch)
tree2085a65550d299ee37369985f47af4fd9f5c951e /lapi.c
parentb123a88673fcf37ebfcc8ea866a3d27da6cdf82e (diff)
downloadlua-5388aa9fc0185b5d7a852e679484e26ba53e5d4d.tar.gz
lua-5388aa9fc0185b5d7a852e679484e26ba53e5d4d.tar.bz2
lua-5388aa9fc0185b5d7a852e679484e26ba53e5d4d.zip
'luaO_str2d' + 'luaO_str2int' replaced by 'luaO_str2num' (which converts
to float or integer according to the string syntax)
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/lapi.c b/lapi.c
index 5b866885..a81d3ecc 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.205 2014/04/15 16:32:49 roberto Exp roberto $ 2** $Id: lapi.c,v 2.206 2014/04/29 18:14:16 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -334,17 +334,12 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
334 334
335 335
336LUA_API int lua_strtonum (lua_State *L, const char *s, size_t len) { 336LUA_API int lua_strtonum (lua_State *L, const char *s, size_t len) {
337 lua_Integer i; lua_Number n; 337 if (!luaO_str2num(s, len, L->top))
338 if (luaO_str2int(s, len, &i)) { /* try as an integer */
339 setivalue(L->top, i);
340 }
341 else if (luaO_str2d(s, len, &n)) { /* else try as a float */
342 setfltvalue(L->top, n);
343 }
344 else
345 return 0; /* conversion failed */ 338 return 0; /* conversion failed */
346 api_incr_top(L); 339 else {
347 return 1; 340 api_incr_top(L);
341 return 1;
342 }
348} 343}
349 344
350 345