From 4d8b815d3b53ae72bce12b535d86bdce51834d50 Mon Sep 17 00:00:00 2001
From: Luigi Scarso <luigi.scarso@gmail.com>
Date: Wed, 1 Mar 2017 18:33:58 +0000
Subject: [PATCH] cleanup (HH) -- WORK IN PROGRESS !!

---
 source/texk/web2c/luatexdir/lua/liolibext.c   | 707 +-----------------
 source/texk/web2c/luatexdir/lua/loslibext.c   |  25 +-
 source/texk/web2c/luatexdir/lua/lstatslib.c   |  27 +-
 source/texk/web2c/luatexdir/lua/luainit.w     | 302 +++++++-
 source/texk/web2c/luatexdir/lua/luajitstuff.w |  52 +-
 source/texk/web2c/luatexdir/lua/luastuff.w    |  44 +-
 source/texk/web2c/luatexdir/lua/luatex-api.h  |   4 +-
 source/texk/web2c/luatexdir/lua/luatex-core.c | 269 +++++++
 .../texk/web2c/luatexdir/lua/luatex-core.lua  | 135 ++++
 9 files changed, 771 insertions(+), 794 deletions(-)
 create mode 100644 source/texk/web2c/luatexdir/lua/luatex-core.c
 create mode 100644 source/texk/web2c/luatexdir/lua/luatex-core.lua

diff --git a/source/texk/web2c/luatexdir/lua/liolibext.c b/source/texk/web2c/luatexdir/lua/liolibext.c
index 419e56ac0..9cab8440d 100644
--- a/source/texk/web2c/luatexdir/lua/liolibext.c
+++ b/source/texk/web2c/luatexdir/lua/liolibext.c
@@ -15,18 +15,13 @@
    License for more details.
 
    You should have received a copy of the GNU General Public License along
-   with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
+   with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
 
-/* This extension only replaces one function: io.popen() and two
-   metatable entries: f:read() and f:lines() but unfortunately
-   it has to copy quite a bunch of lines from the original liolib.c
-   to do so.
 */
 
 #include "ptexlib.h"
 #include "lua/luatex-api.h"
 
-
 #ifdef LuajitTeX
 #include "lua/lauxlib_bridge.h"
 #else
@@ -34,626 +29,24 @@
 #endif
 #include "lualib.h"
 
-
-
-/*
-** {======================================================
-** lua_popen spawns a new process connected to the current
-** one through the file streams.
-** =======================================================
-*/
-
-#if defined(_WIN32)
-
-#ifdef _MSC_VER
-#define lua_popen(L,c,m)		((void)L, win32_popen(c,m))
-#define lua_pclose(L,file)		((void)L, win32_pclose(file))
-#else
-#define lua_popen(L,c,m)		((void)L, _popen(c,m))
-#define lua_pclose(L,file)		((void)L, _pclose(file))
-#endif
-
-#else
-
-#define lua_popen(L,c,m)	((void)L, fflush(NULL), popen(c,m))
-#define lua_pclose(L,file)	((void)L, pclose(file))
-
-#endif
-
-/* }====================================================== */
-
-
-#if defined(LUA_USE_POSIX)
-
-#define l_fseek(f,o,w)		fseeko(f,o,w)
-#define l_ftell(f)		ftello(f)
-#define l_seeknum		off_t
-
-#elif defined(LUA_WIN) && !defined(_CRTIMP_TYPEINFO) \
-   && defined(_MSC_VER) && (_MSC_VER >= 1400)
-/* Windows (but not DDK) and Visual C++ 2005 or higher */
-
-#define l_fseek(f,o,w)		_fseeki64(f,o,w)
-#define l_ftell(f)		_ftelli64(f)
-#define l_seeknum		__int64
-
-#elif defined(__MINGW32__)
-
-#define l_fseek(f,o,w)          fseeko64(f,o,w)
-#define l_ftell(f)              ftello64(f)
-#define l_seeknum               int64_t
-
-#else
-
-#define l_fseek(f,o,w)		fseek(f,o,w)
-#define l_ftell(f)		ftell(f)
-#define l_seeknum		long
-
-#endif
-
-#define IO_PREFIX	"_IO_"
-#define IO_INPUT	(IO_PREFIX "input")
-#define IO_OUTPUT	(IO_PREFIX "output")
-
-typedef luaL_Stream LStream;
-
-#define tolstream(L)	((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
-
-#define isclosed(p)	((p)->closef == NULL)
-
-static int io_type (lua_State *L) {
-  LStream *p;
-  luaL_checkany(L, 1);
-  p = (LStream *)luaL_testudata(L, 1, LUA_FILEHANDLE);
-  if (p == NULL)
-    lua_pushnil(L);  /* not a file */
-  else if (isclosed(p))
-    lua_pushliteral(L, "closed file");
-  else
-    lua_pushliteral(L, "file");
-  return 1;
-}
-
-
-static int f_tostring (lua_State *L) {
-  LStream *p = tolstream(L);
-  if (isclosed(p))
-    lua_pushliteral(L, "file (closed)");
-  else
-    lua_pushfstring(L, "file (%p)", p->f);
-  return 1;
-}
-
 static FILE *tofile (lua_State *L) {
 #ifdef LuajitTeX
-  /* see host/minilua.c */
-  FILE**f=luaL_checkudata(L,1,LUA_FILEHANDLE);
-  if(*f==NULL)
+  FILE **f = luaL_checkudata(L,1,LUA_FILEHANDLE);
+  if (*f == NULL)
     luaL_error(L,"attempt to use a closed file");
-  return*f;
+  return *f;
 #else
-  LStream *p = tolstream(L);
-  if (isclosed(p))
+  luaL_Stream *p = ((luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE));
+  if ((p)->closef == NULL)
     luaL_error(L, "attempt to use a closed file");
   lua_assert(p->f);
   return p->f;
 #endif
 }
 /*
-** When creating file handles, always creates a `closed' file handle
-** before opening the actual file; so, if there is a memory error, the
-** file is not left opened.
-*/
-static LStream *newprefile (lua_State *L) {
-  LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream));
-  p->closef = NULL;  /* mark file handle as 'closed' */
-  luaL_setmetatable(L, LUA_FILEHANDLE);
-  return p;
-}
-
-
-static int aux_close (lua_State *L) {
-  LStream *p = tolstream(L);
-  lua_CFunction cf = p->closef;
-  p->closef = NULL;  /* mark stream as closed */
-  return (*cf)(L);  /* close it */
-}
-
-
-static int io_close (lua_State *L) {
-  if (lua_isnone(L, 1))  /* no argument? */
-    lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT);  /* use standard output */
-  tofile(L);  /* make sure argument is an open stream */
-  return aux_close(L);
-}
-
-static int f_gc (lua_State *L) {
-  LStream *p = tolstream(L);
-  if (!isclosed(p) && p->f != NULL)
-    aux_close(L);  /* ignore closed and incompletely open files */
-  return 0;
-}
-
-
-/*
-** function to close regular files
-*/
-static int io_fclose (lua_State *L) {
-  LStream *p = tolstream(L);
-  int res = fclose(p->f);
-  return luaL_fileresult(L, (res == 0), NULL);
-}
-
-
-static LStream *newfile (lua_State *L) {
-  LStream *p = newprefile(L);
-  p->f = NULL;
-  p->closef = &io_fclose;
-  return p;
-}
-
-
-static void opencheck (lua_State *L, const char *fname, const char *mode) {
-  LStream *p = newfile(L);
-  p->f = fopen(fname, mode);
-  if (p->f == NULL) {
-    luaL_error(L, "cannot open file " LUA_QS " (%s)", fname, strerror(errno));
-  } else {
-#ifdef WIN32
-    _setmode (fileno (p->f), _O_BINARY);
-#endif
-    if (mode[0]=='r')
-       recorder_record_input(fname);
-    else
-       recorder_record_output(fname);
-  }
-}
-
-static int io_open (lua_State *L) {
-  const char *filename = luaL_checkstring(L, 1);
-  const char *mode = luaL_optstring(L, 2, "r");
-  LStream *p = newfile(L);
-  int i = 0;
-  /* check whether 'mode' matches '[rwa]%+?b?' */
-  if (!(mode[i] != '\0' && strchr("rwa", mode[i++]) != NULL &&
-       (mode[i] != '+' || ++i) &&  /* skip if char is '+' */
-       (mode[i] != 'b' || ++i) &&  /* skip if char is 'b' */
-       (mode[i] == '\0')))
-    return luaL_error(L, "invalid mode " LUA_QS
-                         " (should match " LUA_QL("[rwa]%%+?b?") ")", mode);
-  p->f = fopen(filename, mode);
-  if (p->f == NULL) {
-      return luaL_fileresult(L, 0, filename) ;
-  } else {
-#ifdef WIN32
-      _setmode (fileno (p->f), _O_BINARY);
-#endif
-      if (mode[0]=='r')
-	  recorder_record_input(filename);
-      else
-	  recorder_record_output(filename);
-      return 1;
-  }
-}
-
-/*
-** function to close 'popen' files
+    HH: A few helpers to avoid reading numbers as strings. For now we put them in their
+    own namespace. We also have a few helpers that can make io functions tex friendly.
 */
