external/lua: update to Lua 5.4.7

Update the version of Lua included with Callisto to Lua 5.4.7.
Re-generate patches to apply cleanly on top of Lua 5.4.7 sources.

Fixes: https://todo.sr.ht/~jeremy/callisto/8
This commit is contained in:
Jeremy Baxter 2024-07-01 08:51:36 +12:00
parent 045cb437ba
commit cdae936548
33 changed files with 371 additions and 266 deletions

View file

@ -0,0 +1,59 @@
--- loslib.c
+++ loslib.c
@@ -4,6 +4,12 @@
** See Copyright Notice in lua.h
*/
+/***
+ * Operating system related facilities.
+ *
+ * @module os
+ */
+
#define loslib_c
#define LUA_LIB
@@ -14,6 +20,7 @@
#include <locale.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <time.h>
#include "lua.h"
@@ -403,6 +410,27 @@
return 0;
}
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 256 /* according to POSIX */
+#endif
+
+/***
+ * Returns the system hostname.
+ *
+ * @function hostname
+ * @usage local hostname = os.hostname()
+ */
+static int
+os_hostname(lua_State *L)
+{
+ char buffer[HOST_NAME_MAX];
+
+ gethostname(buffer, HOST_NAME_MAX); /* get hostname */
+ lua_pushstring(L, buffer);
+
+ return 1;
+}
+
static const luaL_Reg syslib[] = {
{"clock", os_clock},
@@ -411,6 +439,7 @@
{"execute", os_execute},
{"exit", os_exit},
{"getenv", os_getenv},
+ {"hostname", os_hostname},
{"remove", os_remove},
{"rename", os_rename},
{"setlocale", os_setlocale},