add Lua 5.4.6 patches
This commit is contained in:
		
							parent
							
								
									787820e82f
								
							
						
					
					
						commit
						55b40a17cd
					
				
					 6 changed files with 188 additions and 3 deletions
				
			
		
							
								
								
									
										6
									
								
								external/lua/Makefile
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								external/lua/Makefile
									
										
									
									
										vendored
									
									
								
							|  | @ -6,12 +6,12 @@ | ||||||
| # Your platform. See PLATS for possible values.
 | # Your platform. See PLATS for possible values.
 | ||||||
| PLAT= guess | PLAT= guess | ||||||
| 
 | 
 | ||||||
| CC= gcc -std=gnu99 | CC= cc -std=c99 | ||||||
| CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_3 $(SYSCFLAGS) $(MYCFLAGS) | CFLAGS= -O2 $(SYSCFLAGS) $(MYCFLAGS) | ||||||
| LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) | LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) | ||||||
| LIBS= -lm $(SYSLIBS) $(MYLIBS) | LIBS= -lm $(SYSLIBS) $(MYLIBS) | ||||||
| 
 | 
 | ||||||
| AR= ar rcu | AR= ar cr | ||||||
| RANLIB= ranlib | RANLIB= ranlib | ||||||
| RM= rm -f | RM= rm -f | ||||||
| UNAME= uname | UNAME= uname | ||||||
|  |  | ||||||
							
								
								
									
										25
									
								
								external/lua/liolib.c
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								external/lua/liolib.c
									
										
									
									
										vendored
									
									
								
							|  | @ -4,6 +4,12 @@ | ||||||
