# HG changeset patch # User John W. Eaton # Date 1528487016 14400 # Node ID 893344cee10096194206a9a5e328e5d8d1db7cea # Parent 69fc8935020b7a4eac8920285e769b11fc9cb7db rename defaults source files to installation-data * installation-data.h, installation-data.cc: New files, adapted from defaults.h and defaults.cc. Include installation-data.h instead of defaults.h, but only in files that require it. * defaults.h: Preserve for backward compatibility. Define deprecated functions as inline. * libinterp/corefcn/module.mk: Update. diff -r 69fc8935020b -r 893344cee100 libgui/src/documentation.cc --- a/libgui/src/documentation.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libgui/src/documentation.cc Fri Jun 08 15:43:36 2018 -0400 @@ -24,8 +24,8 @@ # include "config.h" #endif -#include "defaults.h" #include "file-ops.h" +#include "installation-data.h" #include "oct-env.h" #include diff -r 69fc8935020b -r 893344cee100 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libgui/src/m-editor/file-editor-tab.cc Fri Jun 08 15:43:36 2018 -0400 @@ -70,7 +70,6 @@ #include "bp-table.h" #include "call-stack.h" -#include "defaults.h" #include "interpreter-private.h" #include "interpreter.h" #include "oct-map.h" diff -r 69fc8935020b -r 893344cee100 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libgui/src/main-window.cc Fri Jun 08 15:43:36 2018 -0400 @@ -61,10 +61,10 @@ #include "url-transfer.h" #include "builtin-defun-decls.h" -#include "defaults.h" #if defined (HAVE_QT_GRAPHICS) # include "__init_qt__.h" #endif +#include "installation-data.h" #include "interpreter-private.h" #include "interpreter.h" #include "oct-map.h" diff -r 69fc8935020b -r 893344cee100 libgui/src/octave-gui.cc --- a/libgui/src/octave-gui.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libgui/src/octave-gui.cc Fri Jun 08 15:43:36 2018 -0400 @@ -45,7 +45,6 @@ #include "signal-wrappers.h" #include "builtin-defun-decls.h" -#include "defaults.h" #include "display.h" #include "octave.h" #include "sysdep.h" diff -r 69fc8935020b -r 893344cee100 libgui/src/qtinfo/webinfo.cc --- a/libgui/src/qtinfo/webinfo.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libgui/src/qtinfo/webinfo.cc Fri Jun 08 15:43:36 2018 -0400 @@ -36,7 +36,6 @@ #include "file-ops.h" #include "help.h" -#include "defaults.h" #include "resource-manager.h" #include "shortcut-manager.h" diff -r 69fc8935020b -r 893344cee100 libgui/src/resource-manager.cc --- a/libgui/src/resource-manager.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libgui/src/resource-manager.cc Fri Jun 08 15:43:36 2018 -0400 @@ -41,7 +41,7 @@ #include "help.h" #include "oct-env.h" -#include "defaults.h" +#include "installation-data.h" #include "interpreter-private.h" #include "QTerminal.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/default-defs.in.h --- a/libinterp/corefcn/default-defs.in.h Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/default-defs.in.h Fri Jun 08 15:43:36 2018 -0400 @@ -21,8 +21,8 @@ */ -// These are used by functions declared in defaults.h and defined in -// defaults.cc. +// These are used by functions declared in installation-data.h and +// defined in installation-data.cc #if ! defined (OCTAVE_RELEASE) # define OCTAVE_RELEASE %OCTAVE_RELEASE% diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/defaults.cc --- a/libinterp/corefcn/defaults.cc Fri Jun 08 13:42:34 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,598 +0,0 @@ -/* - -Copyright (C) 1996-2018 John W. Eaton - -This file is part of Octave. - -Octave is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Octave is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#if defined (HAVE_CONFIG_H) -# include "config.h" -#endif - -#include - -#include -#include - -#include "dir-ops.h" -#include "file-ops.h" -#include "oct-env.h" - -#include "defaults.h" -#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" -#include "version.h" - -#include "default-defs.h" - -// Variables that name directories or files are substituted into source -// files with "${prefix}/" stripped from the beginning of the string. - -// All configure variables of this form should be specified as absolute -// directory names. The only ones that should not be absolute here are -// ones that have had "${prefix}/" or "${exec_prefix} stripped. - -namespace octave -{ - 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); - - 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); - } - - 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. - - 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; - } - } - - 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 (); - } - - 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 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 (); - } - - std::string include_dir (void) - { - installation_data& inst_data - = __get_installation_data__ ("include_dir"); - - return inst_data.include_dir (); - } - - std::string lib_dir (void) - { - installation_data& inst_data - = __get_installation_data__ ("lib_dir"); - - return inst_data.lib_dir (); - } - - 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 (); - } - - 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) - { - 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 (); - } - - 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"); - - 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 (); - } - - 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 (); - } - - 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 -} - -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}. -@seealso{EXEC_PATH, IMAGE_PATH, OCTAVE_EXEC_HOME} -@end deftypefn */) -{ - if (args.length () != 0) - print_usage (); - - octave::installation_data& inst_data = interp.get_installation_data (); - - return ovl (inst_data.home ()); -} - -/* -%!assert (ischar (OCTAVE_HOME ())) -%!error OCTAVE_HOME (1) -*/ - -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 -is the same as OCTAVE_HOME@. OCTAVE_EXEC_HOME corresponds to the -configuration variable @var{exec_prefix}. -@seealso{EXEC_PATH, IMAGE_PATH, OCTAVE_HOME} -@end deftypefn */) -{ - if (args.length () != 0) - print_usage (); - - octave::installation_data& inst_data = interp.get_installation_data (); - - return ovl (inst_data.exec_home ()); -} - -/* -%!assert (ischar (OCTAVE_EXEC_HOME ())) -%!error OCTAVE_EXEC_HOME (1) -*/ - -DEFUNX ("OCTAVE_VERSION", FOCTAVE_VERSION, args, , - doc: /* -*- texinfo -*- -@deftypefn {} {} OCTAVE_VERSION () -Return the version number of Octave as a string. -@seealso{ver, version} -@end deftypefn */) -{ - if (args.length () != 0) - print_usage (); - - return ovl (OCTAVE_VERSION); -} - -/* -%!assert (ischar (OCTAVE_VERSION ())) -%!error OCTAVE_VERSION (1) -*/ diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/defaults.h --- a/libinterp/corefcn/defaults.h Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/defaults.h Fri Jun 08 15:43:36 2018 -0400 @@ -27,419 +27,391 @@ #include -#include "pathsearch.h" +#include "installation-data.h" 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); + inline 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); + } 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); + inline 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); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::canonical_host_type' instead") - extern OCTINTERP_API std::string canonical_host_type (void); + inline std::string canonical_host_type (void) + { + installation_data& inst_data + = __get_installation_data__ ("canonical_host_type"); + + return inst_data.canonical_host_type (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::release' instead") - extern OCTINTERP_API std::string release (void); + inline std::string release (void) + { + installation_data& inst_data + = __get_installation_data__ ("release"); + + return inst_data.release (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::default_pager' instead") - extern OCTINTERP_API std::string default_pager (void); + inline std::string default_pager (void) + { + installation_data& inst_data + = __get_installation_data__ ("default_pager"); + + return inst_data.default_pager (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::octave_home' instead") - extern OCTINTERP_API std::string octave_home (void); + inline std::string octave_home (void) + { + installation_data& inst_data + = __get_installation_data__ ("octave_home"); + + return inst_data.home (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::octave_exec_home' instead") - extern OCTINTERP_API std::string octave_exec_home (void); + inline std::string octave_exec_home (void) + { + installation_data& inst_data + = __get_installation_data__ ("octave_exec_home"); + + return inst_data.exec_home (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::bin_dir' instead") - extern OCTINTERP_API std::string bin_dir (void); + inline std::string bin_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("bin_dir"); + + return inst_data.bin_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::data_dir' instead") - extern OCTINTERP_API std::string data_dir (void); + inline std::string data_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("data_dir"); + + return inst_data.data_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::dataroot_dir' instead") - extern OCTINTERP_API std::string dataroot_dir (void); + inline std::string dataroot_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("dataroot_dir"); + + return inst_data.dataroot_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::include_dir' instead") - extern OCTINTERP_API std::string include_dir (void); + inline std::string include_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("include_dir"); + + return inst_data.include_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::lib_dir' instead") - extern OCTINTERP_API std::string lib_dir (void); + inline std::string lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("lib_dir"); + + return inst_data.lib_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::libexec_dir' instead") - extern OCTINTERP_API std::string libexec_dir (void); + inline std::string libexec_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("libexec_dir"); + + return inst_data.libexec_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_ver_arch_lib_dir' instead") - extern OCTINTERP_API std::string local_ver_arch_lib_dir (void); + inline std::string arch_lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("arch_lib_dir"); + + return inst_data.arch_lib_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_api_arch_lib_dir' instead") - extern OCTINTERP_API std::string local_api_arch_lib_dir (void); + inline std::string info_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("info_dir"); + + return inst_data.info_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_arch_lib_dir' instead") - extern OCTINTERP_API std::string local_arch_lib_dir (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::arch_lib_dir' instead") - extern OCTINTERP_API std::string arch_lib_dir (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_ver_oct_file_dir' instead") - extern OCTINTERP_API std::string local_ver_oct_file_dir (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_api_oct_file_dir' instead") - extern OCTINTERP_API std::string local_api_oct_file_dir (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_oct_file_dir' instead") - extern OCTINTERP_API std::string local_oct_file_dir (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_file_dir' instead") - extern OCTINTERP_API std::string oct_file_dir (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_ver_fcn_file_dir' instead") - extern OCTINTERP_API std::string local_ver_fcn_file_dir (void); + inline std::string oct_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_file_dir"); + + return inst_data.oct_file_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_api_fcn_file_dir' instead") - extern OCTINTERP_API std::string local_api_fcn_file_dir (void); + inline std::string local_ver_fcn_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_ver_fcn_file_dir"); + + return inst_data.local_ver_fcn_file_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_fcn_file_dir' instead") - extern OCTINTERP_API std::string local_fcn_file_dir (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::fcn_file_dir' instead") - extern OCTINTERP_API std::string fcn_file_dir (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_data_dir' instead") - extern OCTINTERP_API std::string oct_data_dir (void); + inline std::string fcn_file_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("fcn_file_dir"); + + return inst_data.fcn_file_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_doc_dir' instead") - extern OCTINTERP_API std::string oct_doc_dir (void); + inline std::string oct_data_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_data_dir"); + + return inst_data.oct_data_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_etc_dir' instead") - extern OCTINTERP_API std::string oct_etc_dir (void); + inline std::string oct_doc_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_doc_dir"); + + return inst_data.oct_doc_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_fonts_dir' instead") - extern OCTINTERP_API std::string oct_fonts_dir (void); + inline std::string oct_etc_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_etc_dir"); + + return inst_data.oct_etc_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_include_dir' instead") - extern OCTINTERP_API std::string oct_include_dir (void); + inline std::string oct_fonts_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_fonts_dir"); + + return inst_data.oct_fonts_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_lib_dir' instead") - extern OCTINTERP_API std::string oct_lib_dir (void); + inline std::string oct_include_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_include_dir"); + + return inst_data.oct_include_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_locale_dir' instead") - extern OCTINTERP_API std::string oct_locale_dir (void); + inline std::string oct_lib_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_lib_dir"); + + return inst_data.oct_lib_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::oct_tests_dir' instead") - extern OCTINTERP_API std::string oct_tests_dir (void); + inline std::string oct_locale_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_locale_dir"); + + return inst_data.oct_locale_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::info_dir' instead") - extern OCTINTERP_API std::string info_dir (void); + inline std::string oct_tests_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("oct_tests_dir"); + + return inst_data.oct_tests_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::man_dir' instead") - extern OCTINTERP_API std::string man_dir (void); + inline std::string man_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("man_dir"); + + return inst_data.man_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::man1_dir' instead") - extern OCTINTERP_API std::string man1_dir (void); + inline std::string man1_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("man1_dir"); + + return inst_data.man1_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::man1_ext' instead") - extern OCTINTERP_API std::string man1_ext (void); + inline std::string man1_ext (void) + { + installation_data& inst_data + = __get_installation_data__ ("man1_ext"); + + return inst_data.man1_ext (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::image_dir' instead") - extern OCTINTERP_API std::string image_dir (void); + inline std::string image_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("image_dir"); + + return inst_data.image_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_startupfile_dir' instead") - extern OCTINTERP_API std::string local_startupfile_dir (void); + inline std::string local_startupfile_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("local_startupfile_dir"); + + return inst_data.local_startupfile_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::startupfile_dir' instead") - extern OCTINTERP_API std::string startupfile_dir (void); + inline std::string startupfile_dir (void) + { + installation_data& inst_data + = __get_installation_data__ ("startupfile_dir"); + + return inst_data.startupfile_dir (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::local_site_defaults_file' instead") - extern OCTINTERP_API std::string local_site_defaults_file (void); + inline 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 (); + } OCTAVE_DEPRECATED (5, "use 'octave::installation_data::site_defaults_file' instead") - extern OCTINTERP_API std::string site_defaults_file (void); + inline std::string site_defaults_file (void) + { + installation_data& inst_data + = __get_installation_data__ ("site_defaults_file"); + + return inst_data.site_defaults_file (); + } #endif } diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/dynamic-ld.cc --- a/libinterp/corefcn/dynamic-ld.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/dynamic-ld.cc Fri Jun 08 15:43:36 2018 -0400 @@ -31,7 +31,6 @@ #include "oct-env.h" #include "oct-time.h" -#include "defaults.h" #include "defun.h" #include "dynamic-ld.h" #include "interpreter-private.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/environment.cc --- a/libinterp/corefcn/environment.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/environment.cc Fri Jun 08 15:43:36 2018 -0400 @@ -32,9 +32,9 @@ #include "pathsearch.h" #include "str-vec.h" -#include "defaults.h" #include "defun.h" #include "environment.h" +#include "installation-data.h" #include "interpreter.h" #include "variables.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/ft-text-renderer.cc --- a/libinterp/corefcn/ft-text-renderer.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/ft-text-renderer.cc Fri Jun 08 15:43:36 2018 -0400 @@ -54,9 +54,9 @@ #include "singleton-cleanup.h" #include "unistr-wrappers.h" -#include "defaults.h" #include "error.h" #include "file-ops.h" +#include "installation-data.h" #include "interpreter-private.h" #include "oct-env.h" #include "pr-output.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/help.cc --- a/libinterp/corefcn/help.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/help.cc Fri Jun 08 15:43:36 2018 -0400 @@ -44,13 +44,13 @@ #include "Cell.h" #include "builtin-defun-decls.h" #include "call-stack.h" -#include "defaults.h" #include "defun.h" #include "dirfns.h" #include "error.h" #include "errwarn.h" #include "help.h" #include "input.h" +#include "installation-data.h" #include "interpreter-private.h" #include "interpreter.h" #include "load-path.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/installation-data.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libinterp/corefcn/installation-data.cc Fri Jun 08 15:43:36 2018 -0400 @@ -0,0 +1,251 @@ +/* + +Copyright (C) 1996-2018 John W. Eaton + +This file is part of Octave. + +Octave is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Octave is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + +#include +#include + +#include "dir-ops.h" +#include "file-ops.h" +#include "oct-env.h" + +#include "defun.h" +#include "installation-data.h" +#include "interpreter-private.h" +#include "interpreter.h" +#include "ovl.h" +#include "ov.h" +#include "variables.h" +#include "version.h" + +#include "default-defs.h" + +// Variables that name directories or files are substituted into source +// files with "${prefix}/" stripped from the beginning of the string. + +// All configure variables of this form should be specified as absolute +// directory names. The only ones that should not be absolute here are +// ones that have had "${prefix}/" or "${exec_prefix} stripped. + +namespace octave +{ + 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); + + 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); + } + + 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. + + 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; + } + } + + 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; + } +} + +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}. +@seealso{EXEC_PATH, IMAGE_PATH, OCTAVE_EXEC_HOME} +@end deftypefn */) +{ + if (args.length () != 0) + print_usage (); + + octave::installation_data& inst_data = interp.get_installation_data (); + + return ovl (inst_data.home ()); +} + +/* +%!assert (ischar (OCTAVE_HOME ())) +%!error OCTAVE_HOME (1) +*/ + +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 +is the same as OCTAVE_HOME@. OCTAVE_EXEC_HOME corresponds to the +configuration variable @var{exec_prefix}. +@seealso{EXEC_PATH, IMAGE_PATH, OCTAVE_HOME} +@end deftypefn */) +{ + if (args.length () != 0) + print_usage (); + + octave::installation_data& inst_data = interp.get_installation_data (); + + return ovl (inst_data.exec_home ()); +} + +/* +%!assert (ischar (OCTAVE_EXEC_HOME ())) +%!error OCTAVE_EXEC_HOME (1) +*/ + +DEFUNX ("OCTAVE_VERSION", FOCTAVE_VERSION, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} OCTAVE_VERSION () +Return the version number of Octave as a string. +@seealso{ver, version} +@end deftypefn */) +{ + if (args.length () != 0) + print_usage (); + + return ovl (OCTAVE_VERSION); +} + +/* +%!assert (ischar (OCTAVE_VERSION ())) +%!error OCTAVE_VERSION (1) +*/ diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/installation-data.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libinterp/corefcn/installation-data.h Fri Jun 08 15:43:36 2018 -0400 @@ -0,0 +1,311 @@ +/* + +Copyright (C) 1993-2018 John W. Eaton + +This file is part of Octave. + +Octave is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Octave is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#if ! defined (octave_installation_data_h) +#define octave_installation_data_h 1 + +#include "octave-config.h" + +#include + +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; + }; +} + +#endif diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/interpreter.cc --- a/libinterp/corefcn/interpreter.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/interpreter.cc Fri Jun 08 15:43:36 2018 -0400 @@ -38,9 +38,8 @@ #include "signal-wrappers.h" #include "unistd-wrappers.h" +#include "Cell.h" #include "builtin-defun-decls.h" -#include "defaults.h" -#include "Cell.h" #include "call-stack.h" #include "defun.h" #include "display.h" @@ -49,18 +48,19 @@ #include "graphics.h" #include "help.h" #include "input.h" +#include "installation-data.h" #include "interpreter-private.h" #include "interpreter.h" #include "load-path.h" #include "load-save.h" -#include "octave-link.h" -#include "octave.h" #include "oct-hist.h" #include "oct-map.h" #include "oct-mutex.h" -#include "ovl.h" +#include "octave-link.h" +#include "octave.h" +#include "ov-classdef.h" #include "ov.h" -#include "ov-classdef.h" +#include "ovl.h" #include "parse.h" #include "pt-eval.h" #include "pt-jump.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/interpreter.h --- a/libinterp/corefcn/interpreter.h Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/interpreter.h Fri Jun 08 15:43:36 2018 -0400 @@ -31,12 +31,12 @@ #include "quit.h" #include "str-vec.h" -#include "defaults.h" #include "dynamic-ld.h" #include "environment.h" #include "gtk-manager.h" #include "help.h" #include "input.h" +#include "installation-data.h" #include "load-path.h" #include "oct-stream.h" #include "ov-classdef.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/load-path.cc --- a/libinterp/corefcn/load-path.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/load-path.cc Fri Jun 08 15:43:36 2018 -0400 @@ -33,9 +33,9 @@ #include "oct-env.h" #include "pathsearch.h" -#include "defaults.h" #include "defun.h" #include "input.h" +#include "installation-data.h" #include "interpreter-private.h" #include "interpreter.h" #include "load-path.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/ls-mat5.cc --- a/libinterp/corefcn/ls-mat5.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/ls-mat5.cc Fri Jun 08 15:43:36 2018 -0400 @@ -52,10 +52,10 @@ #include "Cell.h" #include "call-stack.h" -#include "defaults.h" #include "defun.h" #include "error.h" #include "errwarn.h" +#include "installation-data.h" #include "interpreter-private.h" #include "interpreter.h" #include "load-path.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/module.mk --- a/libinterp/corefcn/module.mk Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/module.mk Fri Jun 08 15:43:36 2018 -0400 @@ -17,13 +17,12 @@ DIRSTAMP_FILES += %reldir%/$(octave_dirstamp) COREFCN_INC = \ + %reldir%/Cell.h \ %reldir%/base-text-renderer.h \ - %reldir%/Cell.h \ %reldir%/c-file-ptr-stream.h \ %reldir%/call-stack.h \ %reldir%/cdisplay.h \ %reldir%/data.h \ - %reldir%/defaults.h \ %reldir%/defun-dld.h \ %reldir%/defun-int.h \ %reldir%/defun.h \ @@ -45,6 +44,7 @@ %reldir%/help.h \ %reldir%/hook-fcn.h \ %reldir%/input.h \ + %reldir%/installation-data.h \ %reldir%/interpreter.h \ %reldir%/load-path.h \ %reldir%/load-save.h \ @@ -53,8 +53,8 @@ %reldir%/ls-mat-ascii.h \ %reldir%/ls-mat4.h \ %reldir%/ls-mat5.h \ + %reldir%/ls-oct-binary.h \ %reldir%/ls-oct-text.h \ - %reldir%/ls-oct-binary.h \ %reldir%/ls-utils.h \ %reldir%/mex.h \ %reldir%/mexproto.h \ @@ -133,7 +133,6 @@ %reldir%/dassl.cc \ %reldir%/data.cc \ %reldir%/debug.cc \ - %reldir%/defaults.cc \ %reldir%/defun.cc \ %reldir%/det.cc \ %reldir%/dirfns.cc \ @@ -172,6 +171,7 @@ %reldir%/hex2num.cc \ %reldir%/hook-fcn.cc \ %reldir%/input.cc \ + %reldir%/installation-data.cc \ %reldir%/inv.cc \ %reldir%/interpreter-private.cc \ %reldir%/interpreter.cc \ diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/oct-hist.cc --- a/libinterp/corefcn/oct-hist.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/oct-hist.cc Fri Jun 08 15:43:36 2018 -0400 @@ -50,7 +50,6 @@ #include "str-vec.h" #include "unistd-wrappers.h" -#include "defaults.h" #include "defun.h" #include "error.h" #include "errwarn.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/pager.cc --- a/libinterp/corefcn/pager.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/pager.cc Fri Jun 08 15:43:36 2018 -0400 @@ -33,13 +33,13 @@ #include "oct-env.h" #include "oct-syscalls.h" -#include "defaults.h" #include "defun.h" #include "error.h" #include "errwarn.h" #include "input.h" +#include "installation-data.h" +#include "interpreter-private.h" #include "interpreter.h" -#include "interpreter-private.h" #include "octave.h" #include "ovl.h" #include "pager.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/toplev.cc --- a/libinterp/corefcn/toplev.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/toplev.cc Fri Jun 08 15:43:36 2018 -0400 @@ -47,19 +47,19 @@ #include "wait-for-input.h" #include "build-env.h" -#include "liboctinterp-build-info.h" #include "call-stack.h" -#include "defaults.h" #include "defun.h" #include "error.h" #include "file-io.h" #include "help.h" +#include "installation-data.h" #include "interpreter-private.h" #include "interpreter.h" -#include "octave.h" +#include "liboctinterp-build-info.h" #include "oct-map.h" +#include "octave.h" +#include "ov.h" #include "ovl.h" -#include "ov.h" #include "pager.h" #include "procstream.h" #include "sysdep.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/utils.cc --- a/libinterp/corefcn/utils.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/utils.cc Fri Jun 08 15:43:36 2018 -0400 @@ -48,7 +48,6 @@ #include "vasprintf-wrapper.h" #include "Cell.h" -#include "defaults.h" #include "defun.h" #include "dirfns.h" #include "error.h" diff -r 69fc8935020b -r 893344cee100 libinterp/corefcn/variables.cc --- a/libinterp/corefcn/variables.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/corefcn/variables.cc Fri Jun 08 15:43:36 2018 -0400 @@ -40,7 +40,6 @@ #include "str-vec.h" #include "call-stack.h" -#include "defaults.h" #include "Cell.h" #include "defun.h" #include "dirfns.h" diff -r 69fc8935020b -r 893344cee100 libinterp/octave-value/ov-dld-fcn.cc --- a/libinterp/octave-value/ov-dld-fcn.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/octave-value/ov-dld-fcn.cc Fri Jun 08 15:43:36 2018 -0400 @@ -26,13 +26,13 @@ #include "oct-shlib.h" -#include "defaults.h" #include "dynamic-ld.h" #include "error.h" +#include "installation-data.h" #include "interpreter-private.h" -#include "ovl.h" #include "ov-dld-fcn.h" #include "ov.h" +#include "ovl.h" DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_dld_function, diff -r 69fc8935020b -r 893344cee100 libinterp/octave-value/ov-fcn-handle.cc --- a/libinterp/octave-value/ov-fcn-handle.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/octave-value/ov-fcn-handle.cc Fri Jun 08 15:43:36 2018 -0400 @@ -36,12 +36,12 @@ #include "oct-locbuf.h" #include "call-stack.h" -#include "defaults.h" #include "defun.h" #include "error.h" #include "errwarn.h" #include "file-stat.h" #include "input.h" +#include "installation-data.h" #include "interpreter-private.h" #include "interpreter.h" #include "load-path.h" diff -r 69fc8935020b -r 893344cee100 libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/octave-value/ov-java.cc Fri Jun 08 15:43:36 2018 -0400 @@ -45,13 +45,13 @@ #include "Cell.h" #include "builtin-defun-decls.h" #include "cmd-edit.h" -#include "defaults.h" #include "defun.h" #include "error.h" #include "errwarn.h" #include "file-ops.h" #include "file-stat.h" #include "fpucw-wrappers.h" +#include "installation-data.h" #include "interpreter-private.h" #include "load-path.h" #include "oct-env.h" diff -r 69fc8935020b -r 893344cee100 libinterp/octave-value/ov-mex-fcn.cc --- a/libinterp/octave-value/ov-mex-fcn.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/octave-value/ov-mex-fcn.cc Fri Jun 08 15:43:36 2018 -0400 @@ -27,10 +27,10 @@ #include "oct-shlib.h" #include "call-stack.h" -#include "defaults.h" #include "dynamic-ld.h" #include "error.h" #include "errwarn.h" +#include "installation-data.h" #include "interpreter-private.h" #include "interpreter.h" #include "ov-mex-fcn.h" diff -r 69fc8935020b -r 893344cee100 libinterp/octave-value/ov-usr-fcn.cc --- a/libinterp/octave-value/ov-usr-fcn.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/octave-value/ov-usr-fcn.cc Fri Jun 08 15:43:36 2018 -0400 @@ -30,18 +30,23 @@ #include "file-stat.h" #include "str-vec.h" +#include "Cell.h" #include "builtin-defun-decls.h" #include "call-stack.h" -#include "defaults.h" -#include "Cell.h" #include "defun.h" #include "error.h" #include "errwarn.h" #include "input.h" -#include "ovl.h" +#include "installation-data.h" +#include "interpreter-private.h" +#include "interpreter.h" +#include "ov-fcn-handle.h" #include "ov-usr-fcn.h" #include "ov.h" +#include "ovl.h" #include "pager.h" +#include "parse.h" +#include "profiler.h" #include "pt-eval.h" #include "pt-jit.h" #include "pt-jump.h" @@ -50,14 +55,9 @@ #include "pt-stmt.h" #include "pt-walk.h" #include "symtab.h" -#include "interpreter-private.h" -#include "interpreter.h" #include "unwind-prot.h" #include "utils.h" -#include "parse.h" -#include "profiler.h" #include "variables.h" -#include "ov-fcn-handle.h" // Whether to optimize subsasgn method calls. static bool Voptimize_subsasgn_calls = true; diff -r 69fc8935020b -r 893344cee100 libinterp/octave.cc --- a/libinterp/octave.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/octave.cc Fri Jun 08 15:43:36 2018 -0400 @@ -36,7 +36,6 @@ #include "str-vec.h" #include "Cell.h" -#include "defaults.h" #include "defun.h" #include "display.h" #include "error.h" diff -r 69fc8935020b -r 893344cee100 libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Fri Jun 08 13:42:34 2018 -0400 +++ b/libinterp/parse-tree/oct-parse.in.yy Fri Jun 08 15:43:36 2018 -0400 @@ -55,7 +55,6 @@ #include "Cell.h" #include "builtin-defun-decls.h" #include "call-stack.h" -#include "defaults.h" #include "defun.h" #include "dirfns.h" #include "dynamic-ld.h" diff -r 69fc8935020b -r 893344cee100 src/main-cli.cc --- a/src/main-cli.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/src/main-cli.cc Fri Jun 08 15:43:36 2018 -0400 @@ -36,7 +36,6 @@ #include "oct-env.h" #include "signal-wrappers.h" -#include "defaults.h" #include "octave.h" #include "octave-build-info.h" #include "sysdep.h" diff -r 69fc8935020b -r 893344cee100 src/main-gui.cc --- a/src/main-gui.cc Fri Jun 08 13:42:34 2018 -0400 +++ b/src/main-gui.cc Fri Jun 08 15:43:36 2018 -0400 @@ -37,7 +37,6 @@ #include "oct-env.h" -#include "defaults.h" #include "octave.h" #include "octave-build-info.h" #include "octave-gui.h"