mirror of https://github.com/rusefi/lua.git
errors `return' int, to avoid warnings
+ home-made `sprintf' (first version)
This commit is contained in:
parent
0dbf0c5953
commit
71144e3ff0
5
lapi.c
5
lapi.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lapi.c,v 1.187 2002/05/02 16:55:55 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 1.188 2002/05/06 15:51:41 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -641,11 +641,12 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold) {
|
|||
*/
|
||||
|
||||
|
||||
LUA_API void lua_errorobj (lua_State *L) {
|
||||
LUA_API int lua_errorobj (lua_State *L) {
|
||||
lua_lock(L);
|
||||
api_checknelems(L, 1);
|
||||
luaD_errorobj(L, L->top - 1, LUA_ERRRUN);
|
||||
lua_unlock(L);
|
||||
return 0; /* to avoid warnings */
|
||||
}
|
||||
|
||||
|
||||
|
|
63
lauxlib.c
63
lauxlib.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lauxlib.c,v 1.66 2002/04/16 12:00:02 roberto Exp roberto $
|
||||
** $Id: lauxlib.c,v 1.67 2002/05/01 20:40:42 roberto Exp roberto $
|
||||
** Auxiliary functions for building Lua libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -30,23 +30,21 @@ LUALIB_API int luaL_findstring (const char *name, const char *const list[]) {
|
|||
}
|
||||
|
||||
|
||||
LUALIB_API void luaL_argerror (lua_State *L, int narg, const char *extramsg) {
|
||||
LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
|
||||
lua_Debug ar;
|
||||
lua_getstack(L, 0, &ar);
|
||||
lua_getinfo(L, "n", &ar);
|
||||
if (strcmp(ar.namewhat, "method") == 0) narg--; /* do not count `self' */
|
||||
if (ar.name == NULL)
|
||||
ar.name = "?";
|
||||
luaL_verror(L, "bad argument #%d to `%.50s' (%.100s)",
|
||||
narg, ar.name, extramsg);
|
||||
return luaL_verror(L, "bad argument #%d to `%s' (%s)",
|
||||
narg, ar.name, extramsg);
|
||||
}
|
||||
|
||||
|
||||
LUALIB_API void luaL_typerror (lua_State *L, int narg, const char *tname) {
|
||||
char buff[80];
|
||||
sprintf(buff, "%.25s expected, got %.25s", tname,
|
||||
lua_typename(L, lua_type(L,narg)));
|
||||
luaL_argerror(L, narg, buff);
|
||||
LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
|
||||
luaL_vstr(L, "%s expected, got %s", tname, lua_typename(L, lua_type(L,narg)));
|
||||
return luaL_argerror(L, narg, lua_tostring(L, -1));
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,11 +55,11 @@ static void tag_error (lua_State *L, int narg, int tag) {
|
|||
|
||||
LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *mes) {
|
||||
if (!lua_checkstack(L, space))
|
||||
luaL_verror(L, "stack overflow (%.30s)", mes);
|
||||
luaL_verror(L, "stack overflow (%s)", mes);
|
||||
}
|
||||
|
||||
|
||||
LUALIB_API void luaL_check_type(lua_State *L, int narg, int t) {
|
||||
LUALIB_API void luaL_check_type (lua_State *L, int narg, int t) {
|
||||
if (lua_type(L, narg) != t)
|
||||
tag_error(L, narg, t);
|
||||
}
|
||||
|
@ -144,13 +142,48 @@ LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname,
|
|||
}
|
||||
|
||||
|
||||
LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...) {
|
||||
char buff[500];
|
||||
static void vstr (lua_State *L, const char *fmt, va_list argp) {
|
||||
luaL_Buffer b;
|
||||
luaL_buffinit(L, &b);
|
||||
for (;;) {
|
||||
const char *e = strchr(fmt, '%');
|
||||
if (e == NULL) break;
|
||||
luaL_addlstring(&b, fmt, e-fmt);
|
||||
switch (*(e+1)) {
|
||||
case 's':
|
||||
luaL_addstring(&b, va_arg(argp, char *));
|
||||
break;
|
||||
case 'd':
|
||||
lua_pushnumber(L, va_arg(argp, int));
|
||||
luaL_addvalue (&b);
|
||||
break;
|
||||
case '%':
|
||||
luaL_putchar(&b, '%');
|
||||
break;
|
||||
default:
|
||||
lua_error(L, "invalid format option");
|
||||
}
|
||||
fmt = e+2;
|
||||
}
|
||||
luaL_addstring(&b, fmt);
|
||||
luaL_pushresult(&b);
|
||||
}
|
||||
|
||||
|
||||
LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...) {
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
vsprintf(buff, fmt, argp);
|
||||
vstr(L, fmt, argp);
|
||||
va_end(argp);
|
||||
lua_error(L, buff);
|
||||
}
|
||||
|
||||
|
||||
LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...) {
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
vstr(L, fmt, argp);
|
||||
va_end(argp);
|
||||
return lua_errorobj(L);
|
||||
}
|
||||
|
||||
|
||||
|
|
10
lauxlib.h
10
lauxlib.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lauxlib.h,v 1.44 2002/04/02 20:42:49 roberto Exp roberto $
|
||||
** $Id: lauxlib.h,v 1.45 2002/05/01 20:40:42 roberto Exp roberto $
|
||||
** Auxiliary functions for building Lua libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -31,9 +31,8 @@ LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int nup);
|
|||
LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname,
|
||||
const luaL_reg *l, int nup);
|
||||
LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event);
|
||||
LUALIB_API void luaL_typerror (lua_State *L, int narg, const char *tname);
|
||||
LUALIB_API void luaL_argerror (lua_State *L, int numarg,
|
||||
const char *extramsg);
|
||||
LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname);
|
||||
LUALIB_API int luaL_argerror (lua_State *L, int numarg, const char *extramsg);
|
||||
LUALIB_API const char *luaL_check_lstr (lua_State *L, int numArg,
|
||||
size_t *len);
|
||||
LUALIB_API const char *luaL_opt_lstr (lua_State *L, int numArg,
|
||||
|
@ -45,7 +44,8 @@ LUALIB_API void luaL_check_stack (lua_State *L, int space, const char *msg);
|
|||
LUALIB_API void luaL_check_type (lua_State *L, int narg, int t);
|
||||
LUALIB_API void luaL_check_any (lua_State *L, int narg);
|
||||
|
||||
LUALIB_API void luaL_verror (lua_State *L, const char *fmt, ...);
|
||||
LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...);
|
||||
LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...);
|
||||
LUALIB_API int luaL_findstring (const char *name,
|
||||
const char *const list[]);
|
||||
|
||||
|
|
41
lbaselib.c
41
lbaselib.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lbaselib.c,v 1.70 2002/05/01 20:40:42 roberto Exp roberto $
|
||||
** $Id: lbaselib.c,v 1.71 2002/05/02 17:12:27 roberto Exp roberto $
|
||||
** Basic library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -43,9 +43,7 @@ static int luaB__ERRORMESSAGE (lua_State *L) {
|
|||
if (lua_getstack(L, 1, &ar)) {
|
||||
lua_getinfo(L, "Sl", &ar);
|
||||
if (ar.source && ar.currentline > 0) {
|
||||
char buff[100];
|
||||
sprintf(buff, "\n <%.70s: line %d>", ar.short_src, ar.currentline);
|
||||
lua_pushstring(L, buff);
|
||||
luaL_vstr(L, "\n <%s: line %d>", ar.short_src, ar.currentline);
|
||||
lua_concat(L, 2);
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +70,7 @@ static int luaB_print (lua_State *L) {
|
|||
lua_rawcall(L, 1, 1);
|
||||
s = lua_tostring(L, -1); /* get result */
|
||||
if (s == NULL)
|
||||
luaL_verror(L, "`tostring' must return a string to `print'");
|
||||
return luaL_verror(L, "`tostring' must return a string to `print'");
|
||||
if (i>1) fputs("\t", stdout);
|
||||
fputs(s, stdout);
|
||||
lua_pop(L, 1); /* pop result */
|
||||
|
@ -112,8 +110,7 @@ static int luaB_tonumber (lua_State *L) {
|
|||
|
||||
static int luaB_error (lua_State *L) {
|
||||
lua_settop(L, 1);
|
||||
lua_errorobj(L);
|
||||
return 0; /* to avoid warnings */
|
||||
return lua_errorobj(L);
|
||||
}
|
||||
|
||||
|
||||
|
@ -242,7 +239,7 @@ static int luaB_loadfile (lua_State *L) {
|
|||
static int luaB_assert (lua_State *L) {
|
||||
luaL_check_any(L, 1);
|
||||
if (!lua_toboolean(L, 1))
|
||||
luaL_verror(L, "assertion failed! %.90s", luaL_opt_string(L, 2, ""));
|
||||
return luaL_verror(L, "assertion failed! %s", luaL_opt_string(L, 2, ""));
|
||||
lua_settop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -335,6 +332,7 @@ static const char *getpath (lua_State *L) {
|
|||
const char *path;
|
||||
lua_getglobal(L, LUA_PATH); /* try global variable */
|
||||
path = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
if (path) return path;
|
||||
path = getenv(LUA_PATH); /* else try environment variable */
|
||||
if (path) return path;
|
||||
|
@ -342,7 +340,7 @@ static const char *getpath (lua_State *L) {
|
|||
}
|
||||
|
||||
|
||||
static const char *nextpath (lua_State *L, const char *path) {
|
||||
static const char *pushnextpath (lua_State *L, const char *path) {
|
||||
const char *l;
|
||||
if (*path == '\0') return NULL; /* no more pathes */
|
||||
if (*path == LUA_PATH_SEP) path++; /* skip separator */
|
||||
|
@ -353,7 +351,7 @@ static const char *nextpath (lua_State *L, const char *path) {
|
|||
}
|
||||
|
||||
|
||||
static void composename (lua_State *L) {
|
||||
static void pushcomposename (lua_State *L) {
|
||||
const char *path = lua_tostring(L, -1);
|
||||
const char *wild = strchr(path, '?');
|
||||
if (wild == NULL) return; /* no wild char; path is the file name */
|
||||
|
@ -372,35 +370,34 @@ static int luaB_require (lua_State *L) {
|
|||
lua_pushvalue(L, 1);
|
||||
lua_setglobal(L, "_REQUIREDNAME");
|
||||
lua_getglobal(L, REQTAB);
|
||||
if (!lua_istable(L, 2)) luaL_verror(L, REQTAB " is not a table");
|
||||
if (!lua_istable(L, 2)) return luaL_verror(L, REQTAB " is not a table");
|
||||
path = getpath(L);
|
||||
lua_pushvalue(L, 1); /* check package's name in book-keeping table */
|
||||
lua_gettable(L, 2);
|
||||
if (!lua_isnil(L, -1)) /* is it there? */
|
||||
return 0; /* package is already loaded */
|
||||
else { /* must load it */
|
||||
while (status == LUA_ERRFILE && (path = nextpath(L, path)) != NULL) {
|
||||
composename(L);
|
||||
while (status == LUA_ERRFILE) {
|
||||
lua_settop(L, 3); /* reset stack position */
|
||||
if ((path = pushnextpath(L, path)) == NULL) break;
|
||||
pushcomposename(L);
|
||||
status = lua_loadfile(L, lua_tostring(L, -1)); /* try to load it */
|
||||
if (status == 0)
|
||||
status = lua_pcall(L, 0, 0, 0);
|
||||
lua_settop(L, 3); /* pop string and eventual results from dofile */
|
||||
}
|
||||
}
|
||||
switch (status) {
|
||||
case 0: {
|
||||
lua_rawcall(L, 0, 0); /* run loaded module */
|
||||
lua_pushvalue(L, 1);
|
||||
lua_pushboolean(L, 1);
|
||||
lua_settable(L, 2); /* mark it as loaded */
|
||||
return 0;
|
||||
}
|
||||
case LUA_ERRFILE: { /* file not found */
|
||||
luaL_verror(L, "could not load package `%.20s' from path `%.200s'",
|
||||
lua_tostring(L, 1), lua_tostring(L, 3));
|
||||
return luaL_verror(L, "could not load package `%s' from path `%s'",
|
||||
lua_tostring(L, 1), getpath(L));
|
||||
}
|
||||
default: {
|
||||
luaL_verror(L, "error loading package");
|
||||
return 0; /* to avoid warnings */
|
||||
return luaL_verror(L, "error loading package\n%s", lua_tostring(L, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +442,7 @@ static int luaB_resume (lua_State *L) {
|
|||
lua_State *co = (lua_State *)lua_getfrombox(L, lua_upvalueindex(1));
|
||||
lua_settop(L, 0);
|
||||
if (lua_resume(L, co) != 0)
|
||||
lua_errorobj(L);
|
||||
return lua_errorobj(L);
|
||||
return lua_gettop(L);
|
||||
}
|
||||
|
||||
|
@ -466,7 +463,7 @@ static int luaB_coroutine (lua_State *L) {
|
|||
luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
|
||||
"Lua function expected");
|
||||
NL = lua_newthread(L);
|
||||
if (NL == NULL) luaL_verror(L, "unable to create new thread");
|
||||
if (NL == NULL) return luaL_verror(L, "unable to create new thread");
|
||||
/* move function and arguments from L to NL */
|
||||
for (i=0; i<n; i++) {
|
||||
ref = lua_ref(L, 1);
|
||||
|
|
57
ldblib.c
57
ldblib.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ldblib.c,v 1.48 2002/04/22 14:40:50 roberto Exp roberto $
|
||||
** $Id: ldblib.c,v 1.49 2002/05/01 20:40:42 roberto Exp roberto $
|
||||
** Interface from Lua to its debug API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -47,9 +47,9 @@ static int getinfo (lua_State *L) {
|
|||
options = buff;
|
||||
}
|
||||
else
|
||||
luaL_argerror(L, 1, "function or level expected");
|
||||
return luaL_argerror(L, 1, "function or level expected");
|
||||
if (!lua_getinfo(L, options, &ar))
|
||||
luaL_argerror(L, 2, "invalid option");
|
||||
return luaL_argerror(L, 2, "invalid option");
|
||||
lua_newtable(L);
|
||||
for (; *options; options++) {
|
||||
switch (*options) {
|
||||
|
@ -85,7 +85,7 @@ static int getlocal (lua_State *L) {
|
|||
lua_Debug ar;
|
||||
const char *name;
|
||||
if (!lua_getstack(L, luaL_check_int(L, 1), &ar)) /* level out of range? */
|
||||
luaL_argerror(L, 1, "level out of range");
|
||||
return luaL_argerror(L, 1, "level out of range");
|
||||
name = lua_getlocal(L, &ar, luaL_check_int(L, 2));
|
||||
if (name) {
|
||||
lua_pushstring(L, name);
|
||||
|
@ -102,7 +102,7 @@ static int getlocal (lua_State *L) {
|
|||
static int setlocal (lua_State *L) {
|
||||
lua_Debug ar;
|
||||
if (!lua_getstack(L, luaL_check_int(L, 1), &ar)) /* level out of range? */
|
||||
luaL_argerror(L, 1, "level out of range");
|
||||
return luaL_argerror(L, 1, "level out of range");
|
||||
luaL_check_any(L, 3);
|
||||
lua_pushstring(L, lua_setlocal(L, &ar, luaL_check_int(L, 2)));
|
||||
return 1;
|
||||
|
@ -187,20 +187,19 @@ static int errorfb (lua_State *L) {
|
|||
int level = 1; /* skip level 0 (it's this function) */
|
||||
int firstpart = 1; /* still before eventual `...' */
|
||||
lua_Debug ar;
|
||||
luaL_Buffer b;
|
||||
luaL_buffinit(L, &b);
|
||||
luaL_addstring(&b, luaL_check_string(L, 1));
|
||||
luaL_addstring(&b, "\n");
|
||||
luaL_check_string(L, 1);
|
||||
lua_settop(L, 1);
|
||||
lua_pushliteral(L, "\n");
|
||||
while (lua_getstack(L, level++, &ar)) {
|
||||
char buff[120]; /* enough to fit following `sprintf's */
|
||||
char buff[10];
|
||||
if (level == 2)
|
||||
luaL_addstring(&b, "stack traceback:\n");
|
||||
lua_pushliteral(L, "stack traceback:\n");
|
||||
else if (level > LEVELS1 && firstpart) {
|
||||
/* no more than `LEVELS2' more levels? */
|
||||
if (!lua_getstack(L, level+LEVELS2, &ar))
|
||||
level--; /* keep going */
|
||||
else {
|
||||
luaL_addstring(&b, " ...\n"); /* too many levels */
|
||||
lua_pushliteral(L, " ...\n"); /* too many levels */
|
||||
while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */
|
||||
level++;
|
||||
}
|
||||
|
@ -208,40 +207,34 @@ static int errorfb (lua_State *L) {
|
|||
continue;
|
||||
}
|
||||
sprintf(buff, "%4d: ", level-1);
|
||||
luaL_addstring(&b, buff);
|
||||
lua_pushstring(L, buff);
|
||||
lua_getinfo(L, "Snl", &ar);
|
||||
switch (*ar.namewhat) {
|
||||
case 'g': case 'l': /* global, local */
|
||||
sprintf(buff, "function `%.50s'", ar.name);
|
||||
luaL_vstr(L, "function `%s'", ar.name);
|
||||
break;
|
||||
case 'f': /* field */
|
||||
sprintf(buff, "method `%.50s'", ar.name);
|
||||
break;
|
||||
case 't': /* tag method */
|
||||
sprintf(buff, "`%.50s' tag method", ar.name);
|
||||
case 'm': /* method */
|
||||
luaL_vstr(L, "method `%s'", ar.name);
|
||||
break;
|
||||
default: {
|
||||
if (*ar.what == 'm') /* main? */
|
||||
sprintf(buff, "main of %.70s", ar.short_src);
|
||||
luaL_vstr(L, "main of %s", ar.short_src);
|
||||
else if (*ar.what == 'C') /* C function? */
|
||||
sprintf(buff, "%.70s", ar.short_src);
|
||||
luaL_vstr(L, "%s", ar.short_src);
|
||||
else
|
||||
sprintf(buff, "function <%d:%.70s>", ar.linedefined, ar.short_src);
|
||||
luaL_vstr(L, "function <%d:%s>", ar.linedefined, ar.short_src);
|
||||
ar.source = NULL; /* do not print source again */
|
||||
}
|
||||
}
|
||||
luaL_addstring(&b, buff);
|
||||
if (ar.currentline > 0) {
|
||||
sprintf(buff, " at line %d", ar.currentline);
|
||||
luaL_addstring(&b, buff);
|
||||
}
|
||||
if (ar.source) {
|
||||
sprintf(buff, " [%.70s]", ar.short_src);
|
||||
luaL_addstring(&b, buff);
|
||||
}
|
||||
luaL_addstring(&b, "\n");
|
||||
if (ar.currentline > 0)
|
||||
luaL_vstr(L, " at line %d", ar.currentline);
|
||||
if (ar.source)
|
||||
luaL_vstr(L, " [%s]", ar.short_src);
|
||||
lua_pushliteral(L, "\n");
|
||||
lua_concat(L, lua_gettop(L));
|
||||
}
|
||||
luaL_pushresult(&b);
|
||||
lua_concat(L, lua_gettop(L));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
15
liolib.c
15
liolib.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: liolib.c,v 2.3 2002/04/12 19:56:25 roberto Exp roberto $
|
||||
** $Id: liolib.c,v 2.4 2002/05/02 17:12:27 roberto Exp roberto $
|
||||
** Standard I/O (and system) library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -257,7 +257,7 @@ static int g_read (lua_State *L, FILE *f, int first) {
|
|||
else {
|
||||
const char *p = lua_tostring(L, n);
|
||||
if (!p || p[0] != '*')
|
||||
luaL_verror(L, "invalid `read' option");
|
||||
return luaL_verror(L, "invalid `read' option");
|
||||
switch (p[1]) {
|
||||
case 'n': /* number */
|
||||
success = read_number(L, f);
|
||||
|
@ -270,11 +270,10 @@ static int g_read (lua_State *L, FILE *f, int first) {
|
|||
success = 1; /* always success */
|
||||
break;
|
||||
case 'w': /* word */
|
||||
luaL_verror(L, "obsolete option `*w'");
|
||||
return luaL_verror(L, "obsolete option `*w'");
|
||||
break;
|
||||
default:
|
||||
luaL_argerror(L, n, "invalid format");
|
||||
success = 0; /* to avoid warnings */
|
||||
return luaL_argerror(L, n, "invalid format");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +429,7 @@ static int io_rename (lua_State *L) {
|
|||
static int io_tmpname (lua_State *L) {
|
||||
char buff[L_tmpnam];
|
||||
if (tmpnam(buff) != buff)
|
||||
luaL_verror(L, "unable to generate a unique filename");
|
||||
return luaL_verror(L, "unable to generate a unique filename");
|
||||
lua_pushstring(L, buff);
|
||||
return 1;
|
||||
}
|
||||
|
@ -471,7 +470,7 @@ static int getfield (lua_State *L, const char *key, int d) {
|
|||
res = (int)(lua_tonumber(L, -1));
|
||||
else {
|
||||
if (d == -2)
|
||||
luaL_verror(L, "field `%.20s' missing in date table", key);
|
||||
return luaL_verror(L, "field `%s' missing in date table", key);
|
||||
res = d;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
@ -510,7 +509,7 @@ static int io_date (lua_State *L) {
|
|||
if (strftime(b, sizeof(b), s, stm))
|
||||
lua_pushstring(L, b);
|
||||
else
|
||||
luaL_verror(L, "invalid `date' format");
|
||||
return luaL_verror(L, "invalid `date' format");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lmathlib.c,v 1.43 2002/04/04 20:20:49 roberto Exp roberto $
|
||||
** $Id: lmathlib.c,v 1.44 2002/05/02 17:12:27 roberto Exp roberto $
|
||||
** Standard mathematical library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -187,7 +187,7 @@ static int math_random (lua_State *L) {
|
|||
lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between `l' and `u' */
|
||||
break;
|
||||
}
|
||||
default: luaL_verror(L, "wrong number of arguments");
|
||||
default: return luaL_verror(L, "wrong number of arguments");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
11
lstrlib.c
11
lstrlib.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstrlib.c,v 1.80 2002/04/02 20:41:59 roberto Exp roberto $
|
||||
** $Id: lstrlib.c,v 1.81 2002/05/02 17:12:27 roberto Exp roberto $
|
||||
** Standard library for string operations and pattern-matching
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -170,7 +170,7 @@ typedef struct MatchState {
|
|||
static int check_capture (MatchState *ms, int l) {
|
||||
l -= '1';
|
||||
if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
|
||||
luaL_verror(ms->L, "invalid capture index");
|
||||
return luaL_verror(ms->L, "invalid capture index");
|
||||
return l;
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,7 @@ static int capture_to_close (MatchState *ms) {
|
|||
int level = ms->level;
|
||||
for (level--; level>=0; level--)
|
||||
if (ms->capture[level].len == CAP_UNFINISHED) return level;
|
||||
luaL_verror(ms->L, "invalid pattern capture");
|
||||
return 0; /* to avoid warnings */
|
||||
return luaL_verror(ms->L, "invalid pattern capture");
|
||||
}
|
||||
|
||||
|
||||
|
@ -663,7 +662,7 @@ static int str_format (lua_State *L) {
|
|||
char buff[MAX_ITEM]; /* to store the formatted item */
|
||||
int hasprecision = 0;
|
||||
if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$')
|
||||
luaL_verror(L, "obsolete `format' option (d$)");
|
||||
return luaL_verror(L, "obsolete `format' option (d$)");
|
||||
arg++;
|
||||
strfrmt = scanformat(L, strfrmt, form, &hasprecision);
|
||||
switch (*strfrmt++) {
|
||||
|
@ -696,7 +695,7 @@ static int str_format (lua_State *L) {
|
|||
}
|
||||
}
|
||||
default: /* also treat cases `pnLlh' */
|
||||
luaL_verror(L, "invalid option in `format'");
|
||||
return luaL_verror(L, "invalid option in `format'");
|
||||
}
|
||||
luaL_addlstring(&b, buff, strlen(buff));
|
||||
}
|
||||
|
|
4
ltests.c
4
ltests.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ltests.c,v 1.118 2002/05/01 20:40:42 roberto Exp roberto $
|
||||
** $Id: ltests.c,v 1.119 2002/05/02 13:06:20 roberto Exp roberto $
|
||||
** Internal Module for Debugging of the Lua Implementation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -639,7 +639,7 @@ static int testC (lua_State *L) {
|
|||
else if EQ("type") {
|
||||
lua_pushstring(L, lua_typename(L, lua_type(L, getnum)));
|
||||
}
|
||||
else luaL_verror(L, "unknown instruction %.30s", buff);
|
||||
else luaL_verror(L, "unknown instruction %s", buff);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
4
lua.h
4
lua.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lua.h,v 1.129 2002/05/01 20:40:42 roberto Exp roberto $
|
||||
** $Id: lua.h,v 1.130 2002/05/01 20:48:12 roberto Exp roberto $
|
||||
** Lua - An Extensible Extension Language
|
||||
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
||||
** e-mail: info@lua.org
|
||||
|
@ -193,7 +193,7 @@ LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold);
|
|||
** miscellaneous functions
|
||||
*/
|
||||
|
||||
LUA_API void lua_errorobj (lua_State *L);
|
||||
LUA_API int lua_errorobj (lua_State *L);
|
||||
|
||||
LUA_API int lua_next (lua_State *L, int index);
|
||||
LUA_API int lua_getn (lua_State *L, int index);
|
||||
|
|
Loading…
Reference in New Issue