aboutsummaryrefslogtreecommitdiff
path: root/opcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'opcode.c')
-rw-r--r--opcode.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/opcode.c b/opcode.c
index 2b1c02f8..77b680d6 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 4.1 1997/04/03 18:27:06 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 4.2 1997/04/04 22:24:51 roberto Exp roberto $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdio.h> 9#include <stdio.h>
@@ -554,7 +554,7 @@ int luaI_dorun (TFunc *tf)
554 return status; 554 return status;
555} 555}
556 556
557static int do_protectedmain (void) 557static int do_protectedmain (lua_CFunction closef)
558{ 558{
559 TFunc tf; 559 TFunc tf;
560 int status; 560 int status;
@@ -563,16 +563,17 @@ static int do_protectedmain (void)
563 errorJmp = &myErrorJmp; 563 errorJmp = &myErrorJmp;
564 luaI_initTFunc(&tf); 564 luaI_initTFunc(&tf);
565 tf.fileName = lua_parsedfile; 565 tf.fileName = lua_parsedfile;
566 if (setjmp(myErrorJmp) == 0) 566 if (setjmp(myErrorJmp) == 0) {
567 {
568 lua_parse(&tf); 567 lua_parse(&tf);
569 status = luaI_dorun(&tf); 568 status = 0;
570 } 569 }
571 else 570 else {
572 {
573 status = 1;
574 adjustC(0); /* erase extra slot */ 571 adjustC(0); /* erase extra slot */
572 status = 1;
575 } 573 }
574 closef();
575 if (status == 0)
576 status = luaI_dorun(&tf);
576 errorJmp = oldErr; 577 errorJmp = oldErr;
577 luaI_free(tf.code); 578 luaI_free(tf.code);
578 return status; 579 return status;
@@ -620,13 +621,13 @@ int lua_dofile (char *filename)
620 if (c == ID_CHUNK) { 621 if (c == ID_CHUNK) {
621 f = freopen(filename, "rb", f); /* set binary mode */ 622 f = freopen(filename, "rb", f); /* set binary mode */
622 status = luaI_undump(f); 623 status = luaI_undump(f);
624 lua_closefile();
623 } 625 }
624 else { 626 else {
625 if (c == '#') 627 if (c == '#')
626 while ((c=fgetc(f)) != '\n') /* skip first line */; 628 while ((c=fgetc(f)) != '\n') /* skip first line */;
627 status = do_protectedmain(); 629 status = do_protectedmain(lua_closefile);
628 } 630 }
629 lua_closefile();
630 return status; 631 return status;
631} 632}
632 633
@@ -640,8 +641,7 @@ int lua_dostring (char *str)
640 if (str == NULL) 641 if (str == NULL)
641 return 1; 642 return 1;
642 lua_openstring(str); 643 lua_openstring(str);
643 status = do_protectedmain(); 644 status = do_protectedmain(lua_closestring);
644 lua_closestring();
645 return status; 645 return status;
646} 646}
647 647