summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/lua51
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua51')
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/Makefile51
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lapi.c20
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lapi.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lauxlib.c13
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lauxlib.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lbaselib.c87
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lcoco.c59
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lcoco.h6
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lcode.c4
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lcode.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ldblib.c30
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ldebug.c38
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ldebug.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ldo.c10
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ldo.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ldump.c6
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lfunc.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lfunc.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lgc.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lgc.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/linit.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/liolib.c151
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/llex.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/llex.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/llimits.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lmathlib.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lmem.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lmem.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/loadlib.c8
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lobject.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lobject.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lopcodes.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lopcodes.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/loslib.c3
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lparser.c4
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lparser.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lstate.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lstate.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lstring.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lstring.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lstrlib.c15
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ltable.c6
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ltable.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ltablib.c25
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ltm.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/ltm.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lua.c6
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lua.h11
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/luaconf.h9
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lualib.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lundump.c62
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lundump.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lvm.c10
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lvm.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lzio.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua51/lzio.h2
56 files changed, 388 insertions, 314 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua51/Makefile b/Build/source/texk/web2c/luatexdir/lua51/Makefile
index 55bdc11178f..301c703b503 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/Makefile
+++ b/Build/source/texk/web2c/luatexdir/lua51/Makefile
@@ -7,11 +7,12 @@
# Your platform. See PLATS for possible values.
PLAT= none
-LOCALCFLAGS= $(MYCFLAGS) $(COCOCFLAGS)
+CC= gcc
+CFLAGS= -O2 -Wall $(MYCFLAGS) $(COCOCFLAGS)
AR= ar rcu
RANLIB= ranlib
RM= rm -f
-LIBS= $(XLDFLAGS) -lm $(MYLIBS)
+LIBS= -lm $(MYLIBS)
MYCFLAGS=
MYLDFLAGS=
@@ -28,10 +29,9 @@ COCOCFLAGS=
#COCOCFLAGS= -DCOCO_DISABLE
# -- Coco =========
-
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
-PLATS= aix ansi bsd generic linux macosx mingw posix solaris
+PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
# ++ Coco =========
COCO_O= lcoco.o
@@ -76,14 +76,12 @@ clean:
$(RM) $(ALL_T) $(ALL_O)
depend:
- @$(CC) $(LOCALCFLAGS) $(CFLAGS) $(XCFLAGS) -MM l*.c print.c
+ @$(CC) $(CFLAGS) -MM l*.c print.c
echo:
@echo "PLAT = $(PLAT)"
@echo "CC = $(CC)"
- @echo "LOCALCFLAGS = $(LOCALCFLAGS)"
@echo "CFLAGS = $(CFLAGS)"
- @echo "XCFLAGS = $(XCFLAGS)"
@echo "AR = $(AR)"
@echo "RANLIB = $(RANLIB)"
@echo "RM = $(RM)"
@@ -94,47 +92,43 @@ echo:
# convenience targets for popular platforms
none:
- @echo "Please choose a platform: $(PLATS)"
+ @echo "Please choose a platform:"
+ @echo " $(PLATS)"
aix:
- $(MAKE) a CC="xlc" LOCALCFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
+ $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
ansi:
- $(MAKE) a MYCFLAGS=-DLUA_ANSI
+ $(MAKE) all MYCFLAGS=-DLUA_ANSI
bsd:
- $(MAKE) a MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
+ $(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) a MYCFLAGS=
+ $(MAKE) all MYCFLAGS=
linux:
- $(MAKE) a MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
macosx:
- $(MAKE) a MYCFLAGS=-DLUA_USE_MACOSX
-# use this on Mac OS X 10.4
-# $(MAKE) a MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline"
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
+# use this on Mac OS X 10.3-
+# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
mingw:
$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
-
-mingwcross:
- $(MAKE) "LUA_A=liblua.a" "LUA_T=lua.exe" \
- MYCFLAGS= MYLIBS= lua.exe
-
+ $(MAKE) "LUAC_T=luac.exe" luac.exe
posix:
- $(MAKE) a MYCFLAGS=-DLUA_USE_POSIX
+ $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
solaris:
- $(MAKE) a MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
-
-.c.o:
- $(CC) $(LOCALCFLAGS) $(CFLAGS) $(XCFLAGS) -c $<
-
+ $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
# list targets that do not create files (but not all makes understand .PHONY)
.PHONY: all $(PLATS) default o a clean depend echo none
@@ -171,8 +165,7 @@ llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \
lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h lcoco.h ldo.h
-loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \
- lualib.h
+loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
ltm.h lzio.h lmem.h lcoco.h lstring.h lgc.h lvm.h
lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lapi.c b/Build/source/texk/web2c/luatexdir/lua51/lapi.c
index e99ea7a31e6..e8347a28c4d 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lapi.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.55 2006/06/07 12:37:17 roberto Exp $
+** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -93,15 +93,14 @@ void luaA_pushobject (lua_State *L, const TValue *o) {
LUA_API int lua_checkstack (lua_State *L, int size) {
- int res;
+ int res = 1;
lua_lock(L);
- if ((L->top - L->base + size) > LUAI_MAXCSTACK)
+ if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
res = 0; /* stack overflow */
- else {
+ else if (size > 0) {
luaD_checkstack(L, size);
if (L->ci->top < L->top + size)
L->ci->top = L->top + size;
- res = 1;
}
lua_unlock(L);
return res;
@@ -749,7 +748,7 @@ LUA_API int lua_setfenv (lua_State *L, int idx) {
res = 0;
break;
}
- luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
+ if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
L->top--;
lua_unlock(L);
return res;
@@ -925,10 +924,13 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
g->GCthreshold = g->totalbytes - a;
else
g->GCthreshold = 0;
- while (g->GCthreshold <= g->totalbytes)
+ while (g->GCthreshold <= g->totalbytes) {
luaC_step(L);
- if (g->gcstate == GCSpause) /* end of cycle? */
- res = 1; /* signal it */
+ if (g->gcstate == GCSpause) { /* end of cycle? */
+ res = 1; /* signal it */
+ break;
+ }
+ }
break;
}
case LUA_GCSETPAUSE: {
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lapi.h b/Build/source/texk/web2c/luatexdir/lua51/lapi.h
index 9d1d435649c..2c3fab244ef 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lapi.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lapi.h
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.h,v 2.2 2005/04/25 19:24:10 roberto Exp $
+** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions from Lua API
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lauxlib.c b/Build/source/texk/web2c/luatexdir/lua51/lauxlib.c
index 96a6b85237a..10f14e2c088 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lauxlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lauxlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 roberto Exp $
+** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -244,7 +244,7 @@ LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
if (libname) {
int size = libsize(l);
/* check whether lib already exists */
- luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size);
+ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
lua_getfield(L, -1, libname); /* get _LOADED[libname] */
if (!lua_istable(L, -1)) { /* not found? */
lua_pop(L, 1); /* remove previous result */
@@ -535,7 +535,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
return "\n";
}
if (feof(lf->f)) return NULL;
- *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f);
+ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
return (*size > 0) ? lf->buff : NULL;
}
@@ -570,9 +570,8 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
if (c == '\n') c = getc(lf.f);
}
- if (c == LUA_SIGNATURE[0] && lf.f != stdin) { /* binary file? */
- fclose(lf.f);
- lf.f = fopen(filename, "rb"); /* reopen in binary mode */
+ if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
+ lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
/* skip eventual `#!...' */
while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
@@ -581,7 +580,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
ungetc(c, lf.f);
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
readstatus = ferror(lf.f);
- if (lf.f != stdin) fclose(lf.f); /* close file (even in case of errors) */
+ if (filename) fclose(lf.f); /* close file (even in case of errors) */
if (readstatus) {
lua_settop(L, fnameindex); /* ignore results from `lua_load' */
return errfile(L, "read", fnameindex);
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lauxlib.h b/Build/source/texk/web2c/luatexdir/lua51/lauxlib.h
index 1f3430863e4..34258235dbe 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lauxlib.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lauxlib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.h,v 1.88 2006/04/12 20:31:15 roberto Exp $
+** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lbaselib.c b/Build/source/texk/web2c/luatexdir/lua51/lbaselib.c
index a1208d670b4..2366a021abf 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lbaselib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lbaselib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $
+** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -347,10 +347,12 @@ static int luaB_unpack (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1);
e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
+ if (i > e) return 0; /* empty range */
n = e - i + 1; /* number of elements */
- if (n <= 0) return 0; /* empty range */
- luaL_checkstack(L, n, "table too big to unpack");
- for (; i<=e; i++) /* push arg[i...e] */
+ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
+ return luaL_error(L, "too many results to unpack");
+ lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
+ while (i++ < e) /* push arg[i + 1...e] */
lua_rawgeti(L, 1, i);
return n;
}
@@ -480,19 +482,55 @@ static const luaL_Reg base_funcs[] = {
** =======================================================
*/
+#define CO_RUN 0 /* running */
+#define CO_SUS 1 /* suspended */
+#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */
+#define CO_DEAD 3
+
+static const char *const statnames[] =
+ {"running", "suspended", "normal", "dead"};
+
+static int costatus (lua_State *L, lua_State *co) {
+ if (L == co) return CO_RUN;
+ switch (lua_status(co)) {
+ case LUA_YIELD:
+ return CO_SUS;
+ case 0: {
+ lua_Debug ar;
+ if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
+ return CO_NOR; /* it is running */
+ else if (lua_gettop(co) == 0)
+ return CO_DEAD;
+ else
+ return CO_SUS; /* initial state */
+ }
+ default: /* some error occured */
+ return CO_DEAD;
+ }
+}
+
+
+static int luaB_costatus (lua_State *L) {
+ lua_State *co = lua_tothread(L, 1);
+ luaL_argcheck(L, co, 1, "coroutine expected");
+ lua_pushstring(L, statnames[costatus(L, co)]);
+ return 1;
+}
+
+
static int auxresume (lua_State *L, lua_State *co, int narg) {
- int status;
+ int status = costatus(L, co);
if (!lua_checkstack(co, narg))
luaL_error(L, "too many arguments to resume");
- if (lua_status(co) == 0 && lua_gettop(co) == 0) {
- lua_pushliteral(L, "cannot resume dead coroutine");
+ if (status != CO_SUS) {
+ lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
return -1; /* error flag */
}
lua_xmove(L, co, narg);
status = lua_resume(co, narg);
if (status == 0 || status == LUA_YIELD) {
int nres = lua_gettop(co);
- if (!lua_checkstack(L, nres))
+ if (!lua_checkstack(L, nres + 1))
luaL_error(L, "too many results to resume");
lua_xmove(co, L, nres); /* move yielded values */
return nres;
@@ -576,39 +614,10 @@ static int luaB_yield (lua_State *L) {
}
-static int luaB_costatus (lua_State *L) {
- lua_State *co = lua_tothread(L, 1);
- luaL_argcheck(L, co, 1, "coroutine expected");
- if (L == co) lua_pushliteral(L, "running");
- else {
- switch (lua_status(co)) {
- case LUA_YIELD:
- lua_pushliteral(L, "suspended");
- break;
- case 0: {
- lua_Debug ar;
- if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */
- lua_pushliteral(L, "normal"); /* it is running */
- else if (lua_gettop(co) == 0)
- lua_pushliteral(L, "dead");
- else
- lua_pushliteral(L, "suspended"); /* initial state */
- break;
- }
- default: /* some error occured */
- lua_pushliteral(L, "dead");
- break;
- }
- }
- return 1;
-}
-
-
static int luaB_corunning (lua_State *L) {
if (lua_pushthread(L))
- return 0; /* main thread is not a coroutine */
- else
- return 1;
+ lua_pushnil(L); /* main thread is not a coroutine */
+ return 1;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lcoco.c b/Build/source/texk/web2c/luatexdir/lua51/lcoco.c
index f7a4b86c5bc..3399ef8aedf 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lcoco.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lcoco.c
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 2004-2007 Mike Pall. All rights reserved.
+** Copyright (C) 2004-2008 Mike Pall. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
@@ -144,6 +144,52 @@ static inline void coco_switch(coco_ctx from, coco_ctx to)
coco->arg0 = (size_t)(a0);
#define COCO_STATE_HEAD size_t arg0;
+#elif defined(__x86_64__)
+
+void coco_wrap_main(void);
+__asm__ (
+"\t.text\n"
+#ifdef __MACH__
+"\t.private_extern _coco_wrap_main\n"
+"_coco_wrap_main:\n"
+#else
+".local coco_wrap_main\n"
+"\t.type coco_wrap_main, @function\n"
+"coco_wrap_main:\n"
+#endif
+"\tmovq %r12, %rax\n"
+"\tmovq %r13, %rdi\n"
+"\tjmpq *%rax\n"
+);
+
+typedef void *coco_ctx[8]; /* rip, rsp, rbp, rbx, r12, r13, r14, r15 */
+static inline void coco_switch(coco_ctx from, coco_ctx to)
+{
+ __asm__ __volatile__ (
+ "leaq 1f(%%rip), %%rax\n\t"
+ "movq %%rax, (%0)\n\t" "movq %%rsp, 8(%0)\n\t" "movq %%rbp, 16(%0)\n\t"
+ "movq %%rbx, 24(%0)\n\t" "movq %%r12, 32(%0)\n\t" "movq %%r13, 40(%0)\n\t"
+ "movq %%r14, 48(%0)\n\t" "movq %%r15, 56(%0)\n\t"
+ "movq 56(%1), %%r15\n\t" "movq 48(%1), %%r14\n\t" "movq 40(%1), %%r13\n\t"
+ "movq 32(%1), %%r12\n\t" "movq 24(%1), %%rbx\n\t" "movq 16(%1), %%rbp\n\t"
+ "movq 8(%1), %%rsp\n\t" "jmpq *(%1)\n" "1:\n"
+ : "+S" (from), "+D" (to) :
+ : "rax", "rcx", "rdx", "r8", "r9", "r10", "r11", "memory", "cc");
+}
+
+#define COCO_CTX coco_ctx
+#define COCO_SWITCH(from, to) coco_switch(from, to);
+#define COCO_MAKECTX(coco, buf, func, stack, a0) \
+ buf[0] = (void *)(coco_wrap_main); \
+ buf[1] = (void *)(stack); \
+ buf[2] = (void *)0; \
+ buf[3] = (void *)0; \
+ buf[4] = (void *)(func); \
+ buf[5] = (void *)(a0); \
+ buf[6] = (void *)0; \
+ buf[7] = (void *)0; \
+ stack[0] = 0xdeadc0c0deadc0c0; /* Dummy return address. */ \
+
#elif __mips && _MIPS_SIM == _MIPS_SIM_ABI32 && !defined(__mips_eabi)
/* No way to avoid the function prologue with inline assembler. So use this: */
@@ -233,7 +279,7 @@ typedef void *coco_ctx[2]; /* ra, sp */
buf[4] = (int)(stack); \
buf[3] = 0; \
COCO_SETJMP_X86(coco, stack, a0)
-#elif defined(__MACH__) && defined(_BSD_I386_SETJMP_H_) /* x86-macosx */
+#elif defined(__MACH__) && defined(_BSD_I386_SETJMP_H) /* x86-macosx */
#define COCO_PATCHCTX(coco, buf, func, stack, a0) \
buf[12] = (int)(func); \
buf[9] = (int)(stack); \
@@ -248,14 +294,7 @@ typedef void *coco_ctx[2]; /* ra, sp */
#define COCO_MAIN_PARAM \
int _a, int _b, int _c, int _d, int _e, int _f, lua_State *L
-#if __GLIBC__ == 2 && defined(JB_RSP) /* x64-linux-glibc2 */
-#define COCO_PATCHCTX(coco, buf, func, stack, a0) \
- buf->__jmpbuf[JB_PC] = (long)(func); \
- buf->__jmpbuf[JB_RSP] = (long)(stack); \
- buf->__jmpbuf[JB_RBP] = 0; \
- stack[0] = 0xdeadc0c0; /* Dummy return address. */ \
- coco->arg0 = (size_t)(a0);
-#elif defined(__solaris__) && _JBLEN == 8 /* x64-solaris */
+#if defined(__solaris__) && _JBLEN == 8 /* x64-solaris */
#define COCO_PATCHCTX(coco, buf, func, stack, a0) \
buf[7] = (long)(func); \
buf[6] = (long)(stack); \
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lcoco.h b/Build/source/texk/web2c/luatexdir/lua51/lcoco.h
index 6e87a8d3c19..4fb6bca4b32 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lcoco.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lcoco.h
@@ -1,6 +1,6 @@
/*
** Lua/Coco glue.
-** Copyright (C) 2004-2007 Mike Pall. See copyright notice in lcoco.c
+** Copyright (C) 2004-2008 Mike Pall. See copyright notice in lcoco.c
*/
#if defined(__OpenBSD__)
@@ -16,8 +16,8 @@
#ifndef lcoco_h
#define lcoco_h
-#define LUACOCO_VERSION "Coco 1.1.3"
-#define LUACOCO_VERSION_NUM 10103
+#define LUACOCO_VERSION "Coco 1.1.5"
+#define LUACOCO_VERSION_NUM 10105
/* Exported C API to add a C stack to a coroutine. */
LUA_API lua_State *lua_newcthread(lua_State *L, int cstacksize);
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lcode.c b/Build/source/texk/web2c/luatexdir/lua51/lcode.c
index 9ce515ab648..cff626b7fa6 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lcode.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $
+** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -699,7 +699,7 @@ void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
switch (op) {
case OPR_MINUS: {
- if (e->k == VK)
+ if (!isnumeral(e))
luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
codearith(fs, OP_UNM, e, &e2);
break;
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lcode.h b/Build/source/texk/web2c/luatexdir/lua51/lcode.h
index c02cb2b726f..b941c607212 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lcode.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lcode.h
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.h,v 1.48 2006/03/21 19:28:03 roberto Exp $
+** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ldblib.c b/Build/source/texk/web2c/luatexdir/lua51/ldblib.c
index 26a19b6a6f6..67de1222a94 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ldblib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.104 2005/12/29 15:32:11 roberto Exp $
+** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -255,24 +255,25 @@ static void gethooktable (lua_State *L) {
static int db_sethook (lua_State *L) {
- int arg;
+ int arg, mask, count;
+ lua_Hook func;
lua_State *L1 = getthread(L, &arg);
if (lua_isnoneornil(L, arg+1)) {
lua_settop(L, arg+1);
- lua_sethook(L1, NULL, 0, 0); /* turn off hooks */
+ func = NULL; mask = 0; count = 0; /* turn off hooks */
}
else {
const char *smask = luaL_checkstring(L, arg+2);
- int count = luaL_optint(L, arg+3, 0);
luaL_checktype(L, arg+1, LUA_TFUNCTION);
- lua_sethook(L1, hookf, makemask(smask, count), count);
+ count = luaL_optint(L, arg+3, 0);
+ func = hookf; mask = makemask(smask, count);
}
- gethooktable(L1);
- lua_pushlightuserdata(L1, L1);
+ gethooktable(L);
+ lua_pushlightuserdata(L, L1);
lua_pushvalue(L, arg+1);
- lua_xmove(L, L1, 1);
- lua_rawset(L1, -3); /* set new hook */
- lua_pop(L1, 1); /* remove hook table */
+ lua_rawset(L, -3); /* set new hook */
+ lua_pop(L, 1); /* remove hook table */
+ lua_sethook(L1, func, mask, count); /* set hooks */
return 0;
}
@@ -286,11 +287,10 @@ static int db_gethook (lua_State *L) {
if (hook != NULL && hook != hookf) /* external hook? */
lua_pushliteral(L, "external hook");
else {
- gethooktable(L1);
- lua_pushlightuserdata(L1, L1);
- lua_rawget(L1, -2); /* get hook */
- lua_remove(L1, -2); /* remove hook table */
- lua_xmove(L1, L, 1);
+ gethooktable(L);
+ lua_pushlightuserdata(L, L1);
+ lua_rawget(L, -2); /* get hook */
+ lua_remove(L, -2); /* remove hook table */
}
lua_pushstring(L, unmakemask(mask, buff));
lua_pushinteger(L, lua_gethookcount(L1));
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ldebug.c b/Build/source/texk/web2c/luatexdir/lua51/ldebug.c
index d956f3df058..abb3da4a021 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ldebug.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $
+** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -277,12 +277,12 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
static int precheck (const Proto *pt) {
check(pt->maxstacksize <= MAXSTACK);
- lua_assert(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
- lua_assert(!(pt->is_vararg & VARARG_NEEDSARG) ||
+ check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
+ check(!(pt->is_vararg & VARARG_NEEDSARG) ||
(pt->is_vararg & VARARG_HASARG));
check(pt->sizeupvalues <= pt->nups);
check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
- check(GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
+ check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
return 1;
}
@@ -348,9 +348,18 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
int dest = pc+1+b;
check(0 <= dest && dest < pt->sizecode);
if (dest > 0) {
- /* cannot jump to a setlist count */
- Instruction d = pt->code[dest-1];
- check(!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0));
+ int j;
+ /* check that it does not jump to a setlist count; this
+ is tricky, because the count from a previous setlist may
+ have the same value of an invalid setlist; so, we must
+ go all the way back to the first of them (if any) */
+ for (j = 0; j < dest; j++) {
+ Instruction d = pt->code[dest-1-j];
+ if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
+ }
+ /* if 'j' is even, previous value is not a setlist (even if
+ it looks like one) */
+ check((j&1) == 0);
}
}
break;
@@ -365,7 +374,11 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
}
switch (op) {
case OP_LOADBOOL: {
- check(c == 0 || pc+2 < pt->sizecode); /* check its jump */
+ if (c == 1) { /* does it jump? */
+ check(pc+2 < pt->sizecode); /* check its jump */
+ check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
+ GETARG_C(pt->code[pc+1]) != 0);
+ }
break;
}
case OP_LOADNIL: {
@@ -430,7 +443,10 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
}
case OP_SETLIST: {
if (b > 0) checkreg(pt, a + b);
- if (c == 0) pc++;
+ if (c == 0) {
+ pc++;
+ check(pc < pt->sizecode - 1);
+ }
break;
}
case OP_CLOSURE: {
@@ -565,8 +581,8 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
- if (ttisstring(p1)) p1 = p2;
- lua_assert(!ttisstring(p1));
+ if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
+ lua_assert(!ttisstring(p1) && !ttisnumber(p1));
luaG_typeerror(L, p1, "concatenate");
}
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ldebug.h b/Build/source/texk/web2c/luatexdir/lua51/ldebug.h
index 9c76aa10f0a..ba28a97248e 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ldebug.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/ldebug.h
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.h,v 2.3 2005/04/25 19:24:10 roberto Exp $
+** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ldo.c b/Build/source/texk/web2c/luatexdir/lua51/ldo.c
index ab86fb70e8d..91144137788 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ldo.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 2.38 2006/06/05 19:36:14 roberto Exp $
+** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -332,7 +332,7 @@ static StkId callrethooks (lua_State *L, StkId firstResult) {
ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
luaD_callhook(L, LUA_HOOKRET, -1);
if (f_isLua(L->ci)) { /* Lua function? */
- while (L->ci->tailcalls--) /* call hook for eventual tail calls */
+ while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */
luaD_callhook(L, LUA_HOOKTAILRET, -1);
}
return restorestack(L, fr);
@@ -417,12 +417,8 @@ static int resume_error (lua_State *L, const char *msg) {
LUA_API int lua_resume (lua_State *L, int nargs) {
int status;
lua_lock(L);
- if (L->status != LUA_YIELD) {
- if (L->status != 0)
- return resume_error(L, "cannot resume dead coroutine");
- else if (L->ci != L->base_ci)
+ if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
return resume_error(L, "cannot resume non-suspended coroutine");
- }
luai_userstateresume(L, nargs);
lua_assert(L->errfunc == 0 && L->nCcalls == 0);
status = luaD_rawrunprotected(L, resume, L->top - nargs);
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ldo.h b/Build/source/texk/web2c/luatexdir/lua51/ldo.h
index b2de92bb807..98fddac59fb 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ldo.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/ldo.h
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.h,v 2.7 2005/08/24 16:15:49 roberto Exp $
+** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ldump.c b/Build/source/texk/web2c/luatexdir/lua51/ldump.c
index f08277d3ac4..7ff01cc565a 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ldump.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/ldump.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldump.c,v 1.15 2006/02/16 15:53:49 lhf Exp $
+** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** save precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -62,12 +62,12 @@ static void DumpString(const TString* s, DumpState* D)
{
if (s==NULL || getstr(s)==NULL)
{
- size_t size=0;
+ unsigned int size=0;
DumpVar(size,D);
}
else
{
- size_t size=s->tsv.len+1; /* include trailing '\0' */
+ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
DumpVar(size,D);
DumpBlock(getstr(s),size,D);
}
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lfunc.c b/Build/source/texk/web2c/luatexdir/lua51/lfunc.c
index 05bd5ff50fa..813e88f5831 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lfunc.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lfunc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $
+** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lfunc.h b/Build/source/texk/web2c/luatexdir/lua51/lfunc.h
index 2e02419bd6b..a68cf5151cb 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lfunc.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lfunc.h
@@ -1,5 +1,5 @@
/*
-** $Id: lfunc.h,v 2.4 2005/04/25 19:24:10 roberto Exp $
+** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lgc.c b/Build/source/texk/web2c/luatexdir/lua51/lgc.c
index 2d24a127ac6..d9e0b78294e 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lgc.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lgc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 2.38 2006/05/24 14:34:06 roberto Exp $
+** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lgc.h b/Build/source/texk/web2c/luatexdir/lua51/lgc.h
index 5f69acb1e3b..5a8dc605b31 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lgc.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lgc.h
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.h,v 2.15 2005/08/24 16:15:49 roberto Exp $
+** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/linit.c b/Build/source/texk/web2c/luatexdir/lua51/linit.c
index 483d9c8c282..c1f90dfab71 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/linit.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/linit.c
@@ -1,5 +1,5 @@
/*
-** $Id: linit.c,v 1.14 2005/12/29 15:32:11 roberto Exp $
+** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $
** Initialization of libraries for lua.c
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/liolib.c b/Build/source/texk/web2c/luatexdir/lua51/liolib.c
index b98fd9a0448..e79ed1cb2e2 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/liolib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 roberto Exp $
+** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -51,7 +51,7 @@ static void fileerror (lua_State *L, int arg, const char *filename) {
}
-#define topfile(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
+#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
static int io_type (lua_State *L) {
@@ -70,7 +70,7 @@ static int io_type (lua_State *L) {
static FILE *tofile (lua_State *L) {
- FILE **f = topfile(L);
+ FILE **f = tofilep(L);
if (*f == NULL)
luaL_error(L, "attempt to use a closed file");
return *f;
@@ -93,19 +93,31 @@ static FILE **newfile (lua_State *L) {
/*
-** this function has a separated environment, which defines the
-** correct __close for 'popen' files
+** function to (not) close the standard files stdin, stdout, and stderr
+*/
+static int io_noclose (lua_State *L) {
+ lua_pushnil(L);
+ lua_pushliteral(L, "cannot close standard file");
+ return 2;
+}
+
+
+/*
+** function to close 'popen' files
*/
static int io_pclose (lua_State *L) {
- FILE **p = topfile(L);
+ FILE **p = tofilep(L);
int ok = lua_pclose(L, *p);
*p = NULL;
return pushresult(L, ok, NULL);
}
+/*
+** function to close regular files
+*/
static int io_fclose (lua_State *L) {
- FILE **p = topfile(L);
+ FILE **p = tofilep(L);
int ok = (fclose(*p) == 0);
*p = NULL;
return pushresult(L, ok, NULL);
@@ -128,18 +140,18 @@ static int io_close (lua_State *L) {
static int io_gc (lua_State *L) {
- FILE *f = *topfile(L);
- /* ignore closed files and standard files */
- if (f != NULL && f != stdin && f != stdout && f != stderr)
+ FILE *f = *tofilep(L);
+ /* ignore closed files */
+ if (f != NULL)
aux_close(L);
return 0;
}
static int io_tostring (lua_State *L) {
- FILE *f = *topfile(L);
+ FILE *f = *tofilep(L);
if (f == NULL)
- lua_pushstring(L, "file (closed)");
+ lua_pushliteral(L, "file (closed)");
else
lua_pushfstring(L, "file (%p)", f);
return 1;
@@ -154,21 +166,11 @@ static int io_open (lua_State *L) {
return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
}
-static int io_open_ro (lua_State *L) {
- FILE **pf;
- const char *filename = luaL_checkstring(L, 1);
- const char *mode = luaL_optstring(L, 2, "r");
- if ((strcmp(mode,"r")!= 0)&&(strcmp(mode,"rb")!=0))
- return pushresult(L, 0, filename);
- pf = newfile(L);
- *pf = fopen(filename, mode);
- return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
-}
-
-
-
-
+/*
+** this function has a separated environment, which defines the
+** correct __close for 'popen' files
+*/
static int io_popen (lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
@@ -285,7 +287,7 @@ static int test_eof (lua_State *L, FILE *f) {
return (c != EOF);
}
-#if 0
+
static int read_line (lua_State *L, FILE *f) {
luaL_Buffer b;
luaL_buffinit(L, &b);
@@ -294,7 +296,7 @@ static int read_line (lua_State *L, FILE *f) {
char *p = luaL_prepbuffer(&b);
if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */
luaL_pushresult(&b); /* close buffer */
- return (lua_strlen(L, -1) > 0); /* check whether read something */
+ return (lua_objlen(L, -1) > 0); /* check whether read something */
}
l = strlen(p);
if (l == 0 || p[l-1] != '\n')
@@ -306,35 +308,6 @@ static int read_line (lua_State *L, FILE *f) {
}
}
}
-#endif
-
-/* this new version does not care wether the file has
- line endings using an 'alien' convention */
-
-static int new_read_line (lua_State *L, FILE *f) {
- luaL_Buffer buf;
- int c, d;
- luaL_buffinit(L, &buf);
- while (1) {
- c = fgetc(f);
- if (c == EOF) {
- luaL_pushresult(&buf); /* close buffer */
- return (lua_strlen(L, -1) > 0); /* check whether read something */
- };
- if (c == '\n') {
- break;
- } else if (c == '\r') {
- d = fgetc(f);
- if (d != EOF && d != '\n')
- ungetc(d,f);
- break;
- } else {
- luaL_addchar(&buf,c);
- }
- }
- luaL_pushresult(&buf); /* close buffer */
- return 1;
-}
static int read_chars (lua_State *L, FILE *f, size_t n) {
@@ -351,32 +324,7 @@ static int read_chars (lua_State *L, FILE *f, size_t n) {
n -= nr; /* still have to read `n' chars */
} while (n > 0 && nr == rlen); /* until end of count or eof */
luaL_pushresult(&b); /* close buffer */
- return (n == 0 || lua_strlen(L, -1) > 0);
-}
-
-static int read_all (lua_State *L, FILE *f) {
- /* attempt to speed up reading whole files */
- size_t rlen; /* how much to read */
- size_t nr; /* number of chars actually read */
- size_t old; /* old file location */
- char *p;
- old = ftell(f);
- if(old > 0 &&
- (fseek(f,0,SEEK_END)>=0) &&
- ((rlen = ftell(f)) >0 ) &&
- rlen < 1000*1000*100 ) { /* 100 MB */
- fseek(f,old,SEEK_SET);
- p = malloc(rlen);
- if (p != NULL) {
- nr = fread(p, sizeof(char), rlen, f);
- lua_pushlstring(L,p,nr);
- free(p);
- return 1;
- }
- }
- if (old>0)
- fseek(f,old,SEEK_SET);
- return read_chars(L,f, ~((size_t)0));
+ return (n == 0 || lua_objlen(L, -1) > 0);
}
@@ -386,7 +334,7 @@ static int g_read (lua_State *L, FILE *f, int first) {
int n;
clearerr(f);
if (nargs == 0) { /* no arguments? */
- success = new_read_line(L, f);
+ success = read_line(L, f);
n = first+1; /* to return 1 result */
}
else { /* ensure stack space for all results and for auxlib's buffer */
@@ -405,10 +353,10 @@ static int g_read (lua_State *L, FILE *f, int first) {
success = read_number(L, f);
break;
case 'l': /* line */
- success = new_read_line(L, f);
+ success = read_line(L, f);
break;
case 'a': /* file */
- read_all(L, f);
+ read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */
success = 1; /* always success */
break;
default:
@@ -426,20 +374,23 @@ static int g_read (lua_State *L, FILE *f, int first) {
return n - first;
}
+
static int io_read (lua_State *L) {
return g_read(L, getiofile(L, IO_INPUT), 1);
}
+
static int f_read (lua_State *L) {
return g_read(L, tofile(L), 2);
}
+
static int io_readline (lua_State *L) {
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
int sucess;
if (f == NULL) /* file is already closed? */
luaL_error(L, "file is already closed");
- sucess = new_read_line(L, f);
+ sucess = read_line(L, f);
if (ferror(f))
return luaL_error(L, "%s", strerror(errno));
if (sucess) return 1;
@@ -529,7 +480,6 @@ static const luaL_Reg iolib[] = {
{"input", io_input},
{"lines", io_lines},
{"open", io_open},
- {"open_ro", io_open_ro},
{"output", io_output},
{"popen", io_popen},
{"read", io_read},
@@ -568,31 +518,36 @@ static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) {
lua_pushvalue(L, -1);
lua_rawseti(L, LUA_ENVIRONINDEX, k);
}
- lua_setfield(L, -2, fname);
+ lua_pushvalue(L, -2); /* copy environment */
+ lua_setfenv(L, -2); /* set it */
+ lua_setfield(L, -3, fname);
+}
+
+
+static void newfenv (lua_State *L, lua_CFunction cls) {
+ lua_createtable(L, 0, 1);
+ lua_pushcfunction(L, cls);
+ lua_setfield(L, -2, "__close");
}
LUALIB_API int luaopen_io (lua_State *L) {
createmeta(L);
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
- lua_createtable(L, 2, 1);
+ newfenv(L, io_fclose);
lua_replace(L, LUA_ENVIRONINDEX);
/* open library */
luaL_register(L, LUA_IOLIBNAME, iolib);
/* create (and set) default files */
+ newfenv(L, io_noclose); /* close function for default files */
createstdfile(L, stdin, IO_INPUT, "stdin");
createstdfile(L, stdout, IO_OUTPUT, "stdout");
createstdfile(L, stderr, 0, "stderr");
- /* create environment for 'popen' */
+ lua_pop(L, 1); /* pop environment for default files */
lua_getfield(L, -1, "popen");
- lua_createtable(L, 0, 1);
- lua_pushcfunction(L, io_pclose);
- lua_setfield(L, -2, "__close");
- lua_setfenv(L, -2);
+ newfenv(L, io_pclose); /* create environment for 'popen' */
+ lua_setfenv(L, -2); /* set fenv for 'popen' */
lua_pop(L, 1); /* pop 'popen' */
- /* set default close function */
- lua_pushcfunction(L, io_fclose);
- lua_setfield(L, LUA_ENVIRONINDEX, "__close");
return 1;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua51/llex.c b/Build/source/texk/web2c/luatexdir/lua51/llex.c
index 1c07cad9bb6..6dc319358c0 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/llex.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 2.20 2006/03/09 18:14:31 roberto Exp $
+** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/llex.h b/Build/source/texk/web2c/luatexdir/lua51/llex.h
index ff07e83d318..a9201cee484 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/llex.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/llex.h
@@ -1,5 +1,5 @@
/*
-** $Id: llex.h,v 1.58 2006/03/23 18:23:32 roberto Exp $
+** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/llimits.h b/Build/source/texk/web2c/luatexdir/lua51/llimits.h
index 26e7c4f8cf8..a20e22146bd 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/llimits.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/llimits.h
@@ -1,5 +1,5 @@
/*
-** $Id: llimits.h,v 1.69 2005/12/27 17:12:00 roberto Exp $
+** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lmathlib.c b/Build/source/texk/web2c/luatexdir/lua51/lmathlib.c
index d181a731943..441fbf736c2 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lmathlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.67 2005/08/26 17:36:32 roberto Exp $
+** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lmem.c b/Build/source/texk/web2c/luatexdir/lua51/lmem.c
index cef2bc5f851..ae7d8c965f6 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lmem.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lmem.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmem.c,v 1.70 2005/12/26 13:35:47 roberto Exp $
+** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lmem.h b/Build/source/texk/web2c/luatexdir/lua51/lmem.h
index 19df1fbb6c9..7c2dcb32207 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lmem.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lmem.h
@@ -1,5 +1,5 @@
/*
-** $Id: lmem.h,v 1.31 2005/04/25 19:24:10 roberto Exp $
+** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/loadlib.c b/Build/source/texk/web2c/luatexdir/lua51/loadlib.c
index 808368ba431..0d401eba1cf 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/loadlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $
+** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -506,8 +506,10 @@ static int ll_require (lua_State *L) {
static void setfenv (lua_State *L) {
lua_Debug ar;
- lua_getstack(L, 1, &ar);
- lua_getinfo(L, "f", &ar);
+ if (lua_getstack(L, 1, &ar) == 0 ||
+ lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
+ lua_iscfunction(L, -1))
+ luaL_error(L, LUA_QL("module") " not called from a Lua function");
lua_pushvalue(L, -2);
lua_setfenv(L, -2);
lua_pop(L, 1);
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lobject.c b/Build/source/texk/web2c/luatexdir/lua51/lobject.c
index 9fb81f637b2..aec4ec450a7 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lobject.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lobject.c
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.c,v 2.22 2006/02/10 17:43:52 roberto Exp $
+** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lobject.h b/Build/source/texk/web2c/luatexdir/lua51/lobject.h
index 8ce4405b6ae..f1e447ef3ba 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lobject.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 2.20 2006/01/18 11:37:34 roberto Exp $
+** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -208,7 +208,7 @@ typedef union TString {
#define getstr(ts) cast(const char *, (ts) + 1)
-#define svalue(o) getstr(tsvalue(o))
+#define svalue(o) getstr(rawtsvalue(o))
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lopcodes.c b/Build/source/texk/web2c/luatexdir/lua51/lopcodes.c
index bf9cd522c26..4cc745230b7 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lopcodes.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lopcodes.c
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.c,v 1.37 2005/11/08 19:45:36 roberto Exp $
+** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lopcodes.h b/Build/source/texk/web2c/luatexdir/lua51/lopcodes.h
index 48105f1e722..41224d6ee14 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lopcodes.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lopcodes.h
@@ -1,5 +1,5 @@
/*
-** $Id: lopcodes.h,v 1.125 2006/03/14 19:04:44 roberto Exp $
+** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/loslib.c b/Build/source/texk/web2c/luatexdir/lua51/loslib.c
index fdda47414d0..da06a572acf 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/loslib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/loslib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $
+** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $
** Standard Operating System library
** See Copyright Notice in lua.h
*/
@@ -215,7 +215,6 @@ static int os_setlocale (lua_State *L) {
static int os_exit (lua_State *L) {
exit(luaL_optint(L, 1, EXIT_SUCCESS));
- return 0; /* to avoid warnings */
}
static const luaL_Reg syslib[] = {
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lparser.c b/Build/source/texk/web2c/luatexdir/lua51/lparser.c
index 6c473c41d2f..1e2a9a88b79 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lparser.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $
+** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -938,6 +938,8 @@ static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
primaryexp(ls, &nv.v);
if (nv.v.k == VLOCAL)
check_conflict(ls, lh, &nv.v);
+ luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls,
+ "variables in assignment");
assignment(ls, &nv, nvars+1);
}
else { /* assignment -> `=' explist1 */
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lparser.h b/Build/source/texk/web2c/luatexdir/lua51/lparser.h
index e5b5b57e850..18836afd1cd 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lparser.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lparser.h
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.h,v 1.57 2006/03/09 18:14:31 roberto Exp $
+** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua Parser
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lstate.c b/Build/source/texk/web2c/luatexdir/lua51/lstate.c
index 4bcb7594ce8..8d8e512e2d4 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lstate.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lstate.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.c,v 2.36 2006/05/24 14:15:50 roberto Exp $
+** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $
** Global State
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lstate.h b/Build/source/texk/web2c/luatexdir/lua51/lstate.h
index 5209e95c8ac..441c475e12a 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lstate.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lstate.h
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.h,v 2.24 2006/02/06 18:27:59 roberto Exp $
+** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $
** Global State
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lstring.c b/Build/source/texk/web2c/luatexdir/lua51/lstring.c
index 4319930c96d..49113151cc7 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lstring.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lstring.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstring.c,v 2.8 2005/12/22 16:19:56 roberto Exp $
+** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lstring.h b/Build/source/texk/web2c/luatexdir/lua51/lstring.h
index 1d2e91ea13a..73a2ff8b380 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lstring.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lstring.h
@@ -1,5 +1,5 @@
/*
-** $Id: lstring.h,v 1.43 2005/04/25 19:24:10 roberto Exp $
+** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $
** String table (keep all strings handled by Lua)
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lstrlib.c b/Build/source/texk/web2c/luatexdir/lua51/lstrlib.c
index 51a2e09e034..9ff4165248b 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lstrlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.132 2006/04/26 20:41:19 roberto Exp $
+** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -35,7 +35,8 @@ static int str_len (lua_State *L) {
static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
/* relative string position: negative means back from end */
- return (pos>=0) ? pos : (ptrdiff_t)len+pos+1;
+ if (pos < 0) pos += (ptrdiff_t)len + 1;
+ return (pos >= 0) ? pos : 0;
}
@@ -852,10 +853,6 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
lua_gettable(L, 3);
break;
}
- default: {
- luaL_argerror(L, 3, "string/function/table expected");
- return;
- }
}
if (!lua_toboolean(L, -1)) { /* nil or false? */
lua_pop(L, 1);
@@ -871,11 +868,15 @@ static int str_gsub (lua_State *L) {
size_t srcl;
const char *src = luaL_checklstring(L, 1, &srcl);
const char *p = luaL_checkstring(L, 2);
+ int tr = lua_type(L, 3);
int max_s = luaL_optint(L, 4, srcl+1);
int anchor = (*p == '^') ? (p++, 1) : 0;
int n = 0;
MatchState ms;
luaL_Buffer b;
+ luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
+ tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3,
+ "string/function/table expected");
luaL_buffinit(L, &b);
ms.L = L;
ms.src_init = src;
@@ -1055,7 +1056,7 @@ static int str_split (lua_State *L) {
}
p = malloc(l+1);
if (p==NULL) {
- fprintf(stderr, "fatal: memory exhausted (malloc of %u bytes).\n",l+1);
+ fprintf(stderr, "fatal: memory exhausted (malloc of %u bytes).\n",(int)(l+1));
exit(EXIT_FAILURE);
}
strcpy(p,s);
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ltable.c b/Build/source/texk/web2c/luatexdir/lua51/ltable.c
index bc91cacd637..ec84f4fabc5 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ltable.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/ltable.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.c,v 2.32 2006/01/18 11:49:02 roberto Exp $
+** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -84,8 +84,8 @@ static const Node dummynode_ = {
static Node *hashnum (const Table *t, lua_Number n) {
unsigned int a[numints];
int i;
- n += 1; /* normalize number (avoid -0) */
- lua_assert(sizeof(a) <= sizeof(n));
+ if (luai_numeq(n, 0)) /* avoid problems with -0 */
+ return gnode(t, 0);
memcpy(a, &n, sizeof(a));
for (i = 1; i < numints; i++) a[0] += a[i];
return hashmod(t, a[0]);
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ltable.h b/Build/source/texk/web2c/luatexdir/lua51/ltable.h
index 09193cdbe04..f5b9d5ead0f 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ltable.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/ltable.h
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.h,v 2.10 2006/01/10 13:13:06 roberto Exp $
+** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ltablib.c b/Build/source/texk/web2c/luatexdir/lua51/ltablib.c
index 453b23b378b..b6d9cb4ac74 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ltablib.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/ltablib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltablib.c,v 1.38 2005/10/23 17:38:15 roberto Exp $
+** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@@ -118,7 +118,8 @@ static int tinsert (lua_State *L) {
static int tremove (lua_State *L) {
int e = aux_getn(L, 1);
int pos = luaL_optint(L, 2, e);
- if (e == 0) return 0; /* table is `empty' */
+ if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
+ return 0; /* nothing to remove */
luaL_setn(L, 1, e - 1); /* t.n = n-1 */
lua_rawgeti(L, 1, pos); /* result = t[pos] */
for ( ;pos<e; pos++) {
@@ -131,6 +132,15 @@ static int tremove (lua_State *L) {
}
+static void addfield (lua_State *L, luaL_Buffer *b, int i) {
+ lua_rawgeti(L, 1, i);
+ if (!lua_isstring(L, -1))
+ luaL_error(L, "invalid value (%s) at index %d in table for "
+ LUA_QL("concat"), luaL_typename(L, -1), i);
+ luaL_addvalue(b);
+}
+
+
static int tconcat (lua_State *L) {
luaL_Buffer b;
size_t lsep;
@@ -140,13 +150,12 @@ static int tconcat (lua_State *L) {
i = luaL_optint(L, 3, 1);
last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
luaL_buffinit(L, &b);
- for (; i <= last; i++) {
- lua_rawgeti(L, 1, i);
- luaL_argcheck(L, lua_isstring(L, -1), 1, "table contains non-strings");
- luaL_addvalue(&b);
- if (i != last)
- luaL_addlstring(&b, sep, lsep);
+ for (; i < last; i++) {
+ addfield(L, &b, i);
+ luaL_addlstring(&b, sep, lsep);
}
+ if (i == last) /* add last value (if interval was not empty) */
+ addfield(L, &b, i);
luaL_pushresult(&b);
return 1;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ltm.c b/Build/source/texk/web2c/luatexdir/lua51/ltm.c
index 097b815ad3a..c27f0f6fab8 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ltm.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 2.8 2006/01/10 12:50:00 roberto Exp $
+** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/ltm.h b/Build/source/texk/web2c/luatexdir/lua51/ltm.h
index 866c79668d8..64343b781b6 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/ltm.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/ltm.h
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.h,v 2.6 2005/06/06 13:30:25 roberto Exp $
+** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lua.c b/Build/source/texk/web2c/luatexdir/lua51/lua.c
index 5cee7fa9f0b..3a46609328c 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lua.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.160 2006/06/02 15:34:00 roberto Exp $
+** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -74,6 +74,8 @@ static int report (lua_State *L, int status) {
static int traceback (lua_State *L) {
+ if (!lua_isstring(L, 1)) /* 'message' not a string? */
+ return 1; /* keep it intact */
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
if (!lua_istable(L, -1)) {
lua_pop(L, 1);
@@ -144,7 +146,7 @@ static int dostring (lua_State *L, const char *s, const char *name) {
static int dolibrary (lua_State *L, const char *name) {
lua_getglobal(L, "require");
lua_pushstring(L, name);
- return report(L, lua_pcall(L, 1, 0, 0));
+ return report(L, docall(L, 1, 1));
}
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lua.h b/Build/source/texk/web2c/luatexdir/lua51/lua.h
index 2865a7fae96..e4bdfd3b94f 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lua.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $
+** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
** Lua - An Extensible Extension Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
@@ -17,9 +17,9 @@
#define LUA_VERSION "Lua 5.1"
-#define LUA_RELEASE "Lua 5.1.2"
+#define LUA_RELEASE "Lua 5.1.4"
#define LUA_VERSION_NUM 501
-#define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
@@ -294,6 +294,9 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
#define lua_Chunkwriter lua_Writer
+/* hack */
+LUA_API void lua_setlevel (lua_State *from, lua_State *to);
+
/*
** {======================================================================
@@ -359,7 +362,7 @@ struct lua_Debug {
/******************************************************************************
-* Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved.
+* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
diff --git a/Build/source/texk/web2c/luatexdir/lua51/luaconf.h b/Build/source/texk/web2c/luatexdir/lua51/luaconf.h
index 11b002ca925..0650f2c7f64 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/luaconf.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/luaconf.h
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.82 2006/04/10 18:27:23 roberto Exp $
+** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -440,9 +440,10 @@
@* can use.
** CHANGE it if you need lots of (Lua) stack space for your C
** functions. This limit is arbitrary; its only purpose is to stop C
-** functions to consume unlimited stack space.
+** functions to consume unlimited stack space. (must be smaller than
+** -LUA_REGISTRYINDEX)
*/
-#define LUAI_MAXCSTACK 2048
+#define LUAI_MAXCSTACK 8000
@@ -674,7 +675,7 @@ union luai_Cast { double l_d; long l_l; };
*/
#if defined(LUA_USE_POPEN)
-#define lua_popen(L,c,m) ((void)L, popen(c,m))
+#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
#elif defined(LUA_WIN)
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lualib.h b/Build/source/texk/web2c/luatexdir/lua51/lualib.h
index 0c76232c0dd..469417f6703 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lualib.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lualib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp $
+** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua standard libraries
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lundump.c b/Build/source/texk/web2c/luatexdir/lua51/lundump.c
index 7fc635eeb7b..dea1996dcc5 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lundump.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lundump.c
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.c,v 1.60 2006/02/16 15:53:49 lhf Exp $
+** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -25,10 +25,12 @@ typedef struct {
ZIO* Z;
Mbuffer* b;
const char* name;
+ int swap;
} LoadState;
#ifdef LUAC_TRUST_BINARIES
#define IF(c,s)
+#define error(S,s)
#else
#define IF(c,s) if (c) error(S,s)
@@ -39,7 +41,6 @@ static void error(LoadState* S, const char* why)
}
#endif
-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
#define LoadByte(S) (lu_byte)LoadChar(S)
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
@@ -50,6 +51,49 @@ static void LoadBlock(LoadState* S, void* b, size_t size)
IF (r!=0, "unexpected end");
}
+static void LoadMem (LoadState* S, void* b, int n, size_t size)
+{
+ LoadBlock(S,b,n*size);
+ if (S->swap)
+ {
+ char* p=(char*) b;
+ char c;
+ switch (size)
+ {
+ case 1:
+ break;
+ case 2:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[1]; p[1]=c;
+ p+=2;
+ }
+ break;
+ case 4:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[3]; p[3]=c;
+ c=p[1]; p[1]=p[2]; p[2]=c;
+ p+=4;
+ }
+ break;
+ case 8:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[7]; p[7]=c;
+ c=p[1]; p[1]=p[6]; p[6]=c;
+ c=p[2]; p[2]=p[5]; p[5]=c;
+ c=p[3]; p[3]=p[4]; p[4]=c;
+ p+=8;
+ }
+ break;
+ default:
+ IF(1, "bad size");
+ break;
+ }
+ }
+}
+
static int LoadChar(LoadState* S)
{
char x;
@@ -74,7 +118,7 @@ static lua_Number LoadNumber(LoadState* S)
static TString* LoadString(LoadState* S)
{
- size_t size;
+ unsigned int size;
LoadVar(S,size);
if (size==0)
return NULL;
@@ -113,7 +157,7 @@ static void LoadConstants(LoadState* S, Proto* f)
setnilvalue(o);
break;
case LUA_TBOOLEAN:
- setbvalue(o,LoadChar(S));
+ setbvalue(o,LoadChar(S)!=0);
break;
case LUA_TNUMBER:
setnvalue(o,LoadNumber(S));
@@ -122,7 +166,7 @@ static void LoadConstants(LoadState* S, Proto* f)
setsvalue2n(S->L,o,LoadString(S));
break;
default:
- IF (1, "bad constant");
+ error(S,"bad constant");
break;
}
}
@@ -159,7 +203,9 @@ static void LoadDebug(LoadState* S, Proto* f)
static Proto* LoadFunction(LoadState* S, TString* p)
{
- Proto* f=luaF_newproto(S->L);
+ Proto* f;
+ if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
+ f=luaF_newproto(S->L);
setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
f->source=LoadString(S); if (f->source==NULL) f->source=p;
f->linedefined=LoadInt(S);
@@ -173,6 +219,7 @@ static Proto* LoadFunction(LoadState* S, TString* p)
LoadDebug(S,f);
IF (!luaG_checkcode(f), "bad code");
S->L->top--;
+ S->L->nCcalls--;
return f;
}
@@ -182,6 +229,7 @@ static void LoadHeader(LoadState* S)
char s[LUAC_HEADERSIZE];
luaU_header(h);
LoadBlock(S,s,LUAC_HEADERSIZE);
+ S->swap=(s[6]!=h[6]); s[6]=h[6];
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
}
@@ -216,7 +264,7 @@ void luaU_header (char* h)
*h++=(char)LUAC_FORMAT;
*h++=(char)*(char*)&x; /* endianness */
*h++=(char)sizeof(int);
- *h++=(char)sizeof(size_t);
+ *h++=(char)sizeof(unsigned int);
*h++=(char)sizeof(Instruction);
*h++=(char)sizeof(lua_Number);
*h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lundump.h b/Build/source/texk/web2c/luatexdir/lua51/lundump.h
index 58cca5d1908..c80189dbffc 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lundump.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lundump.h
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.h,v 1.40 2005/11/11 14:03:13 lhf Exp $
+** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lvm.c b/Build/source/texk/web2c/luatexdir/lua51/lvm.c
index 08802f440f3..ee3256ab94d 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lvm.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $
+** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -61,11 +61,9 @@ static void traceexec (lua_State *L, const Instruction *pc) {
lu_byte mask = L->hookmask;
const Instruction *oldpc = L->savedpc;
L->savedpc = pc;
- if (mask > LUA_MASKLINE) { /* instruction-hook set? */
- if (L->hookcount == 0) {
- resethookcount(L);
- luaD_callhook(L, LUA_HOOKCOUNT, -1);
- }
+ if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) {
+ resethookcount(L);
+ luaD_callhook(L, LUA_HOOKCOUNT, -1);
}
if (mask & LUA_MASKLINE) {
Proto *p = ci_func(L->ci)->l.p;
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lvm.h b/Build/source/texk/web2c/luatexdir/lua51/lvm.h
index 788423f8e31..bfe4f5678d0 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lvm.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lvm.h
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.h,v 2.5 2005/08/22 18:54:49 roberto Exp $
+** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lzio.c b/Build/source/texk/web2c/luatexdir/lua51/lzio.c
index 5121ada8466..293edd59b08 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lzio.c
+++ b/Build/source/texk/web2c/luatexdir/lua51/lzio.c
@@ -1,5 +1,5 @@
/*
-** $Id: lzio.c,v 1.31 2005/06/03 20:15:29 roberto Exp $
+** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
** a generic input stream interface
** See Copyright Notice in lua.h
*/
diff --git a/Build/source/texk/web2c/luatexdir/lua51/lzio.h b/Build/source/texk/web2c/luatexdir/lua51/lzio.h
index 8f403b8e74f..51d695d8c1d 100644
--- a/Build/source/texk/web2c/luatexdir/lua51/lzio.h
+++ b/Build/source/texk/web2c/luatexdir/lua51/lzio.h
@@ -1,5 +1,5 @@
/*
-** $Id: lzio.h,v 1.21 2005/05/17 19:49:15 roberto Exp $
+** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
** Buffered streams
** See Copyright Notice in lua.h
*/