lua

A copy of the Lua development repository
Log | Files | Refs | README

commit b5745d11cdd93c819f8e881504eb534c7e13badd
parent ebcf546a551cae37835af5ddf6105e2e97706047
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon, 23 Oct 1995 11:53:52 -0200

uses "isatty" to check if executes stdin line by line or as a file.

Diffstat:
Mlua.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lua.c b/lua.c @@ -3,7 +3,7 @@ ** Linguagem para Usuarios de Aplicacao */ -char *rcs_lua="$Id: lua.c,v 1.4 1995/02/07 16:04:15 lhf Exp roberto $"; +char *rcs_lua="$Id: lua.c,v 1.5 1995/10/06 14:11:40 roberto Exp roberto $"; #include <stdio.h> #include <string.h> @@ -15,6 +15,12 @@ static int lua_argc; static char **lua_argv; /* +** although this function is POSIX, there is no standard header file that +** defines it +*/ +int isatty (int fd); + +/* %F Allow Lua code to access argv strings. %i Receive from Lua the argument number (starting with 1). %o Return to Lua the argument, or nil if it does not exist. @@ -35,9 +41,14 @@ static void lua_getargv (void) static void manual_input (void) { + if (isatty(fileno(stdin))) + { char buffer[250]; while (gets(buffer) != 0) lua_dostring(buffer); + } + else + lua_dofile(NULL); /* executes stdin as a file */ }