Skip to content

Commit

Permalink
propagate luatex 1.17.0 to branch
Browse files Browse the repository at this point in the history
git-svn-id: svn://tug.org/texlive/branches/branch2023/Build/source@66984 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
kberry committed May 2, 2023
1 parent 8fe6e9d commit 871c7a2
Show file tree
Hide file tree
Showing 16 changed files with 939 additions and 637 deletions.
36 changes: 35 additions & 1 deletion texk/web2c/luatexdir/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
2023-04-29 Luigi Scarso <luigi.scarso@gmail.com>
* LuaTeX 1.17.0

2023-04-28 Luigi Scarso <luigi.scarso@gmail.com>
* new option --no-socket, same as --nosocket

2023-04-27 Luigi Scarso <luigi.scarso@gmail.com>
* new option --socket to split socket and shell escape;
* the mime library is always available (Max Chernoff);
* Fixed ChangeLog

2023-04-25 Luigi Scarso <luigi.scarso@gmail.com>
* socket library by default not enabled;
it is enabled with --shell-escape but not with --shell-restricted.
The option ---nosocket remains unchanged.
The two new functions os.socketgettime and os.socketsleep are
like socket.gettime and socket.sleep, but they are always available.
* Luatex 1.17.0

2023-04-24 Luigi Scarso <luigi.scarso@gmail.com>
* static kpse.check_permissions in os.kpsepopen
* Fixed date in ChangeLog

2023-04-23 Luigi Scarso <luigi.scarso@gmail.com>
* new os.kpsepopen -- replace io.popen if kpse is active.
* Luatex 1.16.2

2023-04-18 Luigi Scarso <luigi.scarso@gmail.com>
* lua.setluaname(n, s) and lua.getluaname(n):
fixed mismatch between documentation and implementation (J. Friedrich).

2023-03-30 Luigi Scarso <luigi.scarso@gmail.com>
* bugfix for setpdforigin() (A. Matthias)

2023-02-22 Luigi Scarso <luigi.scarso@gmail.com>
* fix latelua data reference (side effect of deferred late additions) (H.Hagen)
* fix latelua data reference (side effect of deferred late additions) (H.Hagen)

2023-02-18 Luigi Scarso <luigi.scarso@gmail.com>
* Fixed the "Invalid unicode ranges in CMap beginbfrange operator bug" as in pdfTeX (Hàn Thế Thành)
Expand Down
27 changes: 27 additions & 0 deletions texk/web2c/luatexdir/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
==============================================================
LuaTeX 1.17.0 2023-04-29
==============================================================

- A breaking backward compatibility change: by default the socket
library is not enabled.
The new option --socket enable the socket library as
before, as also --shell-escape (without --shell-restricted);
--nosocket, --no-socket , --safer disabled the library, and
they have the priority in case of conflicting options.

socket.sleep and socket.gettime are duplicated as os.socketsleep and
os.socketgettime, both always available.

The new function os.kpsepopen replaces io.popen in kpse mode
(i.e. when kpse_init is not zero) as it was before,
but the permission can no longer be changed with
kpse.check_permission.
The function os.kpsepopen follows the same restrictions
as io.popen.

The mime library is always available.

Thanks to Max Chernoff for debugging.



==============================================================
LuaTeX 1.16.0 2023-02-19
==============================================================
Expand Down
3 changes: 1 addition & 2 deletions texk/web2c/luatexdir/font/writettf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ static void do_writeotf(PDF pdf, fd_entry * fd)
if (tracefilenames)
tex_printf("<<%s", cur_file_name);
ttf_read_tabdir();
/*tex Read teh font parameters. */
/*tex Read the font parameters. */
if (ttf_name_lookup("head", false) != NULL)
ttf_read_head();
if (ttf_name_lookup("hhea", false) != NULL)
Expand Down Expand Up @@ -1570,4 +1570,3 @@ void writeotf(PDF pdf, fd_entry * fd)
xfree(ttf_buffer);
cur_file_name = NULL;
}