-static int io_pclose (lua_State *L) {
-  LStream *p = tolstream(L);
-  return luaL_execresult(L, lua_pclose(L, p->f));
-}
-
-static int io_popen(lua_State * L)
-{
-    int ret = 1;
-    char *safecmd = NULL;
-    char *cmdname = NULL;
-    int allow = 0;
-    const char *filename = luaL_checkstring(L, 1);
-    const char *mode = luaL_optstring(L, 2, "r");
-    LStream *p = newprefile(L);
-
-    if (shellenabledp <= 0) {
-        lua_pushnil(L);
-        lua_pushliteral(L, "All command execution is disabled");
-        return 2;
-    }
-    /* If restrictedshell == 0, any command is allowed. */
-    if (restrictedshell == 0)
-        allow = 1;
-    else
-        allow = shell_cmd_is_allowed(filename, &safecmd, &cmdname);
-
-    if (allow == 1) {
-        p->f = lua_popen(L, filename, mode);
-	p->closef = &io_pclose;
-        ret = (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
-    } else if (allow == 2) {
-        p->f = lua_popen(L, safecmd, mode);
-	p->closef = &io_pclose;
-        ret = (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
-    } else if (allow == 0) {
-        lua_pushnil(L);
-        lua_pushliteral(L, "Command execution disabled via shell_escape='p'");
-        ret = 2;
-    } else {
-        lua_pushnil(L);
-        lua_pushliteral(L, "Bad command line quoting");
-        ret = 2;
-    }
-    return ret;
-}
-
-
-static int io_tmpfile (lua_State *L) {
-  LStream *p = newfile(L);
-  p->f = tmpfile();
-  return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1;
-}
-
-
-static FILE *getiofile (lua_State *L, const char *findex) {
-  LStream *p;
-  lua_getfield(L, LUA_REGISTRYINDEX, findex);
-  p = (LStream *)lua_touserdata(L, -1);
-  if (isclosed(p))
-    luaL_error(L, "standard %s file is closed", findex + strlen(IO_PREFIX));
-  return p->f;
-}
-
-
-static int g_iofile (lua_State *L, const char *f, const char *mode) {
-  if (!lua_isnoneornil(L, 1)) {
-    const char *filename = lua_tostring(L, 1);
-    if (filename)
-      opencheck(L, filename, mode);
-    else {
-      tofile(L);  /* check that it's a valid file handle */
-      lua_pushvalue(L, 1);
-    }
-    lua_setfield(L, LUA_REGISTRYINDEX, f);
-  }
-  /* return current value */
-  lua_getfield(L, LUA_REGISTRYINDEX, f);
-  return 1;
-}
-
-
-static int io_input (lua_State *L) {
-  return g_iofile(L, IO_INPUT, "r");
-}
-
-
-static int io_output (lua_State *L) {
-  return g_iofile(L, IO_OUTPUT, "w");
-}
-
-
-static int io_readline (lua_State *L);
-
-
-static void aux_lines (lua_State *L, int toclose) {
-  int i;
-  int n = lua_gettop(L) - 1;  /* number of arguments to read */
-  /* ensure that arguments will fit here and into 'io_readline' stack */
-  luaL_argcheck(L, n <= LUA_MINSTACK - 3, LUA_MINSTACK - 3, "too many options");
-  lua_pushvalue(L, 1);  /* file handle */
-  lua_pushinteger(L, n);  /* number of arguments to read */
-  lua_pushboolean(L, toclose);  /* close/not close file when finished */
-  for (i = 1; i <= n; i++) lua_pushvalue(L, i + 1);  /* copy arguments */
-  lua_pushcclosure(L, io_readline, 3 + n);
-}
-
-
-static int f_lines (lua_State *L) {
-  tofile(L);  /* check that it's a valid file handle */
-  aux_lines(L, 0);
-  return 1;
-}
-
-
-static int io_lines (lua_State *L) {
-  int toclose;
-  if (lua_isnone(L, 1)) lua_pushnil(L);  /* at least one argument */
-  if (lua_isnil(L, 1)) {  /* no file name? */
-    lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT);  /* get default input */
-    lua_replace(L, 1);  /* put it at index 1 */
-    tofile(L);  /* check that it's a valid file handle */
-    toclose = 0;  /* do not close it after iteration */
-  }
-  else {  /* open a new file */
-    const char *filename = luaL_checkstring(L, 1);
-    opencheck(L, filename, "r");
-    lua_replace(L, 1);  /* put file at index 1 */
-    toclose = 1;  /* close it after iteration */
-  }
-  aux_lines(L, toclose);
-  return 1;
-}
-
-/*
-** {======================================================
-** READ
-** =======================================================
-*/
-
-
-static int read_number (lua_State *L, FILE *f) {
-  lua_Number d;
-  if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
-    lua_pushnumber(L, d); /* integer or float */
-    return 1;
-  }
-  else {
-   lua_pushnil(L);  /* "result" to be removed */
-   return 0;  /* read fails */
-  }
-}
-
-
-static int test_eof (lua_State *L, FILE *f) {
-  int c = getc(f);
-  ungetc(c, f);
-  lua_pushlstring(L, NULL, 0);
-  return (c != EOF);
-}
-
-/* this version does not care wether the file has
-   line endings using an 'alien' convention */
-
-static int read_line(lua_State * L, FILE * f, int chop)
-{
-    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_rawlen(L, -1) > 0);     /* check whether read something */
-        };
-        if (c == '\n') {
-	    if (!chop)
-		luaL_addchar(&buf, c);
-            break;
-        } else if (c == '\r') {
-	    if (!chop)
-		luaL_addchar(&buf, c);
-            d = fgetc(f);
-            if (d != EOF && d != '\n') {
-                ungetc(d, f);
-	    } else if (!chop) {
-		luaL_addchar(&buf, d);
-	    }
-            break;
-        } else {
-            luaL_addchar(&buf, c);
-        }
-    }
-    luaL_pushresult(&buf);      /* close buffer */
-    return 1;
-}
-
-#define MAX_SIZE_T	(~(size_t)0)
-
- /* static void read_all (lua_State *L, FILE *f) { */
- /*   size_t rlen = LUAL_BUFFERSIZE;  /\* how much to read in each cycle *\/ */
- /*   l_seeknum old, nrlen = 0;  /\* for testing file size *\/ */
- /*   luaL_Buffer b; */
- /*   luaL_buffinit(L, &b); */
- /*   /\* speed up loading of not too large files: *\/ */
- /*   old = l_ftell(f); */
- /*   if ((l_fseek(f, 0, SEEK_END) >= 0) && */
- /*       ((nrlen = l_ftell(f)) > 0) && nrlen < 1000 * 1000 * 100) { */
- /*       rlen = nrlen; */
- /*   } */
- /*   l_fseek(f, old, SEEK_SET); */
- /*   for (;;) { */
- /*     char *p = luaL_prepbuffsize(&b, rlen); */
- /*     size_t nr = fread(p, sizeof(char), rlen, f); */
- /*     luaL_addsize(&b, nr); */
- /*     if (nr < rlen) break;  /\* eof? *\/ */
- /*     else if (rlen <= (MAX_SIZE_T / 4))  /\* avoid buffers too large *\/ */
- /*       rlen *= 2;  /\* double buffer size at each iteration *\/ */
- /*   } */
- /*   luaL_pushresult(&b);  /\* close buffer *\/ */
- /* } */
-
-static void read_all (lua_State *L, FILE *f) {
-  size_t rlen = LUAL_BUFFERSIZE;  /* how much to read in each cycle */
-  luaL_Buffer b;
-  luaL_buffinit(L, &b);
-  for (;;) {
-    char *p = luaL_prepbuffsize(&b, rlen);
-    size_t nr = fread(p, sizeof(char), rlen, f);
-    luaL_addsize(&b, nr);
-    if (nr < rlen) break;  /* eof? */
-    else if (rlen <= (MAX_SIZE_T / 4))  /* avoid buffers too large */
-      rlen *= 2;  /* double buffer size at each iteration */
-  }
-  luaL_pushresult(&b);  /* close buffer */
-}
-
-static int read_chars (lua_State *L, FILE *f, size_t n) {
-  size_t nr;  /* number of chars actually read */
-  char *p;
-  luaL_Buffer b;
-  luaL_buffinit(L, &b);
-  p = luaL_prepbuffsize(&b, n);  /* prepare buffer to read whole block */
-  nr = fread(p, sizeof(char), n, f);  /* try to read 'n' chars */
-  luaL_addsize(&b, nr);
-  luaL_pushresult(&b);  /* close buffer */
-  return (nr > 0);  /* true iff read something */
-}
-
-
-static int g_read (lua_State *L, FILE *f, int first) {
-  int nargs = lua_gettop(L) - 1;
-  int success;
-  int n;
-  clearerr(f);
-  if (nargs == 0) {  /* no arguments? */
-    success = read_line(L, f, 1);
-    n = first+1;  /* to return 1 result */
-  }
-  else {  /* ensure stack space for all results and for auxlib's buffer */
-    luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments");
-    success = 1;
-    for (n = first; nargs-- && success; n++) {
-      if (lua_type(L, n) == LUA_TNUMBER) {
-        size_t l = (size_t)lua_tointeger(L, n);
-        success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
-      }
-      else {
-        const char *p = lua_tostring(L, n);
-        luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
-        switch (p[1]) {
-          case 'n':  /* number */
-            success = read_number(L, f);
-            break;
-          case 'l':  /* line */
-            success = read_line(L, f, 1);
-            break;
-          case 'L':  /* line with end-of-line */
-            success = read_line(L, f, 0);
-            break;
-          case 'a':  /* file */
-            read_all(L, f);  /* read entire file */
-            success = 1; /* always success */
-            break;
-          default:
-            return luaL_argerror(L, n, "invalid format");
-        }
-      }
-    }
-  }
-  if (ferror(f))
-    return luaL_fileresult(L, 0, NULL);
-  if (!success) {
-    lua_pop(L, 1);  /* remove last result */
-    lua_pushnil(L);  /* push nil instead */
-  }
-  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) {
-  LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1));
-  int i;
-  int n = (int)lua_tointeger(L, lua_upvalueindex(2));
-  if (isclosed(p))  /* file is already closed? */
-    return luaL_error(L, "file is already closed");
-  lua_settop(L , 1);
-  for (i = 1; i <= n; i++)  /* push arguments to 'g_read' */
-    lua_pushvalue(L, lua_upvalueindex(3 + i));
-  n = g_read(L, p->f, 2);  /* 'n' is number of results */
-  lua_assert(n > 0);  /* should return at least a nil */
-  if (!lua_isnil(L, -n))  /* read at least one value? */
-    return n;  /* return them */
-  else {  /* first result is nil: EOF or error */
-    if (n > 1) {  /* is there error information? */
-      /* 2nd result is error message */
-      return luaL_error(L, "%s", lua_tostring(L, -n + 1));
-    }
-    if (lua_toboolean(L, lua_upvalueindex(3))) {  /* generator created file? */
-      lua_settop(L, 0);
-      lua_pushvalue(L, lua_upvalueindex(1));
-      aux_close(L);  /* close it */
-    }
-    return 0;
-  }
-}
-
-/* }====================================================== */
-
-
-static int g_write (lua_State *L, FILE *f, int arg) {
-  int nargs = lua_gettop(L) - arg;
-  int status = 1;
-  for (; nargs--; arg++) {
-    if (lua_type(L, arg) == LUA_TNUMBER) {
-      /* optimization: could be done exactly as for strings */
-      status = status &&
-          fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
-    }
-    else {
-      size_t l;
-      const char *s = luaL_checklstring(L, arg, &l);
-      status = status && (fwrite(s, sizeof(char), l, f) == l);
-    }
-  }
-  if (status) return 1;  /* file handle already on stack top */
-  else return luaL_fileresult(L, status, NULL);
-}
-
-
-static int io_write (lua_State *L) {
-  return g_write(L, getiofile(L, IO_OUTPUT), 1);
-}
-
-
-static int f_write (lua_State *L) {
-  FILE *f = tofile(L);
-  lua_pushvalue(L, 1);  /* push file at the stack top (to be returned) */
-  return g_write(L, f, 2);
-}
-
-
-static int f_seek (lua_State *L) {
-  static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
-  static const char *const modenames[] = {"set", "cur", "end", NULL};
-  FILE *f = tofile(L);
-  int op = luaL_checkoption(L, 2, "cur", modenames);
-  lua_Number p3 = luaL_optnumber(L, 3, 0);
-  l_seeknum offset = (l_seeknum)p3;
-  luaL_argcheck(L, (lua_Number)offset == p3, 3,
-                  "not an integer in proper range");
-  op = l_fseek(f, offset, mode[op]);
-  if (op)
-    return luaL_fileresult(L, 0, NULL);  /* error */
-  else {
-    lua_pushinteger(L, (lua_Number)l_ftell(f));
-    return 1;
-  }
-}
-
-
-static int f_setvbuf (lua_State *L) {
-  int res;
-  static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
-  static const char *const modenames[] = {"no", "full", "line", NULL};
-  FILE *f = tofile(L);
-  int op = luaL_checkoption(L, 2, NULL, modenames);
-  lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE);
-  if(sz == 0)
-    res = setvbuf(f, NULL, _IONBF, sz);
-  else
-    res = setvbuf(f, NULL, mode[op], sz);
-  return luaL_fileresult(L, res == 0, NULL);
-}
-
-
-
-static int io_flush (lua_State *L) {
-  return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL);
-}
-
-
-static int f_flush (lua_State *L) {
-  return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL);
-}
-
-/* a few helpers to avoid reading numbers as strings */
 
 static int readcardinal1(lua_State *L) {
     FILE *f = tofile(L);
@@ -980,90 +373,10 @@ static const luaL_Reg fiolib[] = {
     { "recordfilename",  recordfilename },
     { "checkpermission", checkpermission },
     /* done */
-  {NULL, NULL}
+    {NULL, NULL}
 };
 
-/* functions for 'io' library */
-
-static const luaL_Reg iolib[] = {
-  {"close", io_close},
-  {"flush", io_flush},
-  {"input", io_input},
-  {"lines", io_lines},
-  {"open", io_open},
-  {"output", io_output},
-  {"popen", io_popen},
-  {"read", io_read},
-  {"tmpfile", io_tmpfile},
-  {"type", io_type},
-  {"write", io_write},
-  /* done */
-  {NULL, NULL}
-};
-
-/*
-    Methods for file handles.
-*/
-
-static const luaL_Reg flib[] = {
-  {"close", io_close},
-  {"flush", f_flush},
-  {"lines", f_lines},
-  {"read", f_read},
-  {"seek", f_seek},
-  {"setvbuf", f_setvbuf},
-  {"write", f_write},
-  {"__gc", f_gc},
-  {"__tostring", f_tostring},
-  {NULL, NULL}
-};
-
-
-#ifndef LuajitTeX
-static void createmeta (lua_State *L) {
-  luaL_newmetatable(L, LUA_FILEHANDLE);  /* create metatable for file handles */
-  lua_pushvalue(L, -1);  /* push metatable */
-  lua_setfield(L, -2, "__index");  /* metatable.__index = metatable */
-  luaL_setfuncs(L, flib, 0);  /* add file methods to new metatable */
-  lua_pop(L, 1);  /* pop new metatable */
-}
-
-/*
-    a function to (not) close the standard files stdin, stdout, and stderr
-*/
-
-static int io_noclose (lua_State *L) {
-  LStream *p = tolstream(L);
-  p->closef = &io_noclose;  /* keep file opened */
-  lua_pushnil(L);
-  lua_pushliteral(L, "cannot close standard file");
-  return 2;
-}
-
-static void createstdfile (lua_State *L, FILE *f, const char *k,
-                           const char *fname) {
-  LStream *p = newprefile(L);
-  p->f = f;
-  p->closef = &io_noclose;
-  if (k != NULL) {
-    lua_pushvalue(L, -1);
-    lua_setfield(L, LUA_REGISTRYINDEX, k);  /* add file to registry */
-  }
-  lua_setfield(L, -2, fname);  /* add file to module */
-}
-#endif
-
 int open_iolibext (lua_State *L) {
     luaL_register(L, "fio", fiolib);
-#ifdef LuajitTeX
-  return luaopen_io(L);
-#else
-  luaL_newlib(L, iolib);  /* new module */
-  createmeta(L);
-  /* create (and set) default files */
-  createstdfile(L, stdin, IO_INPUT, "stdin");
-  createstdfile(L, stdout, IO_OUTPUT, "stdout");
-  createstdfile(L, stderr, NULL, "stderr");
-  return 1;
-#endif
+    return 1;
 }
diff --git a/source/texk/web2c/luatexdir/lua/loslibext.c b/source/texk/web2c/luatexdir/lua/loslibext.c
index 87665712a..309d636c4 100644
--- a/source/texk/web2c/luatexdir/lua/loslibext.c
+++ b/source/texk/web2c/luatexdir/lua/loslibext.c
@@ -1014,7 +1014,7 @@ static int os_execute(lua_State * L)
 }
 
 
