#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"
"Upon failure, throw @code{ly-file-failed} key.")
{
SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
- char const *file = scm_i_string_chars (name);
+ string file = ly_scm2string (name);
char const *extensions[] = {"ly", "", 0};
string file_name = global_path.find (file, extensions);
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
{
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;
}