Update of /cvsroot/wxlua/wxLua/modules/lua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv9859/wxLua/modules/lua/src Modified Files: Makefile lbaselib.c lcode.c lfunc.c loadlib.c loslib.c lstrlib.c lua.h luaconf.h lvm.c print.c Log Message: Updated lua to 5.1.2 Index: lbaselib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lbaselib.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lbaselib.c 12 Jun 2006 03:50:37 -0000 1.2 --- lbaselib.c 25 Apr 2007 02:52:20 -0000 1.3 *************** *** 115,123 **** ! static void getfunc (lua_State *L) { if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); else { lua_Debug ar; ! int level = luaL_optint(L, 1, 1); luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); if (lua_getstack(L, level, &ar) == 0) --- 115,123 ---- ! static void getfunc (lua_State *L, int opt) { if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); else { lua_Debug ar; ! int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); if (lua_getstack(L, level, &ar) == 0) *************** *** 132,136 **** static int luaB_getfenv (lua_State *L) { ! getfunc(L); if (lua_iscfunction(L, -1)) /* is a C function? */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ --- 132,136 ---- static int luaB_getfenv (lua_State *L) { ! getfunc(L, 1); if (lua_iscfunction(L, -1)) /* is a C function? */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ *************** *** 143,147 **** static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); ! getfunc(L); lua_pushvalue(L, 2); if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { --- 143,147 ---- static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); ! getfunc(L, 0); lua_pushvalue(L, 2); if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { Index: lua.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lua.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lua.h 12 Jun 2006 03:50:38 -0000 1.2 --- lua.h 25 Apr 2007 02:52:20 -0000 1.3 *************** *** 18,24 **** #define LUA_VERSION "Lua 5.1" ! #define LUA_RELEASE "Lua 5.1.1" #define LUA_VERSION_NUM 501 ! #define LUA_COPYRIGHT "Copyright (C) 1994-2006 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" --- 18,24 ---- #define LUA_VERSION "Lua 5.1" ! #define LUA_RELEASE "Lua 5.1.2" #define LUA_VERSION_NUM 501 ! #define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" *************** *** 360,364 **** /****************************************************************************** ! * Copyright (C) 1994-2006 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining --- 360,364 ---- /****************************************************************************** ! * Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining Index: lstrlib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lstrlib.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lstrlib.c 12 Jun 2006 03:50:38 -0000 1.2 --- lstrlib.c 25 Apr 2007 02:52:20 -0000 1.3 *************** *** 724,728 **** static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { const char *p = strfrmt; ! while (strchr(FLAGS, *p)) p++; /* skip flags */ if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) luaL_error(L, "invalid format (repeated flags)"); --- 724,728 ---- static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { const char *p = strfrmt; ! while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) luaL_error(L, "invalid format (repeated flags)"); Index: print.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/print.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** print.c 12 Jun 2006 03:50:38 -0000 1.2 --- print.c 25 Apr 2007 02:52:20 -0000 1.3 *************** *** 24,29 **** { const char* s=getstr(ts); ! int n=ts->tsv.len; ! int i; putchar('"'); for (i=0; i<n; i++) --- 24,28 ---- { const char* s=getstr(ts); ! size_t i,n=ts->tsv.len; putchar('"'); for (i=0; i<n; i++) *************** *** 33,36 **** --- 32,36 ---- { case '"': printf("\\\""); break; + case '\\': printf("\\\\"); break; case '\a': printf("\\a"); break; case '\b': printf("\\b"); break; Index: loslib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/loslib.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** loslib.c 12 Jun 2006 03:50:37 -0000 1.2 --- loslib.c 25 Apr 2007 02:52:20 -0000 1.3 *************** *** 147,155 **** } else { ! char b[256]; ! if (strftime(b, sizeof(b), s, stm)) ! lua_pushstring(L, b); ! else ! return luaL_error(L, LUA_QL("date") " format too long"); } return 1; --- 147,166 ---- } else { ! char cc[3]; ! luaL_Buffer b; ! cc[0] = '%'; cc[2] = '\0'; ! luaL_buffinit(L, &b); ! for (; *s; s++) { ! if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ ! luaL_addchar(&b, *s); ! else { ! size_t reslen; ! char buff[200]; /* should be big enough for any conversion result */ ! cc[1] = *(++s); ! reslen = strftime(buff, sizeof(buff), cc, stm); ! luaL_addlstring(&b, buff, reslen); ! } ! } ! luaL_pushresult(&b); } return 1; Index: Makefile =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 21 Dec 2006 06:02:03 -0000 1.6 --- Makefile 25 Apr 2007 02:52:20 -0000 1.7 *************** *** 21,25 **** # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= ! PLATS= aix ansi bsd generic linux macosx mingw posix solaris LUA_A= ../../../lib/liblua.a --- 21,25 ---- # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= ! PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris LUA_A= ../../../lib/liblua.a *************** *** 78,82 **** none: ! @echo "Please choose a platform: $(PLATS)" aix: --- 78,83 ---- none: ! @echo "Please choose a platform:" ! @echo " $(PLATS)" aix: *************** *** 89,92 **** --- 90,96 ---- $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" + freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + generic: $(MAKE) all MYCFLAGS= *************** *** 104,107 **** --- 108,112 ---- "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe posix: Index: luaconf.h =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/luaconf.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** luaconf.h 12 Jun 2006 03:50:38 -0000 1.2 --- luaconf.h 25 Apr 2007 02:52:20 -0000 1.3 *************** *** 361,365 **** @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' @* behavior. ! ** CHANGE it to undefined as soon as you replace to 'luaL_registry' ** your uses of 'luaL_openlib' */ --- 361,365 ---- @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' @* behavior. ! ** CHANGE it to undefined as soon as you replace to 'luaL_register' ** your uses of 'luaL_openlib' */ Index: lfunc.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lfunc.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lfunc.c 29 Mar 2006 05:48:11 -0000 1.2 --- lfunc.c 25 Apr 2007 02:52:20 -0000 1.3 *************** *** 56,60 **** UpVal *p; UpVal *uv; ! while ((p = ngcotouv(*pp)) != NULL && p->v >= level) { lua_assert(p->v != &p->u.value); if (p->v == level) { /* found a corresponding upvalue? */ --- 56,60 ---- UpVal *p; UpVal *uv; ! while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { lua_assert(p->v != &p->u.value); if (p->v == level) { /* found a corresponding upvalue? */ *************** *** 97,101 **** UpVal *uv; global_State *g = G(L); ! while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) { GCObject *o = obj2gco(uv); lua_assert(!isblack(o) && uv->v != &uv->u.value); --- 97,101 ---- UpVal *uv; global_State *g = G(L); ! while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { GCObject *o = obj2gco(uv); lua_assert(!isblack(o) && uv->v != &uv->u.value); Index: lcode.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lcode.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** lcode.c 12 Jun 2006 03:50:37 -0000 1.4 --- lcode.c 25 Apr 2007 02:52:20 -0000 1.5 *************** *** 36,48 **** Instruction *previous; if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ ! if (fs->pc == 0) /* function start? */ ! return; /* positions are already clean */ ! if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { ! int pfrom = GETARG_A(*previous); ! int pto = GETARG_B(*previous); ! if (pfrom <= from && from <= pto+1) { /* can connect both? */ ! if (from+n-1 > pto) ! SETARG_B(*previous, from+n-1); ! return; } } --- 36,53 ---- Instruction *previous; if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ ! if (fs->pc == 0) { /* function start? */ ! if (from >= fs->nactvar) ! return; /* positions are already clean */ ! } ! else { ! previous = &fs->f->code[fs->pc-1]; ! if (GET_OPCODE(*previous) == OP_LOADNIL) { ! int pfrom = GETARG_A(*previous); ! int pto = GETARG_B(*previous); ! if (pfrom <= from && from <= pto+1) { /* can connect both? */ ! if (from+n-1 > pto) ! SETARG_B(*previous, from+n-1); ! return; ! } } } *************** *** 658,665 **** return; else { - int o1 = luaK_exp2RK(fs, e1); int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; ! freeexp(fs, e2); ! freeexp(fs, e1); e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); e1->k = VRELOCABLE; --- 663,676 ---- return; else { int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; ! int o1 = luaK_exp2RK(fs, e1); ! if (o1 > o2) { ! freeexp(fs, e1); ! freeexp(fs, e2); ! } ! else { ! freeexp(fs, e2); ! freeexp(fs, e1); ! } e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); e1->k = VRELOCABLE; *************** *** 719,726 **** break; } ! default: { if (!isnumeral(v)) luaK_exp2RK(fs, v); break; } } } --- 730,742 ---- break; } ! case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: ! case OPR_MOD: case OPR_POW: { if (!isnumeral(v)) luaK_exp2RK(fs, v); break; } + default: { + luaK_exp2RK(fs, v); + break; + } } } Index: lvm.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/lvm.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lvm.c 12 Jun 2006 03:50:38 -0000 1.3 --- lvm.c 25 Apr 2007 02:52:20 -0000 1.4 *************** *** 166,170 **** if (ttisnil(tm)) tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ ! if (!ttisfunction(tm)) return 0; callTMres(L, res, tm, p1, p2); return 1; --- 166,170 ---- if (ttisnil(tm)) tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ ! if (ttisnil(tm)) return 0; callTMres(L, res, tm, p1, p2); return 1; *************** *** 282,289 **** StkId top = L->base + last + 1; int n = 2; /* number of elements handled in this pass (at least 2) */ ! if (!tostring(L, top-2) || !tostring(L, top-1)) { if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); ! } else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */ /* at least two string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; --- 282,291 ---- StkId top = L->base + last + 1; int n = 2; /* number of elements handled in this pass (at least 2) */ ! if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); ! } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ ! (void)tostring(L, top - 2); /* result is first op (as string) */ ! else { /* at least two string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; Index: loadlib.c =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/lua/src/loadlib.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** loadlib.c 20 Apr 2006 01:10:58 -0000 1.2 --- loadlib.c 25 Apr 2007 02:52:20 -0000 1.3 *************** *** 17,29 **** #define LUA_LIB - #include "lauxlib.h" - #include "lobject.h" #include "lua.h" - #include "lualib.h" - /* environment variables that hold the search path for packages */ - #define LUA_PATH "LUA_PATH" - #define LUA_CPATH "LUA_CPATH" /* prefix for open functions in C libraries */ --- 17,25 ---- #define LUA_LIB #include "lua.h" + #include "lauxlib.h" + #include "lualib.h" /* prefix for open functions in C libraries */ *************** *** 103,107 **** char *lb; DWORD nsize = sizeof(buff)/sizeof(char); ! DWORD n = GetModuleFileName(NULL, buff, nsize); if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) luaL_error(L, "unable to get ModuleFileName"); --- 99,103 ---- char *lb; DWORD nsize = sizeof(buff)/sizeof(char); ! DWORD n = GetModuleFileNameA(NULL, buff, nsize); if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) luaL_error(L, "unable to get ModuleFileName"); *************** *** 117,121 **** int error = GetLastError(); char buffer[128]; ! if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buffer, sizeof(buffer), NULL)) lua_pushstring(L, buffer); --- 113,117 ---- int error = GetLastError(); char buffer[128]; ! if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buffer, sizeof(buffer), NULL)) lua_pushstring(L, buffer); *************** *** 130,134 **** static void *ll_load (lua_State *L, const char *path) { ! HINSTANCE lib = LoadLibrary(path); if (lib == NULL) pusherror(L); return lib; --- 126,130 ---- static void *ll_load (lua_State *L, const char *path) { ! HINSTANCE lib = LoadLibraryA(path); if (lib == NULL) pusherror(L); return lib; *************** *** 361,396 **** if (path == NULL) luaL_error(L, LUA_QL("package.%s") " must be a string", pname); ! lua_pushstring(L, ""); /* error accumulator */ while ((path = pushnexttemplate(L, path)) != NULL) { const char *filename; filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ ! lua_pop(L, 2); /* remove path template and file name */ ! luaO_pushfstring(L, "\n\tno file " LUA_QS, filename); ! lua_concat(L, 2); ! } ! ! /* Make 5.0 compatible to allow global LUA_PATH to be set from LUA */ ! if (strcmp(pname, "path") == 0) { ! lua_getfield(L, LUA_GLOBALSINDEX, LUA_PATH); ! path = lua_tostring(L, -1); ! if (path != NULL) { ! lua_pushstring(L, ""); /* error accumulator */ ! while ((path = pushnexttemplate(L, path)) != NULL) { ! const char *filename; ! filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); ! if (readable(filename)) /* does file exist and is readable? */ ! return filename; /* return that file name */ ! lua_pop(L, 2); /* remove path template and file name */ ! luaO_pushfstring(L, "\n\tno file " LUA_QS, filename); ! lua_concat(L, 2); ! } ! } } - return NULL; /* not found */ } static void loaderror (lua_State *L, const char *filename) { luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", --- 357,375 ---- if (path == NULL) luaL_error(L, LUA_QL("package.%s") " must be a string", pname); ! lua_pushliteral(L, ""); /* error accumulator */ while ((path = pushnexttemplate(L, path)) != NULL) { const char *filename; filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ ! lua_pushfstring(L, "\n\tno file " LUA_QS, filename); ! lua_remove(L, -2); /* remove file name */ ! lua_concat(L, 2); /* add entry to possible error message */ } return NULL; /* not found */ } + static void loaderror (lua_State *L, const char *filename) { luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", *************** *** 446,451 **** if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { if (stat != ERRFUNC) loaderror(L, filename); /* real error */ ! luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, ! name, filename); return 1; /* function not found */ } --- 425,430 ---- if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { if (stat != ERRFUNC) loaderror(L, filename); /* real error */ ! lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, ! name, filename); return 1; /* function not found */ } *************** *** 461,465 **** lua_getfield(L, -1, name); if (lua_isnil(L, -1)) /* not found? */ ! luaO_pushfstring(L, "\n\tno field package.preload['%s']", name); return 1; } --- 440,444 ---- lua_getfield(L, -1, name); if (lua_isnil(L, -1)) /* not found? */ ! lua_pushfstring(L, "\n\tno field package.preload['%s']", name); return 1; } *************** *** 485,489 **** if (!lua_istable(L, -1)) luaL_error(L, LUA_QL("package.loaders") " must be a table"); ! lua_pushstring(L, ""); /* error message accumulator */ for (i=1; ; i++) { lua_rawgeti(L, -2, i); /* get a loader */ --- 464,468 ---- if (!lua_istable(L, -1)) luaL_error(L, LUA_QL("package.loaders") " must be a table"); ! lua_pushliteral(L, ""); /* error message accumulator */ for (i=1; ; i++) { lua_rawgeti(L, -2, i); /* get a loader */ *************** *** 669,674 **** setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ /* store config information */ ! lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" ! LUA_EXECDIR "\n" LUA_IGMARK); lua_setfield(L, -2, "config"); /* set field `loaded' */ --- 648,653 ---- setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ /* store config information */ ! lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" ! LUA_EXECDIR "\n" LUA_IGMARK); lua_setfield(L, -2, "config"); /* set field `loaded' */ |