mirror of
https://github.com/lua/lua.git
synced 2026-10-26 10:35:26 +00:00
Cast in 'rl_readline_name'
In Mac OS, 'rl_readline_name' is declared as 'char*', instead of 'const char*', so we cannot assign to it a string literal such as "lua".
This commit is contained in:
@@ -465,7 +465,8 @@ static int handle_luainit (lua_State *L) {
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
#define lua_initreadline(L) ((void)L, rl_readline_name="lua")
|
||||
#define lua_initreadline(L) \
|
||||
((void)L, *cast(const char **, &rl_readline_name)="lua")
|
||||
#define lua_readline(buff,prompt) ((void)buff, readline(prompt))
|
||||
#define lua_saveline(line) add_history(line)
|
||||
#define lua_freeline(line) free(line)
|
||||
|
||||
+5
-3
@@ -199,14 +199,16 @@ assert(not string.find(defaultpath, "xxx") and
|
||||
|
||||
-- (LUA_READLINELIB was introduced in 5.5.1)
|
||||
if release >= "5.5.1" then
|
||||
-- OBS: this test is not valid when Lua is compiled with LUA_USE_READLINE
|
||||
print"testing readline library name"
|
||||
-- should generate a warning when trying to load inexistent library "xuxu"
|
||||
local env = [[LUA_READLINELIB=xuxu LUA_INIT="warn('@allow')"]]
|
||||
local code = 'echo " " | env %s lua %s -W -i >%s 2>&1'
|
||||
RUN(code, env, "", out) -- run code with no extra options
|
||||
assert(string.find(getoutput(),
|
||||
"warning: unable to load readline library 'xuxu'"))
|
||||
|
||||
if(not string.find(getoutput(),
|
||||
"warning: unable to load readline library 'xuxu'")) then
|
||||
error("Is Lua compiled with option LUA_USE_READLINE?")
|
||||
end
|
||||
RUN(code, env, "-E", out) -- run again with option -E
|
||||
-- no warning when LUA_READLINELIB is to be ignored
|
||||
assert(not string.find(getoutput(), "warning"))
|
||||
|
||||
Reference in New Issue
Block a user