]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lily-parser-scheme.cc
clean up Sources
[lilypond.git] / lily / lily-parser-scheme.cc
index 0e844d2bc0ec51053f3f938cb4ac747fbf883af8..a1cdfa3c035f9b5d7d26db9f3d81f7928f9930bd 100644 (file)
@@ -11,7 +11,7 @@
 #include "file-name-map.hh"
 #include "file-name.hh"
 #include "file-path.hh"
-#include "input-smob.hh"
+#include "input.hh"
 #include "international.hh"
 #include "lily-lexer.hh"
 #include "lily-parser.hh"
@@ -110,11 +110,12 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
       exit (2);
     }
 
-  if ((file_name != "-") && global_path.find (file_name).empty ())
+
+  bool error = false;
+  if ((file_name != "-") && file_name.empty ())
     {
-      warning (_f ("can't find file: `%s'", file_name));
-      scm_throw (ly_symbol2scm ("ly-file-failed"),
-                scm_list_1 (scm_makfrom0str (file_name.c_str ())));
+      warning (_f ("can't find file: `%s'", file));
+      error = true;
     }
   else
     {
@@ -129,14 +130,20 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
 
       parser->parse_file (init, file_name, out_file);
 
-      bool error = parser->error_level_;
+      error = parser->error_level_;
+
+      parser->clear ();
       parser->unprotect ();
-      parser = 0;
-      if (error)
-       /* TODO: pass renamed input file too.  */
-       scm_throw (ly_symbol2scm ("ly-file-failed"),
-                  scm_list_1 (scm_makfrom0str (file_name.c_str ())));
     }
+
+  /*
+    outside the if-else to ensure cleanup fo Sources object, 
+   */
+  if (error)
+    /* TODO: pass renamed input file too.  */
+    scm_throw (ly_symbol2scm ("ly-file-failed"),
+              scm_list_1 (scm_makfrom0str (file_name.c_str ())));
+  
   return SCM_UNSPECIFIED;
 }