diff -ur aspell/common/config.cpp aspell.binary/common/config.cpp --- aspell/common/config.cpp Thu Nov 28 02:53:44 2002 +++ aspell.binary/common/config.cpp Sun Dec 1 16:02:32 2002 @@ -25,6 +25,26 @@ #define DEFAULT_LANG "en_US" +#ifdef ENABLE_WIN32_RELOCATABLE +#include "windows.h" +#endif + +#ifdef WIN32 +HINSTANCE hInst; +#endif + +#ifdef WIN32 +#ifdef __cplusplus +extern "C" +#endif +BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + if (fdwReason == DLL_PROCESS_ATTACH) + hInst = hInstDLL; + return TRUE; +} +#endif /* WIN32 */ + namespace acommon { static const ConfigModule a_module = ConfigModule(); @@ -44,6 +64,25 @@ kmi.extra_end = 0; kmi.modules_begin = &a_module; kmi.modules_end = &a_module; +#ifdef ENABLE_WIN32_RELOCATABLE + PosibErr ret = retrieve_bool("set-prefix"); + err_.reset(ret.release_err()); + if (err_ == 0) { + char filename[MAX_PATH]; + GetModuleFileName(hInst,filename,MAX_PATH); + char * last_slash = 0; + for (char * i = filename; *i != '\0'; ++i) { + if (*i == '\\') { + *i = '/'; + last_slash = i; + } + } + // Assume executable is in /bin + *(last_slash-4) = '\0'; + PosibErr ret = replace("prefix", filename); + err_.reset(ret.release_err()); + } +#endif } Config::~Config() { @@ -429,7 +468,8 @@ } else { // sep == '|' assert(replace[0] == '$'); const char * env = getenv(replace.c_str()+1); - final_str += env ? env : second; + final_str += env ? env + : have(second) ? (String)retrieve(second) : second; } replace = ""; in_replace = false; @@ -895,7 +935,7 @@ #define CANT_CHANGE 1 #ifdef ENABLE_WIN32_RELOCATABLE -# define HOME_DIR "" +# define HOME_DIR "<$HOME|prefix>" # define PERSONAL ".pws" # define REPL ".prepl" #else