diff -ruN lua-5.0.2-old/Makefile lua-5.0.2-new/Makefile
--- lua-5.0.2-old/Makefile	Fri Mar 12 02:50:55 2004
+++ lua-5.0.2-new/Makefile	Sat Jul 10 10:08:02 2004
@@ -1,102 +1,122 @@
-# makefile for Lua hierarchy
-# see INSTALL for installation instructions
-# see config for customization instructions
-
-LUA= .
-
-include $(LUA)/config
-
-# primary targets ("co" and "klean" are used for making the distribution)
-all clean co klean:	dirs
-	cd include; $(MAKE) $@
-	cd src; $(MAKE) $@
-	cd src/lib; $(MAKE) $@
-	cd src/luac; $(MAKE) $@
-	cd src/lua; $(MAKE) $@
-
-# in case they were not created during unpacking
-dirs:	bin lib
-
-bin lib:
-	mkdir -p $@
-
-# simple test to see Lua working
-test:	all
-	bin/lua test/hello.lua
-
-# remove debug information from binaries
-strip:
-	$(STRIP) bin/*
-
-# official installation
-install: all strip
-	mkdir -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN)
-	$(INSTALL_EXEC) bin/* $(INSTALL_BIN)
-	$(INSTALL_DATA) include/*.h $(INSTALL_INC)
-	$(INSTALL_DATA) lib/*.a $(INSTALL_LIB)
-	$(INSTALL_DATA) doc/*.1 $(INSTALL_MAN)
-
-# shared libraries (for Linux)
-so:
-	ld -o lib/liblua.so.$V -shared src/*.o
-	ld -o lib/liblualib.so.$V -shared src/lib/*.o
-	cd lib; ln -fs liblua.so.$V liblua.so; ln -fs liblualib.so.$V liblualib.so
-
-# binaries using shared libraries
-sobin:
-	rm -f bin/*
-	cd src/lua; $(MAKE)
-	cd src/luac; $(MAKE)
-
-# install shared libraries
-soinstall:
-	$(INSTALL_EXEC) lib/*.so.* $(INSTALL_LIB)
-	cd $(INSTALL_LIB); ln -fs liblua.so.$V liblua.so; ln -fs liblualib.so.$V liblualib.so
-
-# clean shared libraries
-soclean:
-	rm -f lib/*.so* bin/*
-
-# echo config parameters
-echo:
-	@echo ""
-	@echo "These are the parameters currently set in $(LUA)/config to build Lua $V:"
-	@echo ""
-	@echo "LOADLIB = $(LOADLIB)"
-	@echo "DLLIB = $(DLLIB)"
-	@echo "NUMBER = $(NUMBER)"
-	@echo "POPEN = $(POPEN)"
-	@echo "TMPNAM = $(TMPNAM)"
-	@echo "DEGREES = $(DEGREES)"
-	@echo "USERCONF = $(USERCONF)"
-	@echo "CC = $(CC)"
-	@echo "WARN = $(WARN)"
-	@echo "MYCFLAGS = $(MYCFLAGS)"
-	@echo "MYLDFLAGS = $(MYLDFLAGS)"
-	@echo "EXTRA_LIBS = $(EXTRA_LIBS)"
-	@echo "AR = $(AR)"
-	@echo "RANLIB = $(RANLIB)"
-	@echo "STRIP = $(STRIP)"
-	@echo "INSTALL_ROOT = $(INSTALL_ROOT)"
-	@echo "INSTALL_BIN = $(INSTALL_BIN)"
-	@echo "INSTALL_INC = $(INSTALL_INC)"
-	@echo "INSTALL_LIB = $(INSTALL_LIB)"
-	@echo "INSTALL_MAN = $(INSTALL_MAN)"
-	@echo "INSTALL_EXEC = $(INSTALL_EXEC)"
-	@echo "INSTALL_DATA = $(INSTALL_DATA)"
-	@echo ""
-	@echo "Edit $(LUA)/config if needed to suit your platform and then run make."
-	@echo ""
-
-# turn config into Lua code
-# uncomment the last sed expression if you want nil instead of empty strings
-lecho:
-	@echo "-- $(LUA)/config for Lua $V"
-	@echo "VERSION = '$(V)'"
-	@make echo | grep = | sed -e 's/= /= "/' -e 's/$$/"/' #-e 's/""/nil/'
-	@echo "-- EOF"
+include $(CONFIG)
 
-newer:
-	@find . -newer MANIFEST -type f
+ifneq "$(OS)" "Windows"
+  ifneq "$(OS)" "Cygwin"
+	CFLAGS += -DUSE_DLOPEN=1
+  endif
+endif
+ifneq "$(OS)" "Darwin"
+ ifneq "$(OS)" "Darwin-static"
+  ifneq "$(OS)" "OpenBSD"
+   ifneq "$(OS)" "FreeBSD"
+    ifneq "$(OS)" "Solaris"
+	CPFLAGS+= -a
+	LDFLAGS+= -Wl,-E
+	HLDFLAGS+= -Wl,-E
+    endif
+   endif
+  endif
+ endif
+endif
+
+CFLAGS += -I../../include -I../include -I. -I.. -DUSE_POPEN=1
+ifeq "$(OS)" "OpenBSD"
+	LDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -lm
+else
+  ifeq "$(OS)" "Cygwin"
+	LDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -lm
+  else
+    ifeq "$(OS)" "BeOS"
+	LDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -ldl
+    else
+	LDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -lm -ldl
+    endif
+  endif
+endif
+HCFLAGS += -I../../include -I../include -I. -I.. -DUSE_POPEN=1
+ifeq "$(OS)" "FreeBSD"
+	HLDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -lm
+else
+ ifeq "$(OS)" "OpenBSD"
+ 	HLDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -lm
+ else
+   ifeq "$(OS)" "Cygwin"
+ 	HLDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -lm
+   else
+     ifeq "$(OS)" "BeOS"
+ 	  HLDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -ldl
+     else
+       ifeq "$(OS)" "Solaris"
+ 	    HLDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -lsocket -lnsl -lm
+       else
+ 	    HLDFLAGS+= -L../lib/ -L../../lib/ -llua-host -llualib-host -lm -ldl
+       endif
+     endif
+   endif
+ endif
+endif
+
+H=@
+
+all: bin/lua
+	$(H)echo -n
+
+bin/lua:
+	$(H)echo -n ' building core library... '
+	$(H)cd src ; 					\
+		$(CC) $(CFLAGS) -c  *.c ; 		\
+		$(AR) rc ../lib/liblua.a *.o ; 		\
+		$(RANLIB) ../lib/liblua.a ;		\
+		rm -f *.o
+	$(H)echo "done."
+
+	$(H)echo -n ' building standard library... '
+	$(H)cd src/lib;					\
+		$(CC) $(CFLAGS) -c  *.c ;		\
+		$(AR) rc ../../lib/liblualib.a *.o ;	\
+		$(RANLIB) ../../lib/liblualib.a ;	\
+		rm -f *.o 
+	$(H)echo "done."
+
+	$(H)if test "$(HCC)" = "$(CC)" ; then				\
+		cd lib/ ; 						\
+			ln -s liblua.a liblua-host.a ;			\
+			ln -s liblualib.a liblualib-host.a ;		\
+	else								\
+		echo -n ' building core host library... ';	\
+		cd src ; 						\
+			$(HCC) $(HCFLAGS) -c *.c ; 			\
+			$(HAR) rc ../lib/liblua-host.a *.o ; 	\
+			$(HRANLIB) ../lib/liblua-host.a ;		\
+			rm -f *.o;					\
+		echo "done.";						\
+		echo -n ' building standard host library... ';		\
+		cd ../src/lib;						\
+			$(HCC) $(HCFLAGS) -c *.c ;			\
+			$(HAR) rc ../../lib/liblualib-host.a *.o ;	\
+			$(HRANLIB) ../../lib/liblualib-host.a ;		\
+			rm -f *.o ;					\
+		echo "done.";						\
+	fi
+
+	$(H)echo -n ' building lua... '
+	$(H)cd src/lua;					\
+		$(HCC) $(HCFLAGS) -o ../../bin/lua *.c $(HLDFLAGS)
+	$(H)echo "done."
+
+	$(H)echo -n ' building luac... '
+	$(H)cd src/luac ;					\
+		$(HCC) $(HCFLAGS) -o ../../bin/luac *.c 	\
+			-DLUA_OPNAMES ../lopcodes.c $(HLDFLAGS)
+	$(H)echo "done."
+
+	$(H)echo -n ' building bin2c... '
+	$(H)cd etc ;					\
+		$(HCC) $(HCFLAGS) -o ../bin/bin2c bin2c.c 	\
+			$(HLDFLAGS)
+	$(H)echo "done."
+
+	$(H)cp include/*.h $(PREFIX)/include
+	$(H)cp bin/* $(PREFIX)/bin
+	$(H)cp $(CPFLAGS) lib/*.a $(PREFIX)/lib

-# (end of Makefile)
+clean:
+	$(H)rm -f lib/* bin/*
diff -ruN lua-5.0.2-old/build lua-5.0.2-new/build
--- lua-5.0.2-old/build	Fri Mar 28 21:06:41 2003
+++ lua-5.0.2-new/build	Thu Jan  1 01:00:00 1970
@@ -1,33 +0,0 @@
-# If you don't want to use make, run this script.
-# But make sure you read config to see what can be customized.
-
-
-# Easiest way to build bin/lua:
-# cc -O2 -o bin/lua -Iinclude -Isrc src/*.c src/lib/*.c src/lua/*.c -lm -ldl
-
-
-# Easiest way to build Lua libraries and executables:
-echo -n 'building core library... '
-cd src
-cc -O2 -c -I../include *.c
-ar rc ../lib/liblua.a *.o
-rm -f *.o
-
-echo -n 'standard library... '
-cd lib
-cc -O2 -c -I../../include *.c
-ar rc ../../lib/liblualib.a *.o
-rm -f *.o
-
-echo -n 'lua... '
-cd ../lua
-cc -O2 -o ../../bin/lua -I../../include *.c ../../lib/*.a -lm -ldl
-
-echo -n 'luac... '
-cd ../luac
-cc -O2 -o ../../bin/luac -I../../include -I.. *.c -DLUA_OPNAMES ../lopcodes.c ../../lib/*.a
-
-echo 'done'
-
-cd ../..
-bin/lua test/hello.lua
diff -ruN lua-5.0.2-old/src/lib/lauxlib.c lua-5.0.2-new/src/lib/lauxlib.c
--- lua-5.0.2-old/src/lib/lauxlib.c	Mon Apr  7 16:35:00 2003
+++ lua-5.0.2-new/src/lib/lauxlib.c	Sat Jul 10 09:50:58 2004
@@ -475,9 +475,10 @@
 }
 
 
-static int errfile (lua_State *L, int fnameindex) {
+static int errfile (lua_State *L, int id,int fnameindex,int err) {
   const char *filename = lua_tostring(L, fnameindex) + 1;
-  lua_pushfstring(L, "cannot read %s: %s", filename, strerror(errno));
+  const char *error_string = strerror(err);
+  lua_pushfstring(L, "[%d]cannot read %s: (%d) %s",id, filename, err,error_string);
   lua_remove(L, fnameindex);
   return LUA_ERRFILE;
 }
@@ -496,19 +497,19 @@
     lua_pushfstring(L, "@%s", filename);
     lf.f = fopen(filename, "r");
   }
-  if (lf.f == NULL) return errfile(L, fnameindex);  /* unable to open file */
+  if (lf.f == NULL) return errfile(L,0, fnameindex,errno);  /* unable to open file */
   c = ungetc(getc(lf.f), lf.f);
   if (!(isspace(c) || isprint(c)) && lf.f != stdin) {  /* binary file? */
     fclose(lf.f);
     lf.f = fopen(filename, "rb");  /* reopen in binary mode */
-    if (lf.f == NULL) return errfile(L, fnameindex); /* unable to reopen file */
+    if (lf.f == NULL) return errfile(L,1, fnameindex,errno); /* unable to reopen file */
   }
   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 (readstatus) {
     lua_settop(L, fnameindex);  /* ignore results from `lua_load' */
-    return errfile(L, fnameindex);
+    return errfile(L,2, fnameindex,errno);
   }
   lua_remove(L, fnameindex);
   return status;