-void open_oslibext(lua_State * L, int safer)
+void open_oslibext(lua_State * L)
 {
 
     find_env(L);
@@ -1037,17 +1037,16 @@ void open_oslibext(lua_State * L, int safer)
     lua_setfield(L, -2, "gettimeofday");
 #endif
 
-    if (!safer) {
-        lua_pushcfunction(L, os_setenv);
-        lua_setfield(L, -2, "setenv");
-        lua_pushcfunction(L, os_exec);
-        lua_setfield(L, -2, "exec");
-        lua_pushcfunction(L, os_spawn);
-        lua_setfield(L, -2, "spawn");
-        lua_pushcfunction(L, os_execute);
-        lua_setfield(L, -2, "execute");
-        lua_pushcfunction(L, os_tmpdir);
-        lua_setfield(L, -2, "tmpdir");
-    }
+    lua_pushcfunction(L, os_setenv);
+    lua_setfield(L, -2, "setenv");
+    lua_pushcfunction(L, os_exec);
+    lua_setfield(L, -2, "exec");
+    lua_pushcfunction(L, os_spawn);
+    lua_setfield(L, -2, "spawn");
+    lua_pushcfunction(L, os_execute);
+    lua_setfield(L, -2, "execute");
+    lua_pushcfunction(L, os_tmpdir);
+    lua_setfield(L, -2, "tmpdir");
+
     lua_pop(L, 1);              /* pop the table */
 }
