]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/lily-parser-scheme.cc: Use them to fix --output=DIR/BASE
authorjanneke <janneke>
Sat, 15 Apr 2006 07:12:33 +0000 (07:12 +0000)
committerjanneke <janneke>
Sat, 15 Apr 2006 07:12:33 +0000 (07:12 +0000)
pdf conversion behaviour.

* flower/file-name.cc (dir_name)
(get_working_directory): Move from relocate.cc.

* lily/relocate.cc (setup_paths): Remove rogue stat calls.

* lily/relocate.cc: Encapsulate sys/stat.h in
HAVE_STAT_H.

ChangeLog
THANKS
flower/file-name.cc
flower/include/file-name.hh
lily/include/relocate.hh
lily/lily-parser-scheme.cc
lily/relocate.cc

index fe4f2669d87264d0f064aa4b876bbea3b540bc1c..ae9e904f4ef301a17c047ab7319bbd027b5ab103 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-04-15  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/lily-parser-scheme.cc: Use them to fix --output=DIR/BASE
+       pdf conversion behaviour.
+
+       * flower/file-name.cc (dir_name)
+       (get_working_directory): Move from relocate.cc.
+
+       * lily/relocate.cc (setup_paths): Remove rogue stat calls.
+       
+       * lily/relocate.cc: Encapsulate sys/stat.h in
+       HAVE_STAT_H.
+
 2006-04-14  Graham Percival  <gpermus@gmail.com>
 
        * Documentation/user/ various: small updates from Cameron
diff --git a/THANKS b/THANKS
index d3911ef02f133fd0807e028f15e495bc036ae4ab..790a69688c6ab1acc17e54d477d0dade2afaae11 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -41,6 +41,7 @@ David Rogers
 J. Leung
 Harald Wellmann
 Orm Finnendahl
+Rick Hansen
 Stephen Carter
 Werner Lemberg
 
index 41b3f96f3e1adda4e2e9de79068dfe955b443e7e..66b1aaa1149a38e03d394966985ffaa7878f1ac6 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <cstdio>
 #include <cerrno>
+#include <unistd.h>
+
 using namespace std;
 
 #include "config.hh"
@@ -63,6 +65,27 @@ slashify (string file_name)
   return file_name;
 }
 
+string
+dir_name (string const file_name)
+{
+  string s = file_name;
+  s = slashify (s);
+  ssize n = s.length ();
+  if (n && s[n - 1] == '/')
+    s[n - 1] = 0;
+  s = s.substr (0, s.rfind ('/'));
+  return s;
+}
+
+string
+get_working_directory ()
+{
+  char cwd[PATH_MAX];
+  getcwd (cwd, PATH_MAX);
+
+  return string (cwd);
+}
+
 /* Join components to full file_name. */
 string
 File_name::to_string () const
index 5fcadc2ce3264faf3b57763854ba2ea14f29337b..edfa72c23f5fe52faf35501a4fe9da28a47bfefa 100644 (file)
@@ -12,6 +12,9 @@
 #include "std-vector.hh"
 #include "std-string.hh"
 
+std::string dir_name (std::string const file_name);
+std::string get_working_directory ();
+
 class File_name
 {
 public:
index 18188e01b5af22ebb6d41da5aacd93f4053d699f..77929598e42bbe41ee4c75926c953bb13dc558e9 100644 (file)
@@ -10,8 +10,6 @@
 #ifndef RELOCATE_HH
 #define RELOCATE_HH
 
-
-
 #include "std-string.hh"
 
 int sane_putenv (char const *key, string value, bool overwrite);
index 7603487665096a28753677ece6aaf5de9d4a121b..1657438212786785c5a37a102f23fa11a76f394c 100644 (file)
@@ -65,20 +65,21 @@ 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);
     }
index aaf8bb4eca48c5ccb2c857109531560ac71655b1..6bfbc8ae5797ff2433fbfd1981ca66ec8887689a 100644 (file)
@@ -11,9 +11,6 @@
 
 #include "config.hh"
 
-#include <sys/stat.h>
-#include <unistd.h>
-
 #if HAVE_GETTEXT
 #include <libintl.h>
 #endif
@@ -81,18 +78,6 @@ prepend_env_path (char const *key, string value)
   return -1;
 }
 
-string
-dir_name (string const file_name)
-{
-  string s = file_name;
-  replace_all (s, '\\', '/');
-  ssize n = s.length ();
-  if (n && s[n - 1] == '/')
-    s[n - 1] = 0;
-  s = s.substr (0, s.rfind ('/'));
-  return s;
-}
-
 #ifdef __MINGW32__
 #include <winbase.h>
 #endif
@@ -175,15 +160,6 @@ framework_relocation (string prefix)
   prepend_env_path ("PATH", bindir);
 }
 
-string
-get_working_directory ()
-{
-  char cwd[PATH_MAX];
-  getcwd (cwd, PATH_MAX);
-
-  return string (cwd);
-}
-
 void
 setup_paths (char const *argv0_ptr)
 {
@@ -274,14 +250,12 @@ setup_paths (char const *argv0_ptr)
 
   */
   
-  struct stat statbuf;
   string build_prefix_current = prefix_directory + "/share/lilypond/" "current";
   string build_prefix_version = prefix_directory + "/share/lilypond/" TOPLEVEL_VERSION;
-  if (stat (build_prefix_version.c_str (), &statbuf) == 0)
+  if (is_dir (build_prefix_version.c_str ()))
     prefix_directory = build_prefix_version;
-  else if (stat (build_prefix_current.c_str (), &statbuf) == 0)
+  else if (is_dir (build_prefix_current.c_str ()))
     prefix_directory = build_prefix_current;
-
   
   /* Adding mf/out make lilypond unchanged source directory, when setting
      LILYPONDPREFIX to lilypond-x.y.z */