X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Frelocate.cc;h=879377a1cc0928bae14c6fd92c5fd8f032eacac2;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=3b6a57b715c2e3fbbc06bc3a06676d3c8d581732;hpb=2b0cfa199b39f9d5c94baa6a1f190348bd18ea84;p=lilypond.git diff --git a/lily/relocate.cc b/lily/relocate.cc index 3b6a57b715..879377a1cc 100644 --- a/lily/relocate.cc +++ b/lily/relocate.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2005--2012 Han-Wen Nienhuys + Copyright (C) 2005--2015 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,10 +39,14 @@ #include "version.hh" #include "warn.hh" +#ifdef __MINGW32__ +#include +#endif + #define FRAMEWORKDIR ".." int -sane_putenv (char const *key, string value, bool overwrite) +sane_putenv (char const *key, const string &value, bool overwrite) { if (overwrite || !getenv (key)) { @@ -64,7 +68,7 @@ sane_putenv (char const *key, string value, bool overwrite) } static int -set_env_file (char const *key, string value, bool overwrite = false) +set_env_file (char const *key, const string &value, bool overwrite = false) { if (is_file (value)) return sane_putenv (key, value, overwrite); @@ -75,7 +79,7 @@ set_env_file (char const *key, string value, bool overwrite = false) } static int -set_env_dir (char const *key, string value) +set_env_dir (char const *key, const string &value) { if (is_dir (value)) return sane_putenv (key, value, false); @@ -103,12 +107,8 @@ prepend_env_path (char const *key, string value) return -1; } -#ifdef __MINGW32__ -#include -#endif - static void -prefix_relocation (string prefix) +prefix_relocation (const string &prefix) { string bindir = prefix + "/bin"; string datadir = prefix + "/share"; @@ -141,7 +141,7 @@ prefix_relocation (string prefix) */ static void -framework_relocation (string prefix) +framework_relocation (const string &prefix) { debug_output (_f ("Relocation: framework_prefix=%s", prefix)); @@ -181,7 +181,9 @@ setup_paths (char const *argv0_ptr) { /* Find absolute ARGV0 name, using PATH. */ File_path path; - path.parse_path (getenv ("PATH")); + char *p = getenv ("PATH"); + if (p) + path.parse_path (p); #ifndef __MINGW32__ argv0_abs = path.find (argv0_filename.to_string ()); @@ -212,9 +214,8 @@ setup_paths (char const *argv0_ptr) prefix_directory = bindir + "/" + FRAMEWORKDIR; } - lilypond_datadir = prefix_directory - + "/share/lilypond/" TOPLEVEL_VERSION; + + "/share/lilypond/" TOPLEVEL_VERSION; } if (getenv ("LILYPONDPREFIX")) @@ -258,7 +259,7 @@ setup_paths (char const *argv0_ptr) } string -expand_environment_variables (string orig) +expand_environment_variables (const string &orig) { char const *start_ptr = orig.c_str (); char const *ptr = orig.c_str (); @@ -341,7 +342,7 @@ read_line (FILE *f) } void -read_relocation_file (string filename) +read_relocation_file (const string &filename) { debug_output (_f ("Relocation file: %s", filename.c_str ()) + "\n"); char const *cname = filename.c_str (); @@ -384,7 +385,7 @@ read_relocation_file (string filename) } void -read_relocation_dir (string dirname) +read_relocation_dir (const string &dirname) { if (DIR *dir = opendir (dirname.c_str ())) while (struct dirent *ent = readdir (dir))