diff --git a/source/texk/web2c/luatexdir/lua/lstatslib.c b/source/texk/web2c/luatexdir/lua/lstatslib.c
index 7d9435d64..82c549b44 100644
--- a/source/texk/web2c/luatexdir/lua/lstatslib.c
+++ b/source/texk/web2c/luatexdir/lua/lstatslib.c
@@ -239,6 +239,25 @@ static lua_Number shell_escape_state(void)
     }
 }
 
+static lua_Number safer_option_state(void)
+{
+    if (safer_option == 0) {
+        return (lua_Number) 0;
+    } else {
+        return (lua_Number) 1;
+    }
+}
+
+static lua_Number kpse_used_state(void)
+{
+    if (kpse_init == 1) {
+        return (lua_Number) 1;
+    } else {
+        return (lua_Number) 0;
+    }
+}
+
+
 /* temp, for backward compat */
 static int init_pool_ptr = 0;
 
@@ -270,14 +289,16 @@ static struct statistic stats[] = {
     {"log_name", 'S', (void *) &getlogname},
     {"banner", 'S', (void *) &getbanner},
     {"luatex_version", 'G', &get_luatexversion},
-    {"luatex_revision", 'S', (void *) &luatexrevision}, 
+    {"luatex_revision", 'S', (void *) &luatexrevision},
     {"luatex_hashtype", 'S', (void *) &get_luatexhashtype},
     {"luatex_hashchars", 'N',  &get_luatexhashchars},
     {"luatex_engine", 'S', (void *) &getenginename},
 
     {"ini_version", 'b', &ini_version},
 
-    {"shell_escape", 'N', &shell_escape_state}, /* be easy on old time usage */
+    {"shell_escape", 'N', &shell_escape_state},
+    {"safer_option", 'N', &safer_option_state},
+    {"kpse_used", 'N', &kpse_used_state},
     /*
      * mem stat
      */
@@ -331,7 +352,7 @@ static struct statistic stats[] = {
     {"lc_ctype", 'S', (void *) &get_lc_ctype},
     {"lc_collate", 'S', (void *) &get_lc_collate},
     {"lc_numeric",'S', (void *) &get_lc_numeric},
-    
+
     {NULL, 0, 0}
 };
 
diff --git a/source/texk/web2c/luatexdir/lua/luainit.w b/source/texk/web2c/luatexdir/lua/luainit.w
index 075143391..9256a495c 100644
--- a/source/texk/web2c/luatexdir/lua/luainit.w
+++ b/source/texk/web2c/luatexdir/lua/luainit.w
@@ -107,7 +107,7 @@ const_string LUATEX_IHELP[] = {
     NULL
 };
 
-@ Later we will put on environment |LC_CTYPE|, |LC_COLLATE| and 
+@ Later we will put on environment |LC_CTYPE|, |LC_COLLATE| and
 |LC_NUMERIC| set to |C|, so we need a place where to store the old values.
 @c
 const char *lc_ctype;
@@ -177,6 +177,285 @@ static void prepare_cmdline(lua_State * L, char **av, int ac, int zero_offset)
 }
 
 
