Index: module.c =================================================================== RCS file: /cvs/porting/sal/osl/unx/module.c,v retrieving revision 1.33 diff -u -r1.33 module.c --- sal/osl/unx/module.c 9 May 2006 15:43:15 -0000 1.33 +++ sal/osl/unx/module.c 7 Sep 2006 21:37:43 -0000 @@ -95,6 +95,8 @@ oslModule SAL_CALL osl_psz_loadModule(const sal_Char *pszModuleName, sal_Int32 nRtldMode); void* SAL_CALL osl_psz_getSymbol(oslModule hModule, const sal_Char* pszSymbolName); +oslProcessError SAL_CALL osl_bootstrap_getExecutableFile_Impl(rtl_uString ** ppFileURL); + /*****************************************************************************/ /* osl_loadModule */ /*****************************************************************************/ @@ -116,8 +118,21 @@ if (UnicodeToText(buffer, PATH_MAX, ustrTmp->buffer, ustrTmp->length)) pModule = osl_psz_loadModule(buffer, nRtldMode); + + if (!pModule && (0 == strchr(buffer, '/'))) + { + rtl_uString* ustrExecutableFile = NULL; + + if (osl_Process_E_None == osl_bootstrap_getExecutableFile_Impl(&ustrExecutableFile)) + { + sal_Int32 n = rtl_ustr_lastIndexOfChar(ustrExecutableFile->buffer, (sal_Unicode) '/'); + rtl_uString_newReplaceStrAt(&ustrTmp, ustrExecutableFile, n + 1, ustrExecutableFile->length - n - 1, ustrModuleName); + pModule = osl_loadModule(ustrTmp, nRtldMode); + rtl_uString_release(ustrExecutableFile); + } + } + rtl_uString_release(ustrTmp); } - rtl_uString_release(ustrTmp); return pModule; } @@ -134,23 +149,10 @@ { #ifndef NO_DL_FUNCTIONS void* pLib = dlopen(pszModuleName, rtld_mode); - if ((pLib == 0) && (strchr (pszModuleName, '/') == 0)) - { - /* module w/o pathname not found, try cwd as last chance */ - char buffer[PATH_MAX]; - - buffer[0] = '.', buffer[1] = '/', buffer[2] = '\0'; - strncat (buffer, pszModuleName, sizeof(buffer) - 2); - - pLib = dlopen(buffer, rtld_mode); - } #if OSL_DEBUG_LEVEL > 1 if (pLib == 0) - { - /* module not found, give up */ - fprintf (stderr, "Error osl_loadModule: %s\n", dlerror()); - } + OSL_TRACE("Error osl_loadModule: %s\n", dlerror()); #endif /* OSL_DEBUG_LEVEL */ return ((oslModule)(pLib));