From 3bb494bbf05afb4f7de841bfb16ef90d5b620e23 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 14 Jun 2002 15:54:14 +0000 Subject: [PATCH] configpath defaults to .:/fat/people/drose:/usr/local/etc --- dtool/src/dconfig/configTable.I | 10 +----- dtool/src/dconfig/configTable.cxx | 59 +++++++++++++------------------ 2 files changed, 25 insertions(+), 44 deletions(-) diff --git a/dtool/src/dconfig/configTable.I b/dtool/src/dconfig/configTable.I index ba5e8df919..b45505ee42 100644 --- a/dtool/src/dconfig/configTable.I +++ b/dtool/src/dconfig/configTable.I @@ -49,15 +49,7 @@ INLINE void ConfigTable::ConfigSuffixDefault(void) { } INLINE void ConfigTable::ConfigPathDefault(void) { -#ifdef PENV_PS2 - - // When this is empty, ReadConfigFile (ConfigTable.C) is forced - // to look in CONFIG_PATH compiler_flag (instead of env var) - - configpath = ""; -#else - configpath = "CONFIG_PATH"; -#endif + configpath = "CFG_PATH"; } INLINE void ConfigTable::ConfigCmtDefault(void) { diff --git a/dtool/src/dconfig/configTable.cxx b/dtool/src/dconfig/configTable.cxx index 56f95d0d51..c74e06e990 100644 --- a/dtool/src/dconfig/configTable.cxx +++ b/dtool/src/dconfig/configTable.cxx @@ -120,45 +120,34 @@ void ConfigTable::ParseConfigFile(istream& is, const ConfigString& Filename) } void ConfigTable::ReadConfigFile(void) { - if (configpath.empty()) { + // The configpath variable lists the environment variables that + // themselves should be considered to contain search paths for + // Configrc files. This is one level of indirection from the + // intuitive definition. -#ifdef PENV_PS2 - - // roight. PS2 has no environment variables, so the config path - // has to be explicitly set with the CONFIG_PATH compiler variable. - // this is currently done in makefile.config.so... - - // CSN. - -#ifndef CONFIG_PATH -#define CONFIG_PATH "." -#endif - configpath = CONFIG_PATH; -#else - configpath = "."; -#endif - } else { - ConfigString S; - while (!configpath.empty()) { - int i = configpath.find_first_of(" "); - ConfigString stmp = configpath.substr(0, i); - if (ExecutionEnvironment::has_environment_variable(stmp)) { - S += " "; - S += ExecutionEnvironment::get_environment_variable(stmp); - } - configpath.erase(0, i); - CropString(configpath); + DSearchPath config_search; + while (!configpath.empty()) { + int i = configpath.find_first_of(" "); + ConfigString stmp = configpath.substr(0, i); + if (ExecutionEnvironment::has_environment_variable(stmp)) { + config_search.append_path(ExecutionEnvironment::get_environment_variable(stmp)); } - if (S.empty()) - S = "."; - CropString(S); - configpath = S; + configpath.erase(0, i); + CropString(configpath); + } + + if (config_search.is_empty()) { + // If we still have no directories on the search path, then at + // least search the current directory. + config_search.append_directory("."); + } + + if (microconfig_cat->is_spam()) { + microconfig_cat->spam() + << "search path from configpath is: " + << config_search << endl; } - if (microconfig_cat->is_spam()) - microconfig_cat->spam() << "evaluated value of configpath '" - << configpath << "'" << endl; - DSearchPath config_search(configpath); DSearchPath::Results config_files; if (!configsuffix.empty()) {