diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 11:58:26 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-03 11:58:26 -0300 |
commit | 3c9d999424520c809e05bee11d81788b488434f6 (patch) | |
tree | 7556d9ea10bda42b226aec4dd956753467cc0864 /lua.c | |
parent | f7840a3e0bc07813246b2bad6bf4579848187908 (diff) | |
download | lua-3c9d999424520c809e05bee11d81788b488434f6.tar.gz lua-3c9d999424520c809e05bee11d81788b488434f6.tar.bz2 lua-3c9d999424520c809e05bee11d81788b488434f6.zip |
many details (most by lhf).
Diffstat (limited to 'lua.c')
-rw-r--r-- | lua.c | 24 |
1 files changed, 9 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.32 2000/01/19 16:50:14 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.33 2000/02/21 18:30:42 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -87,16 +87,10 @@ static void print_version (void) { | |||
87 | 87 | ||
88 | 88 | ||
89 | static void assign (char *arg) { | 89 | static void assign (char *arg) { |
90 | char buffer[500]; | 90 | char *eq = strchr(arg, '='); |
91 | if (strlen(arg) >= sizeof(buffer)) | 91 | *eq = '\0'; /* spilt `arg' in two strings (name & value) */ |
92 | fprintf(stderr, "lua: shell argument too long"); | 92 | lua_pushstring(eq+1); |
93 | else { | 93 | lua_setglobal(arg); |
94 | char *eq = strchr(arg, '='); | ||
95 | lua_pushstring(eq+1); | ||
96 | strncpy(buffer, arg, eq-arg); | ||
97 | buffer[eq-arg] = 0; | ||
98 | lua_setglobal(buffer); | ||
99 | } | ||
100 | } | 94 | } |
101 | 95 | ||
102 | 96 | ||
@@ -139,7 +133,7 @@ static void manual_input (int prompt) { | |||
139 | if (prompt) { | 133 | if (prompt) { |
140 | const char *s = lua_getstring(lua_getglobal("_PROMPT")); | 134 | const char *s = lua_getstring(lua_getglobal("_PROMPT")); |
141 | if (!s) s = PROMPT; | 135 | if (!s) s = PROMPT; |
142 | printf("%s", s); | 136 | fputs(s, stdout); |
143 | } | 137 | } |
144 | for(;;) { | 138 | for(;;) { |
145 | int c = getchar(); | 139 | int c = getchar(); |
@@ -153,7 +147,7 @@ static void manual_input (int prompt) { | |||
153 | else break; | 147 | else break; |
154 | } | 148 | } |
155 | else if (i >= BUFSIZ-1) { | 149 | else if (i >= BUFSIZ-1) { |
156 | fprintf(stderr, "lua: argument line too long\n"); | 150 | fprintf(stderr, "lua: input line too long\n"); |
157 | break; | 151 | break; |
158 | } | 152 | } |
159 | else buffer[i++] = (char)c; | 153 | else buffer[i++] = (char)c; |
@@ -217,9 +211,9 @@ int main (int argc, char *argv[]) { | |||
217 | print_message(); | 211 | print_message(); |
218 | exit(1); | 212 | exit(1); |
219 | } | 213 | } |
220 | getargs(argc-i, argv+i); /* collect following arguments */ | 214 | getargs(argc-i, argv+i); /* collect remaining arguments */ |
221 | file_input(argv, i); | 215 | file_input(argv, i); |
222 | i = argc; /* stop running arguments */ | 216 | i = argc; /* stop scanning arguments */ |
223 | break; | 217 | break; |
224 | default: | 218 | default: |
225 | print_message(); | 219 | print_message(); |