stage1_2/iec_bison.yy
changeset 761 7b52623a2f37
parent 759 16050b4303a0
child 805 b737cfc92614
--- a/stage1_2/iec_bison.yy	Sat Dec 01 11:27:48 2012 +0000
+++ b/stage1_2/iec_bison.yy	Sat Dec 01 11:30:16 2012 +0000
@@ -8265,8 +8265,9 @@
     fprintf (stderr, "Out of memory. Bailing out!\n");
     return -1;
   }
-
-  if(parse_file(libfilename) < 0) {
+  
+  FILE *libfile = NULL;
+  if((libfile = parse_file(libfilename)) == NULL) {
     char *errmsg = strdup2("Error opening library file ", libfilename);
     perror(errmsg);
     free(errmsg);
@@ -8279,7 +8280,8 @@
   full_token_loc = full_token_loc_;
   if (yyparse() != 0)
       ERROR;
-
+  fclose(libfile);
+      
   if (yynerrs > 0) {
     fprintf (stderr, "\n%d error(s) found in %s. Bailing out!\n", yynerrs /* global variable */, libfilename);
     ERROR;
@@ -8299,8 +8301,8 @@
   #if YYDEBUG
     yydebug = 1;
   #endif
-
-  if(parse_file(filename) < 0) {
+  FILE *mainfile = NULL;
+  if ((mainfile = parse_file(filename)) == NULL) {
     char *errmsg = strdup2("Error opening main file ", filename);
     perror(errmsg);
     free(errmsg);
@@ -8315,7 +8317,8 @@
     fprintf (stderr, "\nParsing failed because of too many consecutive syntax errors. Bailing out!\n");
     exit(EXIT_FAILURE);
   }
-
+  fclose(mainfile);
+  
   if (yynerrs > 0) {
     fprintf (stderr, "\n%d error(s) found. Bailing out!\n", yynerrs /* global variable */);
     exit(EXIT_FAILURE);