aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lua.c b/lua.c
index 01c29bfc..7d4b1c99 100644
--- a/lua.c
+++ b/lua.c
@@ -201,7 +201,7 @@ static int trap_eof (lua_State *l) {
201} 201}
202 202
203 203
204static int load_string (int *toprint) { 204static int load_string (void) {
205 lua_getglobal(L, LUA_ERRORMESSAGE); 205 lua_getglobal(L, LUA_ERRORMESSAGE);
206 lua_pushvalue(L, 1); 206 lua_pushvalue(L, 1);
207 lua_setglobal(L, LUA_ERRORMESSAGE); 207 lua_setglobal(L, LUA_ERRORMESSAGE);
@@ -214,8 +214,7 @@ static int load_string (int *toprint) {
214 lua_setglobal(L, LUA_ERRORMESSAGE); 214 lua_setglobal(L, LUA_ERRORMESSAGE);
215 return 0; 215 return 0;
216 } 216 }
217 *toprint = !incomplete && buffer[0] == '='; 217 if (!incomplete && buffer[0] == '=') {
218 if (*toprint) {
219 buffer[0] = ' '; 218 buffer[0] = ' ';
220 lua_pushstring(L, "return"); 219 lua_pushstring(L, "return");
221 } 220 }
@@ -244,12 +243,11 @@ static int lcall (lua_State *l, const char *name) {
244 243
245 244
246static void manual_input (int version) { 245static void manual_input (int version) {
247 int toprint = 0;
248 if (version) print_version(); 246 if (version) print_version();
249 lua_pushcfunction(L, trap_eof); /* set up handler for incomplete lines */ 247 lua_pushcfunction(L, trap_eof); /* set up handler for incomplete lines */
250 while (load_string(&toprint)) { 248 while (load_string()) {
251 ldo(lcall, NULL, 0); 249 ldo(lcall, NULL, 0);
252 if (toprint && lua_gettop(L) > 1) { /* any result to print? */ 250 if (lua_gettop(L) > 1) { /* any result to print? */
253 lua_getglobal(L, "print"); 251 lua_getglobal(L, "print");
254 lua_insert(L, 2); 252 lua_insert(L, 2);
255 lua_call(L, lua_gettop(L)-2, 0); 253 lua_call(L, lua_gettop(L)-2, 0);
@@ -355,8 +353,8 @@ static void openstdlibs (lua_State *l) {
355int main (int argc, char *argv[]) { 353int main (int argc, char *argv[]) {
356 int status; 354 int status;
357 int toclose = 0; 355 int toclose = 0;
358 (void)argc; /* unused parameter: avoid warnings */ 356 (void)argc; /* to avoid warnings */
359 L = lua_open(0); /* create state */ 357 L = lua_open(); /* create state */
360 LUA_USERINIT(L); /* open libraries */ 358 LUA_USERINIT(L); /* open libraries */
361 register_getargs(argv); /* create `getargs' function */ 359 register_getargs(argv); /* create `getargs' function */
362 status = handle_argv(argv+1, &toclose); 360 status = handle_argv(argv+1, &toclose);