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 | |
parent | 3e1f7318269e56e557d423f07547da1a87ea6d4f (diff) | |
download | lua-e701a86385d652d19b1fd461ae4a84d1db2accba.tar.gz lua-e701a86385d652d19b1fd461ae4a84d1db2accba.tar.bz2 lua-e701a86385d652d19b1fd461ae4a84d1db2accba.zip |
"openfile" now returns the file
-rw-r--r-- | inout.c | 20 | ||||
-rw-r--r-- | inout.h | 5 |
2 files changed, 10 insertions, 15 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)) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: inout.h,v 1.12 1996/01/26 14:05:28 roberto Exp roberto $ | 2 | ** $Id: inout.h,v 1.13 1996/02/07 14:13:47 roberto Exp roberto $ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | 5 | ||
@@ -7,13 +7,14 @@ | |||
7 | #define inout_h | 7 | #define inout_h |
8 | 8 | ||
9 | #include "types.h" | 9 | #include "types.h" |
10 | #include "stdio.h" | ||
10 | 11 | ||
11 | 12 | ||
12 | extern Word lua_linenumber; | 13 | extern Word lua_linenumber; |
13 | extern Word lua_debugline; | 14 | extern Word lua_debugline; |
14 | extern char *lua_parsedfile; | 15 | extern char *lua_parsedfile; |
15 | 16 | ||
16 | int lua_openfile (char *fn); | 17 | FILE *lua_openfile (char *fn); |
17 | void lua_closefile (void); | 18 | void lua_closefile (void); |
18 | void lua_openstring (char *s); | 19 | void lua_openstring (char *s); |
19 | void lua_closestring (void); | 20 | void lua_closestring (void); |