diff options
| -rw-r--r-- | inout.c | 21 | ||||
| -rw-r--r-- | inout.h | 7 |
2 files changed, 12 insertions, 16 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.62 1997/06/17 18:44:31 roberto Exp roberto $"; | 8 | char *rcs_inout="$Id: inout.c,v 2.63 1997/06/18 20:35:49 roberto Exp roberto $"; |
| 9 | 9 | ||
| 10 | #include <stdio.h> | 10 | #include <stdio.h> |
| 11 | #include <string.h> | 11 | #include <string.h> |
| @@ -38,7 +38,7 @@ char *luaI_typenames[] = { /* ORDER LUA_T */ | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | static void setparsedfile (char *name) | 41 | void luaI_setparsedfile (char *name) |
| 42 | { | 42 | { |
| 43 | lua_parsedfile = luaI_createfixedstring(name)->str; | 43 | lua_parsedfile = luaI_createfixedstring(name)->str; |
| 44 | } | 44 | } |
| @@ -47,7 +47,7 @@ static void setparsedfile (char *name) | |||
| 47 | int lua_doFILE (FILE *f, int bin) | 47 | int lua_doFILE (FILE *f, int bin) |
| 48 | { | 48 | { |
| 49 | ZIO z; | 49 | ZIO z; |
| 50 | luaz_Fopen(&z, f); | 50 | luaZ_Fopen(&z, f); |
| 51 | if (bin) | 51 | if (bin) |
| 52 | return luaI_undump(&z); | 52 | return luaI_undump(&z); |
| 53 | else { | 53 | else { |
| @@ -64,7 +64,7 @@ int lua_dofile (char *filename) | |||
| 64 | FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); | 64 | FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); |
| 65 | if (f == NULL) | 65 | if (f == NULL) |
| 66 | return 2; | 66 | return 2; |
| 67 | setparsedfile(filename?filename:"(stdin)"); | 67 | luaI_setparsedfile(filename?filename:"(stdin)"); |
| 68 | c = fgetc(f); | 68 | c = fgetc(f); |
| 69 | ungetc(c, f); | 69 | ungetc(c, f); |
| 70 | if (c == ID_CHUNK) { | 70 | if (c == ID_CHUNK) { |
| @@ -76,7 +76,8 @@ int lua_dofile (char *filename) | |||
| 76 | while ((c=fgetc(f)) != '\n') /* skip first line */; | 76 | while ((c=fgetc(f)) != '\n') /* skip first line */; |
| 77 | status = lua_doFILE(f, 0); | 77 | status = lua_doFILE(f, 0); |
| 78 | } | 78 | } |
| 79 | fclose(f); | 79 | if (f != stdin) |
| 80 | fclose(f); | ||
| 80 | return status; | 81 | return status; |
| 81 | } | 82 | } |
| 82 | 83 | ||
| @@ -89,10 +90,9 @@ int lua_dobuffer (char *buff, int size) | |||
| 89 | { | 90 | { |
| 90 | int status; | 91 | int status; |
| 91 | ZIO z; | 92 | ZIO z; |
| 92 | setparsedfile("(buffer)"); | 93 | luaI_setparsedfile("(buffer)"); |
| 93 | luaz_mopen(&z, buff, size); | 94 | luaZ_mopen(&z, buff, size); |
| 94 | status = luaI_undump(&z); | 95 | status = luaI_undump(&z); |
| 95 | zclose(&z); | ||
| 96 | return status; | 96 | return status; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| @@ -107,11 +107,10 @@ int lua_dostring (char *str) | |||
| 107 | sprintf(buff, "(dostring) >> %.20s", str); | 107 | sprintf(buff, "(dostring) >> %.20s", str); |
| 108 | temp = strchr(buff, '\n'); | 108 | temp = strchr(buff, '\n'); |
| 109 | if (temp) *temp = 0; /* end string after first line */ | 109 | if (temp) *temp = 0; /* end string after first line */ |
| 110 | setparsedfile(buff); | 110 | luaI_setparsedfile(buff); |
| 111 | luaz_sopen(&z, str); | 111 | luaZ_sopen(&z, str); |
| 112 | lua_setinput(&z); | 112 | lua_setinput(&z); |
| 113 | status = lua_domain(); | 113 | status = lua_domain(); |
| 114 | zclose(&z); | ||
| 115 | return status; | 114 | return status; |
| 116 | } | 115 | } |
| 117 | 116 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: inout.h,v 1.18 1997/06/16 16:50:22 roberto Exp roberto $ | 2 | ** $Id: inout.h,v 1.19 1997/06/18 20:35:49 roberto Exp roberto $ |
| 3 | */ | 3 | */ |
| 4 | 4 | ||
| 5 | 5 | ||
| @@ -14,10 +14,7 @@ extern Word lua_linenumber; | |||
| 14 | extern Word lua_debugline; | 14 | extern Word lua_debugline; |
| 15 | extern char *lua_parsedfile; | 15 | extern char *lua_parsedfile; |
| 16 | 16 | ||
| 17 | FILE *lua_openfile (char *fn); | 17 | void luaI_setparsedfile (char *name); |
| 18 | void lua_closefile (void); | ||
| 19 | void lua_openstring (char *s); | ||
| 20 | void lua_closestring (void); | ||
| 21 | 18 | ||
| 22 | void luaI_predefine (void); | 19 | void luaI_predefine (void); |
| 23 | 20 | ||
