]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/relocate.cc (setup_paths): only check path for non-absolute
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 21 Dec 2005 00:53:50 +0000 (00:53 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 21 Dec 2005 00:53:50 +0000 (00:53 +0000)
dir without directory part.

* flower/file-name.cc (is_absolute):  new method.
(is_absolute): check root_ too.

ChangeLog
flower/file-name.cc
lily/relocate.cc

index b332770ce92a265142d701de60a9c0fa70bb44b4..46dc6f460c26f0e3f7b67e545821a0107fc99914 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 2005-12-21  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/relocate.cc (setup_paths): only check path for non-absolute
+       dir without directory part.
+
        * flower/file-name.cc (is_absolute):  new method.
+       (is_absolute): check root_ too.
 
 2005-12-21  Jan Nieuwenhuizen  <janneke@gnu.org>
 
index 3f5318678f0ecd7c730773901cd87fb2cc70b957..be5e6d047ddb6e013ffeacbb7ed86d2fab332423 100644 (file)
@@ -120,5 +120,8 @@ File_name::File_name (String file_name)
 bool
 File_name::is_absolute () const
 {
-  return (dir_[0] == DIRSEP);
+  /*
+    Hmm. Is c:foo absolute?  
+   */
+  return (dir_.length () && dir_[0] == DIRSEP) || root_.length ();
 }
index 0c241aeea72037c585070e240a1607fcaf252a02..0fae879b518249ed4cd0656c9ca27b91faba0b1a 100644 (file)
@@ -139,10 +139,11 @@ get_working_directory ()
 }
 
 void
-setup_paths (char const *argv0)
+setup_paths (char const *argv0_ptr)
 {
-  prefix_directory = LILYPOND_DATADIR;
+  File_name argv0_filename (argv0_ptr);
   
+  prefix_directory = LILYPOND_DATADIR;
   if (relocate_binary
       && getenv ("LILYPOND_RELOCATE_PREFIX"))
     {
@@ -150,34 +151,16 @@ setup_paths (char const *argv0)
       /*
        fixme: need different sep for mingw? 
       */
-      set_relocation (prefix + "/bin", prefix);
+      set_relocation (prefix + "/" + "bin", prefix);
     }
   else if (relocate_binary)
     {
-#if defined (__CYGWIN__) || defined (__MINGW32__)
-      String s = argv0;
-      s.substitute ('\\', '/');
-      argv0 = s.to_str0 ();
-#endif /* __CYGWIN__ || __MINGW32__ */
-
-
-#ifndef __MINGW32__
-
-      /* FIXME, this is broken.
-       what is this supposed to do?
-
-       argv0[0]==/ is not a universal test for absolute files, see
-       below for File_name.dir_[0] .
-      */
-
-      /* if name contains slashes, we should not look in $PATH */
       String argv0_abs;
-      if (argv0[0] == '/')
+      if (argv0_filename.is_absolute ())
        argv0_abs = argv0_abs;
-      else if (String (argv0).index ('/') > 0)
-       argv0_abs = get_working_directory () + "/" + String (argv0);
+      else if (argv0_filename.dir_.length ())
+       argv0_abs = get_working_directory () + "/" + String (argv0_filename.to_string ());
       else
-#endif
        {
          /* Find absolute ARGV0 name, using PATH.  */
          File_path path;
@@ -185,33 +168,22 @@ setup_paths (char const *argv0)
 
       
 #ifndef __MINGW32__
-         String argv0_abs = path.find (argv0);
+         String argv0_abs = path.find (argv0_filename.to_string ());
 #else /* __MINGW32__ */
          char const *ext[] = {"exe", "", 0 };
-         String argv0_abs = path.find (argv0, ext);
+         String argv0_abs = path.find (argv0_filename.to_string (), ext);
 #endif /* __MINGW32__ */
 
          if (argv0_abs.is_empty ())
-           {
-             File_name name (argv0);
-             /* If NAME contains slashes and its DIR is not absolute, it can
-                only be referenced from CWD.  */
-             if (name.to_string ().index ('/') >= 0 && name.dir_[0] != '/')
-               {
-                 argv0_abs =  get_working_directory () + "/" + argv0;
-               }
-             else
-               programming_error ("can't find absolute argv0");
-           }
+           programming_error ("can't find absolute argv0.");
        }
+
       
       String bindir = dir_name (argv0_abs);
       String argv0_prefix = dir_name (bindir);
       if (argv0_prefix != dir_name (dir_name (dir_name (prefix_directory))))
        set_relocation (bindir, argv0_prefix);
     }
-  else
-    (void) argv0;
 
   /* FIXME: use LILYPOND_DATADIR.  */
   if (char const *env = getenv ("LILYPONDPREFIX"))