commit c3cb31fa9aae0c004c1c145b2268c0ffa35a3f62
parent 0c7738240ef81b88ded842e3a8ebfb3180bcf00c
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 16 Mar 2018 11:22:41 -0300
some extra goodies for 'readline'
('rl_readline_name' and 'rl_inhibit_completion')
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lua.c b/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.233 2018/02/06 15:32:36 roberto Exp roberto $
+** $Id: lua.c,v 1.234 2018/03/06 20:30:17 roberto Exp roberto $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -383,12 +383,15 @@ 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", rl_inhibit_completion=1)
#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
#define lua_saveline(L,line) ((void)L, add_history(line))
#define lua_freeline(L,b) ((void)L, free(b))
#else /* }{ */
+#define lua_initreadline(L) ((void)L)
#define lua_readline(L,b,p) \
((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
@@ -539,6 +542,7 @@ static void doREPL (lua_State *L) {
int status;
const char *oldprogname = progname;
progname = NULL; /* no 'progname' on errors in interactive mode */
+ lua_initreadline(L);
while ((status = loadline(L)) != -1) {
if (status == LUA_OK)
status = docall(L, 0, LUA_MULTRET);