From e701a86385d652d19b1fd461ae4a84d1db2accba Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 15 Mar 1996 10:13:13 -0300 Subject: [PATCH] "openfile" now returns the file --- inout.c | 20 +++++++------------- inout.h | 5 +++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/inout.c b/inout.c index fe799e93..48a67545 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.32 1996/02/14 18:25:04 roberto Exp roberto $"; +char *rcs_inout="$Id: inout.c,v 2.33 1996/02/26 21:00:27 roberto Exp roberto $"; #include #include @@ -16,13 +16,7 @@ char *rcs_inout="$Id: inout.c,v 2.32 1996/02/14 18:25:04 roberto Exp roberto $"; #include "table.h" #include "tree.h" #include "lua.h" - - -#ifndef MAXFUNCSTACK -#define MAXFUNCSTACK 100 -#endif - -#define MAXMESSAGE MAXFUNCSTACK*80 +#include "mem.h" /* Exported variables */ @@ -51,9 +45,9 @@ static int stringinput (void) /* ** Function to open a file to be input unit. -** Return 0 on success or 1 error. +** Return the file. */ -int lua_openfile (char *fn) +FILE *lua_openfile (char *fn) { lua_setinput (fileinput); if (fn == NULL) @@ -64,10 +58,10 @@ int lua_openfile (char *fn) else fp = fopen (fn, "r"); if (fp == NULL) - return 1; + return NULL; lua_linenumber = 1; lua_parsedfile = luaI_createfixedstring(fn)->str; - return 0; + return fp; } /* @@ -134,7 +128,7 @@ void lua_internaldofile (void) static char *tostring (lua_Object obj) { - static char buff[20]; + char *buff = luaI_buffer(20); if (lua_isstring(obj)) return lua_getstring(obj); if (lua_isnumber(obj)) diff --git a/inout.h b/inout.h index db0e654a..b27d1c2b 100644 --- a/inout.h +++ b/inout.h @@ -1,5 +1,5 @@ /* -** $Id: inout.h,v 1.12 1996/01/26 14:05:28 roberto Exp roberto $ +** $Id: inout.h,v 1.13 1996/02/07 14:13:47 roberto Exp roberto $ */ @@ -7,13 +7,14 @@ #define inout_h #include "types.h" +#include "stdio.h" extern Word lua_linenumber; extern Word lua_debugline; extern char *lua_parsedfile; -int lua_openfile (char *fn); +FILE *lua_openfile (char *fn); void lua_closefile (void); void lua_openstring (char *s); void lua_closestring (void);