aboutsummaryrefslogtreecommitdiff
path: root/c-api/compat-5.3.c
diff options
context:
space:
mode:
Diffstat (limited to 'c-api/compat-5.3.c')
-rw-r--r--c-api/compat-5.3.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c
index ebaf03f..370027a 100644
--- a/c-api/compat-5.3.c
+++ b/c-api/compat-5.3.c
@@ -204,22 +204,6 @@ COMPAT53_API void lua_rawsetp (lua_State *L, int i, const void *p) {
204} 204}
205 205
206 206
207COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum) {
208 int ok = 0;
209 lua_Number n = lua_tonumberx(L, i, &ok);
210 lua_Integer j = (lua_tointeger)(L, i); /* native lua_tointeger */
211 if (isnum == NULL)
212 isnum = &ok;
213 if (ok && n == j) {
214 *isnum = 1;
215 return j;
216 } else {
217 *isnum = 0;
218 return 0;
219 }
220}
221
222
223COMPAT53_API lua_Number lua_tonumberx (lua_State *L, int i, int *isnum) { 207COMPAT53_API lua_Number lua_tonumberx (lua_State *L, int i, int *isnum) {
224 lua_Number n = lua_tonumber(L, i); 208 lua_Number n = lua_tonumber(L, i);
225 if (isnum != NULL) { 209 if (isnum != NULL) {
@@ -747,6 +731,22 @@ COMPAT53_API int lua_isinteger (lua_State *L, int index) {
747} 731}
748 732
749 733
734COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum) {
735 int ok = 0;
736 lua_Number n = lua_tonumberx(L, i, &ok);
737 if (ok) {
738 if (n == (lua_Integer)n) {
739 if (isnum)
740 *isnum = 1;
741 return (lua_Integer)n;
742 }
743 }
744 if (isnum)
745 *isnum = 0;
746 return 0;
747}
748
749
750static void compat53_reverse (lua_State *L, int a, int b) { 750static void compat53_reverse (lua_State *L, int a, int b) {
751 for (; a < b; ++a, --b) { 751 for (; a < b; ++a, --b) {
752 lua_pushvalue(L, a); 752 lua_pushvalue(L, a);