فهرست منبع

some extra goodies for 'readline'
('rl_readline_name' and 'rl_inhibit_completion')

Roberto Ierusalimschy 7 سال پیش
والد
کامیت
c3cb31fa9a
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      lua.c

+ 5 - 1
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
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -383,12 +383,15 @@ static int handle_luainit (lua_State *L) {
 
 
 #include <readline/readline.h>
 #include <readline/readline.h>
 #include <readline/history.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_readline(L,b,p)	((void)L, ((b)=readline(p)) != NULL)
 #define lua_saveline(L,line)	((void)L, add_history(line))
 #define lua_saveline(L,line)	((void)L, add_history(line))
 #define lua_freeline(L,b)	((void)L, free(b))
 #define lua_freeline(L,b)	((void)L, free(b))
 
 
 #else				/* }{ */
 #else				/* }{ */
 
 
+#define lua_initreadline(L)  ((void)L)
 #define lua_readline(L,b,p) \
 #define lua_readline(L,b,p) \
         ((void)L, fputs(p, stdout), fflush(stdout),  /* show prompt */ \
         ((void)L, fputs(p, stdout), fflush(stdout),  /* show prompt */ \
         fgets(b, LUA_MAXINPUT, stdin) != NULL)  /* get line */
         fgets(b, LUA_MAXINPUT, stdin) != NULL)  /* get line */
@@ -539,6 +542,7 @@ static void doREPL (lua_State *L) {
   int status;
   int status;
   const char *oldprogname = progname;
   const char *oldprogname = progname;
   progname = NULL;  /* no 'progname' on errors in interactive mode */
   progname = NULL;  /* no 'progname' on errors in interactive mode */
+  lua_initreadline(L);
   while ((status = loadline(L)) != -1) {
   while ((status = loadline(L)) != -1) {
     if (status == LUA_OK)
     if (status == LUA_OK)
       status = docall(L, 0, LUA_MULTRET);
       status = docall(L, 0, LUA_MULTRET);