| ** See Copyright Notice in lua.h | ** See Copyright Notice in lua.h | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
|  | /***
 | ||||||
|  |  * Input and output facilities. | ||||||
|  |  * | ||||||
|  |  * @module io | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
| #define liolib_c | #define liolib_c | ||||||
| #define LUA_LIB | #define LUA_LIB | ||||||
| 
 | 
 | ||||||
|  | @ -16,6 +22,7 @@ | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
| #include "lua.h" | #include "lua.h" | ||||||
| 
 | 
 | ||||||
|  | @ -723,6 +730,23 @@ static int f_setvbuf (lua_State *L) { | ||||||
|   return luaL_fileresult(L, res == 0, NULL); |   return luaL_fileresult(L, res == 0, NULL); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /***
 | ||||||
|  |  * Returns whether the stream points to a valid TTY device. | ||||||
|  |  * | ||||||
|  |  * @function file:istty | ||||||
|  |  * @usage | ||||||
|  | local f = io.open("/etc/fstab", 'r'); | ||||||
|  | -- a regular file will never be a TTY device | ||||||
|  | assert(not f:istty()) | ||||||
|  | -- stdin, stdout and stderr can often be TTYs | ||||||
|  | print(io.stdout:istty()) | ||||||
|  |  */ | ||||||
|  | static int f_istty (lua_State *L) { | ||||||
|  |   int fd = fileno(tofile(L)); | ||||||
|  |   lua_pushboolean(L, isatty(fd)); | ||||||
|  |   return 1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| static int io_flush (lua_State *L) { | static int io_flush (lua_State *L) { | ||||||
|  | @ -765,6 +789,7 @@ static const luaL_Reg meth[] = { | ||||||
|   {"seek", f_seek}, |   {"seek", f_seek}, | ||||||
|   {"close", f_close}, |   {"close", f_close}, | ||||||
|   {"setvbuf", f_setvbuf}, |   {"setvbuf", f_setvbuf}, | ||||||
|  |   {"istty", f_istty}, | ||||||
|   {NULL, NULL} |   {NULL, NULL} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										27
									
								
								external/lua/loslib.c
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								external/lua/loslib.c
									
										
									
									
										vendored
									
									
								
							|  | @ -4,6 +4,12 @@ | ||||||
| ** See Copyright Notice in lua.h | ** See Copyright Notice in lua.h | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
|  | /***
 | ||||||
|  |  * Operating system related facilities. | ||||||
|  |  * | ||||||
|  |  * @module os | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
| #define loslib_c | #define loslib_c | ||||||
| #define LUA_LIB | #define LUA_LIB | ||||||
| 
 | 
 | ||||||
|  | @ -14,6 +20,7 @@ | ||||||
| #include <locale.h> | #include <locale.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  | #include <unistd.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| 
 | 
 | ||||||
| #include "lua.h" | #include "lua.h" | ||||||
|  | @ -401,6 +408,25 @@ static int os_exit (lua_State *L) { | ||||||
|   return 0; |   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[] = { | static const luaL_Reg syslib[] = { | ||||||
|   {"clock",     os_clock}, |   {"clock",     os_clock}, | ||||||
|  | @ -409,6 +435,7 @@ static const luaL_Reg syslib[] = { | ||||||
|   {"execute",   os_execute}, |   {"execute",   os_execute}, | ||||||
|   {"exit",      os_exit}, |   {"exit",      os_exit}, | ||||||
|   {"getenv",    os_getenv}, |   {"getenv",    os_getenv}, | ||||||
|  |   {"hostname",  os_hostname}, | ||||||
|   {"remove",    os_remove}, |   {"remove",    os_remove}, | ||||||
|   {"rename",    os_rename}, |   {"rename",    os_rename}, | ||||||
|   {"setlocale", os_setlocale}, |   {"setlocale", os_setlocale}, | ||||||
|  |  | ||||||
							
								
								
									
										57
									
								
								external/lua/patches/lua-5.4.6-iolib-istty.diff
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								external/lua/patches/lua-5.4.6-iolib-istty.diff
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,57 @@ | ||||||
|  | --- liolib.c
 | ||||||
|  | +++ liolib.c
 | ||||||
|  | @@ -4,6 +4,12 @@
 | ||||||
|  |  ** See Copyright Notice in lua.h | ||||||
|  |  */ | ||||||
|  |   | ||||||
|  | +/***
 | ||||||
|  | + * Input and output facilities.
 | ||||||
|  | + *
 | ||||||
|  | + * @module io
 | ||||||
|  | + */
 | ||||||
|  | +
 | ||||||
|  |  #define liolib_c | ||||||
|  |  #define LUA_LIB | ||||||
|  |   | ||||||
|  | @@ -16,6 +22,7 @@
 | ||||||
|  |  #include <stdio.h> | ||||||
|  |  #include <stdlib.h> | ||||||
|  |  #include <string.h> | ||||||
|  | +#include <unistd.h>
 | ||||||
|  |   | ||||||
|  |  #include "lua.h" | ||||||
|  |   | ||||||
|  | @@ -723,8 +730,25 @@
 | ||||||
|  |    return luaL_fileresult(L, res == 0, NULL); | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +/***
 | ||||||
|  | + * Returns whether the stream points to a valid TTY device.
 | ||||||
|  | + *
 | ||||||
|  | + * @function file:istty
 | ||||||
|  | + * @usage
 | ||||||
|  | +local f = io.open("/etc/fstab", 'r');
 | ||||||
|  | +-- a regular file will never be a TTY device
 | ||||||
|  | +assert(not f:istty())
 | ||||||
|  | +-- stdin, stdout and stderr can often be TTYs
 | ||||||
|  | +print(io.stdout:istty())
 | ||||||
|  | + */
 | ||||||
|  | +static int f_istty (lua_State *L) {
 | ||||||
|  | +  int fd = fileno(tofile(L));
 | ||||||
|  | +  lua_pushboolean(L, isatty(fd));
 | ||||||
|  | +  return 1;
 | ||||||
|  | +}
 | ||||||
|  |   | ||||||
|  |   | ||||||
|  | +
 | ||||||
|  |  static int io_flush (lua_State *L) { | ||||||
|  |    return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); | ||||||
|  |  } | ||||||
|  | @@ -765,6 +789,7 @@
 | ||||||
|  |    {"seek", f_seek}, | ||||||
|  |    {"close", f_close}, | ||||||
|  |    {"setvbuf", f_setvbuf}, | ||||||
|  | +  {"istty", f_istty},
 | ||||||
|  |    {NULL, NULL} | ||||||
|  |  }; | ||||||
|  |   | ||||||
							
								
								
									
										18
									
								
								external/lua/patches/lua-5.4.6-makefile.diff
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								external/lua/patches/lua-5.4.6-makefile.diff
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | ||||||
|  | --- Makefile
 | ||||||
|  | +++ Makefile
 | ||||||
|  | @@ -6,12 +6,12 @@
 | ||||||
|  |  # Your platform. See PLATS for possible values. | ||||||
|  |  PLAT= guess | ||||||
|  | 
 | ||||||
|  | -CC= gcc -std=gnu99
 | ||||||
|  | -CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_3 $(SYSCFLAGS) $(MYCFLAGS)
 | ||||||
|  | +CC= cc -std=c99
 | ||||||
|  | +CFLAGS= -O2 $(SYSCFLAGS) $(MYCFLAGS)
 | ||||||
|  |  LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) | ||||||
|  |  LIBS= -lm $(SYSLIBS) $(MYLIBS) | ||||||
|  |   | ||||||
|  | -AR= ar rcu
 | ||||||
|  | +AR= ar cr
 | ||||||
|  |  RANLIB= ranlib | ||||||
|  |  RM= rm -f | ||||||
|  |  UNAME= uname | ||||||
							
								
								
									
										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