aboutsummaryrefslogtreecommitdiff
path: root/lua.c
diff options
context:
space:
mode:
Diffstat (limited to 'lua.c')
-rw-r--r--lua.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/lua.c b/lua.c
index e0ca0669..dfb5d1d1 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.208 2013/12/16 14:27:17 roberto Exp roberto $ 2** $Id: lua.c,v 1.209 2014/02/05 14:22:55 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*/
@@ -43,16 +43,26 @@
43** lua_stdin_is_tty detects whether the standard input is a 'tty' (that 43** lua_stdin_is_tty detects whether the standard input is a 'tty' (that
44** is, whether we're running lua interactively). 44** is, whether we're running lua interactively).
45*/ 45*/
46#if defined(LUA_USE_ISATTY) 46#if !defined(lua_stdin_is_tty) /* { */
47
48#if defined(LUA_USE_POSIX) /* { */
49
47#include <unistd.h> 50#include <unistd.h>
48#define lua_stdin_is_tty() isatty(0) 51#define lua_stdin_is_tty() isatty(0)
49#elif defined(LUA_WIN) 52
53#elif defined(LUA_WIN) /* }{ */
54
50#include <io.h> 55#include <io.h>
51#include <stdio.h>
52#define lua_stdin_is_tty() _isatty(_fileno(stdin)) 56#define lua_stdin_is_tty() _isatty(_fileno(stdin))
53#else 57
58#else /* }{ */
59
60/* ANSI definition */
54#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ 61#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
55#endif 62
63#endif /* } */
64
65#endif /* } */
56 66
57 67
58/* 68/*
@@ -61,9 +71,10 @@
61** lua_saveline defines how to "save" a read line in a "history". 71** lua_saveline defines how to "save" a read line in a "history".
62** lua_freeline defines how to free a line read by lua_readline. 72** lua_freeline defines how to free a line read by lua_readline.
63*/ 73*/
64#if defined(LUA_USE_READLINE) 74#if !defined(lua_readline) /* { */
75
76#if defined(LUA_USE_READLINE) /* { */
65 77
66#include <stdio.h>
67#include <readline/readline.h> 78#include <readline/readline.h>
68#include <readline/history.h> 79#include <readline/history.h>
69#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) 80#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
@@ -72,7 +83,7 @@
72 add_history(lua_tostring(L, idx)); /* add it to history */ 83 add_history(lua_tostring(L, idx)); /* add it to history */
73#define lua_freeline(L,b) ((void)L, free(b)) 84#define lua_freeline(L,b) ((void)L, free(b))
74 85
75#elif !defined(lua_readline) 86#else /* }{ */
76 87
77#define lua_readline(L,b,p) \ 88#define lua_readline(L,b,p) \
78 ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ 89 ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
@@ -80,7 +91,9 @@
80#define lua_saveline(L,idx) { (void)L; (void)idx; } 91#define lua_saveline(L,idx) { (void)L; (void)idx; }
81#define lua_freeline(L,b) { (void)L; (void)b; } 92#define lua_freeline(L,b) { (void)L; (void)b; }
82 93
83#endif 94#endif /* } */
95
96#endif /* } */
84 97
85 98
86 99