diff options
-rw-r--r-- | lua.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.233 2018/02/06 15:32:36 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.234 2018/03/06 20:30:17 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -383,12 +383,15 @@ static int handle_luainit (lua_State *L) { | |||
383 | 383 | ||
384 | #include <readline/readline.h> | 384 | #include <readline/readline.h> |
385 | #include <readline/history.h> | 385 | #include <readline/history.h> |
386 | #define lua_initreadline(L) \ | ||
387 | ((void)L, rl_readline_name="lua", rl_inhibit_completion=1) | ||
386 | #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) | 388 | #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) |
387 | #define lua_saveline(L,line) ((void)L, add_history(line)) | 389 | #define lua_saveline(L,line) ((void)L, add_history(line)) |
388 | #define lua_freeline(L,b) ((void)L, free(b)) | 390 | #define lua_freeline(L,b) ((void)L, free(b)) |
389 | 391 | ||
390 | #else /* }{ */ | 392 | #else /* }{ */ |
391 | 393 | ||
394 | #define lua_initreadline(L) ((void)L) | ||
392 | #define lua_readline(L,b,p) \ | 395 | #define lua_readline(L,b,p) \ |
393 | ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ | 396 | ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ |
394 | fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ | 397 | fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ |
@@ -539,6 +542,7 @@ static void doREPL (lua_State *L) { | |||
539 | int status; | 542 | int status; |
540 | const char *oldprogname = progname; | 543 | const char *oldprogname = progname; |
541 | progname = NULL; /* no 'progname' on errors in interactive mode */ | 544 | progname = NULL; /* no 'progname' on errors in interactive mode */ |
545 | lua_initreadline(L); | ||
542 | while ((status = loadline(L)) != -1) { | 546 | while ((status = loadline(L)) != -1) { |
543 | if (status == LUA_OK) | 547 | if (status == LUA_OK) |
544 | status = docall(L, 0, LUA_MULTRET); | 548 | status = docall(L, 0, LUA_MULTRET); |