From 6d475731cae37e8e46abf217697198bcce316b42 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 21 Mar 2005 15:12:07 -0300 Subject: cleaner configuration for lua.c --- luaconf.h | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'luaconf.h') diff --git a/luaconf.h b/luaconf.h index 7eaf50ed..fe26dc2b 100644 --- a/luaconf.h +++ b/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.36 2005/03/18 18:02:04 roberto Exp roberto $ +** $Id: luaconf.h,v 1.37 2005/03/18 18:55:45 roberto Exp roberto $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -133,28 +133,48 @@ /* CONFIG: definition of isatty */ #ifdef _POSIX_C_SOURCE #include -#define stdin_is_tty() isatty(0) +#define lua_stdin_is_tty() isatty(0) #elif defined(_WIN32) #include #include -#define stdin_is_tty() _isatty(_fileno(stdin)) +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) #else -#define stdin_is_tty() 1 /* assume stdin is a tty */ +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ #endif -#define PROMPT "> " -#define PROMPT2 ">> " -#define PROGNAME "lua" - +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " +#define LUA_PROGNAME "lua" +/* +*@ LUA_MAXINPUT is the maximum length for an input line +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 /* -** CONFIG: this macro can be used by some history system to save lines -** read in manual input +*@ lua_readline defines how to show a prompt and then read a line from +** the standard input. +*@ lua_saveline defines how to "save" a read line. +** CHANGE them if you want to improve this functionality (e.g., using GNU +** readline and history facilities). (Lua already tries to use those +** facilities when it detects a GNU compiler.) */ -#define lua_saveline(L,line) /* empty */ +#ifdef __GNUC__ +#include +#include +#define lua_readline(L,b,p) (((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#else +#define lua_readline(L,b,p) \ + (fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) ((void)0) +#endif -- cgit v1.2.3-55-g6feb