add Lua 5.4.6 patches
This commit is contained in:
parent
787820e82f
commit
55b40a17cd
6 changed files with 188 additions and 3 deletions
58
external/lua/patches/lua-5.4.6-oslib-hostname.diff
vendored
Normal file
58
external/lua/patches/lua-5.4.6-oslib-hostname.diff
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
--- 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"
|
||||
@@ -401,7 +408,26 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#define HOST_NAME_MAX 256 /* according to POSIX */
|
||||
|
||||
+/***
|
||||
+ * 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},
|
||||
{"date", os_date},
|
||||
@@ -409,6 +435,7 @@
|
||||
{"execute", os_execute},
|
||||
{"exit", os_exit},
|
||||
{"getenv", os_getenv},
|
||||
+ {"hostname", os_hostname},
|
||||
{"remove", os_remove},
|
||||
{"rename", os_rename},
|
||||
{"setlocale", os_setlocale},
|
Loading…
Add table
Add a link
Reference in a new issue