+@ Embed |luatex_core.lua| as binary stream. We use the program
+|xxd|, and add |0x0| at the end. In this way we avoid the quoting
+of strings, given that in the Lua source we mix  double and single
+quotes.
+
+@c
+static int load_luatex_core_lua (lua_State * L) {
+ static 
+ unsigned char luatex_core_lua[] = {
+  0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c,
+  0x65, 0x73, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x6d, 0x6f, 0x64, 0x75,
+  0x6c, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x7b, 0x20, 0x7d, 0x20, 0x65, 0x6e,
+  0x64, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x20, 0x5b, 0x27,
+  0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x27,
+  0x5d, 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65,
+  0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x31, 0x2e,
+  0x30, 0x34, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d,
+  0x65, 0x6e, 0x74, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x22, 0x63, 0x6f, 0x6d,
+  0x70, 0x61, 0x6e, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x6c, 0x75,
+  0x61, 0x74, 0x65, 0x78, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61,
+  0x75, 0x74, 0x68, 0x6f, 0x72, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x22,
+  0x48, 0x61, 0x6e, 0x73, 0x20, 0x48, 0x61, 0x67, 0x65, 0x6e, 0x20, 0x26,
+  0x20, 0x4c, 0x75, 0x69, 0x67, 0x69, 0x20, 0x53, 0x63, 0x61, 0x72, 0x73,
+  0x6f, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x70, 0x79,
+  0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3d, 0x20, 0x22, 0x4c, 0x75, 0x61,
+  0x54, 0x65, 0x58, 0x20, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d,
+  0x65, 0x6e, 0x74, 0x20, 0x54, 0x65, 0x61, 0x6d, 0x22, 0x2c, 0x0a, 0x7d,
+  0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69,
+  0x6c, 0x65, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, 0x61, 0x64, 0x73,
+  0x20, 0x73, 0x6f, 0x6d, 0x65, 0x20, 0x4c, 0x75, 0x61, 0x20, 0x66, 0x75,
+  0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x20, 0x54, 0x68, 0x65,
+  0x20, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x76, 0x61,
+  0x72, 0x69, 0x61, 0x6e, 0x74, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69,
+  0x64, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x6d, 0x65, 0x0a,
+  0x2d, 0x2d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61,
+  0x6c, 0x69, 0x74, 0x79, 0x20, 0x61, 0x73, 0x20, 0x4c, 0x75, 0x61, 0x54,
+  0x65, 0x58, 0x20, 0x3c, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x34, 0x20, 0x61,
+  0x6e, 0x64, 0x20, 0x64, 0x6f, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x74, 0x20,
+  0x74, 0x68, 0x69, 0x73, 0x20, 0x77, 0x61, 0x79, 0x20, 0x70, 0x65, 0x72,
+  0x6d, 0x69, 0x74, 0x73, 0x20, 0x75, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x6b,
+  0x65, 0x65, 0x70, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 0x6f,
+  0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x20, 0x69, 0x6f, 0x20, 0x6c,
+  0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x20, 0x63, 0x6c, 0x65,
+  0x61, 0x6e, 0x2e, 0x20, 0x50, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x61,
+  0x6e, 0x63, 0x65, 0x20, 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x62, 0x61,
+  0x62, 0x6c, 0x79, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x20, 0x61, 0x20, 0x62,
+  0x69, 0x74, 0x20, 0x62, 0x65, 0x74, 0x74, 0x65, 0x72, 0x20, 0x6e, 0x6f,
+  0x77, 0x2e, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x74, 0x79,
+  0x70, 0x65, 0x2c, 0x20, 0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x67, 0x65,
+  0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2c, 0x20,
+  0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x20, 0x3d, 0x20, 0x74, 0x79,
+  0x70, 0x65, 0x2c, 0x20, 0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x67, 0x65,
+  0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2c, 0x20,
+  0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x0a, 0x6c, 0x6f, 0x63, 0x61,
+  0x6c, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x2c, 0x20, 0x67, 0x73, 0x75, 0x62,
+  0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x66, 0x69,
+  0x6e, 0x64, 0x2c, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x67,
+  0x73, 0x75, 0x62, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x69,
+  0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e,
+  0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x69,
+  0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e,
+  0x70, 0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+  0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e,
+  0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x66,
+  0x69, 0x6f, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x0a,
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x63, 0x68,
+  0x65, 0x63, 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
+  0x6e, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f, 0x2e, 0x63, 0x68, 0x65, 0x63,
+  0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x0a,
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65,
+  0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65,
+  0x20, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f, 0x2e, 0x72, 0x65, 0x63, 0x6f,
+  0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x0a, 0x0a,
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x74, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x3d, 0x20, 0x67, 0x65, 0x74, 0x6d, 0x65, 0x74, 0x61, 0x74,
+  0x61, 0x62, 0x6c, 0x65, 0x28, 0x69, 0x6f, 0x2e, 0x73, 0x74, 0x64, 0x65,
+  0x72, 0x72, 0x29, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73,
+  0x61, 0x66, 0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c,
+  0x73, 0x65, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x68, 0x65,
+  0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75,
+  0x73, 0x2e, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x65, 0x73, 0x63, 0x61,
+  0x70, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x30, 0x20,
+  0x31, 0x20, 0x32, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65,
+  0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74,
+  0x75, 0x73, 0x2e, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x72, 0x65, 0x73,
+  0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x20, 0x30,
+  0x20, 0x31, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6b, 0x70, 0x73,
+  0x65, 0x75, 0x73, 0x65, 0x64, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75,
+  0x73, 0x2e, 0x6b, 0x70, 0x73, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x30, 0x20,
+  0x31, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e,
+  0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78,
+  0x5f, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d,
+  0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
+  0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x74, 0x68,
+  0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68,
+  0x6f, 0x77, 0x20, 0x3d, 0x20, 0x22, 0x72, 0x22, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63,
+  0x61, 0x6c, 0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70,
+  0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68,
+  0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69,
+  0x66, 0x20, 0x74, 0x79, 0x70, 0x65, 0x28, 0x68, 0x6f, 0x77, 0x29, 0x20,
+  0x3d, 0x3d, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x20,
+  0x61, 0x6e, 0x64, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x28, 0x68, 0x6f, 0x77,
+  0x2c, 0x22, 0x77, 0x22, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66,
+  0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c,
+  0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x22,
+  0x77, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63,
+  0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28,
+  0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x22, 0x72, 0x22, 0x29, 0x0a, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20,
+  0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+  0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a,
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+  0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f,
+  0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6f, 0x6e,
+  0x6c, 0x79, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x68, 0x6f, 0x77, 0x20,
+  0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x22, 0x72, 0x22, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x67, 0x73,
+  0x75, 0x62, 0x28, 0x68, 0x6f, 0x77, 0x2c, 0x22, 0x5b, 0x5e, 0x72, 0x62,
+  0x5d, 0x22, 0x2c, 0x22, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x3d,
+  0x20, 0x22, 0x22, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x6f, 0x77,
+  0x20, 0x3d, 0x20, 0x22, 0x72, 0x22, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65,
+  0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+  0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e,
+  0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f,
+  0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e,
+  0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x22, 0x72, 0x22,
+  0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20,
+  0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x0a, 0x65,
+  0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75,
+  0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65,
+  0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e,
+  0x61, 0x6d, 0x65, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6f, 0x6b, 0x61, 0x79, 0x2c,
+  0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f,
+  0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73,
+  0x73, 0x69, 0x6f, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6f, 0x6b, 0x61, 0x79, 0x20, 0x61,
+  0x6e, 0x64, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x74, 0x68, 0x65,
+  0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+  0x74, 0x75, 0x72, 0x6e, 0x20, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65,
+  0x6e, 0x28, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x2c, 0x2e, 0x2e, 0x2e, 0x29,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64,
+  0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63,
+  0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f,
+  0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x28, 0x6e, 0x61, 0x6d,
+  0x65, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+  0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e,
+  0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x27, 0x72, 0x27, 0x29, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+  0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+  0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x69,
+  0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66,
+  0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e,
+  0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e,
+  0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e,
+  0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78,
+  0x5f, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65,
+  0x28, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+  0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+  0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+  0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61,
+  0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x6f,
+  0x2e, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73,
+  0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x0a,
+  0x6d, 0x74, 0x2e, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e,
+  0x65, 0x73, 0x20, 0x3d, 0x20, 0x6d, 0x74, 0x2e, 0x6c, 0x69, 0x6e, 0x65,
+  0x73, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20,
+  0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f,
+  0x6c, 0x69, 0x6e, 0x65, 0x73, 0x0a, 0x6d, 0x74, 0x2e, 0x6c, 0x69, 0x6e,
+  0x65, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f,
+  0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x0a,
+  0x0a, 0x69, 0x66, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x75, 0x73, 0x65, 0x64,
+  0x20, 0x3d, 0x3d, 0x20, 0x31, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x20,
+  0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f,
+  0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f,
+  0x2e, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61,
+  0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e,
+  0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x73, 0x61, 0x66,
+  0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65,
+  0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6f,
+  0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x20, 0x3d, 0x20,
+  0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x6f, 0x73, 0x2e, 0x73, 0x70, 0x61, 0x77, 0x6e, 0x20, 0x20, 0x20, 0x3d,
+  0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x20, 0x20, 0x20, 0x20,
+  0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20,
+  0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x20,
+  0x20, 0x20, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f,
+  0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64,
+  0x6f, 0x6e, 0x6c, 0x79, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x6f, 0x73, 0x2e, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x20,
+  0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65,
+  0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x74, 0x6d, 0x70, 0x66,
+  0x69, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x75, 0x74,
+  0x70, 0x75, 0x74, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73, 0x2e,
+  0x63, 0x68, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73,
+  0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69,
+  0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66,
+  0x73, 0x2e, 0x74, 0x6f, 0x75, 0x63, 0x68, 0x20, 0x20, 0x3d, 0x20, 0x6e,
+  0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
+  0x66, 0x73, 0x2e, 0x72, 0x6d, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d, 0x20,
+  0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x6c, 0x66, 0x73, 0x2e, 0x6d, 0x6b, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d,
+  0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e,
+  0x64, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x73, 0x61,
+  0x66, 0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x72,
+  0x20, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65,
+  0x20, 0x3d, 0x3d, 0x20, 0x30, 0x20, 0x6f, 0x72, 0x20, 0x28, 0x73, 0x68,
+  0x65, 0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x3d, 0x3d,
+  0x20, 0x31, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x73, 0x74, 0x72,
+  0x69, 0x63, 0x74, 0x65, 0x64, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x29, 0x20,
+  0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x66, 0x69, 0x20, 0x3d,
+  0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x28, 0x22, 0x66, 0x66,
+  0x69, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x66, 0x6f, 0x72, 0x20, 0x6b, 0x2c, 0x20, 0x76, 0x20, 0x69, 0x6e, 0x20,
+  0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x66, 0x66, 0x69, 0x20, 0x64, 0x6f,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x69, 0x66, 0x20, 0x6b, 0x20, 0x7e, 0x3d, 0x20, 0x27, 0x67, 0x63,
+  0x27, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66,
+  0x66, 0x69, 0x5b, 0x6b, 0x5d, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x66, 0x66, 0x69, 0x20, 0x3d, 0x20, 0x6e, 0x69,
+  0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e,
+  0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x74, 0x6f, 0x64, 0x6f, 0x3a, 0x20,
+  0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x74, 0x6f, 0x64, 0x6f, 0x3a, 0x20,
+  0x6f, 0x73, 0x2e, 0x73, 0x70, 0x61, 0x77, 0x6e, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x2d, 0x2d, 0x20, 0x74, 0x6f, 0x64, 0x6f, 0x3a, 0x20, 0x6f, 0x73,
+  0x2e, 0x65, 0x78, 0x65, 0x63, 0x0a, 0x0a, 0x65, 0x6c, 0x73, 0x65, 0x0a,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x57, 0x65, 0x20, 0x61,
+  0x73, 0x73, 0x75, 0x6d, 0x65, 0x20, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65,
+  0x6d, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, 0x20, 0x70,
+  0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74,
+  0x68, 0x65, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65,
+  0x6e, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x2e, 0x20,
+  0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x63, 0x61, 0x73, 0x65, 0x20,
+  0x69, 0x6e, 0x20, 0x43, 0x6f, 0x6e, 0x54, 0x65, 0x58, 0x74, 0x2e, 0x0a,
+  0x0a, 0x65, 0x6e, 0x64, 0x0a,
+0x0};
+  return luaL_dostring(L, (const char*)luatex_core_lua); 
+}
+
 @ @c
 int kpse_init = -1;
 
