From 79f0c1f29cd183ec13e263e779542814d2264369 Mon Sep 17 00:00:00 2001 From: janneke Date: Fri, 3 Jun 2005 12:52:34 +0000 Subject: [PATCH] * lily/main.cc (setup_localisation): Listen to LILYPOND_LOCALEDIR. * flower/file-path.cc (is_file, is_dir): Export. * lily/main.cc (prepend_env_path, set_env_file): Use them. --- ChangeLog | 8 +++++ flower/file-path.cc | 5 ++- flower/include/file-path.hh | 3 ++ lily/main.cc | 62 +++++++++++++++++++++++++++++-------- 4 files changed, 62 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec307e5f99..7e882f1286 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-06-03 Jan Nieuwenhuizen + + * lily/main.cc (setup_localisation): Listen to LILYPOND_LOCALEDIR. + + * flower/file-path.cc (is_file, is_dir): Export. + + * lily/main.cc (prepend_env_path, set_env_file): Use them. + 2005-06-02 Mats Bengtsson * lily/easy-notation.cc: Added include cctype to correct diff --git a/flower/file-path.cc b/flower/file-path.cc index 783b1095ea..727ea046ca 100644 --- a/flower/file-path.cc +++ b/flower/file-path.cc @@ -48,7 +48,7 @@ File_path::parse_path (String p) } } -static bool +bool is_file (String file_name) { #if 0 /* Check if directory. TODO: encapsulate for autoconf */ @@ -79,7 +79,7 @@ is_file (String file_name) return false; } -static bool +bool is_dir (String file_name) { #if !STAT_MACROS_BROKEN @@ -98,7 +98,6 @@ is_dir (String file_name) return false; } - /** Find a file. Check absolute file name, search in the current dir (DUH! FIXME!), diff --git a/flower/include/file-path.hh b/flower/include/file-path.hh index 37a4b6c2b1..918b981cf3 100644 --- a/flower/include/file-path.hh +++ b/flower/include/file-path.hh @@ -35,4 +35,7 @@ public: void prepend (String str); }; +bool is_file (String file_name); +bool is_dir (String file_name); + #endif /* FILE_PATH */ diff --git a/lily/main.cc b/lily/main.cc index 4c8af368e0..f8b0343eef 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -269,12 +269,26 @@ sane_putenv (char const* key, String value, bool overwrite = true) return -1; } +static int +set_env_file (char const* key, String value) +{ + if (is_file (value)) + return sane_putenv (key, value, false); + else if (be_verbose_global) + warning (_f ("no such file: %s", value)); + return -1; +} + static int prepend_env_path (char const *key, String value) { if (char const* cur = getenv (key)) value += to_string (PATHSEP) + cur; - return sane_putenv (key, value.to_str0 ()); + if (is_dir (value + "/")) + return sane_putenv (key, value.to_str0 ()); + else if (be_verbose_global) + warning (_f ("no such directory: %s", value)); + return -1; } String @@ -297,38 +311,58 @@ setup_paths (char const* argv0) prefix_directory = LILYPOND_DATADIR; #if ARGV0_RELOCATION + + if (getenv ("LILYPOND_VERBOSE")) + be_verbose_global = true; + String bindir = dir_name (argv0); String argv0_prefix = dir_name (bindir); if (argv0_prefix != dir_name (dir_name (dir_name (prefix_directory)))) { -#if 0 - warning (_f ("argv0 relocation: argv0=%s, prefix=%s", argv0, - prefix_directory)); -#endif + if (be_verbose_global) + warning (_f ("argv0 relocation: argv0=%s, prefix=%s", argv0, + prefix_directory)); String datadir = argv0_prefix + "/share"; String libdir = argv0_prefix + "/lib"; + String localedir = argv0_prefix + "/locale"; String sysconfdir = argv0_prefix + "/etc"; - prefix_directory = datadir + "/lilypond/" TOPLEVEL_VERSION; + String argv0_lilypond_datadir = datadir + "/lilypond/" TOPLEVEL_VERSION; - sane_putenv ("FONTCONFIG_FILE", sysconfdir + "/fonts/fonts.conf", false); + if (is_dir (argv0_lilypond_datadir)) + prefix_directory = argv0_lilypond_datadir; + +#if HAVE_GETTEXT + if (is_dir (localedir)) + bindtextdomain ("lilypond", localedir.to_str0 ()); +#endif + + set_env_file ("FONTCONFIG_FILE", sysconfdir + "/fonts/fonts.conf"); #ifdef __MINGW32__ char font_dir[PATH_MAX]; ExpandEnvironmentStrings ("%windir%/fonts", font_dir, sizeof (font_dir)); prepend_env_path ("GS_FONTPATH", font_dir); #endif + + /* FIXME: *cough* 8.15 *cough* */ + prepend_env_path ("GS_FONTPATH", datadir + "/ghostscript/8.15/fonts"); + prepend_env_path ("GS_LIB", datadir + "/ghostscript/8.15/Resource"); + prepend_env_path ("GS_LIB", datadir + "/ghostscript/8.15/lib"); + prepend_env_path ("GS_FONTPATH", datadir + "/gs/fonts"); prepend_env_path ("GS_LIB", datadir + "/gs/Resource"); prepend_env_path ("GS_LIB", datadir + "/gs/lib"); + prepend_env_path ("GUILE_LOAD_PATH", datadir + to_string ("/guile/%d.%d", SCM_MAJOR_VERSION, SCM_MINOR_VERSION)); - sane_putenv ("PANGO_RC_FILE", sysconfdir + "/pango/pangorc", false); + set_env_file ("PANGO_RC_FILE", sysconfdir + "/pango/pangorc"); prepend_env_path ("PATH", bindir); } #else (void) argv0; #endif /* ARGV0_RELOCATION */ - + + /* FIXME: use LILYPOND_DATADIR. */ if (char const *env = getenv ("LILYPONDPREFIX")) { #ifdef __MINGW32__ @@ -553,10 +587,12 @@ setup_localisation () Disable localisation of float values. This breaks TeX output. */ setlocale (LC_NUMERIC, "C"); - String name (PACKAGE); - name.to_lower (); - bindtextdomain (name.to_str0 (), LOCALEDIR); - textdomain (name.to_str0 ()); + String localedir = LOCALEDIR; + if (char const *env = getenv ("LILYPOND_LOCALEDIR")) + localedir = env; + + bindtextdomain ("lilypond", localedir.to_str0 ()); + textdomain ("lilypond"); #endif } -- 2.39.5