]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lily-parser-scheme.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / lily-parser-scheme.cc
index 212ca92e682b8e783323f6d820c2a1b972e22ec8..1657438212786785c5a37a102f23fa11a76f394c 100644 (file)
@@ -39,7 +39,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
   char const *file = scm_i_string_chars (name);
   char const *extensions[] = {"ly", "", 0};
 
-  std::string file_name = global_path.find (file, extensions);
+  string file_name = global_path.find (file, extensions);
 
   /* By default, use base name of input file for output file name,
      write output to cwd; do not use root and directory parts of input
@@ -65,31 +65,32 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
   if (!output_name_global.empty ())
     {
       /* Interpret --output=DIR to mean --output=DIR/BASE.  */
+      string dir;
       if (is_dir (output_name_global))
        {
-         char cwd[PATH_MAX];
-         getcwd (cwd, PATH_MAX);
-
-         if (output_name_global != cwd)
-           {
-             global_path.prepend (cwd);
-             message (_f ("Changing working directory to `%s'",
-                          output_name_global.c_str ()));
-             chdir (output_name_global.c_str ());
-           }
+         dir = output_name_global;
          output_name_global = "";
        }
+      else
+       dir = dir_name (output_name_global);
+      if (dir != "" && dir != "." && dir != get_working_directory ())
+       {
+         global_path.prepend (get_working_directory ());
+         message (_f ("Changing working directory to `%s'",
+                      dir.c_str ()));
+         chdir (dir.c_str ());
+       }
       else
        out_file_name = File_name (output_name_global);
     }
 
-  std::string init;
+  string init;
   if (!init_name_global.empty ())
     init = init_name_global;
   else
     init = "init.ly";
 
-  std::string out_file = out_file_name.to_string ();
+  string out_file = out_file_name.to_string ();
 
   if (init.length () && global_path.find (init).empty ())
     {
@@ -110,7 +111,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
       Sources sources;
       sources.set_path (&global_path);
 
-      std::string mapped_fn = map_file_name (file_name);
+      string mapped_fn = map_file_name (file_name);
       message (_f ("Processing `%s'", mapped_fn.c_str ()));
       progress_indication ("\n");