@@ -315,7 +594,7 @@ static void parse_options(int ac, char **av)
     if ((strstr(argv[0], "luajittexlua") != NULL) ||
         (strstr(argv[0], "texluajit") != NULL)) {
 #else
-    if ((strstr(argv[0], "luatexlua") != NULL) || 
+    if ((strstr(argv[0], "luatexlua") != NULL) ||
         (strstr(argv[0], "texlua") != NULL)) {
 #endif
         lua_only = 1;
@@ -925,7 +1204,7 @@ void lua_initialize(int ac, char **av)
     if (lua_only)
         shellenabledp = true;
 
-    /* Get the current locale (it should be C )          */   
+    /* Get the current locale (it should be C )          */
     /* and save LC_CTYPE, LC_COLLATE and LC_NUMERIC.     */
     /* Later luainterpreter() will consciously use them. */
     old_locale = setlocale (LC_ALL, NULL);
@@ -940,15 +1219,15 @@ void lua_initialize(int ac, char **av)
 	  fprintf(stderr,"Unable to read environment locale:exit now.\n");
 	  exit(1);
 	}
-        tmp = setlocale (LC_CTYPE, NULL);    
+        tmp = setlocale (LC_CTYPE, NULL);
 	if (tmp) {
 	  lc_ctype = xstrdup(tmp);
         }
-	tmp = setlocale (LC_COLLATE, NULL);    
+	tmp = setlocale (LC_COLLATE, NULL);
 	if (tmp){
 	  lc_collate = xstrdup(tmp);
         }
-	tmp = setlocale (LC_NUMERIC, NULL);    
+	tmp = setlocale (LC_NUMERIC, NULL);
 	if (tmp){
 	  lc_numeric = xstrdup(tmp);
         }
@@ -963,7 +1242,7 @@ void lua_initialize(int ac, char **av)
     } else {
        fprintf(stderr,"Unable to store environment locale.\n");
     }
-    
+
     /* make sure that the locale is 'sane' (for lua) */
     putenv(LC_CTYPE_C);
     putenv(LC_COLLATE_C);
@@ -1119,10 +1398,11 @@ void lua_initialize(int ac, char **av)
             fix_dumpname();
         }
     }
-    /* Maybe we can extend this way to the others tables, using luac. */
-    if ( safer_option || ((shellenabledp == 0) || (shellenabledp == 1 && restrictedshell == 1)) ) {
-       (void)   luaL_dostring(Luas,"ffi=require[[ffi]]; for k,_ in pairs(ffi) do if k~='gc' then ffi[k]=nil end; end; ffi=nil;");
-    }
+
+    /* Here we load luatex-core.lua which takes care of some protection on demand. */
+    if (load_luatex_core_lua (Luas))
+      fprintf(stderr, "Error in execution of luatex-core.lua .\n");
+    /* Done. */
 }
 
 @ @c
