summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lauxlib.h18
-rw-r--r--lbaselib.c18
-rw-r--r--lbitlib.c26
-rw-r--r--ldblib.c22
-rw-r--r--lmathlib.c4
-rw-r--r--loslib.c4
-rw-r--r--lstrlib.c8
-rw-r--r--ltests.c18
-rw-r--r--ltests.h4
-rw-r--r--lua.h4
-rw-r--r--luaconf.h9
11 files changed, 70 insertions, 65 deletions
diff --git a/lauxlib.h b/lauxlib.h
index 866f66af..3772333f 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.124 2014/04/15 18:25:49 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.125 2014/06/26 17:25:11 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -115,10 +115,6 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
115 ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) 115 ((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
116#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 116#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
117#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 117#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
118#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
119#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
120#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
121#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
122 118
123#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) 119#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
124 120
@@ -210,15 +206,21 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
210 206
211/* 207/*
212** {============================================================ 208** {============================================================
213** Compatibility with deprecated unsigned conversions 209** Compatibility with deprecated conversions
214** ============================================================= 210** =============================================================
215*/ 211*/
216#if defined(LUA_COMPAT_APIUNSIGNED) 212#if defined(LUA_COMPAT_APIINTCASTS)
217 213
218#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) 214#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
219#define luaL_optunsigned(L,a,d) \ 215#define luaL_optunsigned(L,a,d) \
220 ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) 216 ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
221 217
218#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
219#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
220
221#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
222#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
223
222#endif 224#endif
223/* }============================================================ */ 225/* }============================================================ */
224 226
diff --git a/lbaselib.c b/lbaselib.c
index f7ac6ed1..b41908d1 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.297 2014/09/22 06:42:15 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.298 2014/09/30 13:53:26 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -87,11 +87,11 @@ static int luaB_tonumber (lua_State *L) {
87 size_t l; 87 size_t l;
88 const char *s; 88 const char *s;
89 lua_Integer n = 0; /* to avoid warnings */ 89 lua_Integer n = 0; /* to avoid warnings */
90 int base = luaL_checkint(L, 2); 90 lua_Integer base = luaL_checkinteger(L, 2);
91 luaL_checktype(L, 1, LUA_TSTRING); /* before 'luaL_checklstring'! */ 91 luaL_checktype(L, 1, LUA_TSTRING); /* before 'luaL_checklstring'! */
92 s = luaL_checklstring(L, 1, &l); 92 s = luaL_checklstring(L, 1, &l);
93 luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); 93 luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
94 if (b_str2int(s, base, &n) == s + l) { 94 if (b_str2int(s, (int)base, &n) == s + l) {
95 lua_pushinteger(L, n); 95 lua_pushinteger(L, n);
96 return 1; 96 return 1;
97 } /* else not a number */ 97 } /* else not a number */
@@ -102,7 +102,7 @@ static int luaB_tonumber (lua_State *L) {
102 102
103 103
104static int luaB_error (lua_State *L) { 104static int luaB_error (lua_State *L) {
105 int level = luaL_optint(L, 2, 1); 105 int level = (int)luaL_optinteger(L, 2, 1);
106 lua_settop(L, 1); 106 lua_settop(L, 1);
107 if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ 107 if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
108 luaL_where(L, level); 108 luaL_where(L, level);
@@ -180,7 +180,7 @@ static int luaB_collectgarbage (lua_State *L) {
180 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, 180 LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
181 LUA_GCISRUNNING}; 181 LUA_GCISRUNNING};
182 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; 182 int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
183 int ex = luaL_optint(L, 2, 0); 183 int ex = (int)luaL_optinteger(L, 2, 0);
184 int res = lua_gc(L, o, ex); 184 int res = lua_gc(L, o, ex);
185 switch (o) { 185 switch (o) {
186 case LUA_GCCOUNT: { 186 case LUA_GCCOUNT: {
@@ -248,7 +248,7 @@ static int luaB_pairs (lua_State *L) {
248** Traversal function for 'ipairs' for raw tables 248** Traversal function for 'ipairs' for raw tables
249*/ 249*/
250static int ipairsaux_raw (lua_State *L) { 250static int ipairsaux_raw (lua_State *L) {
251 int i = luaL_checkint(L, 2) + 1; 251 lua_Integer i = luaL_checkinteger(L, 2) + 1;
252 luaL_checktype(L, 1, LUA_TTABLE); 252 luaL_checktype(L, 1, LUA_TTABLE);
253 lua_pushinteger(L, i); 253 lua_pushinteger(L, i);
254 return (lua_rawgeti(L, 1, i) == LUA_TNIL) ? 1 : 2; 254 return (lua_rawgeti(L, 1, i) == LUA_TNIL) ? 1 : 2;
@@ -259,7 +259,7 @@ static int ipairsaux_raw (lua_State *L) {
259** Traversal function for 'ipairs' for tables with metamethods 259** Traversal function for 'ipairs' for tables with metamethods
260*/ 260*/
261static int ipairsaux (lua_State *L) { 261static int ipairsaux (lua_State *L) {
262 int i = luaL_checkint(L, 2) + 1; 262 lua_Integer i = luaL_checkinteger(L, 2) + 1;
263 lua_pushinteger(L, i); 263 lua_pushinteger(L, i);
264 return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2; 264 return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2;
265} 265}
@@ -405,11 +405,11 @@ static int luaB_select (lua_State *L) {
405 return 1; 405 return 1;
406 } 406 }
407 else { 407 else {
408 int i = luaL_checkint(L, 1); 408 lua_Integer i = luaL_checkinteger(L, 1);
409 if (i < 0) i = n + i; 409 if (i < 0) i = n + i;
410 else if (i > n) i = n; 410 else if (i > n) i = n;
411 luaL_argcheck(L, 1 <= i, 1, "index out of range"); 411 luaL_argcheck(L, 1 <= i, 1, "index out of range");
412 return n - i; 412 return n - (int)i;
413 } 413 }
414} 414}
415 415
diff --git a/lbitlib.c b/lbitlib.c
index 05895b2e..be02892f 100644
--- a/lbitlib.c
+++ b/lbitlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbitlib.c,v 1.25 2014/03/20 19:22:16 roberto Exp roberto $ 2** $Id: lbitlib.c,v 1.26 2014/05/15 19:28:34 roberto Exp roberto $
3** Standard library for bitwise operations 3** Standard library for bitwise operations
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -89,7 +89,7 @@ static int b_not (lua_State *L) {
89} 89}
90 90
91 91
92static int b_shift (lua_State *L, lua_Unsigned r, int i) { 92static int b_shift (lua_State *L, lua_Unsigned r, lua_Integer i) {
93 if (i < 0) { /* shift right? */ 93 if (i < 0) { /* shift right? */
94 i = -i; 94 i = -i;
95 r = trim(r); 95 r = trim(r);
@@ -107,18 +107,18 @@ static int b_shift (lua_State *L, lua_Unsigned r, int i) {
107 107
108 108
109static int b_lshift (lua_State *L) { 109static int b_lshift (lua_State *L) {
110 return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkint(L, 2)); 110 return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkinteger(L, 2));
111} 111}
112 112
113 113
114static int b_rshift (lua_State *L) { 114static int b_rshift (lua_State *L) {
115 return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkint(L, 2)); 115 return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkinteger(L, 2));
116} 116}
117 117
118 118
119static int b_arshift (lua_State *L) { 119static int b_arshift (lua_State *L) {
120 lua_Unsigned r = luaL_checkunsigned(L, 1); 120 lua_Unsigned r = luaL_checkunsigned(L, 1);
121 int i = luaL_checkint(L, 2); 121 lua_Integer i = luaL_checkinteger(L, 2);
122 if (i < 0 || !(r & ((lua_Unsigned)1 << (LUA_NBITS - 1)))) 122 if (i < 0 || !(r & ((lua_Unsigned)1 << (LUA_NBITS - 1))))
123 return b_shift(L, r, -i); 123 return b_shift(L, r, -i);
124 else { /* arithmetic shift for 'negative' number */ 124 else { /* arithmetic shift for 'negative' number */
@@ -131,9 +131,9 @@ static int b_arshift (lua_State *L) {
131} 131}
132 132
133 133
134static int b_rot (lua_State *L, int i) { 134static int b_rot (lua_State *L, lua_Integer d) {
135 lua_Unsigned r = luaL_checkunsigned(L, 1); 135 lua_Unsigned r = luaL_checkunsigned(L, 1);
136 i &= (LUA_NBITS - 1); /* i = i % NBITS */ 136 int i = d & (LUA_NBITS - 1); /* i = d % NBITS */
137 r = trim(r); 137 r = trim(r);
138 if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */ 138 if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */
139 r = (r << i) | (r >> (LUA_NBITS - i)); 139 r = (r << i) | (r >> (LUA_NBITS - i));
@@ -143,12 +143,12 @@ static int b_rot (lua_State *L, int i) {
143 143
144 144
145static int b_lrot (lua_State *L) { 145static int b_lrot (lua_State *L) {
146 return b_rot(L, luaL_checkint(L, 2)); 146 return b_rot(L, luaL_checkinteger(L, 2));
147} 147}
148 148
149 149
150static int b_rrot (lua_State *L) { 150static int b_rrot (lua_State *L) {
151 return b_rot(L, -luaL_checkint(L, 2)); 151 return b_rot(L, -luaL_checkinteger(L, 2));
152} 152}
153 153
154 154
@@ -159,14 +159,14 @@ static int b_rrot (lua_State *L) {
159** 'width' being used uninitialized.) 159** 'width' being used uninitialized.)
160*/ 160*/
161static int fieldargs (lua_State *L, int farg, int *width) { 161static int fieldargs (lua_State *L, int farg, int *width) {
162 int f = luaL_checkint(L, farg); 162 lua_Integer f = luaL_checkinteger(L, farg);
163 int w = luaL_optint(L, farg + 1, 1); 163 lua_Integer w = luaL_optinteger(L, farg + 1, 1);
164 luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); 164 luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");
165 luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); 165 luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");
166 if (f + w > LUA_NBITS) 166 if (f + w > LUA_NBITS)
167 luaL_error(L, "trying to access non-existent bits"); 167 luaL_error(L, "trying to access non-existent bits");
168 *width = w; 168 *width = (int)w;
169 return f; 169 return (int)f;
170} 170}
171 171
172 172
diff --git a/ldblib.c b/ldblib.c
index 5047a9dd..79da10c8 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.140 2014/08/21 19:12:40 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.141 2014/08/22 16:22:42 roberto Exp roberto $
3** Interface from Lua to its debug API 3** Interface from Lua to its debug API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -160,7 +160,7 @@ static int db_getinfo (lua_State *L) {
160 lua_xmove(L, L1, 1); 160 lua_xmove(L, L1, 1);
161 } 161 }
162 else { /* stack level */ 162 else { /* stack level */
163 if (!lua_getstack(L1, luaL_checkint(L, arg + 1), &ar)) { 163 if (!lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)) {
164 lua_pushnil(L); /* level out of range */ 164 lua_pushnil(L); /* level out of range */
165 return 1; 165 return 1;
166 } 166 }
@@ -201,14 +201,15 @@ static int db_getlocal (lua_State *L) {
201 lua_State *L1 = getthread(L, &arg); 201 lua_State *L1 = getthread(L, &arg);
202 lua_Debug ar; 202 lua_Debug ar;
203 const char *name; 203 const char *name;
204 int nvar = luaL_checkint(L, arg+2); /* local-variable index */ 204 int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */
205 if (lua_isfunction(L, arg + 1)) { /* function argument? */ 205 if (lua_isfunction(L, arg + 1)) { /* function argument? */
206 lua_pushvalue(L, arg + 1); /* push function */ 206 lua_pushvalue(L, arg + 1); /* push function */
207 lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */ 207 lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
208 return 1; /* return only name (there is no value) */ 208 return 1; /* return only name (there is no value) */
209 } 209 }
210 else { /* stack-level argument */ 210 else { /* stack-level argument */
211 if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ 211 int level = (int)luaL_checkinteger(L, arg + 1);
212 if (!lua_getstack(L1, level, &ar)) /* out of range? */
212 return luaL_argerror(L, arg+1, "level out of range"); 213 return luaL_argerror(L, arg+1, "level out of range");
213 name = lua_getlocal(L1, &ar, nvar); 214 name = lua_getlocal(L1, &ar, nvar);
214 if (name) { 215 if (name) {
@@ -229,12 +230,13 @@ static int db_setlocal (lua_State *L) {
229 int arg; 230 int arg;
230 lua_State *L1 = getthread(L, &arg); 231 lua_State *L1 = getthread(L, &arg);
231 lua_Debug ar; 232 lua_Debug ar;
232 if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ 233 int level = (int)luaL_checkinteger(L, arg + 1);
234 if (!lua_getstack(L1, level, &ar)) /* out of range? */
233 return luaL_argerror(L, arg+1, "level out of range"); 235 return luaL_argerror(L, arg+1, "level out of range");
234 luaL_checkany(L, arg+3); 236 luaL_checkany(L, arg+3);
235 lua_settop(L, arg+3); 237 lua_settop(L, arg+3);
236 lua_xmove(L, L1, 1); 238 lua_xmove(L, L1, 1);
237 lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); 239 lua_pushstring(L, lua_setlocal(L1, &ar, (int)luaL_checkinteger(L, arg+2)));
238 return 1; 240 return 1;
239} 241}
240 242
@@ -244,7 +246,7 @@ static int db_setlocal (lua_State *L) {
244*/ 246*/
245static int auxupvalue (lua_State *L, int get) { 247static int auxupvalue (lua_State *L, int get) {
246 const char *name; 248 const char *name;
247 int n = luaL_checkint(L, 2); /* upvalue index */ 249 int n = (int)luaL_checkinteger(L, 2); /* upvalue index */
248 luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */ 250 luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */
249 name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); 251 name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
250 if (name == NULL) return 0; 252 if (name == NULL) return 0;
@@ -270,7 +272,7 @@ static int db_setupvalue (lua_State *L) {
270** returns its index 272** returns its index
271*/ 273*/
272static int checkupval (lua_State *L, int argf, int argnup) { 274static int checkupval (lua_State *L, int argf, int argnup) {
273 int nup = luaL_checkint(L, argnup); /* upvalue index */ 275 int nup = (int)luaL_checkinteger(L, argnup); /* upvalue index */
274 luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ 276 luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */
275 luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup, 277 luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup,
276 "invalid upvalue index"); 278 "invalid upvalue index");
@@ -359,7 +361,7 @@ static int db_sethook (lua_State *L) {
359 else { 361 else {
360 const char *smask = luaL_checkstring(L, arg+2); 362 const char *smask = luaL_checkstring(L, arg+2);
361 luaL_checktype(L, arg+1, LUA_TFUNCTION); 363 luaL_checktype(L, arg+1, LUA_TFUNCTION);
362 count = luaL_optint(L, arg+3, 0); 364 count = (int)luaL_optinteger(L, arg + 3, 0);
363 func = hookf; mask = makemask(smask, count); 365 func = hookf; mask = makemask(smask, count);
364 } 366 }
365 if (gethooktable(L) == 0) { /* creating hook table? */ 367 if (gethooktable(L) == 0) { /* creating hook table? */
@@ -418,7 +420,7 @@ static int db_traceback (lua_State *L) {
418 if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ 420 if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */
419 lua_pushvalue(L, arg + 1); /* return it untouched */ 421 lua_pushvalue(L, arg + 1); /* return it untouched */
420 else { 422 else {
421 int level = luaL_optint(L, arg + 2, (L == L1) ? 1 : 0); 423 int level = (int)luaL_optinteger(L, arg + 2, (L == L1) ? 1 : 0);
422 luaL_traceback(L, L1, msg, level); 424 luaL_traceback(L, L1, msg, level);
423 } 425 }
424 return 1; 426 return 1;
diff --git a/lmathlib.c b/lmathlib.c
index 43f10d7e..59e529cb 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.107 2014/07/17 12:30:53 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.108 2014/07/28 17:35:47 roberto Exp roberto $
3** Standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -324,7 +324,7 @@ static int math_frexp (lua_State *L) {
324 324
325static int math_ldexp (lua_State *L) { 325static int math_ldexp (lua_State *L) {
326 lua_Number x = luaL_checknumber(L, 1); 326 lua_Number x = luaL_checknumber(L, 1);
327 int ep = luaL_checkint(L, 2); 327 int ep = (int)luaL_checkinteger(L, 2);
328 lua_pushnumber(L, l_mathop(ldexp)(x, ep)); 328 lua_pushnumber(L, l_mathop(ldexp)(x, ep));
329 return 1; 329 return 1;
330} 330}
diff --git a/loslib.c b/loslib.c
index c55a6526..209e74cd 100644
--- a/loslib.c
+++ b/loslib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loslib.c,v 1.45 2014/03/20 19:18:54 roberto Exp roberto $ 2** $Id: loslib.c,v 1.46 2014/04/29 17:05:13 roberto Exp roberto $
3** Standard Operating System library 3** Standard Operating System library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -319,7 +319,7 @@ static int os_exit (lua_State *L) {
319 if (lua_isboolean(L, 1)) 319 if (lua_isboolean(L, 1))
320 status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE); 320 status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
321 else 321 else
322 status = luaL_optint(L, 1, EXIT_SUCCESS); 322 status = (int)luaL_optinteger(L, 1, EXIT_SUCCESS);
323 if (lua_toboolean(L, 2)) 323 if (lua_toboolean(L, 2))
324 lua_close(L); 324 lua_close(L);
325 if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */ 325 if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */
diff --git a/lstrlib.c b/lstrlib.c
index b73b306e..eb40995f 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.200 2014/07/30 13:59:24 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.201 2014/08/20 22:06:41 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -890,7 +890,7 @@ static int str_format (lua_State *L) {
890 strfrmt = scanformat(L, strfrmt, form); 890 strfrmt = scanformat(L, strfrmt, form);
891 switch (*strfrmt++) { 891 switch (*strfrmt++) {
892 case 'c': { 892 case 'c': {
893 nb = sprintf(buff, form, luaL_checkint(L, arg)); 893 nb = sprintf(buff, form, (int)luaL_checkinteger(L, arg));
894 break; 894 break;
895 } 895 }
896 case 'd': case 'i': 896 case 'd': case 'i':
@@ -984,11 +984,11 @@ static int getendian (lua_State *L, int arg) {
984 984
985 985
986static int getintsize (lua_State *L, int arg) { 986static int getintsize (lua_State *L, int arg) {
987 int size = luaL_optint(L, arg, 0); 987 lua_Integer size = luaL_optinteger(L, arg, 0);
988 if (size == 0) size = SZINT; 988 if (size == 0) size = SZINT;
989 luaL_argcheck(L, 1 <= size && size <= MAXINTSIZE, arg, 989 luaL_argcheck(L, 1 <= size && size <= MAXINTSIZE, arg,
990 "integer size out of valid range"); 990 "integer size out of valid range");
991 return size; 991 return (int)size;
992} 992}
993 993
994 994
diff --git a/ltests.c b/ltests.c
index efddc393..9057cde3 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.184 2014/09/01 17:58:55 roberto Exp roberto $ 2** $Id: ltests.c,v 2.185 2014/09/04 18:15:29 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -530,7 +530,7 @@ static int listk (lua_State *L) {
530 530
531static int listlocals (lua_State *L) { 531static int listlocals (lua_State *L) {
532 Proto *p; 532 Proto *p;
533 int pc = luaL_checkint(L, 2) - 1; 533 int pc = (int)luaL_checkinteger(L, 2) - 1;
534 int i = 0; 534 int i = 0;
535 const char *name; 535 const char *name;
536 luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 536 luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
@@ -659,7 +659,7 @@ static int stacklevel (lua_State *L) {
659 659
660static int table_query (lua_State *L) { 660static int table_query (lua_State *L) {
661 const Table *t; 661 const Table *t;
662 int i = luaL_optint(L, 2, -1); 662 int i = (int)luaL_optinteger(L, 2, -1);
663 luaL_checktype(L, 1, LUA_TTABLE); 663 luaL_checktype(L, 1, LUA_TTABLE);
664 t = hvalue(obj_at(L, 1)); 664 t = hvalue(obj_at(L, 1));
665 if (i == -1) { 665 if (i == -1) {
@@ -692,7 +692,7 @@ static int table_query (lua_State *L) {
692 692
693static int string_query (lua_State *L) { 693static int string_query (lua_State *L) {
694 stringtable *tb = &G(L)->strt; 694 stringtable *tb = &G(L)->strt;
695 int s = luaL_optint(L, 1, 0) - 1; 695 int s = (int)luaL_optinteger(L, 1, 0) - 1;
696 if (s == -1) { 696 if (s == -1) {
697 lua_pushinteger(L ,tb->size); 697 lua_pushinteger(L ,tb->size);
698 lua_pushinteger(L ,tb->nuse); 698 lua_pushinteger(L ,tb->nuse);
@@ -723,21 +723,21 @@ static int tref (lua_State *L) {
723 723
724static int getref (lua_State *L) { 724static int getref (lua_State *L) {
725 int level = lua_gettop(L); 725 int level = lua_gettop(L);
726 lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkint(L, 1)); 726 lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkinteger(L, 1));
727 lua_assert(lua_gettop(L) == level+1); 727 lua_assert(lua_gettop(L) == level+1);
728 return 1; 728 return 1;
729} 729}
730 730
731static int unref (lua_State *L) { 731static int unref (lua_State *L) {
732 int level = lua_gettop(L); 732 int level = lua_gettop(L);
733 luaL_unref(L, LUA_REGISTRYINDEX, luaL_checkint(L, 1)); 733 luaL_unref(L, LUA_REGISTRYINDEX, (int)luaL_checkinteger(L, 1));
734 lua_assert(lua_gettop(L) == level); 734 lua_assert(lua_gettop(L) == level);
735 return 0; 735 return 0;
736} 736}
737 737
738 738
739static int upvalue (lua_State *L) { 739static int upvalue (lua_State *L) {
740 int n = luaL_checkint(L, 2); 740 int n = (int)luaL_checkinteger(L, 2);
741 luaL_checktype(L, 1, LUA_TFUNCTION); 741 luaL_checktype(L, 1, LUA_TFUNCTION);
742 if (lua_isnone(L, 3)) { 742 if (lua_isnone(L, 3)) {
743 const char *name = lua_getupvalue(L, 1, n); 743 const char *name = lua_getupvalue(L, 1, n);
@@ -886,7 +886,7 @@ static int doremote (lua_State *L) {
886 886
887 887
888static int int2fb_aux (lua_State *L) { 888static int int2fb_aux (lua_State *L) {
889 int b = luaO_int2fb(luaL_checkint(L, 1)); 889 int b = luaO_int2fb((unsigned int)luaL_checkinteger(L, 1));
890 lua_pushinteger(L, b); 890 lua_pushinteger(L, b);
891 lua_pushinteger(L, luaO_fb2int(b)); 891 lua_pushinteger(L, luaO_fb2int(b));
892 return 2; 892 return 2;
@@ -1389,7 +1389,7 @@ static int sethook (lua_State *L) {
1389 else { 1389 else {
1390 const char *scpt = luaL_checkstring(L, 1); 1390 const char *scpt = luaL_checkstring(L, 1);
1391 const char *smask = luaL_checkstring(L, 2); 1391 const char *smask = luaL_checkstring(L, 2);
1392 int count = luaL_optint(L, 3, 0); 1392 int count = (int)luaL_optinteger(L, 3, 0);
1393 int mask = 0; 1393 int mask = 0;
1394 if (strchr(smask, 'c')) mask |= LUA_MASKCALL; 1394 if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
1395 if (strchr(smask, 'r')) mask |= LUA_MASKRET; 1395 if (strchr(smask, 'r')) mask |= LUA_MASKRET;
diff --git a/ltests.h b/ltests.h
index 56b0d352..5f0fba92 100644
--- a/ltests.h
+++ b/ltests.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.h,v 2.38 2014/07/24 14:00:16 roberto Exp roberto $ 2** $Id: ltests.h,v 2.39 2014/07/24 19:33:29 roberto Exp roberto $
3** Internal Header for Debugging of the Lua Implementation 3** Internal Header for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -14,7 +14,7 @@
14#undef LUA_COMPAT_MATHLIB 14#undef LUA_COMPAT_MATHLIB
15#undef LUA_COMPAT_IPAIRS 15#undef LUA_COMPAT_IPAIRS
16#undef LUA_COMPAT_BITLIB 16#undef LUA_COMPAT_BITLIB
17#undef LUA_COMPAT_APIUNSIGNED 17#undef LUA_COMPAT_APIINTCASTS
18#undef LUA_COMPAT_FLOATSTRING 18#undef LUA_COMPAT_FLOATSTRING
19#undef LUA_COMPAT_UNPACK 19#undef LUA_COMPAT_UNPACK
20#undef LUA_COMPAT_LOADERS 20#undef LUA_COMPAT_LOADERS
diff --git a/lua.h b/lua.h
index a092f829..0443c9d4 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.313 2014/08/01 17:33:08 roberto Exp roberto $ 2** $Id: lua.h,v 1.314 2014/08/21 20:07:56 roberto Exp roberto $
3** Lua - A Scripting Language 3** Lua - A Scripting Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 4** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
5** See Copyright Notice at the end of this file 5** See Copyright Notice at the end of this file
@@ -379,7 +379,7 @@ LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);
379** compatibility macros for unsigned conversions 379** compatibility macros for unsigned conversions
380** =============================================================== 380** ===============================================================
381*/ 381*/
382#if defined(LUA_COMPAT_APIUNSIGNED) 382#if defined(LUA_COMPAT_APIINTCASTS)
383 383
384#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) 384#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))
385#define lua_tounsignedx(L,i,is) ((lua_Integer)lua_tointegerx(L,i,is)) 385#define lua_tounsignedx(L,i,is) ((lua_Integer)lua_tointegerx(L,i,is))
diff --git a/luaconf.h b/luaconf.h
index 3b51a1f3..1cf7a9a8 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.212 2014/07/24 19:33:29 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.213 2014/08/01 17:33:08 roberto Exp roberto $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -311,10 +311,11 @@
311#define LUA_COMPAT_IPAIRS 311#define LUA_COMPAT_IPAIRS
312 312
313/* 313/*
314@@ LUA_COMPAT_APIUNSIGNED controls the presence of macros for 314@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
315** manipulating unsigned integers (lua_pushunsigned, lua_tounsigned, etc.) 315** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
316** luaL_checkint, luaL_checklong, etc.)
316*/ 317*/
317#define LUA_COMPAT_APIUNSIGNED 318#define LUA_COMPAT_APIINTCASTS
318 319
319 320
320/* 321/*