From fa71304e54f304ceceddef3a4b97b38228822e94 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 23 Oct 1995 11:54:11 -0200 Subject: "dofile" now accepts NULL as parameter, to run stdin. --- inout.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/inout.c b/inout.c index 0717c8ab..0506d11e 100644 --- a/inout.c +++ b/inout.c @@ -5,7 +5,7 @@ ** Also provides some predefined lua functions. */ -char *rcs_inout="$Id: inout.c,v 2.22 1995/10/09 13:06:20 roberto Exp roberto $"; +char *rcs_inout="$Id: inout.c,v 2.23 1995/10/17 11:58:41 roberto Exp roberto $"; #include #include @@ -60,7 +60,13 @@ static int stringinput (void) char *lua_openfile (char *fn) { lua_setinput (fileinput); - fp = fopen (fn, "r"); + if (fn == NULL) + { + fp = stdin; + fn = "(stdin)"; + } + else + fp = fopen (fn, "r"); if (fp == NULL) { static char buff[255]; @@ -77,7 +83,7 @@ char *lua_openfile (char *fn) */ void lua_closefile (void) { - if (fp != NULL) + if (fp != NULL && fp != stdin) { fclose (fp); fp = NULL; -- cgit v1.2.3-55-g6feb