10 changes: 5 additions & 5 deletions texk/web2c/luatexdir/lua/llualib.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,17 @@ static int set_luaname(lua_State * L)
{
int k;
const char *s;
if (lua_gettop(L) == 3) {
k = (int) luaL_checkinteger(L, 2);
if (lua_gettop(L) == 2) {
k = (int) luaL_checkinteger(L, 1);
if (k > 65535 || k < 0) {
/* error */
} else {
if (luanames[k] != NULL) {
free(luanames[k]);
luanames[k] = NULL;
}
if (lua_type(L,3) == LUA_TSTRING) {
s = lua_tostring(L, 3);
if (lua_type(L, 2) == LUA_TSTRING) {
s = lua_tostring(L, 2);
if (s != NULL)
luanames[k] = xstrdup(s);
}
Expand All @@ -340,7 +340,7 @@ static int set_luaname(lua_State * L)

static int get_luaname(lua_State * L)
{
int k = (int) luaL_checkinteger(L, 2);
int k = (int) luaL_checkinteger(L, 1);
if (k > 65535 || k < 0) {
/* error */
lua_pushnil(L);
Expand Down
171 changes: 171 additions & 0 deletions texk/web2c/luatexdir/lua/loslibext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,167 @@ static int os_execute(lua_State * L)
}


/*
** ======================================================
** l_kpse_popen spawns a new process connected to the current
** one through the file streams with some checks by kpse.
** Almost verbatim from Lua liolib.c .
** =======================================================
*/
#if !defined(l_kpse_popen) /* { */

#if defined(LUA_USE_POSIX) /* { */

#define l_kpse_popen(L,c,m) (fflush(NULL), popen(c,m))
#define l_kpse_pclose(L,file) (pclose(file))

#elif defined(LUA_USE_WINDOWS) /* }{ */

#define l_kpse_popen(L,c,m) (_popen(c,m))
#define l_kpse_pclose(L,file) (_pclose(file))

#else /* }{ */

/* ISO C definitions */
#define l_kpse_popen(L,c,m) \
((void)((void)c, m), \
luaL_error(L, "'popen' not supported"), \
(FILE*)0)
#define l_kpse_pclose(L,file) ((void)L, (void)file, -1)

#endif /* } */

#endif /* } */
typedef luaL_Stream LStream;
#define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
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 io_kpse_pclose (lua_State *L) {
LStream *p = tolstream(L);
return luaL_execresult(L, l_kpse_pclose(L, p->f));
}
static int io_kpse_check_permissions(lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
if (filename == NULL) {
lua_pushboolean(L,0);
lua_pushliteral(L,"no command name given");
} else if (shellenabledp <= 0) {
lua_pushboolean(L,0);
lua_pushliteral(L,"all command execution is disabled");
} else if (restrictedshell == 0) {
lua_pushboolean(L,1);
lua_pushstring(L,filename);
} else {
char *safecmd = NULL;
char *cmdname = NULL;
switch (shell_cmd_is_allowed(filename, &safecmd, &cmdname)) {
case 0:
lua_pushboolean(L,0);
lua_pushliteral(L, "specific command execution disabled");
break;
case 1:
/* doesn't happen */
lua_pushboolean(L,1);
lua_pushstring(L,filename);
break;
case 2:
lua_pushboolean(L,1);
lua_pushstring(L,safecmd);
break;
default:
/* -1 */
lua_pushboolean(L,0);
lua_pushliteral(L, "bad command line quoting");
break;
}
}
return 2;
}
static int io_kpse_popen (lua_State *L) {
const char *filename = NULL;
const char *mode = NULL;
LStream *p = NULL;
int okay;
filename = luaL_checkstring(L, 1);
mode = luaL_optstring(L, 2, "r");
lua_pushstring(L,filename);
io_kpse_check_permissions(L);
filename = luaL_checkstring(L, -1);
okay = lua_toboolean(L,-2);
if (okay && filename) {
p = newprefile(L);
luaL_argcheck(L, ((mode[0] == 'r' || mode[0] == 'w') && mode[1] == '\0'),
2, "invalid mode");
p->f = l_kpse_popen(L, filename, mode);
p->closef = &io_kpse_pclose;
return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1;
} else {
lua_pushnil(L);
lua_pushvalue(L,-2);
return 2;
}
}



/* socket.sleep and socket.gettime */
/* are duplicated here, and they are */
/* always available (the socket library */
/* can be nil in some setups) */
#ifdef _WIN32
static int socket_timeout_lua_sleep(lua_State *L)
{
double n = luaL_checknumber(L, 1);
if (n < 0.0) n = 0.0;
if (n < DBL_MAX/1000.0) n *= 1000.0;
if (n > INT_MAX) n = INT_MAX;
Sleep((int)n);
return 0;
}
static double socket_timeout_gettime(void) {
FILETIME ft;
double t;
GetSystemTimeAsFileTime(&ft);
/* Windows file time (time since January 1, 1601 (UTC)) */
t = ft.dwLowDateTime/1.0e7 + ft.dwHighDateTime*(4294967296.0/1.0e7);
/* convert to Unix Epoch time (time since January 1, 1970 (UTC)) */
return (t - 11644473600.0);
}
#else
static int socket_timeout_lua_sleep(lua_State *L)
{
double n = luaL_checknumber(L, 1);
struct timespec t, r;
if (n < 0.0) n = 0.0;
if (n > INT_MAX) n = INT_MAX;
t.tv_sec = (int) n;
n -= t.tv_sec;
t.tv_nsec = (int) (n * 1000000000);
if (t.tv_nsec >= 1000000000) t.tv_nsec = 999999999;
while (nanosleep(&t, &r) != 0) {
t.tv_sec = r.tv_sec;
t.tv_nsec = r.tv_nsec;
}
return 0;
}
static double socket_timeout_gettime(void) {
struct timeval v;
gettimeofday(&v, (struct timezone *) NULL);
/* Unix Epoch time (time since January 1, 1970 (UTC)) */
return v.tv_sec + v.tv_usec/1.0e6;
}
#endif
static int socket_timeout_lua_gettime(lua_State *L)
{
lua_pushnumber(L, socket_timeout_gettime());
return 1;
}


void open_oslibext(lua_State * L)
{

Expand Down Expand Up @@ -1081,5 +1242,15 @@ void open_oslibext(lua_State * L)
lua_pushcfunction(L, os_tmpdir);
lua_setfield(L, -2, "tmpdir");

lua_pushcfunction(L, io_kpse_popen);
lua_setfield(L, -2, "kpsepopen");

lua_pushcfunction(L, socket_timeout_lua_sleep);
lua_setfield(L, -2, "socketsleep");

lua_pushcfunction(L, socket_timeout_lua_gettime);
lua_setfield(L, -2, "socketgettime");


lua_pop(L, 1); /* pop the table */
}
2 changes: 1 addition & 1 deletion texk/web2c/luatexdir/lua/lpdflib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ static int setpdforigin(lua_State * L)
if (lua_type(L, 1) == LUA_TNUMBER) {
h = (int) lua_roundnumber(L, 1);
if (lua_type(L, 2) == LUA_TNUMBER) {
v = (int) lua_roundnumber(L, 1);
v = (int) lua_roundnumber(L, 2);
} else {
v = h;
}
Expand Down
Loading

0 comments on commit 871c7a2

Please sign in to comment.