aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@impa.br>2015-03-01 22:49:04 -0300
committerDiego Nehab <diego@impa.br>2015-03-01 22:49:04 -0300
commit8396a0291b2d97bc837c4c55bb99f7f6777ce515 (patch)
tree3e65b498ff30b00b32819037e4bfa2719286e9c7
parent9d49cdcf05d49a99d9095d63318f11adc73c10d0 (diff)
downloadluasocket-8396a0291b2d97bc837c4c55bb99f7f6777ce515.tar.gz
luasocket-8396a0291b2d97bc837c4c55bb99f7f6777ce515.tar.bz2
luasocket-8396a0291b2d97bc837c4c55bb99f7f6777ce515.zip
Better solution to luaL_checkint...
-rw-r--r--src/luasocket.c7
-rw-r--r--src/mime.c7
2 files changed, 2 insertions, 12 deletions
diff --git a/src/luasocket.c b/src/luasocket.c
index 40731f1..c4eeab3 100644
--- a/src/luasocket.c
+++ b/src/luasocket.c
@@ -31,11 +31,6 @@
31#include "udp.h" 31#include "udp.h"
32#include "select.h" 32#include "select.h"
33 33
34#if LUA_VERSION_NUM > 502 && !defined(LUA_COMPAT_APIINTCASTS)
35#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
36#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
37#endif
38
39/*-------------------------------------------------------------------------*\ 34/*-------------------------------------------------------------------------*\
40* Internal function prototypes 35* Internal function prototypes
41\*-------------------------------------------------------------------------*/ 36\*-------------------------------------------------------------------------*/
@@ -68,7 +63,7 @@ static luaL_Reg func[] = {
68* Skip a few arguments 63* Skip a few arguments
69\*-------------------------------------------------------------------------*/ 64\*-------------------------------------------------------------------------*/
70static int global_skip(lua_State *L) { 65static int global_skip(lua_State *L) {
71 int amount = luaL_checkint(L, 1); 66 int amount = luaL_checkinteger(L, 1);
72 int ret = lua_gettop(L) - amount - 1; 67 int ret = lua_gettop(L) - amount - 1;
73 return ret >= 0 ? ret : 0; 68 return ret >= 0 ? ret : 0;
74} 69}
diff --git a/src/mime.c b/src/mime.c
index fdd1477..8edb750 100644
--- a/src/mime.c
+++ b/src/mime.c
@@ -13,11 +13,6 @@
13 13
14#include "mime.h" 14#include "mime.h"
15 15
16#if LUA_VERSION_NUM > 502 && !defined(LUA_COMPAT_APIINTCASTS)
17#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
18#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
19#endif
20
21/*=========================================================================*\ 16/*=========================================================================*\
22* Don't want to trust escape character constants 17* Don't want to trust escape character constants
23\*=========================================================================*/ 18\*=========================================================================*/
@@ -666,7 +661,7 @@ static int eolprocess(int c, int last, const char *marker,
666\*-------------------------------------------------------------------------*/ 661\*-------------------------------------------------------------------------*/
667static int mime_global_eol(lua_State *L) 662static int mime_global_eol(lua_State *L)
668{ 663{
669 int ctx = luaL_checkint(L, 1); 664 int ctx = luaL_checkinteger(L, 1);
670 size_t isize = 0; 665 size_t isize = 0;
671 const char *input = luaL_optlstring(L, 2, NULL, &isize); 666 const char *input = luaL_optlstring(L, 2, NULL, &isize);
672 const char *last = input + isize; 667 const char *last = input + isize;