diff --git a/source/texk/web2c/luatexdir/lua/luajitstuff.w b/source/texk/web2c/luatexdir/lua/luajitstuff.w
index 3b5cc5eff..d8165b723 100644
--- a/source/texk/web2c/luatexdir/lua/luajitstuff.w
+++ b/source/texk/web2c/luatexdir/lua/luajitstuff.w
@@ -121,7 +121,8 @@ static const luaL_Reg lualibs[] = {
     {"package", luaopen_package},
     /*{"coroutine", luaopen_coroutine},*/
     {"table", luaopen_table},
-    {"io", open_iolibext},
+    {"io", luaopen_io},
+    {"fio", open_iolibext},
     {"os", luaopen_os},
     {"string", luaopen_string},
     {"math", luaopen_math},
@@ -250,20 +251,21 @@ void luainterpreter(void)
 
     luatex_md5_lua_open(L);
 
-    open_oslibext(L, safer_option);
-/*
-    open_iolibext(L);
-*/
+    open_oslibext(L);
+ /* open_iolibext(L); */
     open_strlibext(L);
     open_lfslibext(L);
 
-    /* luasockets */
-    /* socket and mime are a bit tricky to open because
-     they use a load-time  dependency that has to be
-     worked around for luatex, where the C module is
-     loaded way before the lua module.
-     */
+    /*
+        The socket and mime libraries are a bit tricky to open because they use a load-time
+        dependency that has to be worked around for luatex, where the C module is loaded
+        way before the lua module.
+    */
+
     if (!nosocket_option) {
+
+        /* todo: move this to common */
+
         lua_getglobal(L, "package");
         lua_getfield(L, -1, "loaded");
         if (!lua_istable(L, -1)) {
@@ -280,7 +282,7 @@ void luainterpreter(void)
         lua_setfield(L, -2, "mime.core");
         lua_pushnil(L);
         lua_setfield(L, -2, "mime");    /* package.loaded.mime = nil */
-        lua_pop(L, 2);          /* pop the tables */
+        lua_pop(L, 2);                  /* pop the tables */
 
         luatex_socketlua_open(L);       /* preload the pure lua modules */
     }
@@ -329,31 +331,7 @@ void luainterpreter(void)
 
     lua_createtable(L, 0, 0);
     lua_setglobal(L, "texconfig");
- 
-    /* LuaJITTeX is stricter with restrictedshell: if enabled it's like safer.   */
-    /* The rationale is that popen requires an important amount of internal code */
-    /* rewrite, which is not what we want now.                                   */
-    if (safer_option||(shellenabledp == 1 && restrictedshell == 1)) {
-        /* disable some stuff if --safer */
-        (void) hide_lua_value(L, "os", "execute");
-        (void) hide_lua_value(L, "os", "rename");
-        (void) hide_lua_value(L, "os", "remove");
-        (void) hide_lua_value(L, "io", "popen");
-        /* make io.open only read files */
-        luaL_checkstack(L, 2, "out of stack space");
-        lua_getglobal(L, "io");
-        lua_getfield(L, -1, "open_ro");
-        lua_setfield(L, -2, "open");
-        (void) hide_lua_value(L, "io", "tmpfile");
-        (void) hide_lua_value(L, "io", "output");
-        (void) hide_lua_value(L, "lfs", "chdir");
-        (void) hide_lua_value(L, "lfs", "lock");
-        (void) hide_lua_value(L, "lfs", "touch");
-        (void) hide_lua_value(L, "lfs", "rmdir");
-        (void) hide_lua_value(L, "lfs", "mkdir");
-    }
-    /* fprintf(stdout, "\nLuajitTeX default hash function type:%s\n", */
-    /* 		                                jithash_hashname); */
+
     Luas = L;
 }
 
diff --git a/source/texk/web2c/luatexdir/lua/luastuff.w b/source/texk/web2c/luatexdir/lua/luastuff.w
index 6dc70d54c..4ab388ad5 100644
--- a/source/texk/web2c/luatexdir/lua/luastuff.w
+++ b/source/texk/web2c/luatexdir/lua/luastuff.w
@@ -116,7 +116,8 @@ static const luaL_Reg lualibs[] = {
     {"package", luaopen_package},
     {"coroutine", luaopen_coroutine},
     {"table", luaopen_table},
-    {"io", open_iolibext},
+    {"io", luaopen_io},
+    {"fio",open_iolibext},
     {"os", luaopen_os},
     {"string", luaopen_string},
     {"math", luaopen_math},
@@ -214,21 +215,21 @@ void luainterpreter(void)
 
     luatex_md5_lua_open(L);
 
-    open_oslibext(L, safer_option);
-/*
-    open_iolibext(L);
-*/
+    open_oslibext(L);
+ /* open_iolibext(L); */
     open_strlibext(L);
     open_lfslibext(L);
 
+    /*
+        The socket and mime libraries are a bit tricky to open because they use a load-time
+        dependency that has to be worked around for luatex, where the C module is loaded
+        way before the lua module.
+    */
 
-    /* luasockets */
-    /* socket and mime are a bit tricky to open because
-     they use a load-time  dependency that has to be
-     worked around for luatex, where the C module is
-     loaded way before the lua module.
-     */
     if (!nosocket_option) {
+
+        /* todo: move this to common */
+
         lua_getglobal(L, "package");
         lua_getfield(L, -1, "loaded");
         if (!lua_istable(L, -1)) {
@@ -245,7 +246,7 @@ void luainterpreter(void)
         lua_setfield(L, -2, "mime.core");
         lua_pushnil(L);
         lua_setfield(L, -2, "mime");    /* package.loaded.mime = nil */
-        lua_pop(L, 2);          /* pop the tables */
+        lua_pop(L, 2);                  /* pop the tables */
 
         luatex_socketlua_open(L);       /* preload the pure lua modules */
     }
@@ -291,25 +292,6 @@ void luainterpreter(void)
     lua_createtable(L, 0, 0);
     lua_setglobal(L, "texconfig");
 
-    if (safer_option) {
-        /* disable some stuff if --safer */
-        (void) hide_lua_value(L, "os", "execute");
-        (void) hide_lua_value(L, "os", "rename");
-        (void) hide_lua_value(L, "os", "remove");
-        (void) hide_lua_value(L, "io", "popen");
-        /* make io.open only read files */
-        luaL_checkstack(L, 2, "out of stack space");
-        lua_getglobal(L, "io");
-        lua_getfield(L, -1, "open_ro");
-        lua_setfield(L, -2, "open");
-        (void) hide_lua_value(L, "io", "tmpfile");
-        (void) hide_lua_value(L, "io", "output");
-        (void) hide_lua_value(L, "lfs", "chdir");
-        (void) hide_lua_value(L, "lfs", "lock");
-        (void) hide_lua_value(L, "lfs", "touch");
-        (void) hide_lua_value(L, "lfs", "rmdir");
-        (void) hide_lua_value(L, "lfs", "mkdir");
-    }
     Luas = L;
 }
 
diff --git a/source/texk/web2c/luatexdir/lua/luatex-api.h b/source/texk/web2c/luatexdir/lua/luatex-api.h
index 87b4bf0f6..8981e164b 100644
--- a/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -106,7 +106,7 @@ extern int luaopen_epdf(lua_State * L);
 extern int luaopen_pdfscanner(lua_State * L);
 extern int luaopen_mplib(lua_State * L);
 
-extern void open_oslibext(lua_State * L, int safer_option);
+extern void open_oslibext(lua_State * L);
 extern int open_iolibext(lua_State * L);
 extern void open_strlibext(lua_State * L);
 extern void open_lfslibext(lua_State * L);
@@ -159,7 +159,7 @@ extern const char *lc_collate;
 extern const char *lc_numeric;
 
 
-  
+
 #ifdef LuajitTeX
 extern int luajiton;
 extern char *jithash_hashname ;
diff --git a/source/texk/web2c/luatexdir/lua/luatex-core.c b/source/texk/web2c/luatexdir/lua/luatex-core.c
new file mode 100644
index 000000000..a7786669b
--- /dev/null
+++ b/source/texk/web2c/luatexdir/lua/luatex-core.c
@@ -0,0 +1,269 @@
+unsigned char luatex_core_lua[] = {
+  0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c,
+  0x65, 0x73, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x6d, 0x6f, 0x64, 0x75,
+  0x6c, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x7b, 0x20, 0x7d, 0x20, 0x65, 0x6e,
+  0x64, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x20, 0x5b, 0x27,
+  0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x27,
+  0x5d, 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65,
+  0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x31, 0x2e,
+  0x30, 0x34, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d,
+  0x65, 0x6e, 0x74, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x22, 0x63, 0x6f, 0x6d,
+  0x70, 0x61, 0x6e, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x6c, 0x75,
+  0x61, 0x74, 0x65, 0x78, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61,
+  0x75, 0x74, 0x68, 0x6f, 0x72, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x22,
+  0x48, 0x61, 0x6e, 0x73, 0x20, 0x48, 0x61, 0x67, 0x65, 0x6e, 0x20, 0x26,
+  0x20, 0x4c, 0x75, 0x69, 0x67, 0x69, 0x20, 0x53, 0x63, 0x61, 0x72, 0x73,
+  0x6f, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x70, 0x79,
+  0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3d, 0x20, 0x22, 0x4c, 0x75, 0x61,
+  0x54, 0x65, 0x58, 0x20, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d,
+  0x65, 0x6e, 0x74, 0x20, 0x54, 0x65, 0x61, 0x6d, 0x22, 0x2c, 0x0a, 0x7d,
+  0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69,
+  0x6c, 0x65, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, 0x61, 0x64, 0x73,
+  0x20, 0x73, 0x6f, 0x6d, 0x65, 0x20, 0x4c, 0x75, 0x61, 0x20, 0x66, 0x75,
+  0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x20, 0x54, 0x68, 0x65,
+  0x20, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x76, 0x61,
+  0x72, 0x69, 0x61, 0x6e, 0x74, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69,
+  0x64, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x6d, 0x65, 0x0a,
+  0x2d, 0x2d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61,
+  0x6c, 0x69, 0x74, 0x79, 0x20, 0x61, 0x73, 0x20, 0x4c, 0x75, 0x61, 0x54,
+  0x65, 0x58, 0x20, 0x3c, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x34, 0x20, 0x61,
+  0x6e, 0x64, 0x20, 0x64, 0x6f, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x74, 0x20,
+  0x74, 0x68, 0x69, 0x73, 0x20, 0x77, 0x61, 0x79, 0x20, 0x70, 0x65, 0x72,
+  0x6d, 0x69, 0x74, 0x73, 0x20, 0x75, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x6b,
+  0x65, 0x65, 0x70, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 0x6f,
+  0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x20, 0x69, 0x6f, 0x20, 0x6c,
+  0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x20, 0x63, 0x6c, 0x65,
+  0x61, 0x6e, 0x2e, 0x20, 0x50, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x61,
+  0x6e, 0x63, 0x65, 0x20, 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x62, 0x61,
+  0x62, 0x6c, 0x79, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x20, 0x61, 0x20, 0x62,
+  0x69, 0x74, 0x20, 0x62, 0x65, 0x74, 0x74, 0x65, 0x72, 0x20, 0x6e, 0x6f,
+  0x77, 0x2e, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x74, 0x79,
+  0x70, 0x65, 0x2c, 0x20, 0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x67, 0x65,
+  0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2c, 0x20,
+  0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x20, 0x3d, 0x20, 0x74, 0x79,
+  0x70, 0x65, 0x2c, 0x20, 0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x67, 0x65,
+  0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2c, 0x20,
+  0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x0a, 0x6c, 0x6f, 0x63, 0x61,
+  0x6c, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x2c, 0x20, 0x67, 0x73, 0x75, 0x62,
+  0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x66, 0x69,
+  0x6e, 0x64, 0x2c, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x67,
+  0x73, 0x75, 0x62, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x69,
+  0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e,
+  0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x69,
+  0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e,
+  0x70, 0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+  0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e,
+  0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x66,
+  0x69, 0x6f, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x0a,
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x63, 0x68,
+  0x65, 0x63, 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
+  0x6e, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f, 0x2e, 0x63, 0x68, 0x65, 0x63,
+  0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x0a,
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65,
+  0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65,
+  0x20, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f, 0x2e, 0x72, 0x65, 0x63, 0x6f,
+  0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x0a, 0x0a,
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x74, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x3d, 0x20, 0x67, 0x65, 0x74, 0x6d, 0x65, 0x74, 0x61, 0x74,
+  0x61, 0x62, 0x6c, 0x65, 0x28, 0x69, 0x6f, 0x2e, 0x73, 0x74, 0x64, 0x65,
+  0x72, 0x72, 0x29, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73,
+  0x61, 0x66, 0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c,
+  0x73, 0x65, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x68, 0x65,
+  0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75,
+  0x73, 0x2e, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x65, 0x73, 0x63, 0x61,
+  0x70, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x30, 0x20,
+  0x31, 0x20, 0x32, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65,
+  0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74,
+  0x75, 0x73, 0x2e, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x72, 0x65, 0x73,
+  0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x20, 0x2d, 0x2d, 0x20, 0x30,
+  0x20, 0x31, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6b, 0x70, 0x73,
+  0x65, 0x75, 0x73, 0x65, 0x64, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75,
+  0x73, 0x2e, 0x6b, 0x70, 0x73, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x30, 0x20,
+  0x31, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e,
+  0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78,
+  0x5f, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d,
+  0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
+  0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x74, 0x68,
+  0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68,
+  0x6f, 0x77, 0x20, 0x3d, 0x20, 0x22, 0x72, 0x22, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63,
+  0x61, 0x6c, 0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70,
+  0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68,
+  0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69,
+  0x66, 0x20, 0x74, 0x79, 0x70, 0x65, 0x28, 0x68, 0x6f, 0x77, 0x29, 0x20,
+  0x3d, 0x3d, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x20,
+  0x61, 0x6e, 0x64, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x28, 0x68, 0x6f, 0x77,
+  0x2c, 0x22, 0x77, 0x22, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66,
+  0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c,
+  0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x22,
+  0x77, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63,
+  0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28,
+  0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x22, 0x72, 0x22, 0x29, 0x0a, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20,
+  0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+  0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a,
+  0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+  0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f,
+  0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6f, 0x6e,
+  0x6c, 0x79, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x68, 0x6f, 0x77, 0x20,
+  0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x22, 0x72, 0x22, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x67, 0x73,
+  0x75, 0x62, 0x28, 0x68, 0x6f, 0x77, 0x2c, 0x22, 0x5b, 0x5e, 0x72, 0x62,
+  0x5d, 0x22, 0x2c, 0x22, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x3d,
+  0x20, 0x22, 0x22, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x6f, 0x77,
+  0x20, 0x3d, 0x20, 0x22, 0x72, 0x22, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65,
+  0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+  0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e,
+  0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f,
+  0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e,
+  0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x22, 0x72, 0x22,
+  0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20,
+  0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x0a, 0x65,
+  0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75,
+  0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65,
+  0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e,
+  0x61, 0x6d, 0x65, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6f, 0x6b, 0x61, 0x79, 0x2c,
+  0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f,
+  0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73,
+  0x73, 0x69, 0x6f, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6f, 0x6b, 0x61, 0x79, 0x20, 0x61,
+  0x6e, 0x64, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x74, 0x68, 0x65,
+  0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+  0x74, 0x75, 0x72, 0x6e, 0x20, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65,
+  0x6e, 0x28, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x2c, 0x2e, 0x2e, 0x2e, 0x29,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64,
+  0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63,
+  0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f,
+  0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x28, 0x6e, 0x61, 0x6d,
+  0x65, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+  0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e,
+  0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x27, 0x72, 0x27, 0x29, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+  0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+  0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x69,
+  0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66,
+  0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e,
+  0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e,
+  0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e,
+  0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78,
+  0x5f, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65,
+  0x28, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+  0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28,
+  0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+  0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61,
+  0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x6f,
+  0x2e, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73,
+  0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x0a,
+  0x6d, 0x74, 0x2e, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e,
+  0x65, 0x73, 0x20, 0x3d, 0x20, 0x6d, 0x74, 0x2e, 0x6c, 0x69, 0x6e, 0x65,
+  0x73, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20,
+  0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f,
+  0x6c, 0x69, 0x6e, 0x65, 0x73, 0x0a, 0x6d, 0x74, 0x2e, 0x6c, 0x69, 0x6e,
+  0x65, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f,
+  0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x0a,
+  0x0a, 0x69, 0x66, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x75, 0x73, 0x65, 0x64,
+  0x20, 0x3d, 0x3d, 0x20, 0x31, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x20,
+  0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f,
+  0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f,
+  0x2e, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61,
+  0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e,
+  0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x73, 0x61, 0x66,
+  0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65,
+  0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6f,
+  0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x20, 0x3d, 0x20,
+  0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x6f, 0x73, 0x2e, 0x73, 0x70, 0x61, 0x77, 0x6e, 0x20, 0x20, 0x20, 0x3d,
+  0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x20, 0x20, 0x20, 0x20,
+  0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20,
+  0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x20,
+  0x20, 0x20, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f,
+  0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64,
+  0x6f, 0x6e, 0x6c, 0x79, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x6f, 0x73, 0x2e, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x20,
+  0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65,
+  0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x74, 0x6d, 0x70, 0x66,
+  0x69, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x75, 0x74,
+  0x70, 0x75, 0x74, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73, 0x2e,
+  0x63, 0x68, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73,
+  0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69,
+  0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66,
+  0x73, 0x2e, 0x74, 0x6f, 0x75, 0x63, 0x68, 0x20, 0x20, 0x3d, 0x20, 0x6e,
+  0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
+  0x66, 0x73, 0x2e, 0x72, 0x6d, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d, 0x20,
+  0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x6c, 0x66, 0x73, 0x2e, 0x6d, 0x6b, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d,
+  0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e,
+  0x64, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x73, 0x61,
+  0x66, 0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x72,
+  0x20, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65,
+  0x20, 0x3d, 0x3d, 0x20, 0x30, 0x20, 0x6f, 0x72, 0x20, 0x28, 0x73, 0x68,
+  0x65, 0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x3d, 0x3d,
+  0x20, 0x31, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x73, 0x74, 0x72,
+  0x69, 0x63, 0x74, 0x65, 0x64, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x29, 0x20,
+  0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x66, 0x69, 0x20, 0x3d,
+  0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x28, 0x22, 0x66, 0x66,
+  0x69, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x66, 0x6f, 0x72, 0x20, 0x6b, 0x2c, 0x20, 0x76, 0x20, 0x69, 0x6e, 0x20,
+  0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x66, 0x66, 0x69, 0x20, 0x64, 0x6f,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x69, 0x66, 0x20, 0x6b, 0x20, 0x7e, 0x3d, 0x20, 0x27, 0x67, 0x63,
+  0x27, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66,
+  0x66, 0x69, 0x5b, 0x6b, 0x5d, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+  0x20, 0x20, 0x20, 0x20, 0x66, 0x66, 0x69, 0x20, 0x3d, 0x20, 0x6e, 0x69,
+  0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e,
+  0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x74, 0x6f, 0x64, 0x6f, 0x3a, 0x20,
+  0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x0a, 0x20,
+  0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x74, 0x6f, 0x64, 0x6f, 0x3a, 0x20,
+  0x6f, 0x73, 0x2e, 0x73, 0x70, 0x61, 0x77, 0x6e, 0x0a, 0x20, 0x20, 0x20,
+  0x20, 0x2d, 0x2d, 0x20, 0x74, 0x6f, 0x64, 0x6f, 0x3a, 0x20, 0x6f, 0x73,
+  0x2e, 0x65, 0x78, 0x65, 0x63, 0x0a, 0x0a, 0x65, 0x6c, 0x73, 0x65, 0x0a,
+  0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x57, 0x65, 0x20, 0x61,
+  0x73, 0x73, 0x75, 0x6d, 0x65, 0x20, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65,
+  0x6d, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, 0x20, 0x70,
+  0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74,
+  0x68, 0x65, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65,
+  0x6e, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x2e, 0x20,
+  0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x0a,
+  0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x63, 0x61, 0x73, 0x65, 0x20,
+  0x69, 0x6e, 0x20, 0x43, 0x6f, 0x6e, 0x54, 0x65, 0x58, 0x74, 0x2e, 0x0a,
+  0x0a, 0x65, 0x6e, 0x64, 0x0a,
+0x00 };
+unsigned int luatex_core_lua_len = 3185+1;
diff --git a/source/texk/web2c/luatexdir/lua/luatex-core.lua b/source/texk/web2c/luatexdir/lua/luatex-core.lua
new file mode 100644
index 000000000..9859d30f7
--- /dev/null
+++ b/source/texk/web2c/luatexdir/lua/luatex-core.lua
@@ -0,0 +1,135 @@
+if not modules then modules = { } end modules ['luatex-core'] = {
+    version   = 1.04,
+    comment   = "companion to luatex",
+    author    = "Hans Hagen & Luigi Scarso",
+    copyright = "LuaTeX Development Team",
+}
+
+-- This file overloads some Lua functions. The readline variants provide the same
+-- functionality as LuaTeX <= 1.04 and doing it this way permits us to keep the
+-- original io libraries clean. Performance is probably even a bit better now.
+
+local type, next, getmetatable, require = type, next, getmetatable, require
+local find, gsub = string.find, string.gsub
+
+local io_open             = io.open
+local io_popen            = io.popen
+
+local fio_readline        = fio.readline
+local fio_checkpermission = fio.checkpermission
+local fio_recordfilename  = fio.recordfilename
+
+local mt                  = getmetatable(io.stderr)
+
+local saferoption         = false
+local shellescape         = status.shell_escape     -- 0 1 2
+local restricted          = status.shell_restricted -- 0 1
+local kpseused            = status.kpse_used        -- 0 1
+
+local function luatex_io_open(name,how)
+    if not how then
+        how = "r"
+    end
+    local f = io_open(name,how)
+    if f then
+        if type(how) == "string" and find(how,"w") then
+            fio_recordfilename(name,"w")
+        else
+            fio_recordfilename(name,"r")
+        end
+    end
+    return f
+end
+
+local function luatex_io_open_readonly(name,how)
+    if how then
+        how = "r"
+    else
+        how = gsub(how,"[^rb]","")
+        if how == "" then
+            how = "r"
+        end
+    end
+    local f = io_open(name,how)
+    if f then
+        fio_recordfilename(name,"r")
+    end
+    return f
+end
+
+local function luatex_io_popen(name,...)
+    local okay, found = fio_checkpermission(name)
+    if okay and found then
+        return io_popen(found,...)
+    end
+end
+
+local function luatex_io_lines(name)
+    local f = io_open(name,'r')
+    if f then
+        return function()
+            return fio_readline(f)
+        end
+    end
+end
+
+local function luatex_io_readline(f)
+    return function()
+        return fio_readline(f)
+    end
+end
+
+io.saved_lines = io.lines
+mt.saved_lines = mt.lines
+
+io.lines = luatex_io_lines
+mt.lines = luatex_io_readline
+
+if kpseused == 1 then
+
+    io.open  = luatex_io_open
+    io.popen = luatex_io_popen
+
+    if saferoption then
+
+        os.execute = nil
+        os.spawn   = nil
+        os.exec    = nil
+
+        io.popen   = nil
+        io.open    = luatex_io_open_readonly
+
+        os.rename  = nil
+        os.remove  = nil
+
+        io.tmpfile = nil
+        io.output  = nil
+
+        lfs.chdir  = nil
+        lfs.lock   = nil
+        lfs.touch  = nil
+        lfs.rmdir  = nil
+        lfs.mkdir  = nil
+
+    end
+
+    if saferoption or shellescape == 0 or (shellescape == 1 and restricted == 1) then
+        local ffi = require("ffi")
+        for k, v in next, ffi do
+            if k ~= 'gc' then
+                ffi[k] = nil
+            end
+            ffi = nil
+        end
+    end
+
+    -- todo: os.execute
+    -- todo: os.spawn
+    -- todo: os.exec
+
+else
+
+    -- We assume management to be provided by the replacement of kpse. This is the
+    -- case in ConTeXt.
+
+end
-- 
GitLab