]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/relocate.cc
robust_scm2fraction
[lilypond.git] / lily / relocate.cc
index 8cb2b0861f25636ad4a01b3d603777e47f892a5a..47502f7dbda9f054f9524c0587763cf5b26bc91b 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
 */
 
@@ -41,9 +41,15 @@ sane_putenv (char const *key, string value, bool overwrite)
       char *s = strdup (combine.c_str ());
 
       if (be_verbose_global)
-       progress_indication (_f ("Setting %s to %s\n" , key, value.c_str ())); 
+       progress_indication (_f ("Setting %s to %s" , key, value.c_str ())
+                            + "\n");
                             
-      return putenv (s);
+      int retval =  putenv (s);
+      /*
+       unfortunately, we can't portably free S here,
+       due to various bugs in glibc prior to 2.1.1
+       */ 
+      return retval;
     }
   
   return -1;
@@ -192,7 +198,7 @@ setup_paths (char const *argv0_ptr)
 #endif /* __MINGW32__ */
 
          if (argv0_abs.empty ())
-           programming_error ("can't find absolute argv0.");
+           programming_error ("cannot find absolute argv0");
        }
 
       string bindir = dir_name (argv0_abs);
@@ -227,11 +233,7 @@ setup_paths (char const *argv0_ptr)
   /*
     When running from build dir, a full LILYPOND_PREFIX is set-up at
 
-        $(OUTBASE)/share/lilypond/TOPLEVEL_VERSION
-
-     This historical hack will allow the shorthand
-
-        LILYPONDPREFIX=out lily/out/lilypond ...
+        $(OUTBASE)/{share,lib}/lilypond/current
 
   */
   
@@ -350,12 +352,13 @@ void
 read_relocation_file (string filename)
 {
   if (be_verbose_global)
-    progress_indication (_f ("Relocation file %s\n", filename.c_str ()));
+    progress_indication (_f ("Relocation file: %s", filename.c_str ())
+                        + "\n");
       
   char const *cname = filename.c_str ();
   FILE *f = fopen (cname, "r");
   if (!f)
-    error (_f ("can't open file %s", cname));
+    error (_f ("cannot open file: `%s'", cname));
 
   while (!feof (f))
     {
@@ -385,7 +388,7 @@ read_relocation_file (string filename)
       else if (command == "prependdir")
        prepend_env_path (variable.c_str (), value);
       else
-       error ( _f("Unknown relocation command %s", command));
+       error (_f ("Unknown relocation command %s", command));
     }
 
   fclose (f);
@@ -394,14 +397,11 @@ read_relocation_file (string filename)
 void
 read_relocation_dir (string dirname)
 {
-  DIR *dir = opendir  (dirname.c_str ());
-
-  while (struct dirent *ent = readdir (dir))
-    {
-      File_name name (ent->d_name);
-      if (name.ext_ == "reloc")
-       {
-         read_relocation_file (dirname + "/" + name.to_string ());
-       }
-    }
+  if (DIR *dir = opendir (dirname.c_str ()))
+    while (struct dirent *ent = readdir (dir))
+      {
+       File_name name (ent->d_name);
+       if (name.ext_ == "reloc")
+           read_relocation_file (dirname + "/" + name.to_string ());
+      }
 }