Mercurial > octave
changeset 25439:69fc8935020b
move some static configuration variables inside a class
* defaults.h, defaults.cc: Move static configuration variables inside
a new installation_data class with access methods instead of a set of
global functions to access the static data.
* interpreter.h, interpreter.cc (interpreter::m_installation_data,
interpreter::get_installation_data): New data member and access
method. Change all uses of these configuration values to access them
through the interpreter object.
* interpreter-private.h, interpreter-private.cc
(__get_installation_data__): New function.
line wrap: on
line diff
--- a/libgui/src/documentation.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libgui/src/documentation.cc Fri Jun 08 13:42:34 2018 -0400 @@ -46,6 +46,7 @@ #include <QVBoxLayout> #include "documentation.h" +#include "interpreter-private.h" #include "resource-manager.h" #include "shortcut-manager.h" @@ -62,9 +63,15 @@ // Get original collection QString collection = getenv ("OCTAVE_QTHELP_COLLECTION"); if (collection.isEmpty ()) - collection = QString::fromStdString (config::oct_doc_dir () - + sys::file_ops::dir_sep_str () - + "octave_interpreter.qhc"); + { + // Hmm. + installation_data& inst_data + = __get_installation_data__ ("documentation::documentation"); + + collection = QString::fromStdString (inst_data.oct_doc_dir () + + sys::file_ops::dir_sep_str () + + "octave_interpreter.qhc"); + } // Setup the help engine with the original collection, use a writable copy // of the original collection and load the help data
--- a/libgui/src/main-window.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libgui/src/main-window.cc Fri Jun 08 13:42:34 2018 -0400 @@ -461,7 +461,10 @@ { if (! m_release_notes_window) { - std::string news_file = config::oct_etc_dir () + "/NEWS"; + installation_data& inst_data + = __get_installation_data__ ("main_window::display_release_notes"); + + std::string news_file = inst_data.oct_etc_dir () + "/NEWS"; QString news;
--- a/libgui/src/resource-manager.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libgui/src/resource-manager.cc Fri Jun 08 13:42:34 2018 -0400 @@ -42,6 +42,7 @@ #include "oct-env.h" #include "defaults.h" +#include "interpreter-private.h" #include "QTerminal.h" #include "workspace-model.h" @@ -58,9 +59,15 @@ std::string dsf = sys::env::getenv ("OCTAVE_DEFAULT_QT_SETTINGS"); if (dsf.empty ()) - dsf = (config::oct_etc_dir () - + sys::file_ops::dir_sep_str () - + "default-qt-settings"); + { + // Hmm. + installation_data& inst_data + = __get_installation_data__ ("default_qt_settings_file"); + + dsf = (inst_data.oct_etc_dir () + + sys::file_ops::dir_sep_str () + + "default-qt-settings"); + } return QString::fromStdString (dsf); } @@ -96,7 +103,15 @@ // get environment variable for the locale dir (e.g. from run-octave) std::string dldir = sys::env::getenv ("OCTAVE_LOCALE_DIR"); if (dldir.empty ()) - dldir = config::oct_locale_dir (); // env-var empty, load the default location + { + // Hmm. + installation_data& inst_data + = __get_installation_data__ ("resource_manager::get_gui_translation_dir"); + + // env-var empty, load the default location + dldir = inst_data.oct_locale_dir (); + } + return QString::fromStdString (dldir); }
--- a/libinterp/corefcn/defaults.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/defaults.cc Fri Jun 08 13:42:34 2018 -0400 @@ -37,6 +37,8 @@ #include "defun.h" #include "error.h" #include "file-ops.h" +#include "interpreter-private.h" +#include "interpreter.h" #include "ovl.h" #include "ov.h" #include "variables.h" @@ -44,56 +46,6 @@ #include "default-defs.h" -static bool initialized = false; - -static std::string Voctave_home; -static std::string Voctave_exec_home; - -static std::string Vbin_dir; -static std::string Vdata_dir; -static std::string Vdataroot_dir; -static std::string Vinclude_dir; -static std::string Vlib_dir; -static std::string Vlibexec_dir; - -static std::string Vlocal_ver_arch_lib_dir; -static std::string Vlocal_api_arch_lib_dir; -static std::string Vlocal_arch_lib_dir; -static std::string Varch_lib_dir; - -static std::string Vlocal_ver_oct_file_dir; -static std::string Vlocal_api_oct_file_dir; -static std::string Vlocal_oct_file_dir; -static std::string Voct_file_dir; - -static std::string Vlocal_ver_fcn_file_dir; -static std::string Vlocal_api_fcn_file_dir; -static std::string Vlocal_fcn_file_dir; -static std::string Vfcn_file_dir; - -static std::string Voct_data_dir; -static std::string Voct_doc_dir; -static std::string Voct_etc_dir; -static std::string Voct_fonts_dir; -static std::string Voct_include_dir; -static std::string Voct_lib_dir; -static std::string Voct_locale_dir; -static std::string Voct_tests_dir; - -static std::string Vinfo_dir; - -static std::string Vman_dir; -static std::string Vman1_dir; -static std::string Vman1_ext; - -static std::string Vimage_dir; - -static std::string Vlocal_startupfile_dir; -static std::string Vstartupfile_dir; - -static std::string Vlocal_site_defaults_file; -static std::string Vsite_defaults_file; - // Variables that name directories or files are substituted into source // files with "${prefix}/" stripped from the beginning of the string. @@ -101,224 +53,490 @@ // directory names. The only ones that should not be absolute here are // ones that have had "${prefix}/" or "${exec_prefix} stripped. -static std::string -prepend_home_dir (const std::string& hd, const std::string& s) +namespace octave { - std::string retval = s; + static std::string + prepend_dir (const std::string& dir, const std::string& s) + { + std::string retval = s; + + char dir_sep_char = octave::sys::file_ops::dir_sep_char (); + + if (! octave::sys::env::absolute_pathname (retval)) + retval = dir + dir_sep_char + s; + + if (dir_sep_char != '/') + std::replace (retval.begin (), retval.end (), '/', dir_sep_char); + + return retval; + } + + installation_data::installation_data (void) + { + m_canonical_host_type = OCTAVE_CANONICAL_HOST_TYPE; + m_release = OCTAVE_RELEASE; + m_default_pager = OCTAVE_DEFAULT_PAGER; + + // OCTAVE_HOME must be set before other variables that depend on it. + + set_home (); + + m_bin_dir = prepend_exec_home (OCTAVE_BINDIR); + m_data_dir = prepend_home (OCTAVE_DATADIR); + m_dataroot_dir = prepend_home (OCTAVE_DATAROOTDIR); + m_include_dir = prepend_home (OCTAVE_INCLUDEDIR); + m_lib_dir = prepend_exec_home (OCTAVE_LIBDIR); + m_libexec_dir = prepend_exec_home (OCTAVE_LIBEXECDIR); + + m_local_ver_arch_lib_dir + = prepend_exec_home (OCTAVE_LOCALVERARCHLIBDIR); + m_local_api_arch_lib_dir + = prepend_exec_home (OCTAVE_LOCALAPIARCHLIBDIR); + m_local_arch_lib_dir = prepend_exec_home (OCTAVE_LOCALARCHLIBDIR); + m_arch_lib_dir = prepend_exec_home (OCTAVE_ARCHLIBDIR); + + m_local_ver_oct_file_dir + = prepend_exec_home (OCTAVE_LOCALVEROCTFILEDIR); + m_local_api_oct_file_dir + = prepend_exec_home (OCTAVE_LOCALAPIOCTFILEDIR); + m_local_oct_file_dir = prepend_exec_home (OCTAVE_LOCALOCTFILEDIR); + m_oct_file_dir = prepend_exec_home (OCTAVE_OCTFILEDIR); + + m_local_ver_fcn_file_dir = prepend_home (OCTAVE_LOCALVERFCNFILEDIR); + m_local_api_fcn_file_dir = prepend_home (OCTAVE_LOCALAPIFCNFILEDIR); + m_local_fcn_file_dir = prepend_home (OCTAVE_LOCALFCNFILEDIR); + m_fcn_file_dir = prepend_home (OCTAVE_FCNFILEDIR); - char dir_sep_char = octave::sys::file_ops::dir_sep_char (); + m_oct_data_dir = prepend_home (OCTAVE_OCTDATADIR); + m_oct_doc_dir = prepend_home (OCTAVE_OCTDOCDIR); + m_oct_etc_dir = prepend_home (OCTAVE_OCTETCDIR); + m_oct_fonts_dir = prepend_home (OCTAVE_OCTFONTSDIR); + m_oct_include_dir = prepend_home (OCTAVE_OCTINCLUDEDIR); + m_oct_lib_dir = prepend_exec_home (OCTAVE_OCTLIBDIR); + m_oct_locale_dir = prepend_home (OCTAVE_OCTLOCALEDIR); + m_oct_tests_dir = prepend_home (OCTAVE_OCTTESTSDIR); + + m_info_dir = prepend_home (OCTAVE_INFODIR); + + m_man_dir = prepend_home (OCTAVE_MANDIR); + m_man1_dir = prepend_home (OCTAVE_MAN1DIR); + m_man1_ext = OCTAVE_MAN1EXT; + + m_image_dir = prepend_home (OCTAVE_IMAGEDIR); + + m_local_startupfile_dir = prepend_home (OCTAVE_LOCALSTARTUPFILEDIR); + m_startupfile_dir = prepend_home (OCTAVE_STARTUPFILEDIR); + + set_local_site_defaults_file (); + + set_site_defaults_file (); + } + + std::string installation_data::prepend_home (const std::string& s) const + { + return prepend_dir (m_home, s); + } - if (! octave::sys::env::absolute_pathname (retval)) - retval = hd + dir_sep_char + s; + std::string installation_data::prepend_exec_home (const std::string& s) const + { + return prepend_dir (m_exec_home, s); + } + + void installation_data::set_home (void) + { + std::string op = OCTAVE_PREFIX; + std::string oep = OCTAVE_EXEC_PREFIX; + + std::string oh = sys::env::getenv ("OCTAVE_HOME"); + std::string oeh = sys::env::getenv ("OCTAVE_EXEC_HOME"); + + // If OCTAVE_HOME is set in the enviornment, use that. Otherwise, + // default to ${prefix} from configure. - if (dir_sep_char != '/') - std::replace (retval.begin (), retval.end (), '/', dir_sep_char); + m_home = (oh.empty () ? op : oh); + + // If OCTAVE_EXEC_HOME is set in the environment, use that. + // Otherwise, if ${prefix} and ${exec_prefix} from configure are set + // to the same value, use OCTAVE_HOME from the environment if it is set. + // Othewise, default to ${exec_prefix} from configure. + + if (! oeh.empty ()) + m_exec_home = oeh; + else + { + if (op == oep && ! oh.empty ()) + m_exec_home = oh; + else + m_exec_home = oep; + } + } - return retval; -} + void installation_data::set_local_site_defaults_file (void) + { + std::string lsf = sys::env::getenv ("OCTAVE_SITE_INITFILE"); + + if (lsf.empty ()) + m_local_site_defaults_file = m_local_startupfile_dir + "/octaverc"; + else + m_local_site_defaults_file = lsf; + } + + void installation_data::set_site_defaults_file (void) + { + std::string sf = sys::env::getenv ("OCTAVE_VERSION_INITFILE"); + + if (sf.empty ()) + m_site_defaults_file = m_startupfile_dir + "/octaverc"; + else + m_site_defaults_file = sf; + } + +#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) + + namespace config + { + std::string prepend_octave_home (const std::string& s) + { + installation_data& inst_data + = __get_installation_data__ ("prepend_octave_home"); + + return inst_data.prepend_home (s); + } + + std::string prepend_octave_exec_home (const std::string& s) + { + installation_data& inst_data + = __get_installation_data__ ("prepend_octave_exec_home"); + + return inst_data.prepend_exec_home (s); + } + + std::string canonical_host_type (void) + { + installation_data& inst_data + = __get_installation_data__ ("canonical_host_type"); + + return inst_data.canonical_host_type (); + } + + std::string release (void) + { + installation_data& inst_data + = __get_installation_data__ ("release"); + + return inst_data.release (); + } -static void -set_octave_home (void) -{ - std::string op = OCTAVE_PREFIX; - std::string oep = OCTAVE_EXEC_PREFIX; + std::string default_pager (void) + { + installation_data& inst_data + = __get_installation_data__ ("default_pager"); + + return inst_data.default_pager (); + } + + std::string octave_home (void) + { + installation_data& inst_data + = __get_installation_data__ ("octave_home"); + + return inst_data.home (); + } + + std::string octave_exec_home (void) + { + installation_data& inst_data + = __get_installation_data__ ("octave_exec_home"); + + return inst_data.exec_home (); + } + + std::string bin_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("bin_dir"); + + return inst_data.bin_dir (); + } - std::string oh = octave::sys::env::getenv ("OCTAVE_HOME"); - std::string oeh = octave::sys::env::getenv ("OCTAVE_EXEC_HOME"); + std::string data_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("data_dir"); + + return inst_data.data_dir (); + } + + std::string dataroot_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("dataroot_dir"); + + return inst_data.dataroot_dir (); + } - // If OCTAVE_HOME is set in the enviornment, use that. Otherwise, - // default to ${prefix} from configure. + std::string include_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("include_dir"); + + return inst_data.include_dir (); + } - Voctave_home = (oh.empty () ? op : oh); + std::string lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("lib_dir"); + + return inst_data.lib_dir (); + } - // If OCTAVE_EXEC_HOME is set in the environment, use that. - // Otherwise, if ${prefix} and ${exec_prefix} from configure are set - // to the same value, use OCTAVE_HOME from the environment if it is set. - // Othewise, default to ${exec_prefix} from configure. + std::string libexec_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("libexec_dir"); + + return inst_data.libexec_dir (); + } + + std::string arch_lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("arch_lib_dir"); + + return inst_data.arch_lib_dir (); + } + + std::string info_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("info_dir"); + + return inst_data.info_dir (); + } + + std::string local_ver_arch_lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_ver_arch_lib_dir"); + + return inst_data.local_ver_arch_lib_dir (); + } + + std::string local_api_arch_lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_api_arch_lib_dir"); + + return inst_data.local_api_arch_lib_dir (); + } + + std::string local_arch_lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_arch_lib_dir"); + + return inst_data.local_arch_lib_dir (); + } + + std::string local_ver_oct_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_ver_oct_file_dir"); + + return inst_data.local_ver_oct_file_dir (); + } - if (! oeh.empty ()) - Voctave_exec_home = oeh; - else + std::string local_api_oct_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_api_oct_file_dir"); + + return inst_data.local_api_oct_file_dir (); + } + + std::string local_oct_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_oct_file_dir"); + + return inst_data.local_oct_file_dir (); + } + + std::string oct_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_file_dir"); + + return inst_data.oct_file_dir (); + } + + std::string local_ver_fcn_file_dir (void) { - if (op == oep && ! oh.empty ()) - Voctave_exec_home = oh; - else - Voctave_exec_home = oep; + installation_data& inst_data + = __get_installation_data__ ("local_ver_fcn_file_dir"); + + return inst_data.local_ver_fcn_file_dir (); + } + + std::string local_api_fcn_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_api_fcn_file_dir"); + + return inst_data.local_api_fcn_file_dir (); } -} + + std::string local_fcn_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_fcn_file_dir"); + + return inst_data.local_fcn_file_dir (); + } + + std::string fcn_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("fcn_file_dir"); + + return inst_data.fcn_file_dir (); + } + + std::string oct_data_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_data_dir"); + + return inst_data.oct_data_dir (); + } -static void -set_local_site_defaults_file (void) -{ - std::string lsf = octave::sys::env::getenv ("OCTAVE_SITE_INITFILE"); + std::string oct_doc_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_doc_dir"); + + return inst_data.oct_doc_dir (); + } + + std::string oct_etc_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_etc_dir"); + + return inst_data.oct_etc_dir (); + } + + std::string oct_fonts_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_fonts_dir"); + + return inst_data.oct_fonts_dir (); + } + + std::string oct_include_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_include_dir"); + + return inst_data.oct_include_dir (); + } + + std::string oct_lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_lib_dir"); + + return inst_data.oct_lib_dir (); + } + + std::string oct_locale_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_locale_dir"); + + return inst_data.oct_locale_dir (); + } + + std::string oct_tests_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_tests_dir"); + + return inst_data.oct_tests_dir (); + } + + std::string man_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("man_dir"); - if (lsf.empty ()) - Vlocal_site_defaults_file = Vlocal_startupfile_dir + "/octaverc"; - else - Vlocal_site_defaults_file = lsf; -} + return inst_data.man_dir (); + } + + std::string man1_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("man1_dir"); + + return inst_data.man1_dir (); + } + + std::string man1_ext (void) + { + installation_data& inst_data + = __get_installation_data__ ("man1_ext"); + + return inst_data.man1_ext (); + } + + std::string image_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("image_dir"); + + return inst_data.image_dir (); + } -static void -set_site_defaults_file (void) -{ - std::string sf = octave::sys::env::getenv ("OCTAVE_VERSION_INITFILE"); + std::string local_startupfile_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_startupfile_dir"); + + return inst_data.local_startupfile_dir (); + } + + std::string startupfile_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("startupfile_dir"); + + return inst_data.startupfile_dir (); + } - if (sf.empty ()) - Vsite_defaults_file = Vstartupfile_dir + "/octaverc"; - else - Vsite_defaults_file = sf; + std::string local_site_defaults_file (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_site_defaults_file"); + + return inst_data.local_site_defaults_file (); + } + + std::string site_defaults_file (void) + { + installation_data& inst_data + = __get_installation_data__ ("site_defaults_file"); + + return inst_data.site_defaults_file (); + } + } + +#endif } -static void -init_defaults (void) -{ - if (initialized) - return; - - // OCTAVE_HOME must be set first! - - set_octave_home (); - - Vbin_dir = octave::config::prepend_octave_exec_home (OCTAVE_BINDIR); - Vdata_dir = octave::config::prepend_octave_home (OCTAVE_DATADIR); - Vdataroot_dir = octave::config::prepend_octave_home (OCTAVE_DATAROOTDIR); - Vinclude_dir = octave::config::prepend_octave_home (OCTAVE_INCLUDEDIR); - Vlib_dir = octave::config::prepend_octave_exec_home (OCTAVE_LIBDIR); - Vlibexec_dir = octave::config::prepend_octave_exec_home (OCTAVE_LIBEXECDIR); - - Vlocal_ver_arch_lib_dir - = octave::config::prepend_octave_exec_home (OCTAVE_LOCALVERARCHLIBDIR); - Vlocal_api_arch_lib_dir - = octave::config::prepend_octave_exec_home (OCTAVE_LOCALAPIARCHLIBDIR); - Vlocal_arch_lib_dir - = octave::config::prepend_octave_exec_home (OCTAVE_LOCALARCHLIBDIR); - Varch_lib_dir = octave::config::prepend_octave_exec_home (OCTAVE_ARCHLIBDIR); - - Vlocal_ver_oct_file_dir - = octave::config::prepend_octave_exec_home (OCTAVE_LOCALVEROCTFILEDIR); - Vlocal_api_oct_file_dir - = octave::config::prepend_octave_exec_home (OCTAVE_LOCALAPIOCTFILEDIR); - Vlocal_oct_file_dir - = octave::config::prepend_octave_exec_home (OCTAVE_LOCALOCTFILEDIR); - Voct_file_dir = octave::config::prepend_octave_exec_home (OCTAVE_OCTFILEDIR); - - Vlocal_ver_fcn_file_dir - = octave::config::prepend_octave_home (OCTAVE_LOCALVERFCNFILEDIR); - Vlocal_api_fcn_file_dir - = octave::config::prepend_octave_home (OCTAVE_LOCALAPIFCNFILEDIR); - Vlocal_fcn_file_dir - = octave::config::prepend_octave_home (OCTAVE_LOCALFCNFILEDIR); - Vfcn_file_dir = octave::config::prepend_octave_home (OCTAVE_FCNFILEDIR); - - Voct_data_dir = octave::config::prepend_octave_home (OCTAVE_OCTDATADIR); - Voct_doc_dir = octave::config::prepend_octave_home (OCTAVE_OCTDOCDIR); - Voct_etc_dir = octave::config::prepend_octave_home (OCTAVE_OCTETCDIR); - Voct_fonts_dir = octave::config::prepend_octave_home (OCTAVE_OCTFONTSDIR); - Voct_include_dir = octave::config::prepend_octave_home (OCTAVE_OCTINCLUDEDIR); - Voct_lib_dir = octave::config::prepend_octave_exec_home (OCTAVE_OCTLIBDIR); - Voct_locale_dir = octave::config::prepend_octave_home (OCTAVE_OCTLOCALEDIR); - Voct_tests_dir = octave::config::prepend_octave_home (OCTAVE_OCTTESTSDIR); - - Vinfo_dir = octave::config::prepend_octave_home (OCTAVE_INFODIR); - - Vman_dir = octave::config::prepend_octave_home (OCTAVE_MANDIR); - Vman1_dir = octave::config::prepend_octave_home (OCTAVE_MAN1DIR); - Vman1_ext = OCTAVE_MAN1EXT; - - Vimage_dir = octave::config::prepend_octave_home (OCTAVE_IMAGEDIR); - - Vlocal_startupfile_dir - = octave::config::prepend_octave_home (OCTAVE_LOCALSTARTUPFILEDIR); - Vstartupfile_dir - = octave::config::prepend_octave_home (OCTAVE_STARTUPFILEDIR); - - set_local_site_defaults_file (); - - set_site_defaults_file (); - - initialized = true; -} - -#define RETURN(VAR) \ - if (! initialized) \ - init_defaults (); \ - return VAR; - -namespace octave -{ - namespace config - { - std::string - prepend_octave_home (const std::string& s) - { - return prepend_home_dir (Voctave_home, s); - } - - std::string - prepend_octave_exec_home (const std::string& s) - { - return prepend_home_dir (Voctave_exec_home, s); - } - - std::string canonical_host_type (void) { return OCTAVE_CANONICAL_HOST_TYPE; } - - std::string release (void) { return OCTAVE_RELEASE; } - - std::string default_pager (void) { return OCTAVE_DEFAULT_PAGER; } - - std::string octave_home (void) { RETURN (Voctave_home); } - std::string octave_exec_home (void) { RETURN (Voctave_exec_home); } - - std::string bin_dir (void) { RETURN (Vbin_dir); } - std::string data_dir (void) { RETURN (Vdata_dir); } - std::string dataroot_dir (void) { RETURN (Vdataroot_dir); } - std::string include_dir (void) { RETURN (Vinclude_dir); } - std::string lib_dir (void) { RETURN (Vlib_dir); } - std::string libexec_dir (void) { RETURN (Vlibexec_dir); } - std::string arch_lib_dir (void) { RETURN (Varch_lib_dir); } - std::string info_dir (void) { RETURN (Vinfo_dir); } - - std::string local_ver_arch_lib_dir (void) { RETURN (Vlocal_ver_arch_lib_dir); } - std::string local_api_arch_lib_dir (void) { RETURN (Vlocal_api_arch_lib_dir); } - std::string local_arch_lib_dir (void) { RETURN (Vlocal_arch_lib_dir); } - - std::string local_ver_oct_file_dir (void) { RETURN (Vlocal_ver_oct_file_dir); } - std::string local_api_oct_file_dir (void) { RETURN (Vlocal_api_oct_file_dir); } - std::string local_oct_file_dir (void) { RETURN (Vlocal_oct_file_dir); } - std::string oct_file_dir (void) { RETURN (Voct_file_dir); } - - std::string local_ver_fcn_file_dir (void) { RETURN (Vlocal_ver_fcn_file_dir); } - std::string local_api_fcn_file_dir (void) { RETURN (Vlocal_api_fcn_file_dir); } - std::string local_fcn_file_dir (void) { RETURN (Vlocal_fcn_file_dir); } - std::string fcn_file_dir (void) { RETURN (Vfcn_file_dir); } - - std::string oct_data_dir (void) { RETURN (Voct_data_dir); } - std::string oct_doc_dir (void) { RETURN (Voct_doc_dir); } - std::string oct_etc_dir (void) { RETURN (Voct_etc_dir); } - std::string oct_fonts_dir (void) { RETURN (Voct_fonts_dir); } - std::string oct_include_dir (void) { RETURN (Voct_include_dir); } - std::string oct_lib_dir (void) { RETURN (Voct_lib_dir); } - std::string oct_locale_dir (void) { RETURN (Voct_locale_dir); } - std::string oct_tests_dir (void) { RETURN (Voct_tests_dir); } - - std::string man_dir (void) { RETURN (Vman_dir); } - std::string man1_dir (void) { RETURN (Vman1_dir); } - std::string man1_ext (void) { RETURN (Vman1_ext); } - - std::string image_dir (void) { RETURN (Vimage_dir); } - - std::string local_startupfile_dir (void) { RETURN (Vlocal_startupfile_dir); } - std::string startupfile_dir (void) { RETURN (Vstartupfile_dir); } - - std::string local_site_defaults_file (void) { RETURN (Vlocal_site_defaults_file); } - std::string site_defaults_file (void) { RETURN (Vsite_defaults_file); } - } -} - -#undef RETURN - -DEFUN (OCTAVE_HOME, args, , - doc: /* -*- texinfo -*- +DEFMETHOD (OCTAVE_HOME, interp, args, , + doc: /* -*- texinfo -*- @deftypefn {} {} OCTAVE_HOME () Return the name of the top-level Octave installation directory. OCTAVE_HOME corresponds to the configuration variable @var{prefix}. @@ -328,7 +546,9 @@ if (args.length () != 0) print_usage (); - return ovl (octave::config::octave_home ()); + octave::installation_data& inst_data = interp.get_installation_data (); + + return ovl (inst_data.home ()); } /* @@ -336,8 +556,8 @@ %!error OCTAVE_HOME (1) */ -DEFUN (OCTAVE_EXEC_HOME, args, , - doc: /* -*- texinfo -*- +DEFMETHOD (OCTAVE_EXEC_HOME, interp, args, , + doc: /* -*- texinfo -*- @deftypefn {} {} OCTAVE_HOME () Return the name of the top-level Octave installation directory for architecture-dependent files. If not specified separately, the value @@ -349,7 +569,9 @@ if (args.length () != 0) print_usage (); - return ovl (octave::config::octave_exec_home ()); + octave::installation_data& inst_data = interp.get_installation_data (); + + return ovl (inst_data.exec_home ()); } /*
--- a/libinterp/corefcn/defaults.h Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/defaults.h Fri Jun 08 13:42:34 2018 -0400 @@ -31,73 +31,417 @@ namespace octave { + class + installation_data + { + public: + + installation_data (void); + + installation_data (const installation_data&) = delete; + + installation_data& operator = (const installation_data&) = delete; + + ~installation_data (void) = default; + + std::string canonical_host_type (void) const + { + return m_canonical_host_type; + } + + std::string release (void) const + { + return m_release; + } + + std::string default_pager (void) const + { + return m_default_pager; + } + + std::string home (void) const + { + return m_home; + } + + std::string exec_home (void) const + { + return m_exec_home; + } + + std::string bin_dir (void) const + { + return m_bin_dir; + } + + std::string data_dir (void) const + { + return m_data_dir; + } + + std::string dataroot_dir (void) const + { + return m_dataroot_dir; + } + + std::string include_dir (void) const + { + return m_include_dir; + } + + std::string lib_dir (void) const + { + return m_lib_dir; + } + + std::string libexec_dir (void) const + { + return m_libexec_dir; + } + + std::string local_ver_arch_lib_dir (void) const + { + return m_local_ver_arch_lib_dir; + } + + std::string local_api_arch_lib_dir (void) const + { + return m_local_api_arch_lib_dir; + } + + std::string local_arch_lib_dir (void) const + { + return m_local_arch_lib_dir; + } + + std::string arch_lib_dir (void) const + { + return m_arch_lib_dir; + } + + std::string local_ver_oct_file_dir (void) const + { + return m_local_ver_oct_file_dir; + } + + std::string local_api_oct_file_dir (void) const + { + return m_local_api_oct_file_dir; + } + + std::string local_oct_file_dir (void) const + { + return m_local_oct_file_dir; + } + + std::string oct_file_dir (void) const + { + return m_oct_file_dir; + } + + std::string local_ver_fcn_file_dir (void) const + { + return m_local_ver_fcn_file_dir; + } + + std::string local_api_fcn_file_dir (void) const + { + return m_local_api_fcn_file_dir; + } + + std::string local_fcn_file_dir (void) const + { + return m_local_fcn_file_dir; + } + + std::string fcn_file_dir (void) const + { + return m_fcn_file_dir; + } + + std::string oct_data_dir (void) const + { + return m_oct_data_dir; + } + + std::string oct_doc_dir (void) const + { + return m_oct_doc_dir; + } + + std::string oct_etc_dir (void) const + { + return m_oct_etc_dir; + } + + std::string oct_fonts_dir (void) const + { + return m_oct_fonts_dir; + } + + std::string oct_include_dir (void) const + { + return m_oct_include_dir; + } + + std::string oct_lib_dir (void) const + { + return m_oct_lib_dir; + } + + std::string oct_locale_dir (void) const + { + return m_oct_locale_dir; + } + + std::string oct_tests_dir (void) const + { + return m_oct_tests_dir; + } + + std::string info_dir (void) const + { + return m_info_dir; + } + + std::string man_dir (void) const + { + return m_man_dir; + } + + std::string man1_dir (void) const + { + return m_man1_dir; + } + + std::string man1_ext (void) const + { + return m_man1_ext; + } + + std::string image_dir (void) const + { + return m_image_dir; + } + + std::string local_startupfile_dir (void) const + { + return m_local_startupfile_dir; + } + + std::string startupfile_dir (void) const + { + return m_startupfile_dir; + } + + std::string local_site_defaults_file (void) const + { + return m_local_site_defaults_file; + } + + std::string site_defaults_file (void) const + { + return m_site_defaults_file; + } + + std::string prepend_home (const std::string& s) const; + + std::string prepend_exec_home (const std::string& s) const; + + private: + + void set_home (void); + + void set_local_site_defaults_file (void); + + void set_site_defaults_file (void); + + std::string m_canonical_host_type; + std::string m_release; + std::string m_default_pager; + + std::string m_home; + std::string m_exec_home; + + std::string m_bin_dir; + std::string m_data_dir; + std::string m_dataroot_dir; + std::string m_include_dir; + std::string m_lib_dir; + std::string m_libexec_dir; + + std::string m_local_ver_arch_lib_dir; + std::string m_local_api_arch_lib_dir; + std::string m_local_arch_lib_dir; + std::string m_arch_lib_dir; + + std::string m_local_ver_oct_file_dir; + std::string m_local_api_oct_file_dir; + std::string m_local_oct_file_dir; + std::string m_oct_file_dir; + + std::string m_local_ver_fcn_file_dir; + std::string m_local_api_fcn_file_dir; + std::string m_local_fcn_file_dir; + std::string m_fcn_file_dir; + + std::string m_oct_data_dir; + std::string m_oct_doc_dir; + std::string m_oct_etc_dir; + std::string m_oct_fonts_dir; + std::string m_oct_include_dir; + std::string m_oct_lib_dir; + std::string m_oct_locale_dir; + std::string m_oct_tests_dir; + + std::string m_info_dir; + + std::string m_man_dir; + std::string m_man1_dir; + std::string m_man1_ext; + + std::string m_image_dir; + + std::string m_local_startupfile_dir; + std::string m_startupfile_dir; + + std::string m_local_site_defaults_file; + std::string m_site_defaults_file; + }; + namespace config { +#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::prepend_octave_home' instead") extern OCTINTERP_API std::string prepend_octave_home (const std::string& s); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::prepend_octave_exec_home' instead") extern OCTINTERP_API std::string prepend_octave_exec_home (const std::string& s); - // These could be defined as pure constants, but we'll use - // functions to be consistent with the values that require - // initialization. + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::canonical_host_type' instead") + extern OCTINTERP_API std::string canonical_host_type (void); - extern OCTINTERP_API std::string canonical_host_type (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::release' instead") extern OCTINTERP_API std::string release (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::default_pager' instead") extern OCTINTERP_API std::string default_pager (void); - // These require initialization, so can't be defined as pure - // constants. We use functions to access these values so that - // they can't be modified by users. + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::octave_home' instead") + extern OCTINTERP_API std::string octave_home (void); - extern OCTINTERP_API std::string octave_home (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::octave_exec_home' instead") extern OCTINTERP_API std::string octave_exec_home (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::bin_dir' instead") extern OCTINTERP_API std::string bin_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::data_dir' instead") extern OCTINTERP_API std::string data_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::dataroot_dir' instead") extern OCTINTERP_API std::string dataroot_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::include_dir' instead") extern OCTINTERP_API std::string include_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::lib_dir' instead") extern OCTINTERP_API std::string lib_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::libexec_dir' instead") extern OCTINTERP_API std::string libexec_dir (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_ver_arch_lib_dir' instead") extern OCTINTERP_API std::string local_ver_arch_lib_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_api_arch_lib_dir' instead") extern OCTINTERP_API std::string local_api_arch_lib_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_arch_lib_dir' instead") extern OCTINTERP_API std::string local_arch_lib_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::arch_lib_dir' instead") extern OCTINTERP_API std::string arch_lib_dir (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_ver_oct_file_dir' instead") extern OCTINTERP_API std::string local_ver_oct_file_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_api_oct_file_dir' instead") extern OCTINTERP_API std::string local_api_oct_file_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_oct_file_dir' instead") extern OCTINTERP_API std::string local_oct_file_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_file_dir' instead") extern OCTINTERP_API std::string oct_file_dir (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_ver_fcn_file_dir' instead") extern OCTINTERP_API std::string local_ver_fcn_file_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_api_fcn_file_dir' instead") extern OCTINTERP_API std::string local_api_fcn_file_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_fcn_file_dir' instead") extern OCTINTERP_API std::string local_fcn_file_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::fcn_file_dir' instead") extern OCTINTERP_API std::string fcn_file_dir (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_data_dir' instead") extern OCTINTERP_API std::string oct_data_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_doc_dir' instead") extern OCTINTERP_API std::string oct_doc_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_etc_dir' instead") extern OCTINTERP_API std::string oct_etc_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_fonts_dir' instead") extern OCTINTERP_API std::string oct_fonts_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_include_dir' instead") extern OCTINTERP_API std::string oct_include_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_lib_dir' instead") extern OCTINTERP_API std::string oct_lib_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_locale_dir' instead") extern OCTINTERP_API std::string oct_locale_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_tests_dir' instead") extern OCTINTERP_API std::string oct_tests_dir (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::info_dir' instead") extern OCTINTERP_API std::string info_dir (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::man_dir' instead") extern OCTINTERP_API std::string man_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::man1_dir' instead") extern OCTINTERP_API std::string man1_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::man1_ext' instead") extern OCTINTERP_API std::string man1_ext (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::image_dir' instead") extern OCTINTERP_API std::string image_dir (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_startupfile_dir' instead") extern OCTINTERP_API std::string local_startupfile_dir (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::startupfile_dir' instead") extern OCTINTERP_API std::string startupfile_dir (void); + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_site_defaults_file' instead") extern OCTINTERP_API std::string local_site_defaults_file (void); + + OCTAVE_DEPRECATED (5, "use 'octave::installation_data::site_defaults_file' instead") extern OCTINTERP_API std::string site_defaults_file (void); + +#endif } }
--- a/libinterp/corefcn/environment.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/environment.cc Fri Jun 08 13:42:34 2018 -0400 @@ -113,25 +113,30 @@ return retval; } - std::string environment::init_exec_path (void) + std::string environment::init_exec_path (interpreter& interp) { std::string exec_path = sys::env::getenv ("OCTAVE_EXEC_PATH"); std::string path_sep = directory_path::path_sep_str (); if (exec_path.empty ()) - exec_path = (config::local_ver_arch_lib_dir () + path_sep - + config::local_api_arch_lib_dir () + path_sep - + config::local_arch_lib_dir () + path_sep - + config::arch_lib_dir () + path_sep - + config::bin_dir ()); + { + installation_data& inst_data = interp.get_installation_data (); + + exec_path = (inst_data.local_ver_arch_lib_dir () + path_sep + + inst_data.local_api_arch_lib_dir () + path_sep + + inst_data.local_arch_lib_dir () + path_sep + + inst_data.arch_lib_dir () + path_sep + + inst_data.bin_dir ()); + + } append_to_shell_path (exec_path); return exec_path; } - std::string environment::init_image_path (void) + std::string environment::init_image_path (interpreter& interp) { std::string image_path = "."; @@ -142,7 +147,9 @@ if (! env_path.empty ()) image_path += path_sep + env_path; - std::string gen_path = genpath (config::image_dir (), ""); + installation_data& inst_data = interp.get_installation_data (); + + std::string gen_path = genpath (inst_data.image_dir (), ""); if (! gen_path.empty ()) image_path += path_sep + gen_path;
--- a/libinterp/corefcn/environment.h Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/environment.h Fri Jun 08 13:42:34 2018 -0400 @@ -32,14 +32,16 @@ namespace octave { + class interpreter; + class environment { public: - environment (void) + environment (interpreter& interp) : m_editor (init_editor ()), - m_exec_path (init_exec_path ()), - m_image_path (init_image_path ()) + m_exec_path (init_exec_path (interp)), + m_image_path (init_image_path (interp)) { } octave_value editor (const octave_value_list& args, int nargout); @@ -76,9 +78,9 @@ static std::string init_editor (void); - static std::string init_exec_path (void); + static std::string init_exec_path (interpreter& interp); - static std::string init_image_path (void); + static std::string init_image_path (interpreter& interp); std::string set (std::string& var, const std::string& new_val) {
--- a/libinterp/corefcn/ft-text-renderer.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/ft-text-renderer.cc Fri Jun 08 13:42:34 2018 -0400 @@ -57,6 +57,7 @@ #include "defaults.h" #include "error.h" #include "file-ops.h" +#include "interpreter-private.h" #include "oct-env.h" #include "pr-output.h" #include "text-renderer.h" @@ -213,10 +214,15 @@ fonts_dir = sys::env::getenv ("OCTAVE_FONTS_DIR"); if (fonts_dir.empty ()) + { #if defined (SYSTEM_FREEFONT_DIR) - fonts_dir = SYSTEM_FREEFONT_DIR; + fonts_dir = SYSTEM_FREEFONT_DIR; #else - fonts_dir = config::oct_fonts_dir (); + installation_data& inst_data + = __get_installation_data__ ("do_get_font"); + + fonts_dir = inst_data.oct_fonts_dir (); + } #endif }
--- a/libinterp/corefcn/help.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/help.cc Fri Jun 08 13:42:34 2018 -0400 @@ -427,30 +427,36 @@ } } - std::string help_system::init_built_in_docstrings_file (void) + std::string help_system::init_built_in_docstrings_file (interpreter& interp) { + installation_data& inst_data = interp.get_installation_data (); + std::string df = sys::env::getenv ("OCTAVE_BUILT_IN_DOCSTRINGS_FILE"); std::string dir_sep = sys::file_ops::dir_sep_str (); if (df.empty ()) - df = config::oct_etc_dir () + dir_sep + "built-in-docstrings"; + df = inst_data.oct_etc_dir () + dir_sep + "built-in-docstrings"; return df; } - std::string help_system::init_doc_cache_file (void) + std::string help_system::init_doc_cache_file (interpreter& interp) { - std::string def_file = config::prepend_octave_home (OCTAVE_DOC_CACHE_FILE); + installation_data& inst_data = interp.get_installation_data (); + + std::string def_file = inst_data.prepend_home (OCTAVE_DOC_CACHE_FILE); std::string env_file = sys::env::getenv ("OCTAVE_DOC_CACHE_FILE"); return (env_file.empty () ? def_file : env_file); } - std::string help_system::init_info_file (void) + std::string help_system::init_info_file (interpreter& interp) { - std::string std_info_file = config::prepend_octave_home (OCTAVE_INFOFILE); + installation_data& inst_data = interp.get_installation_data (); + + std::string std_info_file = inst_data.prepend_home (OCTAVE_INFOFILE); std::string oct_info_file = sys::env::getenv ("OCTAVE_INFO_FILE"); @@ -467,10 +473,12 @@ return info_prog; } - std::string help_system::init_texi_macros_file (void) + std::string help_system::init_texi_macros_file (interpreter& interp) { + installation_data& inst_data = interp.get_installation_data (); + std::string def_file - = config::prepend_octave_home (OCTAVE_TEXI_MACROS_FILE); + = inst_data.prepend_home (OCTAVE_TEXI_MACROS_FILE); std::string env_file = sys::env::getenv ("OCTAVE_TEXI_MACROS_FILE");
--- a/libinterp/corefcn/help.h Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/help.h Fri Jun 08 13:42:34 2018 -0400 @@ -43,13 +43,13 @@ help_system (interpreter& interp) : m_interpreter (interp), - m_built_in_docstrings_file (init_built_in_docstrings_file ()), - m_doc_cache_file (init_doc_cache_file ()), - m_info_file (init_info_file ()), + m_built_in_docstrings_file (init_built_in_docstrings_file (interp)), + m_doc_cache_file (init_doc_cache_file (interp)), + m_info_file (init_info_file (interp)), m_info_program (init_info_program ()), m_makeinfo_program ("makeinfo"), m_suppress_verbose_help_message (false), - m_texi_macros_file (init_texi_macros_file ()) + m_texi_macros_file (init_texi_macros_file (interp)) { } octave_value @@ -166,15 +166,15 @@ // (--texi-macros-file) std::string m_texi_macros_file; - static std::string init_built_in_docstrings_file (void); + static std::string init_built_in_docstrings_file (interpreter& interp); - static std::string init_doc_cache_file (void); + static std::string init_doc_cache_file (interpreter& interp); - static std::string init_info_file (void); + static std::string init_info_file (interpreter& interp); static std::string init_info_program (void); - static std::string init_texi_macros_file (void); + static std::string init_texi_macros_file (interpreter& interp); template <typename T> T set (T& var, const T& new_val)
--- a/libinterp/corefcn/interpreter-private.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/interpreter-private.cc Fri Jun 08 13:42:34 2018 -0400 @@ -55,6 +55,13 @@ return *interp; } + installation_data& __get_installation_data__ (const std::string& who) + { + interpreter& interp = __get_interpreter__ (who); + + return interp.get_installation_data (); + } + dynamic_loader& __get_dynamic_loader__ (const std::string& who) { interpreter& interp = __get_interpreter__ (who);
--- a/libinterp/corefcn/interpreter-private.h Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/interpreter-private.h Fri Jun 08 13:42:34 2018 -0400 @@ -36,6 +36,7 @@ class bp_table; class call_stack; class child_list; + class installation_data; class dynamic_loader; class gtk_manager; class help_system; @@ -48,6 +49,8 @@ extern interpreter& __get_interpreter__ (const std::string& who); + extern installation_data& __get_installation_data__ (const std::string& who); + extern dynamic_loader& __get_dynamic_loader__ (const std::string& who); extern help_system& __get_help_system__ (const std::string& who);
--- a/libinterp/corefcn/interpreter.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/interpreter.cc Fri Jun 08 13:42:34 2018 -0400 @@ -88,6 +88,10 @@ Undocumented internal function. @end deftypefn */) { + // FIXME: this seems backwards. Shouldn't the version info be stored + // in the interpreter object and simply returned from this function + // instead of being stored in a static here? + static octave_map vinfo; int nargin = args.length (); @@ -126,19 +130,6 @@ return retval; } -static void -initialize_version_info (void) -{ - octave_value_list args; - - args(3) = OCTAVE_RELEASE_DATE; - args(2) = octave::config::release (); - args(1) = OCTAVE_VERSION; - args(0) = "GNU Octave"; - - F__version_info__ (args, 0); -} - OCTAVE_NORETURN static void lo_error_handler (const char *fmt, ...) { @@ -324,12 +315,13 @@ interpreter::interpreter (application *app_context) : m_app_context (app_context), - m_environment (), + m_installation_data (), + m_environment (*this), m_help_system (*this), m_input_system (*this), m_output_system (*this), m_dynamic_loader (*this), - m_load_path (), + m_load_path (*this), m_type_info (), m_symbol_table (), m_evaluator (*this), @@ -508,6 +500,18 @@ cleanup (); } + void interpreter::initialize_version_info (void) + { + octave_value_list args; + + args(3) = OCTAVE_RELEASE_DATE; + args(2) = m_installation_data.release (); + args(1) = OCTAVE_VERSION; + args(0) = "GNU Octave"; + + F__version_info__ (args, 0); + } + void interpreter::intern_nargin (octave_idx_type nargs) { // FIXME: should this explicitly be top_scope? @@ -724,13 +728,14 @@ // (if it exists), then from the file // $(prefix)/share/octave/$(version)/m/octaverc (if it exists). - int status = safe_source_file (config::local_site_defaults_file (), - context, verbose, require_file); + int status + = safe_source_file (m_installation_data.local_site_defaults_file (), + context, verbose, require_file); if (status) exit_status = status; - status = safe_source_file (config::site_defaults_file (), + status = safe_source_file (m_installation_data.site_defaults_file (), context, verbose, require_file); if (status)
--- a/libinterp/corefcn/interpreter.h Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/interpreter.h Fri Jun 08 13:42:34 2018 -0400 @@ -31,6 +31,7 @@ #include "quit.h" #include "str-vec.h" +#include "defaults.h" #include "dynamic-ld.h" #include "environment.h" #include "gtk-manager.h" @@ -85,6 +86,8 @@ ~interpreter (void); + void initialize_version_info (void); + void intern_nargin (octave_idx_type nargs); // If creating an embedded interpreter, you may inhibit reading @@ -146,6 +149,11 @@ return m_initialized; } + installation_data& get_installation_data (void) + { + return m_installation_data; + } + environment& get_environment (void) { return m_environment; @@ -256,6 +264,8 @@ application *m_app_context; + installation_data m_installation_data; + environment m_environment; help_system m_help_system;
--- a/libinterp/corefcn/load-path.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/load-path.cc Fri Jun 08 13:42:34 2018 -0400 @@ -188,9 +188,9 @@ std::string load_path::sys_path; load_path::abs_dir_cache_type load_path::abs_dir_cache; - load_path::load_path (void) - : package_map (), top_level_package (), dir_info_list (), init_dirs (), - m_command_line_path (), + load_path::load_path (interpreter& interp) + : m_interpreter (interp), package_map (), top_level_package (), + dir_info_list (), init_dirs (), m_command_line_path (), add_hook ([this] (const std::string& dir) { this->execute_pkg_add (dir); }), remove_hook ([this] (const std::string& dir) { this->execute_pkg_del (dir); }) { } @@ -202,15 +202,17 @@ if (set_initial_path) { - maybe_add_path_elts (sys_path, config::local_ver_oct_file_dir ()); - maybe_add_path_elts (sys_path, config::local_api_oct_file_dir ()); - maybe_add_path_elts (sys_path, config::local_oct_file_dir ()); - maybe_add_path_elts (sys_path, config::local_ver_fcn_file_dir ()); - maybe_add_path_elts (sys_path, config::local_api_fcn_file_dir ()); - maybe_add_path_elts (sys_path, config::local_fcn_file_dir ()); - maybe_add_path_elts (sys_path, config::oct_file_dir ()); - maybe_add_path_elts (sys_path, config::fcn_file_dir ()); - maybe_add_path_elts (sys_path, config::oct_data_dir ()); + installation_data& inst_data = m_interpreter.get_installation_data (); + + maybe_add_path_elts (sys_path, inst_data.local_ver_oct_file_dir ()); + maybe_add_path_elts (sys_path, inst_data.local_api_oct_file_dir ()); + maybe_add_path_elts (sys_path, inst_data.local_oct_file_dir ()); + maybe_add_path_elts (sys_path, inst_data.local_ver_fcn_file_dir ()); + maybe_add_path_elts (sys_path, inst_data.local_api_fcn_file_dir ()); + maybe_add_path_elts (sys_path, inst_data.local_fcn_file_dir ()); + maybe_add_path_elts (sys_path, inst_data.oct_file_dir ()); + maybe_add_path_elts (sys_path, inst_data.fcn_file_dir ()); + maybe_add_path_elts (sys_path, inst_data.oct_data_dir ()); } std::string tpath = load_path::m_command_line_path;
--- a/libinterp/corefcn/load-path.h Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/load-path.h Fri Jun 08 13:42:34 2018 -0400 @@ -39,13 +39,15 @@ namespace octave { + class interpreter; + class OCTINTERP_API load_path { public: - load_path (void); + load_path (interpreter& interp); typedef void (*hook_fcn_ptr) (const std::string& dir); @@ -507,6 +509,8 @@ typedef package_map_type::const_iterator const_package_map_iterator; typedef package_map_type::iterator package_map_iterator; + interpreter& m_interpreter; + mutable package_map_type package_map; mutable package_info top_level_package;
--- a/libinterp/corefcn/ls-mat5.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/ls-mat5.cc Fri Jun 08 13:42:34 2018 -0400 @@ -864,9 +864,12 @@ std::string mroot = m0.contents ("matlabroot").string_value (); + octave::installation_data& inst_data + = octave::__get_installation_data__ ("read_mat5_binary_element"); + if ((fpath.length () >= mroot.length ()) && fpath.substr (0, mroot.length ()) == mroot - && octave::config::octave_exec_home () != mroot) + && inst_data.exec_home () != mroot) { // If fpath starts with matlabroot, and matlabroot // doesn't equal __octave_config_info__ ("exec_prefix") @@ -877,7 +880,7 @@ // First check if just replacing matlabroot is enough std::string str - = (octave::config::octave_exec_home () + = (inst_data.exec_home () + fpath.substr (mroot.length ())); octave::sys::file_stat fs (str);
--- a/libinterp/corefcn/pager.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/pager.cc Fri Jun 08 13:42:34 2018 -0400 @@ -111,12 +111,16 @@ return false; } - static std::string default_pager (void) + static std::string default_pager (interpreter& interp) { std::string pager_binary = sys::env::getenv ("PAGER"); if (pager_binary.empty ()) - pager_binary = config::default_pager (); + { + installation_data& inst_data = interp.get_installation_data (); + + pager_binary = inst_data.default_pager (); + } return pager_binary; } @@ -265,7 +269,7 @@ output_system::output_system (interpreter& interp) : m_interpreter (interp), m_pager_stream (), m_diary_stream (), m_external_pager (nullptr), m_external_diary_file (), - m_diary_file_name ("diary"), m_PAGER (default_pager ()), + m_diary_file_name ("diary"), m_PAGER (default_pager (interp)), m_PAGER_FLAGS (), m_page_output_immediately (false), m_page_screen_output (false), m_write_to_diary_file (false), m_really_flush_to_pager (false), m_flushing_output_to_pager (false)
--- a/libinterp/corefcn/toplev.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/corefcn/toplev.cc Fri Jun 08 13:42:34 2018 -0400 @@ -55,6 +55,7 @@ #include "file-io.h" #include "help.h" #include "interpreter-private.h" +#include "interpreter.h" #include "octave.h" #include "oct-map.h" #include "ovl.h" @@ -334,8 +335,8 @@ return octave_value (); } -DEFUN (__octave_config_info__, args, , - doc: /* -*- texinfo -*- +DEFMETHOD (__octave_config_info__, interp, args, , + doc: /* -*- texinfo -*- @deftypefn {} {} __octave_config_info__ () @deftypefnx {} {} __octave_config_info__ (@var{option}) Return a structure containing configuration and installation information for @@ -361,8 +362,10 @@ if (! initialized) { + octave::installation_data& inst_data = interp.get_installation_data (); + std::map<std::string, octave_value> conf_info_map - = {{ "DEFAULT_PAGER", octave::config::default_pager () }, + = {{ "DEFAULT_PAGER", inst_data.default_pager () }, #if defined (OCTAVE_ENABLE_64) { "ENABLE_64", true }, @@ -407,46 +410,46 @@ #endif { "api_version", OCTAVE_API_VERSION }, - { "archlibdir", octave::config::arch_lib_dir () }, - { "bindir", octave::config::bin_dir () }, - { "canonical_host_type", octave::config::canonical_host_type () }, - { "datadir", octave::config::data_dir () }, - { "datarootdir", octave::config::dataroot_dir () }, - { "fcnfiledir", octave::config::fcn_file_dir () }, + { "archlibdir", inst_data.arch_lib_dir () }, + { "bindir", inst_data.bin_dir () }, + { "canonical_host_type", inst_data.canonical_host_type () }, + { "datadir", inst_data.data_dir () }, + { "datarootdir", inst_data.dataroot_dir () }, + { "fcnfiledir", inst_data.fcn_file_dir () }, { "fftw_version", octave::fftw_version () }, { "fftwf_version", octave::fftwf_version () }, - { "imagedir", octave::config::image_dir () }, - { "includedir", octave::config::include_dir () }, - { "infodir", octave::config::info_dir () }, - { "libdir", octave::config::lib_dir () }, - { "libexecdir", octave::config::libexec_dir () }, + { "imagedir", inst_data.image_dir () }, + { "includedir", inst_data.include_dir () }, + { "infodir", inst_data.info_dir () }, + { "libdir", inst_data.lib_dir () }, + { "libexecdir", inst_data.libexec_dir () }, // Each library and executable has its own definition of the hg // id. We check for consistency when Octave starts so we just // store and report one of them here. { "hg_id", liboctinterp_hg_id () }, - { "localapiarchlibdir", octave::config::local_api_arch_lib_dir () }, - { "localapifcnfiledir", octave::config::local_api_fcn_file_dir () }, - { "localapioctfiledir", octave::config::local_api_oct_file_dir () }, - { "localarchlibdir", octave::config::local_arch_lib_dir () }, - { "localfcnfiledir", octave::config::local_fcn_file_dir () }, - { "localoctfiledir", octave::config::local_oct_file_dir () }, - { "localstartupfiledir", octave::config::local_startupfile_dir () }, - { "localverarchlibdir", octave::config::local_ver_arch_lib_dir () }, - { "localverfcnfiledir", octave::config::local_ver_fcn_file_dir () }, - { "localveroctfiledir", octave::config::local_ver_oct_file_dir () }, - { "man1dir", octave::config::man1_dir () }, - { "man1ext", octave::config::man1_ext () }, - { "mandir", octave::config::man_dir () }, - { "octdatadir", octave::config::oct_data_dir () }, - { "octdocdir", octave::config::oct_doc_dir () }, - { "octetcdir", octave::config::oct_etc_dir () }, - { "octfiledir", octave::config::oct_file_dir () }, - { "octfontsdir", octave::config::oct_fonts_dir () }, - { "octincludedir", octave::config::oct_include_dir () }, - { "octlibdir", octave::config::oct_lib_dir () }, - { "octtestsdir", octave::config::oct_tests_dir () }, + { "localapiarchlibdir", inst_data.local_api_arch_lib_dir () }, + { "localapifcnfiledir", inst_data.local_api_fcn_file_dir () }, + { "localapioctfiledir", inst_data.local_api_oct_file_dir () }, + { "localarchlibdir", inst_data.local_arch_lib_dir () }, + { "localfcnfiledir", inst_data.local_fcn_file_dir () }, + { "localoctfiledir", inst_data.local_oct_file_dir () }, + { "localstartupfiledir", inst_data.local_startupfile_dir () }, + { "localverarchlibdir", inst_data.local_ver_arch_lib_dir () }, + { "localverfcnfiledir", inst_data.local_ver_fcn_file_dir () }, + { "localveroctfiledir", inst_data.local_ver_oct_file_dir () }, + { "man1dir", inst_data.man1_dir () }, + { "man1ext", inst_data.man1_ext () }, + { "mandir", inst_data.man_dir () }, + { "octdatadir", inst_data.oct_data_dir () }, + { "octdocdir", inst_data.oct_doc_dir () }, + { "octetcdir", inst_data.oct_etc_dir () }, + { "octfiledir", inst_data.oct_file_dir () }, + { "octfontsdir", inst_data.oct_fonts_dir () }, + { "octincludedir", inst_data.oct_include_dir () }, + { "octlibdir", inst_data.oct_lib_dir () }, + { "octtestsdir", inst_data.oct_tests_dir () }, { "release_date", OCTAVE_RELEASE_DATE }, - { "startupfiledir", octave::config::startupfile_dir () }, + { "startupfiledir", inst_data.startupfile_dir () }, { "version", OCTAVE_VERSION }}; std::map<std::string, octave_value> build_env_map
--- a/libinterp/octave-value/ov-dld-fcn.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/octave-value/ov-dld-fcn.cc Fri Jun 08 13:42:34 2018 -0400 @@ -48,7 +48,10 @@ std::string file_name = fcn_file_name (); - std::string oct_file_dir = octave::config::oct_file_dir (); + octave::installation_data& inst_data + = octave::__get_installation_data__ ("octave_dld_function::octave_dld_function"); + + std::string oct_file_dir = inst_data.oct_file_dir (); system_fcn_file = (! file_name.empty () @@ -64,7 +67,10 @@ std::string file_name = fcn_file_name (); - std::string oct_file_dir = octave::config::oct_file_dir (); + octave::installation_data& inst_data + = octave::__get_installation_data__ ("octave_dld_function::octave_dld_function"); + + std::string oct_file_dir = inst_data.oct_file_dir (); system_fcn_file = (! file_name.empty ()
--- a/libinterp/octave-value/ov-fcn-handle.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/octave-value/ov-fcn-handle.cc Fri Jun 08 13:42:34 2018 -0400 @@ -255,14 +255,17 @@ octave_fcn_handle::set_fcn (const std::string& octaveroot, const std::string& fpath) { + octave::installation_data& inst_data + = octave::__get_installation_data__ ("octave_fcn_handle::set_fcn"); + if (octaveroot.length () != 0 && fpath.length () >= octaveroot.length () && fpath.substr (0, octaveroot.length ()) == octaveroot - && octave::config::octave_exec_home () != octaveroot) + && inst_data.exec_home () != octaveroot) { // First check if just replacing matlabroot is enough std::string str - = (octave::config::octave_exec_home () + = (inst_data.exec_home () + fpath.substr (octaveroot.length ())); octave::sys::file_stat fs (str); @@ -382,7 +385,10 @@ octave_function *f = function_value (); std::string fnm = (f ? f->fcn_file_name () : ""); - os << "# octaveroot: " << octave::config::octave_exec_home () << "\n"; + octave::installation_data& inst_data + = octave::__get_installation_data__ ("octave_fcn_handle::save_ascii"); + + os << "# octaveroot: " << inst_data.exec_home () << "\n"; if (! fnm.empty ()) os << "# path: " << fnm << "\n"; os << nm << "\n"; @@ -580,7 +586,10 @@ octave_function *f = function_value (); std::string fnm = (f ? f->fcn_file_name () : ""); - nmbuf << nm << "\n" << octave::config::octave_exec_home () << "\n" << fnm; + octave::installation_data& inst_data + = octave::__get_installation_data__ ("octave_fcn_handle::save_binary"); + + nmbuf << nm << "\n" << inst_data.exec_home () << "\n" << fnm; std::string buf_str = nmbuf.str (); int32_t tmp = buf_str.length (); @@ -860,7 +869,10 @@ } else { - std::string octaveroot = octave::config::octave_exec_home (); + octave::installation_data& inst_data + = octave::__get_installation_data__ ("octave_fcn_handle::save_binary"); + + std::string octaveroot = inst_data.exec_home (); octave_function *f = function_value (); std::string fpath = (f ? f->fcn_file_name () : "");
--- a/libinterp/octave-value/ov-java.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/octave-value/ov-java.cc Fri Jun 08 13:42:34 2018 -0400 @@ -52,6 +52,7 @@ #include "file-ops.h" #include "file-stat.h" #include "fpucw-wrappers.h" +#include "interpreter-private.h" #include "load-path.h" #include "oct-env.h" #include "oct-shlib.h" @@ -332,8 +333,13 @@ java_dir = octave::sys::env::getenv ("OCTAVE_JAVA_DIR"); if (java_dir.empty ()) - java_dir = (octave::config::fcn_file_dir () - + octave::sys::file_ops::dir_sep_str () + "java"); + { + octave::installation_data& inst_data + = octave::__get_installation_data__ ("initial_java_dir"); + + java_dir = (inst_data.fcn_file_dir () + + octave::sys::file_ops::dir_sep_str () + "java"); + } } return java_dir;
--- a/libinterp/octave-value/ov-mex-fcn.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/octave-value/ov-mex-fcn.cc Fri Jun 08 13:42:34 2018 -0400 @@ -53,7 +53,10 @@ std::string file_name = fcn_file_name (); - std::string oct_file_dir = octave::config::oct_file_dir (); + octave::installation_data& inst_data + = octave::__get_installation_data__ ("octave_mex_function::octave_mex_function"); + + std::string oct_file_dir = inst_data.oct_file_dir (); m_is_system_fcn_file = (! file_name.empty () && oct_file_dir == file_name.substr (0, oct_file_dir.length ()));
--- a/libinterp/octave-value/ov-usr-fcn.cc Thu Jun 07 10:11:54 2018 -0400 +++ b/libinterp/octave-value/ov-usr-fcn.cc Fri Jun 08 13:42:34 2018 -0400 @@ -334,7 +334,10 @@ std::string ff_name = fcn_file_in_path (file_name); - std::string fcn_file_dir = octave::config::fcn_file_dir (); + octave::installation_data& inst_data + = octave::__get_installation_data__ ("octave_user_function::mark_as_system_fcn_file"); + + std::string fcn_file_dir = inst_data.fcn_file_dir (); if (fcn_file_dir == ff_name.substr (0, fcn_file_dir.length ())) system_fcn_file = true; }