mirror of https://github.com/rusefi/lua.git
small changes for "clean C"
This commit is contained in:
parent
1f691a4fcd
commit
74f1c3d025
9
lapi.c
9
lapi.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.69 2000/01/19 12:00:45 roberto Exp roberto $
|
** $Id: lapi.c,v 1.70 2000/01/24 20:14:07 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -129,12 +129,13 @@ lua_Object lua_gettable (lua_State *L) {
|
||||||
|
|
||||||
|
|
||||||
lua_Object lua_rawgettable (lua_State *L) {
|
lua_Object lua_rawgettable (lua_State *L) {
|
||||||
|
lua_Object res;
|
||||||
luaA_checkCparams(L, 2);
|
luaA_checkCparams(L, 2);
|
||||||
if (ttype(L->top-2) != LUA_T_ARRAY)
|
if (ttype(L->top-2) != LUA_T_ARRAY)
|
||||||
lua_error(L, "indexed expression not a table in rawgettable");
|
lua_error(L, "indexed expression not a table in rawgettable");
|
||||||
*(L->top-2) = *luaH_get(L, avalue(L->top-2), L->top-1);
|
res = luaA_putluaObject(L, luaH_get(L, avalue(L->top-2), L->top-1));
|
||||||
--L->top;
|
L->top -= 2;
|
||||||
return luaA_putObjectOnTop(L);
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.24 1999/12/28 11:52:49 roberto Exp roberto $
|
** $Id: lauxlib.c,v 1.25 2000/01/19 12:00:45 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,11 +42,11 @@ void luaL_argerror (lua_State *L, int narg, const char *extramsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void type_error (lua_State *L, int narg, const char *typename,
|
static void type_error (lua_State *L, int narg, const char *type_name,
|
||||||
lua_Object o) {
|
lua_Object o) {
|
||||||
char buff[100];
|
char buff[100];
|
||||||
const char *otype = (o == LUA_NOOBJECT) ? "no value" : lua_type(L, o);
|
const char *otype = (o == LUA_NOOBJECT) ? "no value" : lua_type(L, o);
|
||||||
sprintf(buff, "%.10s expected, got %.10s", typename, otype);
|
sprintf(buff, "%.10s expected, got %.10s", type_name, otype);
|
||||||
luaL_argerror(L, narg, buff);
|
luaL_argerror(L, narg, buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
ldo.c
14
ldo.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.65 2000/01/13 15:56:03 roberto Exp roberto $
|
** $Id: ldo.c,v 1.66 2000/01/19 12:00:45 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -266,9 +266,9 @@ void lua_error (lua_State *L, const char *s) {
|
||||||
*/
|
*/
|
||||||
int luaD_protectedrun (lua_State *L) {
|
int luaD_protectedrun (lua_State *L) {
|
||||||
struct lua_longjmp myErrorJmp;
|
struct lua_longjmp myErrorJmp;
|
||||||
volatile StkId base = L->Cstack.base;
|
StkId base = L->Cstack.base;
|
||||||
volatile int numCblocks = L->numCblocks;
|
int numCblocks = L->numCblocks;
|
||||||
volatile int status;
|
int status;
|
||||||
struct lua_longjmp *volatile oldErr = L->errorJmp;
|
struct lua_longjmp *volatile oldErr = L->errorJmp;
|
||||||
L->errorJmp = &myErrorJmp;
|
L->errorJmp = &myErrorJmp;
|
||||||
if (setjmp(myErrorJmp.b) == 0) {
|
if (setjmp(myErrorJmp.b) == 0) {
|
||||||
|
@ -295,9 +295,9 @@ int luaD_protectedrun (lua_State *L) {
|
||||||
*/
|
*/
|
||||||
static int protectedparser (lua_State *L, ZIO *z, int bin) {
|
static int protectedparser (lua_State *L, ZIO *z, int bin) {
|
||||||
struct lua_longjmp myErrorJmp;
|
struct lua_longjmp myErrorJmp;
|
||||||
volatile StkId base = L->Cstack.base;
|
StkId base = L->Cstack.base;
|
||||||
volatile int numCblocks = L->numCblocks;
|
int numCblocks = L->numCblocks;
|
||||||
volatile int status;
|
int status;
|
||||||
TProtoFunc *volatile tf;
|
TProtoFunc *volatile tf;
|
||||||
struct lua_longjmp *volatile oldErr = L->errorJmp;
|
struct lua_longjmp *volatile oldErr = L->errorJmp;
|
||||||
L->errorJmp = &myErrorJmp;
|
L->errorJmp = &myErrorJmp;
|
||||||
|
|
36
liolib.c
36
liolib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: liolib.c,v 1.55 1999/12/30 18:28:40 roberto Exp roberto $
|
** $Id: liolib.c,v 1.56 2000/01/19 12:00:45 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
|
||||||
*/
|
*/
|
||||||
|
@ -80,28 +80,30 @@ static int gettag (lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ishandle (lua_State *L, lua_Object f) {
|
static FILE *gethandle (lua_State *L, lua_Object f) {
|
||||||
if (lua_isuserdata(L, f)) {
|
if (lua_isuserdata(L, f)) {
|
||||||
int tag = gettag(L);
|
int ftag = lua_tag(L, f);
|
||||||
if (lua_tag(L, f) == CLOSEDTAG(L, tag))
|
int iotag = gettag(L);
|
||||||
|
if (ftag == iotag)
|
||||||
|
return (FILE *)lua_getuserdata(L, f);
|
||||||
|
if (ftag == CLOSEDTAG(L, iotag))
|
||||||
lua_error(L, "cannot access a closed file");
|
lua_error(L, "cannot access a closed file");
|
||||||
return lua_tag(L, f) == tag;
|
/* else go through */
|
||||||
}
|
}
|
||||||
else return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static FILE *getfilebyname (lua_State *L, const char *name) {
|
static FILE *getfilebyname (lua_State *L, const char *name) {
|
||||||
lua_Object f = lua_rawgetglobal(L, name);
|
FILE *handle = gethandle(L, lua_rawgetglobal(L, name));
|
||||||
if (!ishandle(L, f))
|
if (!handle)
|
||||||
luaL_verror(L, "global variable `%.50s' is not a file handle", name);
|
luaL_verror(L, "global variable `%.50s' is not a file handle", name);
|
||||||
return lua_getuserdata(L, f);
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static FILE *getfile (lua_State *L, int arg) {
|
static FILE *getfile (lua_State *L, int arg) {
|
||||||
lua_Object f = lua_getparam(L, arg);
|
return gethandle(L, lua_getparam(L, arg));
|
||||||
return (ishandle(L, f)) ? lua_getuserdata(L, f) : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,7 +184,7 @@ static void io_readfrom (lua_State *L) {
|
||||||
current = NULL; /* to signal error */
|
current = NULL; /* to signal error */
|
||||||
}
|
}
|
||||||
else if (lua_tag(L, f) == gettag(L)) /* deprecated option */
|
else if (lua_tag(L, f) == gettag(L)) /* deprecated option */
|
||||||
current = lua_getuserdata(L, f);
|
current = (FILE *)lua_getuserdata(L, f);
|
||||||
else {
|
else {
|
||||||
const char *s = luaL_check_string(L, FIRSTARG);
|
const char *s = luaL_check_string(L, FIRSTARG);
|
||||||
current = (*s == '|') ? popen(s+1, "r") : fopen(s, "r");
|
current = (*s == '|') ? popen(s+1, "r") : fopen(s, "r");
|
||||||
|
@ -201,7 +203,7 @@ static void io_writeto (lua_State *L) {
|
||||||
current = NULL; /* to signal error */
|
current = NULL; /* to signal error */
|
||||||
}
|
}
|
||||||
else if (lua_tag(L, f) == gettag(L)) /* deprecated option */
|
else if (lua_tag(L, f) == gettag(L)) /* deprecated option */
|
||||||
current = lua_getuserdata(L, f);
|
current = (FILE *)lua_getuserdata(L, f);
|
||||||
else {
|
else {
|
||||||
const char *s = luaL_check_string(L, FIRSTARG);
|
const char *s = luaL_check_string(L, FIRSTARG);
|
||||||
current = (*s == '|') ? popen(s+1,"w") : fopen(s, "w");
|
current = (*s == '|') ? popen(s+1,"w") : fopen(s, "w");
|
||||||
|
@ -301,7 +303,7 @@ static int read_number (lua_State *L, FILE *f) {
|
||||||
|
|
||||||
static void read_word (lua_State *L, FILE *f) {
|
static void read_word (lua_State *L, FILE *f) {
|
||||||
int c;
|
int c;
|
||||||
do { c = fgetc(f); } while isspace(c); /* skip spaces */
|
do { c = fgetc(f); } while (isspace(c)); /* skip spaces */
|
||||||
while (c != EOF && !isspace(c)) {
|
while (c != EOF && !isspace(c)) {
|
||||||
luaL_addchar(L, c);
|
luaL_addchar(L, c);
|
||||||
c = fgetc(f);
|
c = fgetc(f);
|
||||||
|
@ -477,10 +479,10 @@ static void io_clock (lua_State *L) {
|
||||||
static void io_date (lua_State *L) {
|
static void io_date (lua_State *L) {
|
||||||
char b[256];
|
char b[256];
|
||||||
const char *s = luaL_opt_string(L, 1, "%c");
|
const char *s = luaL_opt_string(L, 1, "%c");
|
||||||
struct tm *tm;
|
struct tm *stm;
|
||||||
time_t t;
|
time_t t;
|
||||||
time(&t); tm = localtime(&t);
|
time(&t); stm = localtime(&t);
|
||||||
if (strftime(b,sizeof(b),s,tm))
|
if (strftime(b, sizeof(b), s, stm))
|
||||||
lua_pushstring(L, b);
|
lua_pushstring(L, b);
|
||||||
else
|
else
|
||||||
lua_error(L, "invalid `date' format");
|
lua_error(L, "invalid `date' format");
|
||||||
|
|
14
llex.c
14
llex.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 1.49 2000/01/25 18:44:21 roberto Exp roberto $
|
** $Id: llex.c,v 1.50 2000/01/26 18:51:49 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -31,15 +31,15 @@
|
||||||
|
|
||||||
|
|
||||||
/* ORDER RESERVED */
|
/* ORDER RESERVED */
|
||||||
static const char *const reserved [] = {"and", "do", "else", "elseif", "end",
|
static const char *const token2string [] = {"and", "do", "else", "elseif", "end",
|
||||||
"function", "if", "local", "nil", "not", "or", "repeat", "return", "then",
|
"function", "if", "local", "nil", "not", "or", "repeat", "return", "then",
|
||||||
"until", "while", "", "..", "...", "==", ">=", "<=", "~=", "", "", ""};
|
"until", "while", "", "..", "...", "==", ">=", "<=", "~=", "", "", "<eof>"};
|
||||||
|
|
||||||
|
|
||||||
void luaX_init (lua_State *L) {
|
void luaX_init (lua_State *L) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) {
|
for (i=0; i<NUM_RESERVED; i++) {
|
||||||
TaggedString *ts = luaS_new(L, reserved[i]);
|
TaggedString *ts = luaS_new(L, token2string[i]);
|
||||||
ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */
|
ts->marked = (unsigned char)(RESERVEDMARK+i); /* reserved word */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,6 @@ void luaX_init (lua_State *L) {
|
||||||
void luaX_syntaxerror (LexState *ls, const char *s, const char *token) {
|
void luaX_syntaxerror (LexState *ls, const char *s, const char *token) {
|
||||||
char buff[MAXSRC];
|
char buff[MAXSRC];
|
||||||
luaL_chunkid(buff, zname(ls->lex_z), sizeof(buff));
|
luaL_chunkid(buff, zname(ls->lex_z), sizeof(buff));
|
||||||
if (token[0] == '\0')
|
|
||||||
token = "<eof>";
|
|
||||||
luaL_verror(ls->L, "%.100s;\n last token read: `%.50s' at line %d in %.80s",
|
luaL_verror(ls->L, "%.100s;\n last token read: `%.50s' at line %d in %.80s",
|
||||||
s, token, ls->linenumber, buff);
|
s, token, ls->linenumber, buff);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +73,7 @@ void luaX_token2str (int token, char *s) {
|
||||||
s[1] = '\0';
|
s[1] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strcpy(s, reserved[token-FIRST_RESERVED]);
|
strcpy(s, token2string[token-FIRST_RESERVED]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
7
llex.h
7
llex.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.h,v 1.16 1999/12/27 17:33:22 roberto Exp roberto $
|
** $Id: llex.h,v 1.17 2000/01/25 18:44:21 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,10 @@ enum RESERVED {
|
||||||
DO, ELSE, ELSEIF, END, FUNCTION, IF, LOCAL, NIL, NOT, OR,
|
DO, ELSE, ELSEIF, END, FUNCTION, IF, LOCAL, NIL, NOT, OR,
|
||||||
REPEAT, RETURN, THEN, UNTIL, WHILE,
|
REPEAT, RETURN, THEN, UNTIL, WHILE,
|
||||||
/* other terminal symbols */
|
/* other terminal symbols */
|
||||||
NAME, CONC, DOTS, EQ, GE, LE, NE, NUMBER, STRING, EOS};
|
NAME, CONC, DOTS, EQ, GE, LE, NE, NUMBER, STRING, EOS
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NUM_RESERVED (WHILE-FIRST_RESERVED+1) /* number of reserved words */
|
||||||
|
|
||||||
|
|
||||||
#ifndef MAX_IFS
|
#ifndef MAX_IFS
|
||||||
|
|
4
lmem.c
4
lmem.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lmem.c,v 1.23 1999/12/27 17:33:22 roberto Exp roberto $
|
** $Id: lmem.c,v 1.24 2000/01/13 16:30:47 roberto Exp roberto $
|
||||||
** Interface to Memory Manager
|
** Interface to Memory Manager
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -83,7 +83,7 @@ static void *debug_realloc (void *block, size_t size) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *newblock = (malloc)(realsize); /* alloc a new block */
|
char *newblock = (char *)(malloc)(realsize); /* alloc a new block */
|
||||||
int i;
|
int i;
|
||||||
if (block) {
|
if (block) {
|
||||||
size_t oldsize = *blocksize(block);
|
size_t oldsize = *blocksize(block);
|
||||||
|
|
6
lref.c
6
lref.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lref.c,v 1.5 1999/12/23 18:19:57 roberto Exp roberto $
|
** $Id: lref.c,v 1.6 1999/12/27 17:33:22 roberto Exp roberto $
|
||||||
** reference mechanism
|
** reference mechanism
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -25,7 +25,7 @@ int lua_ref (lua_State *L, int lock) {
|
||||||
L->refFree = L->refArray[ref].st;
|
L->refFree = L->refArray[ref].st;
|
||||||
}
|
}
|
||||||
else { /* no more free places */
|
else { /* no more free places */
|
||||||
luaM_growvector(L, L->refArray, L->refSize, 1, struct ref, refEM, MAX_INT);
|
luaM_growvector(L, L->refArray, L->refSize, 1, struct Ref, refEM, MAX_INT);
|
||||||
ref = L->refSize++;
|
ref = L->refSize++;
|
||||||
}
|
}
|
||||||
L->refArray[ref].o = *(L->top-1);
|
L->refArray[ref].o = *(L->top-1);
|
||||||
|
@ -102,7 +102,7 @@ void luaR_invalidaterefs (lua_State *L) {
|
||||||
int n = L->refSize;
|
int n = L->refSize;
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
struct ref *r = &L->refArray[i];
|
struct Ref *r = &L->refArray[i];
|
||||||
if (r->st == HOLD && !ismarked(&r->o))
|
if (r->st == HOLD && !ismarked(&r->o))
|
||||||
r->st = COLLECTED;
|
r->st = COLLECTED;
|
||||||
LUA_ASSERT(L, (r->st == LOCK && ismarked(&r->o)) ||
|
LUA_ASSERT(L, (r->st == LOCK && ismarked(&r->o)) ||
|
||||||
|
|
4
lref.h
4
lref.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lref.h,v 1.4 1999/12/14 18:33:29 roberto Exp roberto $
|
** $Id: lref.h,v 1.5 1999/12/27 17:33:22 roberto Exp roberto $
|
||||||
** reference mechanism
|
** reference mechanism
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
#define LOCK -4
|
#define LOCK -4
|
||||||
|
|
||||||
|
|
||||||
struct ref {
|
struct Ref {
|
||||||
TObject o;
|
TObject o;
|
||||||
int st; /* can be LOCK, HOLD, COLLECTED, or next (for free list) */
|
int st; /* can be LOCK, HOLD, COLLECTED, or next (for free list) */
|
||||||
};
|
};
|
||||||
|
|
6
lstate.h
6
lstate.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstate.h,v 1.27 1999/12/27 17:33:22 roberto Exp roberto $
|
** $Id: lstate.h,v 1.28 2000/01/19 12:00:45 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +30,7 @@ struct lua_longjmp {
|
||||||
/*
|
/*
|
||||||
** stack layout for C point of view:
|
** stack layout for C point of view:
|
||||||
** [lua2C, lua2C+num) - `array' lua2C
|
** [lua2C, lua2C+num) - `array' lua2C
|
||||||
** [lua2C+num, base) - space for extra lua_Objects
|
** [lua2C+num, base) - space for extra lua_Objects (limbo)
|
||||||
** [base, L->top) - `stack' C2Lua
|
** [base, L->top) - `stack' C2Lua
|
||||||
*/
|
*/
|
||||||
struct C_Lua_Stack {
|
struct C_Lua_Stack {
|
||||||
|
@ -70,7 +70,7 @@ struct lua_State {
|
||||||
stringtable *string_root; /* array of hash tables for strings and udata */
|
stringtable *string_root; /* array of hash tables for strings and udata */
|
||||||
struct IM *IMtable; /* table for tag methods */
|
struct IM *IMtable; /* table for tag methods */
|
||||||
int last_tag; /* last used tag in IMtable */
|
int last_tag; /* last used tag in IMtable */
|
||||||
struct ref *refArray; /* locked objects */
|
struct Ref *refArray; /* locked objects */
|
||||||
int refSize; /* size of refArray */
|
int refSize; /* size of refArray */
|
||||||
int refFree; /* list of free positions in refArray */
|
int refFree; /* list of free positions in refArray */
|
||||||
unsigned long GCthreshold;
|
unsigned long GCthreshold;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.38 1999/11/22 17:39:51 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.39 1999/12/27 17:33:22 roberto Exp roberto $
|
||||||
** Standard library for string operations and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -382,7 +382,7 @@ static const char *memfind (const char *s1, long l1, const char *s2, long l2) {
|
||||||
const char *init; /* to search for a `*s2' inside `s1' */
|
const char *init; /* to search for a `*s2' inside `s1' */
|
||||||
l2--; /* 1st char will be checked by `memchr' */
|
l2--; /* 1st char will be checked by `memchr' */
|
||||||
l1 = l1-l2; /* `s2' cannot be found after that */
|
l1 = l1-l2; /* `s2' cannot be found after that */
|
||||||
while (l1 > 0 && (init = memchr(s1, *s2, l1)) != NULL) {
|
while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
|
||||||
init++; /* 1st char is already checked */
|
init++; /* 1st char is already checked */
|
||||||
if (memcmp(init, s2+1, l2) == 0)
|
if (memcmp(init, s2+1, l2) == 0)
|
||||||
return init-1;
|
return init-1;
|
||||||
|
|
4
ltable.c
4
ltable.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ltable.c,v 1.32 1999/12/07 12:05:34 roberto Exp roberto $
|
** $Id: ltable.c,v 1.33 1999/12/23 18:19:57 roberto Exp roberto $
|
||||||
** Lua tables (hash)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -86,7 +86,7 @@ const TObject *luaH_get (lua_State *L, const Hash *t, const TObject *key) {
|
||||||
int luaH_pos (lua_State *L, const Hash *t, const TObject *key) {
|
int luaH_pos (lua_State *L, const Hash *t, const TObject *key) {
|
||||||
const TObject *v = luaH_get(L, t, key);
|
const TObject *v = luaH_get(L, t, key);
|
||||||
return (v == &luaO_nilobject) ? -1 : /* key not found */
|
return (v == &luaO_nilobject) ? -1 : /* key not found */
|
||||||
((const char *)v - (const char *)(&t->node[0].val))/sizeof(Node);
|
(int)(((const char *)v - (const char *)(&t->node[0].val))/sizeof(Node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
6
ltests.c
6
ltests.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ltests.c,v 1.5 2000/01/19 12:00:45 roberto Exp roberto $
|
** $Id: ltests.c,v 1.6 2000/01/24 20:11:26 roberto Exp roberto $
|
||||||
** Internal Module for Debugging of the Lua Implementation
|
** Internal Module for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -243,7 +243,7 @@ static void testC (lua_State *L) {
|
||||||
lua_pushuserdata(L, L1);
|
lua_pushuserdata(L, L1);
|
||||||
}
|
}
|
||||||
else if EQ("closestate") {
|
else if EQ("closestate") {
|
||||||
lua_close(lua_getuserdata(L, reg[getreg(L, &pc)]));
|
lua_close((lua_State *)lua_getuserdata(L, reg[getreg(L, &pc)]));
|
||||||
}
|
}
|
||||||
else if EQ("doremote") {
|
else if EQ("doremote") {
|
||||||
lua_Object ol1 = reg[getreg(L, &pc)];
|
lua_Object ol1 = reg[getreg(L, &pc)];
|
||||||
|
@ -253,7 +253,7 @@ static void testC (lua_State *L) {
|
||||||
int i;
|
int i;
|
||||||
if (!lua_isuserdata(L, ol1) || !lua_isstring(L, str))
|
if (!lua_isuserdata(L, ol1) || !lua_isstring(L, str))
|
||||||
lua_error(L, "bad arguments for `doremote'");
|
lua_error(L, "bad arguments for `doremote'");
|
||||||
L1 = lua_getuserdata(L, ol1);
|
L1 = (lua_State *)lua_getuserdata(L, ol1);
|
||||||
lua_dostring(L1, lua_getstring(L, str));
|
lua_dostring(L1, lua_getstring(L, str));
|
||||||
i = 1;
|
i = 1;
|
||||||
while ((temp = lua_getresult(L1, i++)) != LUA_NOOBJECT)
|
while ((temp = lua_getresult(L1, i++)) != LUA_NOOBJECT)
|
||||||
|
|
6
lvm.c
6
lvm.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 1.83 2000/01/25 13:57:18 roberto Exp roberto $
|
** $Id: lvm.c,v 1.84 2000/01/28 16:53:00 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -311,7 +311,7 @@ static void adjust_varargs (lua_State *L, StkId base, int nfixargs) {
|
||||||
** Returns n such that the the results are between [n,top).
|
** Returns n such that the the results are between [n,top).
|
||||||
*/
|
*/
|
||||||
StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
|
StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
|
||||||
StkId base) {
|
register StkId base) {
|
||||||
register StkId top; /* keep top local, for performance */
|
register StkId top; /* keep top local, for performance */
|
||||||
register const Byte *pc = tf->code;
|
register const Byte *pc = tf->code;
|
||||||
TaggedString **kstr = tf->kstr;
|
TaggedString **kstr = tf->kstr;
|
||||||
|
@ -661,7 +661,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, const TProtoFunc *tf,
|
||||||
case SETNAMEW: aux += highbyte(L, *pc++);
|
case SETNAMEW: aux += highbyte(L, *pc++);
|
||||||
case SETNAME: aux += *pc++;
|
case SETNAME: aux += *pc++;
|
||||||
if ((base-2)->ttype == LUA_T_LINE) { /* function has debug info? */
|
if ((base-2)->ttype == LUA_T_LINE) { /* function has debug info? */
|
||||||
(base-1)->ttype = -(*pc++);
|
(base-1)->ttype = (lua_Type)(-(*pc++));
|
||||||
(base-1)->value.i = aux;
|
(base-1)->value.i = aux;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
6
lzio.c
6
lzio.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lzio.c,v 1.8 1999/08/16 20:52:00 roberto Exp roberto $
|
** $Id: lzio.c,v 1.9 1999/11/09 17:59:35 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
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +35,7 @@ ZIO* zmopen (ZIO* z, const char* b, int size, const char *name) {
|
||||||
|
|
||||||
ZIO* zsopen (ZIO* z, const char* s, const char *name) {
|
ZIO* zsopen (ZIO* z, const char* s, const char *name) {
|
||||||
if (s==NULL) return NULL;
|
if (s==NULL) return NULL;
|
||||||
return zmopen(z,s,strlen(s),name);
|
return zmopen(z, s, strlen(s), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------- FILEs --- */
|
/* -------------------------------------------------------------- FILEs --- */
|
||||||
|
@ -43,7 +43,7 @@ ZIO* zsopen (ZIO* z, const char* s, const char *name) {
|
||||||
static int zffilbuf (ZIO* z) {
|
static int zffilbuf (ZIO* z) {
|
||||||
int n;
|
int n;
|
||||||
if (feof((FILE *)z->u)) return EOZ;
|
if (feof((FILE *)z->u)) return EOZ;
|
||||||
n = fread(z->buffer,1,ZBSIZE,z->u);
|
n = fread(z->buffer, 1, ZBSIZE, (FILE *)z->u);
|
||||||
if (n==0) return EOZ;
|
if (n==0) return EOZ;
|
||||||
z->n = n-1;
|
z->n = n-1;
|
||||||
z->p = z->buffer;
|
z->p = z->buffer;
|
||||||
|
|
Loading…
Reference in New Issue