diff options
author | daurnimator <quae@daurnimator.com> | 2018-07-08 20:27:02 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-07-08 20:27:02 +1000 |
commit | 942e9fb5c80368fe93ca195bc14272b2d4cd2881 (patch) | |
tree | 5d3e140408e31e79177eca74e27ce4abc2f224e7 /c-api/compat-5.3.c | |
parent | 18b7d200cbaadf7aee592f739e2e0cb4be4ce298 (diff) | |
download | luaossl-942e9fb5c80368fe93ca195bc14272b2d4cd2881.tar.gz luaossl-942e9fb5c80368fe93ca195bc14272b2d4cd2881.tar.bz2 luaossl-942e9fb5c80368fe93ca195bc14272b2d4cd2881.zip |
Squashed 'vendor/compat53/' changes from bc91f40..daebe77
daebe77 Fix feature test for C11 Annex K (strerror_s).
d48f7f5 Provide strict lua_tointegerx for Lua 5.2 as well.
340f2f4 lua_tointeger(x) rejects non-ints for Lua 5.1.
30077d2 Verify that lua_getuservalue returns type.
git-subtree-dir: vendor/compat53
git-subtree-split: daebe77a2f498817713df37f0bb316db1d82222f
Diffstat (limited to 'c-api/compat-5.3.c')
-rw-r--r-- | c-api/compat-5.3.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c index b82c654..bf81673 100644 --- a/c-api/compat-5.3.c +++ b/c-api/compat-5.3.c @@ -37,8 +37,8 @@ #endif /* strerror_r */ #ifndef COMPAT53_HAVE_STRERROR_S -# if defined(_MSC_VER) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ - (defined(__STDC_LIB_EXT1__) && __STDC_LIB_EXT1__) +# if defined(_MSC_VER) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \ + defined(__STDC_LIB_EXT1__) && __STDC_LIB_EXT1__) # define COMPAT53_HAVE_STRERROR_S 1 # else /* not VC++ or C11 */ # define COMPAT53_HAVE_STRERROR_S 0 @@ -204,15 +204,6 @@ COMPAT53_API void lua_rawsetp (lua_State *L, int i, const void *p) { } -COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum) { - lua_Integer n = lua_tointeger(L, i); - if (isnum != NULL) { - *isnum = (n != 0 || lua_isnumber(L, i)); - } - return n; -} - - COMPAT53_API lua_Number lua_tonumberx (lua_State *L, int i, int *isnum) { lua_Number n = lua_tonumber(L, i); if (isnum != NULL) { @@ -740,6 +731,22 @@ COMPAT53_API int lua_isinteger (lua_State *L, int index) { } +COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum) { + int ok = 0; + lua_Number n = lua_tonumberx(L, i, &ok); + if (ok) { + if (n == (lua_Integer)n) { + if (isnum) + *isnum = 1; + return (lua_Integer)n; + } + } + if (isnum) + *isnum = 0; + return 0; +} + + static void compat53_reverse (lua_State *L, int a, int b) { for (; a < b; ++a, --b) { lua_pushvalue(L, a); |