diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-03-15 10:13:13 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-03-15 10:13:13 -0300 |
| commit | e701a86385d652d19b1fd461ae4a84d1db2accba (patch) | |
| tree | 627af0146fa50b71ba5878389b3a32557cf4793d /inout.c | |
| parent | 3e1f7318269e56e557d423f07547da1a87ea6d4f (diff) | |
| download | lua-e701a86385d652d19b1fd461ae4a84d1db2accba.tar.gz lua-e701a86385d652d19b1fd461ae4a84d1db2accba.tar.bz2 lua-e701a86385d652d19b1fd461ae4a84d1db2accba.zip | |
"openfile" now returns the file
Diffstat (limited to '')
| -rw-r--r-- | inout.c | 20 |
1 files changed, 7 insertions, 13 deletions
| @@ -5,7 +5,7 @@ | |||
| 5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | char *rcs_inout="$Id: inout.c,v 2.32 1996/02/14 18:25:04 roberto Exp roberto $"; | 8 | char *rcs_inout="$Id: inout.c,v 2.33 1996/02/26 21:00:27 roberto Exp roberto $"; |
| 9 | 9 | ||
| 10 | #include <stdio.h> | 10 | #include <stdio.h> |
| 11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
| @@ -16,13 +16,7 @@ char *rcs_inout="$Id: inout.c,v 2.32 1996/02/14 18:25:04 roberto Exp roberto $"; | |||
| 16 | #include "table.h" | 16 | #include "table.h" |
| 17 | #include "tree.h" | 17 | #include "tree.h" |
| 18 | #include "lua.h" | 18 | #include "lua.h" |
| 19 | 19 | #include "mem.h" | |
| 20 | |||
| 21 | #ifndef MAXFUNCSTACK | ||
| 22 | #define MAXFUNCSTACK 100 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #define MAXMESSAGE MAXFUNCSTACK*80 | ||
| 26 | 20 | ||
| 27 | 21 | ||
| 28 | /* Exported variables */ | 22 | /* Exported variables */ |
| @@ -51,9 +45,9 @@ static int stringinput (void) | |||
| 51 | 45 | ||
| 52 | /* | 46 | /* |
| 53 | ** Function to open a file to be input unit. | 47 | ** Function to open a file to be input unit. |
| 54 | ** Return 0 on success or 1 error. | 48 | ** Return the file. |
| 55 | */ | 49 | */ |
| 56 | int lua_openfile (char *fn) | 50 | FILE *lua_openfile (char *fn) |
| 57 | { | 51 | { |
| 58 | lua_setinput (fileinput); | 52 | lua_setinput (fileinput); |
| 59 | if (fn == NULL) | 53 | if (fn == NULL) |
| @@ -64,10 +58,10 @@ int lua_openfile (char *fn) | |||
| 64 | else | 58 | else |
| 65 | fp = fopen (fn, "r"); | 59 | fp = fopen (fn, "r"); |
| 66 | if (fp == NULL) | 60 | if (fp == NULL) |
| 67 | return 1; | 61 | return NULL; |
| 68 | lua_linenumber = 1; | 62 | lua_linenumber = 1; |
| 69 | lua_parsedfile = luaI_createfixedstring(fn)->str; | 63 | lua_parsedfile = luaI_createfixedstring(fn)->str; |
| 70 | return 0; | 64 | return fp; |
| 71 | } | 65 | } |
| 72 | 66 | ||
| 73 | /* | 67 | /* |
| @@ -134,7 +128,7 @@ void lua_internaldofile (void) | |||
| 134 | 128 | ||
| 135 | static char *tostring (lua_Object obj) | 129 | static char *tostring (lua_Object obj) |
| 136 | { | 130 | { |
| 137 | static char buff[20]; | 131 | char *buff = luaI_buffer(20); |
| 138 | if (lua_isstring(obj)) | 132 | if (lua_isstring(obj)) |
| 139 | return lua_getstring(obj); | 133 | return lua_getstring(obj); |
| 140 | if (lua_isnumber(obj)) | 134 | if (lua_isnumber(obj)) |
