mirror of https://github.com/rusefi/lua.git
to avoid warnings about "typecast" (Visual C++)
This commit is contained in:
parent
4c94d8cc2c
commit
766e67ef3b
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lauxlib.h,v 1.8 1998/06/18 16:57:03 roberto Exp roberto $
|
** $Id: lauxlib.h,v 1.9 1998/06/19 16:14:09 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -28,7 +28,11 @@ char *luaL_check_lstr (int numArg, long *len);
|
||||||
#define luaL_opt_string(n, d) (luaL_opt_lstr((n), (d), NULL))
|
#define luaL_opt_string(n, d) (luaL_opt_lstr((n), (d), NULL))
|
||||||
char *luaL_opt_lstr (int numArg, char *def, long *len);
|
char *luaL_opt_lstr (int numArg, char *def, long *len);
|
||||||
double luaL_check_number (int numArg);
|
double luaL_check_number (int numArg);
|
||||||
|
#define luaL_check_int(n) ((int)luaL_check_number(n))
|
||||||
|
#define luaL_check_long(n) ((long)luaL_check_number(n))
|
||||||
double luaL_opt_number (int numArg, double def);
|
double luaL_opt_number (int numArg, double def);
|
||||||
|
#define luaL_opt_int(n,d) ((int)luaL_opt_number(n,d))
|
||||||
|
#define luaL_opt_long(n,d) ((long)luaL_opt_number(n,d))
|
||||||
lua_Object luaL_functionarg (int arg);
|
lua_Object luaL_functionarg (int arg);
|
||||||
lua_Object luaL_tablearg (int arg);
|
lua_Object luaL_tablearg (int arg);
|
||||||
lua_Object luaL_nonnullarg (int numArg);
|
lua_Object luaL_nonnullarg (int numArg);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbuffer.c,v 1.3 1998/06/02 20:37:04 roberto Exp roberto $
|
** $Id: lbuffer.c,v 1.4 1998/06/19 16:14:09 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -42,7 +42,7 @@ char *luaL_openspace (int size)
|
||||||
void luaL_addchar (int c)
|
void luaL_addchar (int c)
|
||||||
{
|
{
|
||||||
openspace(BUFF_STEP);
|
openspace(BUFF_STEP);
|
||||||
L->Mbuffer[L->Mbuffnext++] = c;
|
L->Mbuffer[L->Mbuffnext++] = (char)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
18
lbuiltin.c
18
lbuiltin.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbuiltin.c,v 1.38 1998/12/15 15:21:09 roberto Exp roberto $
|
** $Id: lbuiltin.c,v 1.40 1998/12/27 20:22:36 roberto Exp roberto $
|
||||||
** Built-in functions
|
** Built-in functions
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -133,7 +133,7 @@ static void luaB_print (void) {
|
||||||
|
|
||||||
|
|
||||||
static void luaB_tonumber (void) {
|
static void luaB_tonumber (void) {
|
||||||
int base = luaL_opt_number(2, 10);
|
int base = luaL_opt_int(2, 10);
|
||||||
if (base == 10) { /* standard conversion */
|
if (base == 10) { /* standard conversion */
|
||||||
lua_Object o = lua_getparam(1);
|
lua_Object o = lua_getparam(1);
|
||||||
if (lua_isnumber(o))
|
if (lua_isnumber(o))
|
||||||
|
@ -186,7 +186,7 @@ static void luaB_luatag (void) {
|
||||||
static void luaB_settag (void) {
|
static void luaB_settag (void) {
|
||||||
lua_Object o = luaL_tablearg(1);
|
lua_Object o = luaL_tablearg(1);
|
||||||
lua_pushobject(o);
|
lua_pushobject(o);
|
||||||
lua_settag(luaL_check_number(2));
|
lua_settag(luaL_check_int(2));
|
||||||
lua_pushobject(o); /* returns first argument */
|
lua_pushobject(o); /* returns first argument */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,8 +195,8 @@ static void luaB_newtag (void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void luaB_copytagmethods (void) {
|
static void luaB_copytagmethods (void) {
|
||||||
lua_pushnumber(lua_copytagmethods(luaL_check_number(1),
|
lua_pushnumber(lua_copytagmethods(luaL_check_int(1),
|
||||||
luaL_check_number(2)));
|
luaL_check_int(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void luaB_rawgettable (void) {
|
static void luaB_rawgettable (void) {
|
||||||
|
@ -215,13 +215,11 @@ static void luaB_rawsettable (void) {
|
||||||
static void luaB_settagmethod (void) {
|
static void luaB_settagmethod (void) {
|
||||||
lua_Object nf = luaL_nonnullarg(3);
|
lua_Object nf = luaL_nonnullarg(3);
|
||||||
lua_pushobject(nf);
|
lua_pushobject(nf);
|
||||||
lua_pushobject(lua_settagmethod((int)luaL_check_number(1),
|
lua_pushobject(lua_settagmethod(luaL_check_int(1), luaL_check_string(2)));
|
||||||
luaL_check_string(2)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void luaB_gettagmethod (void) {
|
static void luaB_gettagmethod (void) {
|
||||||
lua_pushobject(lua_gettagmethod((int)luaL_check_number(1),
|
lua_pushobject(lua_gettagmethod(luaL_check_int(1), luaL_check_string(2)));
|
||||||
luaL_check_string(2)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void luaB_seterrormethod (void) {
|
static void luaB_seterrormethod (void) {
|
||||||
|
@ -231,7 +229,7 @@ static void luaB_seterrormethod (void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void luaB_collectgarbage (void) {
|
static void luaB_collectgarbage (void) {
|
||||||
lua_pushnumber(lua_collectgarbage(luaL_opt_number(1, 0)));
|
lua_pushnumber(lua_collectgarbage(luaL_opt_int(1, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
15
liolib.c
15
liolib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: liolib.c,v 1.26 1998/11/20 15:41:43 roberto Exp roberto $
|
** $Id: liolib.c,v 1.27 1998/12/27 20:21:28 roberto Exp roberto $
|
||||||
** Standard I/O (and system) library
|
** Standard I/O (and system) library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -105,8 +105,11 @@ static FILE *getfileparam (char *name, int *arg) {
|
||||||
static char *getmode (char mode) {
|
static char *getmode (char mode) {
|
||||||
static char m[3];
|
static char m[3];
|
||||||
m[0] = mode;
|
m[0] = mode;
|
||||||
m[1] = (*luaL_opt_string(FIRSTARG+1, "text") == 'b') ? 'b' : '\0';
|
if (*luaL_opt_string(FIRSTARG+1, "text") == 'b') {
|
||||||
m[2] = '\0';
|
m[1] = 'b';
|
||||||
|
m[2] = '\0';
|
||||||
|
}
|
||||||
|
else m[1] = '\0';
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +311,7 @@ static void io_read (void) {
|
||||||
l = luaL_getsize();
|
l = luaL_getsize();
|
||||||
if (!success && l==0) return; /* read fails */
|
if (!success && l==0) return; /* read fails */
|
||||||
lua_pushlstring(luaL_buffer(), l);
|
lua_pushlstring(luaL_buffer(), l);
|
||||||
} while ((p = luaL_opt_string(arg++, NULL)));
|
} while ((p = luaL_opt_string(arg++, NULL)) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,7 +322,7 @@ static void io_write (void) {
|
||||||
char *s;
|
char *s;
|
||||||
long l;
|
long l;
|
||||||
while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL)
|
while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL)
|
||||||
status = status && (fwrite(s, 1, l, f) == l);
|
status = status && ((long)fwrite(s, 1, l, f) == l);
|
||||||
pushresult(status);
|
pushresult(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +332,7 @@ static void io_seek (void) {
|
||||||
static char *modenames[] = {"set", "cur", "end", NULL};
|
static char *modenames[] = {"set", "cur", "end", NULL};
|
||||||
FILE *f = getfile(FIRSTARG-1+1);
|
FILE *f = getfile(FIRSTARG-1+1);
|
||||||
int op = luaL_findstring(luaL_opt_string(FIRSTARG-1+2, "cur"), modenames);
|
int op = luaL_findstring(luaL_opt_string(FIRSTARG-1+2, "cur"), modenames);
|
||||||
long offset = luaL_opt_number(FIRSTARG-1+3, 0);
|
long offset = luaL_opt_long(FIRSTARG-1+3, 0);
|
||||||
luaL_arg_check(f, FIRSTARG-1+1, "invalid file handler");
|
luaL_arg_check(f, FIRSTARG-1+1, "invalid file handler");
|
||||||
luaL_arg_check(op != -1, FIRSTARG-1+2, "invalid mode");
|
luaL_arg_check(op != -1, FIRSTARG-1+2, "invalid mode");
|
||||||
op = fseek(f, offset, mode[op]);
|
op = fseek(f, offset, mode[op]);
|
||||||
|
|
8
llex.c
8
llex.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 1.25 1998/12/03 15:45:15 roberto Exp $
|
** $Id: llex.c,v 1.26 1998/12/27 20:25:20 roberto Exp roberto $
|
||||||
** Lexical Analizer
|
** Lexical Analizer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -61,7 +61,7 @@ void luaX_error (LexState *ls, char *s) {
|
||||||
|
|
||||||
void luaX_token2str (int token, char *s) {
|
void luaX_token2str (int token, char *s) {
|
||||||
if (token < 255) {
|
if (token < 255) {
|
||||||
s[0] = token;
|
s[0] = (char)token;
|
||||||
s[1] = '\0';
|
s[1] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -138,7 +138,7 @@ static void readname (LexState *LS, char *buff)
|
||||||
buff[PRAGMASIZE] = 0;
|
buff[PRAGMASIZE] = 0;
|
||||||
luaX_syntaxerror(LS, "pragma too long", buff);
|
luaX_syntaxerror(LS, "pragma too long", buff);
|
||||||
}
|
}
|
||||||
buff[i++] = LS->current;
|
buff[i++] = (char)LS->current;
|
||||||
next(LS);
|
next(LS);
|
||||||
}
|
}
|
||||||
buff[i] = 0;
|
buff[i] = 0;
|
||||||
|
@ -344,7 +344,7 @@ int luaX_lex (LexState *LS) {
|
||||||
c = 10*c + (LS->current-'0');
|
c = 10*c + (LS->current-'0');
|
||||||
next(LS);
|
next(LS);
|
||||||
} while (++i<3 && isdigit(LS->current));
|
} while (++i<3 && isdigit(LS->current));
|
||||||
if (c > (unsigned char)c)
|
if (c != (unsigned char)c)
|
||||||
luaX_error(LS, "escape sequence too large");
|
luaX_error(LS, "escape sequence too large");
|
||||||
save(c);
|
save(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lmathlib.c,v 1.10 1998/06/19 16:14:09 roberto Exp roberto $
|
** $Id: lmathlib.c,v 1.11 1998/09/08 19:25:35 roberto Exp roberto $
|
||||||
** Lua standard mathematical library
|
** Lua standard mathematical library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -122,7 +122,7 @@ static void math_frexp (void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void math_ldexp (void) {
|
static void math_ldexp (void) {
|
||||||
lua_pushnumber(ldexp(luaL_check_number(1), luaL_check_number(2)));
|
lua_pushnumber(ldexp(luaL_check_number(1), luaL_check_int(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,9 +166,8 @@ static void math_random (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void math_randomseed (void)
|
static void math_randomseed (void) {
|
||||||
{
|
srand(luaL_check_int(1));
|
||||||
srand(luaL_check_number(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
30
lparser.c
30
lparser.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 1.5 1998/08/11 13:28:05 roberto Exp roberto $
|
** $Id: lparser.c,v 1.6 1998/12/23 14:06:57 roberto Exp roberto $
|
||||||
** LL(1) Parser and code generator for Lua
|
** LL(1) Parser and code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -158,18 +158,18 @@ static int code_oparg_at (LexState *ls, int pc, OpCode op, int builtin,
|
||||||
Byte *code = ls->fs->f->code;
|
Byte *code = ls->fs->f->code;
|
||||||
deltastack(ls, delta);
|
deltastack(ls, delta);
|
||||||
if (arg < builtin) {
|
if (arg < builtin) {
|
||||||
code[pc] = op+1+arg;
|
code[pc] = (Byte)(op+1+arg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (arg <= 255) {
|
else if (arg <= 255) {
|
||||||
code[pc] = op;
|
code[pc] = (Byte)op;
|
||||||
code[pc+1] = arg;
|
code[pc+1] = (Byte)arg;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
else if (arg <= MAX_WORD) {
|
else if (arg <= MAX_WORD) {
|
||||||
code[pc] = op+1+builtin;
|
code[pc] = (Byte)(op+1+builtin);
|
||||||
code[pc+1] = arg>>8;
|
code[pc+1] = (Byte)(arg>>8);
|
||||||
code[pc+2] = arg&0xFF;
|
code[pc+2] = (Byte)(arg&0xFF);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
else luaX_error(ls, "code too long " MES_LIM("64K")
|
else luaX_error(ls, "code too long " MES_LIM("64K")
|
||||||
|
@ -202,7 +202,7 @@ static void code_oparg (LexState *ls, OpCode op, int builtin, int arg,
|
||||||
|
|
||||||
static void code_opcode (LexState *ls, OpCode op, int delta) {
|
static void code_opcode (LexState *ls, OpCode op, int delta) {
|
||||||
deltastack(ls, delta);
|
deltastack(ls, delta);
|
||||||
code_byte(ls->fs, op);
|
code_byte(ls->fs, (Byte)op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ static void flush_record (LexState *ls, int n) {
|
||||||
static void flush_list (LexState *ls, int m, int n) {
|
static void flush_list (LexState *ls, int m, int n) {
|
||||||
if (n == 0) return;
|
if (n == 0) return;
|
||||||
code_oparg(ls, SETLIST, 1, m, -n);
|
code_oparg(ls, SETLIST, 1, m, -n);
|
||||||
code_byte(ls->fs, n);
|
code_byte(ls->fs, (Byte)n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ static void adjuststack (LexState *ls, int n) {
|
||||||
static void close_exp (LexState *ls, int pc, int nresults) {
|
static void close_exp (LexState *ls, int pc, int nresults) {
|
||||||
if (pc > 0) { /* expression is an open function call */
|
if (pc > 0) { /* expression is an open function call */
|
||||||
Byte *code = ls->fs->f->code;
|
Byte *code = ls->fs->f->code;
|
||||||
int nparams = code[pc]; /* save nparams */
|
Byte nparams = code[pc]; /* save nparams */
|
||||||
pc += fix_opcode(ls, pc-2, CALLFUNC, 2, nresults);
|
pc += fix_opcode(ls, pc-2, CALLFUNC, 2, nresults);
|
||||||
code[pc] = nparams; /* restore nparams */
|
code[pc] = nparams; /* restore nparams */
|
||||||
if (nresults != MULT_RET)
|
if (nresults != MULT_RET)
|
||||||
|
@ -426,11 +426,11 @@ static void code_args (LexState *ls, int nparams, int dots) {
|
||||||
fs->nlocalvar += nparams; /* "self" may already be there */
|
fs->nlocalvar += nparams; /* "self" may already be there */
|
||||||
nparams = fs->nlocalvar;
|
nparams = fs->nlocalvar;
|
||||||
if (!dots) {
|
if (!dots) {
|
||||||
fs->f->code[1] = nparams; /* fill-in arg information */
|
fs->f->code[1] = (Byte)nparams; /* fill-in arg information */
|
||||||
deltastack(ls, nparams);
|
deltastack(ls, nparams);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fs->f->code[1] = nparams+ZEROVARARG;
|
fs->f->code[1] = (Byte)(nparams+ZEROVARARG);
|
||||||
deltastack(ls, nparams+1);
|
deltastack(ls, nparams+1);
|
||||||
add_localvar(ls, luaS_new("arg"));
|
add_localvar(ls, luaS_new("arg"));
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ static void func_onstack (LexState *ls, FuncState *func) {
|
||||||
for (i=0; i<func->nupvalues; i++)
|
for (i=0; i<func->nupvalues; i++)
|
||||||
lua_pushvar(ls, &func->upvalues[i]);
|
lua_pushvar(ls, &func->upvalues[i]);
|
||||||
code_oparg(ls, CLOSURE, 0, c, -func->nupvalues+1);
|
code_oparg(ls, CLOSURE, 0, c, -func->nupvalues+1);
|
||||||
code_byte(fs, func->nupvalues);
|
code_byte(fs, (Byte)func->nupvalues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ static void close_func (LexState *ls) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
TProtoFunc *f = fs->f;
|
TProtoFunc *f = fs->f;
|
||||||
code_opcode(ls, ENDCODE, 0);
|
code_opcode(ls, ENDCODE, 0);
|
||||||
f->code[0] = fs->maxstacksize;
|
f->code[0] = (Byte)fs->maxstacksize;
|
||||||
f->code = luaM_reallocvector(f->code, fs->pc, Byte);
|
f->code = luaM_reallocvector(f->code, fs->pc, Byte);
|
||||||
f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject);
|
f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject);
|
||||||
if (fs->maxvars != -1) { /* debug information? */
|
if (fs->maxvars != -1) { /* debug information? */
|
||||||
|
@ -1092,7 +1092,7 @@ static int funcparams (LexState *ls, int slf) {
|
||||||
}
|
}
|
||||||
code_byte(fs, 0); /* save space for opcode */
|
code_byte(fs, 0); /* save space for opcode */
|
||||||
code_byte(fs, 0); /* and nresult */
|
code_byte(fs, 0); /* and nresult */
|
||||||
code_byte(fs, nparams+slf);
|
code_byte(fs, (Byte)(nparams+slf));
|
||||||
return fs->pc-1;
|
return fs->pc-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
lstrlib.c
18
lstrlib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.20 1998/11/10 19:38:12 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.21 1998/12/01 18:41:25 roberto Exp roberto $
|
||||||
** Standard library for strings and pattern-matching
|
** Standard library for strings and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -46,8 +46,8 @@ static long posrelat (long pos, long len) {
|
||||||
static void str_sub (void) {
|
static void str_sub (void) {
|
||||||
long l;
|
long l;
|
||||||
char *s = luaL_check_lstr(1, &l);
|
char *s = luaL_check_lstr(1, &l);
|
||||||
long start = posrelat(luaL_check_number(2), l);
|
long start = posrelat(luaL_check_long(2), l);
|
||||||
long end = posrelat(luaL_opt_number(3, -1), l);
|
long end = posrelat(luaL_opt_long(3, -1), l);
|
||||||
if (start < 1) start = 1;
|
if (start < 1) start = 1;
|
||||||
if (end > l) end = l;
|
if (end > l) end = l;
|
||||||
if (start <= end)
|
if (start <= end)
|
||||||
|
@ -82,7 +82,7 @@ static void str_rep (void)
|
||||||
{
|
{
|
||||||
long l;
|
long l;
|
||||||
char *s = luaL_check_lstr(1, &l);
|
char *s = luaL_check_lstr(1, &l);
|
||||||
int n = (int)luaL_check_number(2);
|
int n = luaL_check_int(2);
|
||||||
luaL_resetbuffer();
|
luaL_resetbuffer();
|
||||||
while (n-- > 0)
|
while (n-- > 0)
|
||||||
addnchar(s, l);
|
addnchar(s, l);
|
||||||
|
@ -94,7 +94,7 @@ static void str_byte (void)
|
||||||
{
|
{
|
||||||
long l;
|
long l;
|
||||||
char *s = luaL_check_lstr(1, &l);
|
char *s = luaL_check_lstr(1, &l);
|
||||||
long pos = posrelat(luaL_opt_number(2, 1), l);
|
long pos = posrelat(luaL_opt_long(2, 1), l);
|
||||||
luaL_arg_check(0<pos && pos<=l, 2, "out of range");
|
luaL_arg_check(0<pos && pos<=l, 2, "out of range");
|
||||||
lua_pushnumber((unsigned char)s[pos-1]);
|
lua_pushnumber((unsigned char)s[pos-1]);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ static void str_char (void) {
|
||||||
while (lua_getparam(++i) != LUA_NOOBJECT) {
|
while (lua_getparam(++i) != LUA_NOOBJECT) {
|
||||||
double c = luaL_check_number(i);
|
double c = luaL_check_number(i);
|
||||||
luaL_arg_check((unsigned char)c == c, i, "invalid value");
|
luaL_arg_check((unsigned char)c == c, i, "invalid value");
|
||||||
luaL_addchar((int)c);
|
luaL_addchar((unsigned char)c);
|
||||||
}
|
}
|
||||||
closeandpush();
|
closeandpush();
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ static void str_find (void)
|
||||||
long l;
|
long l;
|
||||||
char *s = luaL_check_lstr(1, &l);
|
char *s = luaL_check_lstr(1, &l);
|
||||||
char *p = luaL_check_string(2);
|
char *p = luaL_check_string(2);
|
||||||
long init = posrelat(luaL_opt_number(3, 1), l) - 1;
|
long init = posrelat(luaL_opt_long(3, 1), l) - 1;
|
||||||
struct Capture cap;
|
struct Capture cap;
|
||||||
luaL_arg_check(0 <= init && init <= l, 3, "out of range");
|
luaL_arg_check(0 <= init && init <= l, 3, "out of range");
|
||||||
if (lua_getparam(4) != LUA_NOOBJECT ||
|
if (lua_getparam(4) != LUA_NOOBJECT ||
|
||||||
|
@ -418,7 +418,7 @@ static void str_gsub (void)
|
||||||
char *src = luaL_check_lstr(1, &srcl);
|
char *src = luaL_check_lstr(1, &srcl);
|
||||||
char *p = luaL_check_string(2);
|
char *p = luaL_check_string(2);
|
||||||
lua_Object newp = lua_getparam(3);
|
lua_Object newp = lua_getparam(3);
|
||||||
int max_s = (int)luaL_opt_number(4, srcl+1);
|
int max_s = luaL_opt_int(4, srcl+1);
|
||||||
int anchor = (*p == '^') ? (p++, 1) : 0;
|
int anchor = (*p == '^') ? (p++, 1) : 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
struct Capture cap;
|
struct Capture cap;
|
||||||
|
@ -507,7 +507,7 @@ static void str_format (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'c': case 'd': case 'i':
|
case 'c': case 'd': case 'i':
|
||||||
sprintf(buff, form, (int)luaL_check_number(arg));
|
sprintf(buff, form, luaL_check_int(arg));
|
||||||
break;
|
break;
|
||||||
case 'o': case 'u': case 'x': case 'X':
|
case 'o': case 'u': case 'x': case 'X':
|
||||||
sprintf(buff, form, (unsigned int)luaL_check_number(arg));
|
sprintf(buff, form, (unsigned int)luaL_check_number(arg));
|
||||||
|
|
36
lua.c
36
lua.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lua.c,v 1.13 1998/01/19 19:49:49 roberto Exp roberto $
|
** $Id: lua.c,v 1.14 1998/02/11 20:56:05 roberto Exp roberto $
|
||||||
** Lua stand-alone interpreter
|
** Lua stand-alone interpreter
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -32,27 +32,27 @@ typedef void (*handler)(int); /* type for signal actions */
|
||||||
|
|
||||||
static void laction (int i);
|
static void laction (int i);
|
||||||
|
|
||||||
static handler lreset (void)
|
|
||||||
{
|
static handler lreset (void) {
|
||||||
lua_linehook = NULL;
|
lua_linehook = NULL;
|
||||||
lua_callhook = NULL;
|
lua_callhook = NULL;
|
||||||
return signal(SIGINT, laction);
|
return signal(SIGINT, laction);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lstop (void)
|
|
||||||
{
|
static void lstop (void) {
|
||||||
lreset();
|
lreset();
|
||||||
lua_error("interrupted!");
|
lua_error("interrupted!");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void laction (int i)
|
|
||||||
{
|
static void laction (int i) {
|
||||||
lua_linehook = (lua_LHFunction)lstop;
|
lua_linehook = (lua_LHFunction)lstop;
|
||||||
lua_callhook = (lua_CHFunction)lstop;
|
lua_callhook = (lua_CHFunction)lstop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ldo (int (*f)(char *), char *name)
|
|
||||||
{
|
static int ldo (int (*f)(char *), char *name) {
|
||||||
int res;
|
int res;
|
||||||
handler h = lreset();
|
handler h = lreset();
|
||||||
res = f(name); /* dostring | dofile */
|
res = f(name); /* dostring | dofile */
|
||||||
|
@ -61,8 +61,7 @@ static int ldo (int (*f)(char *), char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void print_message (void)
|
static void print_message (void) {
|
||||||
{
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Lua: command line options:\n"
|
"Lua: command line options:\n"
|
||||||
" -v print version information\n"
|
" -v print version information\n"
|
||||||
|
@ -76,8 +75,7 @@ static void print_message (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void assign (char *arg)
|
static void assign (char *arg) {
|
||||||
{
|
|
||||||
if (strlen(arg) >= 500)
|
if (strlen(arg) >= 500)
|
||||||
fprintf(stderr, "lua: shell argument too long");
|
fprintf(stderr, "lua: shell argument too long");
|
||||||
else {
|
else {
|
||||||
|
@ -90,13 +88,11 @@ static void assign (char *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUF_SIZE 512
|
|
||||||
|
|
||||||
static void manual_input (int prompt)
|
static void manual_input (int prompt) {
|
||||||
{
|
|
||||||
int cont = 1;
|
int cont = 1;
|
||||||
while (cont) {
|
while (cont) {
|
||||||
char buffer[BUF_SIZE];
|
char buffer[BUFSIZ];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
lua_beginblock();
|
lua_beginblock();
|
||||||
if (prompt)
|
if (prompt)
|
||||||
|
@ -112,13 +108,13 @@ static void manual_input (int prompt)
|
||||||
buffer[i-1] = '\n';
|
buffer[i-1] = '\n';
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
else if (i >= BUF_SIZE-1) {
|
else if (i >= BUFSIZ-1) {
|
||||||
fprintf(stderr, "lua: argument line too long\n");
|
fprintf(stderr, "lua: argument line too long\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else buffer[i++] = c;
|
else buffer[i++] = (char)c;
|
||||||
}
|
}
|
||||||
buffer[i] = 0;
|
buffer[i] = '\0';
|
||||||
ldo(lua_dostring, buffer);
|
ldo(lua_dostring, buffer);
|
||||||
lua_endblock();
|
lua_endblock();
|
||||||
}
|
}
|
||||||
|
|
6
lzio.c
6
lzio.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lzio.c,v 1.2 1997/11/21 19:00:46 roberto Exp roberto $
|
** $Id: lzio.c,v 1.3 1997/12/22 20:57:18 roberto Exp roberto $
|
||||||
** a generic input stream interface
|
** a generic input stream interface
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -15,11 +15,11 @@
|
||||||
|
|
||||||
/* ----------------------------------------------------- memory buffers --- */
|
/* ----------------------------------------------------- memory buffers --- */
|
||||||
|
|
||||||
static int zmfilbuf (ZIO* z)
|
static int zmfilbuf (ZIO* z) {
|
||||||
{
|
|
||||||
return EOZ;
|
return EOZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ZIO* zmopen (ZIO* z, char* b, int size, char *name)
|
ZIO* zmopen (ZIO* z, char* b, int size, char *name)
|
||||||
{
|
{
|
||||||
if (b==NULL) return NULL;
|
if (b==NULL) return NULL;
|
||||||
|
|
Loading…
Reference in New Issue