source file of the GNU LilyPond music typesetter
- (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "config.h"
bool store_locations_global_b;
+/*
+ TODO: should merge with My_lily_parser.
+ */
/*
no ! suffix since it doesn't modify 1st argument.
out = " ";
}
String dep = deps[i];
- if (!dependency_prefix_global.empty_b ())
+ if (!dependency_prefix_global.is_empty ())
{
if (dep.index ('/') < 0)
dep = dependency_prefix_global + dep;
if (parser.error_level_)
{
exit_status_global = 1;
+ failed_files.push (in_file);
}
do_deps (out_file);
}
+/* Distill full input file name from command argument. PATH describes
+ file name with added default extension, ".ly" if none. "-" is
+ STDIN. */
+Path
+distill_inname (String str)
+{
+ Path p = split_path (str);
+ if (str.is_empty () || str == "-")
+ p.base = "-";
+ else
+ {
+ String orig_ext = p.ext;
+ char const *extensions[] = {"ly", "", 0};
+ for (int i = 0; extensions[i]; i++)
+ {
+ p.ext = orig_ext;
+ if (*extensions[i] && !p.ext.is_empty ())
+ p.ext += ".";
+ p.ext += extensions[i];
+ if (!global_path.find (p.to_string ()).is_empty ())
+ break;
+ }
+ /* Reshuffle extension */
+ p = split_path (p.to_string ());
+ }
+ return p;
+}
+/* ugr. */
void
-do_one_file (String init, String in_file, String out_file)
+do_one_file (char const *file)
{
- if (init.length () && global_path.find (init).empty_b ())
+ String infile (file);
+ Path inpath = distill_inname (infile);
+
+ /* By default, use base name of input file for output file name */
+ Path outpath = inpath;
+ if (inpath.to_string () != "-")
+ outpath.ext = output_format_global;
+
+ /* By default, write output to cwd; do not copy directory part
+ of input file name */
+ outpath.root = "";
+ outpath.dir = "";
+
+ if (!output_name_global.is_empty ())
+ outpath = split_path (output_name_global);
+
+ String init;
+ if (!init_name_global.is_empty ())
+ init = init_name_global;
+ else
+ init = "init.ly";
+
+ String in_file = inpath.to_string ();
+ String out_file = outpath.to_string ();
+
+#if 0
+ /* Code to debug memory leaks. Cannot call from within .ly
+ since then we get the protects from the parser state too. */
+ static SCM proc ;
+ if (!proc)
+ proc = scm_c_eval_string ("dump-gc-protects");
+ scm_gc ();
+ scm_call_0 (proc);
+#endif
+
+ if (init.length () && global_path.find (init).is_empty ())
{
warning (_f ("can't find file: `%s'", init));
warning (_f ("(search path: `%s')", global_path.to_string ().to_str0 ()));
return;
}
- if ((in_file != "-") && global_path.find (in_file).empty_b ())
+ if ((in_file != "-") && global_path.find (in_file).is_empty ())
{
warning (_f ("can't find file: `%s'", in_file));
return;
}
+ static SCM proc;
+ if (!proc)
+ proc = scm_c_eval_string ("dump-gc-protects");
+
Input_file_results inp_file (init, in_file, out_file);
}