diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-05-01 15:18:06 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-05-01 15:18:06 -0300 |
commit | c549d4fe64c48ab645740e6d12c69c91250fad3d (patch) | |
tree | 1f98183ee7518f107d5902916468d99d7fce9527 /lapi.c | |
parent | ddff6ecf305e6da4f275b473ef6b66811848a3c6 (diff) | |
download | lua-c549d4fe64c48ab645740e6d12c69c91250fad3d.tar.gz lua-c549d4fe64c48ab645740e6d12c69c91250fad3d.tar.bz2 lua-c549d4fe64c48ab645740e6d12c69c91250fad3d.zip |
'lua_strtonum' (and 'luaO_str2num') now return string size, instead of
receiving it
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.206 2014/04/29 18:14:16 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.207 2014/04/30 16:48:44 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 | */ |
@@ -333,13 +333,11 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { | |||
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | LUA_API int lua_strtonum (lua_State *L, const char *s, size_t len) { | 336 | LUA_API size_t lua_strtonum (lua_State *L, const char *s) { |
337 | if (!luaO_str2num(s, len, L->top)) | 337 | size_t sz = luaO_str2num(s, L->top); |
338 | return 0; /* conversion failed */ | 338 | if (sz != 0) |
339 | else { | ||
340 | api_incr_top(L); | 339 | api_incr_top(L); |
341 | return 1; | 340 | return sz; |
342 | } | ||
343 | } | 341 | } |
344 | 342 | ||
345 | 343 | ||