mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
'int' -> 'lua_Integer' in several functions
This commit is contained in:
parent
8b45d9806a
commit
9737832641
22
ltablib.c
22
ltablib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltablib.c,v 1.66 2014/03/21 13:52:33 roberto Exp roberto $
|
** $Id: ltablib.c,v 1.67 2014/04/01 18:50:34 roberto Exp roberto $
|
||||||
** Library for Table Manipulation
|
** Library for Table Manipulation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -40,16 +40,16 @@ static int maxn (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
static int tinsert (lua_State *L) {
|
static int tinsert (lua_State *L) {
|
||||||
int e = aux_getn(L, 1) + 1; /* first empty element */
|
lua_Integer e = aux_getn(L, 1) + 1; /* first empty element */
|
||||||
int pos; /* where to insert new element */
|
lua_Integer pos; /* where to insert new element */
|
||||||
switch (lua_gettop(L)) {
|
switch (lua_gettop(L)) {
|
||||||
case 2: { /* called with only 2 arguments */
|
case 2: { /* called with only 2 arguments */
|
||||||
pos = e; /* insert new element at the end */
|
pos = e; /* insert new element at the end */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
int i;
|
lua_Integer i;
|
||||||
pos = luaL_checkint(L, 2); /* 2nd argument is the position */
|
pos = luaL_checkinteger(L, 2); /* 2nd argument is the position */
|
||||||
luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds");
|
luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds");
|
||||||
for (i = e; i > pos; i--) { /* move up elements */
|
for (i = e; i > pos; i--) { /* move up elements */
|
||||||
lua_rawgeti(L, 1, i-1);
|
lua_rawgeti(L, 1, i-1);
|
||||||
@ -67,8 +67,8 @@ static int tinsert (lua_State *L) {
|
|||||||
|
|
||||||
|
|
||||||
static int tremove (lua_State *L) {
|
static int tremove (lua_State *L) {
|
||||||
int size = aux_getn(L, 1);
|
lua_Integer size = aux_getn(L, 1);
|
||||||
int pos = luaL_optint(L, 2, size);
|
lua_Integer pos = luaL_optinteger(L, 2, size);
|
||||||
if (pos != size) /* validate 'pos' if given */
|
if (pos != size) /* validate 'pos' if given */
|
||||||
luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds");
|
luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds");
|
||||||
lua_rawgeti(L, 1, pos); /* result = t[pos] */
|
lua_rawgeti(L, 1, pos); /* result = t[pos] */
|
||||||
@ -82,7 +82,7 @@ static int tremove (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void addfield (lua_State *L, luaL_Buffer *b, int i) {
|
static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) {
|
||||||
lua_rawgeti(L, 1, i);
|
lua_rawgeti(L, 1, i);
|
||||||
if (!lua_isstring(L, -1))
|
if (!lua_isstring(L, -1))
|
||||||
luaL_error(L, "invalid value (%s) at index %d in table for "
|
luaL_error(L, "invalid value (%s) at index %d in table for "
|
||||||
@ -94,11 +94,11 @@ static void addfield (lua_State *L, luaL_Buffer *b, int i) {
|
|||||||
static int tconcat (lua_State *L) {
|
static int tconcat (lua_State *L) {
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
size_t lsep;
|
size_t lsep;
|
||||||
int i, last;
|
lua_Integer i, last;
|
||||||
const char *sep = luaL_optlstring(L, 2, "", &lsep);
|
const char *sep = luaL_optlstring(L, 2, "", &lsep);
|
||||||
luaL_checktype(L, 1, LUA_TTABLE);
|
luaL_checktype(L, 1, LUA_TTABLE);
|
||||||
i = luaL_optint(L, 3, 1);
|
i = luaL_optinteger(L, 3, 1);
|
||||||
last = luaL_opt(L, luaL_checkint, 4, luaL_len(L, 1));
|
last = luaL_opt(L, luaL_checkinteger, 4, luaL_len(L, 1));
|
||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
for (; i < last; i++) {
|
for (; i < last; i++) {
|
||||||
addfield(L, &b, i);
|
addfield(L, &b, i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user