diff -ruN lua-5.0.2-old/src/lib/loadlib.c lua-5.0.2-new/src/lib/loadlib.c
--- lua-5.0.2-old/src/lib/loadlib.c	Mon Apr  7 22:11:53 2003
+++ lua-5.0.2-new/src/lib/loadlib.c	Sat Jul 10 10:08:56 2004
@@ -49,7 +49,11 @@
 {
  const char *path=luaL_checkstring(L,1);
  const char *init=luaL_checkstring(L,2);
+#ifndef RTLD_NOW
+ void *lib=dlopen(path,RTLD_LAZY);
+#else
  void *lib=dlopen(path,RTLD_NOW);
+#endif
  if (lib!=NULL)
  {
   lua_CFunction f=(lua_CFunction) dlsym(lib,init);
--- lua-5.0.2-old/src/lib/liolib.c	2003-10-01 15:16:49.000000000 +0200
+++ lua-5.0.2-new/src/lib/liolib.c	2004-08-26 11:42:11.000000000 +0200
@@ -46,6 +46,12 @@
 
 #ifndef USE_POPEN
 #define USE_POPEN	0
+#else
+  #if !defined(WIN32)
+    #include <sys/types.h>
+    #include <unistd.h>
+    #include <sys/wait.h>
+  #endif
 #endif
 
 
@@ -208,6 +212,104 @@
 #endif
 }
 
+static int io_dpopen(lua_State*l){
+#if !defined(USE_POPEN) || defined(WIN32)
+  luaL_error(l, "`dpopen' not supported");
+  return 0;
+#else
+	#define READ	0
+	#define WRITE	1
+	int in[2],out[2];
+	int narg = lua_gettop(l);
+	const char ** argv = NULL;
+	int i,rc;
+	pid_t pid;
+	FILE **pf_r,**pf_w;
+
+
+	if (narg < 1) {
+		luaL_error(l,"create wants at least one argument");
+	}
+	
+	argv = calloc(narg+1,sizeof(char*));
+	if (argv == NULL){
+		luaL_error(l,"Unable to alloc.");
+	}
+
+	for (i=0;i < narg;i++) {
+		argv[i] = luaL_checkstring(l,i+1);
+		//fprintf(stderr,"getting %s",argv[i]);
+	}
+	argv[i] = NULL;
+	
+	rc = pipe(out);
+	if (rc == -1) {
+		luaL_error(l,strerror(errno));
+	}
+	rc = pipe(in);
+	if (rc == -1) {
+		luaL_error(l,strerror(errno));
+	}
+
+	pid = fork();
+	if (pid == 0) {
+		// son
+		pid = fork();
+		if (pid == 0) {
+			// grandson, inherited by init, no Zombie
+			rc = dup2(out[READ],STDIN_FILENO);
+			if (rc == -1) {
+				luaL_error(l,strerror(errno));
+			}
+			rc = dup2(in[WRITE],STDOUT_FILENO);
+			if (rc == -1) {
+				luaL_error(l,strerror(errno));
+			}
+			rc = close(in[READ]);
+			if (rc == -1) {
+				luaL_error(l,strerror(errno));
+			}
+			rc = close(out[WRITE]);
+			if (rc == -1) {
+				luaL_error(l,strerror(errno));
+			}
+			//fprintf(stderr,"starting %s...\n",argv[0]);
+			rc = execv(argv[0],(char* const*)argv);
+			if (rc == -1) {
+				luaL_error(l,strerror(errno));
+			}
+			luaL_error(l,"dead code");
+		} else {
+			_exit(0);
+		}
+	} else {
+		if (pid == -1) {
+			luaL_error(l,strerror(errno));
+		}
+		waitpid(pid,NULL,0); //wait the son
+	}
+	pf_r = newfile(l);
+	pf_w = newfile(l);
+
+	rc = close(out[READ]);
+	if (rc == -1) {
+		luaL_error(l,strerror(errno));
+	}
+	rc = close(in[WRITE]);
+	if (rc == -1) {
+		luaL_error(l,strerror(errno));
+	}
+	
+	*pf_r = fdopen(in[READ],"r");
+	*pf_w = fdopen(out[WRITE],"w");
+
+	free(argv);
+	
+	return 2;
+#endif
+}
+
+
 
 static int io_tmpfile (lua_State *L) {
   FILE **pf = newfile(L);
@@ -497,6 +599,7 @@
   {"flush", io_flush},
   {"open", io_open},
   {"popen", io_popen},
+  {"dpopen", io_dpopen},
   {"read", io_read},
   {"tmpfile", io_tmpfile},
   {"type", io_type},


syntax highlighted by Code2HTML, v. 0.9.1