]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/relocate.cc
Merge with master
[lilypond.git] / lily / relocate.cc
index d7f7888c4a6ecdf7e2d0401b8be4af941caecd26..635b4165c9b2039bdda7fe8654795665ff81beaa 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
 
   */
   
@@ -266,9 +268,9 @@ setup_paths (char const *argv0_ptr)
 string
 expand_environment_variables (string orig)
 {
-  const char *start_ptr = orig.c_str();
-  const char *ptr = orig.c_str();
-  size_t len = orig.length();
+  const char *start_ptr = orig.c_str ();
+  const char *ptr = orig.c_str ();
+  size_t len = orig.length ();
 
   string out;
   while (ptr < start_ptr + len)
@@ -316,7 +318,7 @@ expand_environment_variables (string orig)
          if (start_var < end_var)
            {
              string var_name (start_var, end_var - start_var);
-             const char *value = getenv (var_name.c_str());
+             const char *value = getenv (var_name.c_str ());
              if (value != NULL)
                out += string (value);
 
@@ -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))
     {
@@ -377,15 +380,15 @@ read_relocation_file (string filename)
       value = expand_environment_variables (value);
 
       if (command == "set")
-       sane_putenv (variable.c_str(), value, true);
+       sane_putenv (variable.c_str (), value, true);
       else if (command == "setdir")
-       set_env_dir (variable.c_str(), value);
+       set_env_dir (variable.c_str (), value);
       else if (command == "setfile")
-       set_env_file (variable.c_str(), value);
+       set_env_file (variable.c_str (), value);
       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);