summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2008-12-11 12:57:12 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2008-12-11 12:57:12 +0000
commit392fb0681022a7fa4b04003f7267cdcf96873a60 (patch)
tree200b7b82f396b779edbaec09765ab6fa11ff6cf7
parent8a7a7106325711640c7a63f2bfa7b2c1aede314a (diff)
CWS-TOOLING: integrate CWS sb101
2008-12-08 16:52:06 +0100 sb r265009 : #i95330# python23.dll needs to be copied to brand layer, not just moved there 2008-11-24 18:15:54 +0100 sb r264259 : #i95022# tools::extendApplicationEnvironment gets URE_BOOTSTRAP value from outside bootstrap.cxx, so needs to operate in LOOKUP_MODE_URE_BOOTSTRAP, too 2008-11-20 21:12:31 +0100 jbu r264103 : deactivated debug log 2008-11-20 21:09:03 +0100 jbu r264102 : #i95331# ld_library_path now contains ure/lib directory 2008-11-20 21:05:37 +0100 jbu r264101 : #i95330# python.dll is now installed in the brand-program directory (unix remains unchanged) 2008-11-20 20:46:57 +0100 jbu r264099 : #i95118# + #i93994# Python scripts in share and user uno packages now work again 2008-11-20 20:38:23 +0100 jbu r264098 : #i95037# python wrapper now waits for completion of python executable and currectly returns the exit state 2008-11-20 10:46:28 +0100 sb r264034 : #i95028# import socket, since on Windows sal3.dll no longer calls WSAStartup (and import socket does) 2008-11-18 17:01:09 +0100 sb r263784 : #i96314# fixed encode() 2008-11-18 15:59:17 +0100 sb r263779 : #i95024# missing vnd.sun.star.pathname: in URE_BOOTSTRAP 2008-11-18 13:51:36 +0100 sb r263765 : #i95022# treat \ and $ verbatim in URE_BOOTSTRAP=vnd.sun.star.pathname values
-rw-r--r--pyuno/source/loader/pythonloader.py2
-rw-r--r--pyuno/source/module/uno.py1
-rw-r--r--pyuno/zipcore/python.cxx22
-rw-r--r--pyuno/zipcore/python.sh2
-rw-r--r--sal/rtl/source/bootstrap.cxx197
5 files changed, 135 insertions, 89 deletions
diff --git a/pyuno/source/loader/pythonloader.py b/pyuno/source/loader/pythonloader.py
index 5a246ea4237e..0a5e8f5fc271 100644
--- a/pyuno/source/loader/pythonloader.py
+++ b/pyuno/source/loader/pythonloader.py
@@ -38,7 +38,7 @@ from com.sun.star.loader import XImplementationLoader
from com.sun.star.lang import XServiceInfo
MODULE_PROTOCOL = "vnd.openoffice.pymodule:"
-DEBUG = 1
+DEBUG = 0
g_supportedServices = "com.sun.star.loader.Python", # referenced by the native C++ loader !
g_implementationName = "org.openoffice.comp.pyuno.Loader" # referenced by the native C++ loader !
diff --git a/pyuno/source/module/uno.py b/pyuno/source/module/uno.py
index e9484bb67fb9..e35cdd0133c6 100644
--- a/pyuno/source/module/uno.py
+++ b/pyuno/source/module/uno.py
@@ -32,6 +32,7 @@ import sys
import pyuno
import __builtin__
+import socket # since on Windows sal3.dll no longer calls WSAStartup
# all functions and variables starting with a underscore (_) must be considered private
# and can be changed at any time. Don't use them
diff --git a/pyuno/zipcore/python.cxx b/pyuno/zipcore/python.cxx
index 4a7fa06d85c1..412f75a84598 100644
--- a/pyuno/zipcore/python.cxx
+++ b/pyuno/zipcore/python.cxx
@@ -55,14 +55,17 @@ wchar_t * encode(wchar_t * buffer, wchar_t const * text) {
wchar_t c = *text++;
if (c == L'\0') {
break;
- } else if (c == L'$') {
+ } else if (c == L'"') {
+ // Double any preceding backslashes as required by Windows:
+ for (std::size_t i = 0; i < n; ++i) {
+ *buffer++ = L'\\';
+ }
*buffer++ = L'\\';
- *buffer++ = L'$';
+ *buffer++ = L'"';
n = 0;
} else if (c == L'\\') {
*buffer++ = L'\\';
- *buffer++ = L'\\';
- n += 2;
+ ++n;
} else {
*buffer++ = c;
n = 0;
@@ -88,9 +91,11 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
exit(EXIT_FAILURE);
}
wchar_t * pathEnd = tools::filename(path);
- wchar_t bootstrap[MAX_PATH];
+ wchar_t bootstrap[MY_LENGTH(L"vnd.sun.star.pathname:") + MAX_PATH] =
+ L"vnd.sun.star.pathname:"; //TODO: overflow
wchar_t * bootstrapEnd = tools::buildPath(
- bootstrap, path, pathEnd, MY_STRING(L"fundamental.ini"));
+ bootstrap + MY_LENGTH(L"vnd.sun.star.pathname:"), path, pathEnd,
+ MY_STRING(L"fundamental.ini"));
if (bootstrapEnd == NULL ||
(tools::buildPath(path, path, pathEnd, MY_STRING(L"..\\basis-link"))
== NULL))
@@ -251,5 +256,8 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
NULL, &startinfo, &procinfo)) {
exit(EXIT_FAILURE);
}
- exit(EXIT_SUCCESS);
+ WaitForSingleObject(procinfo.hProcess,INFINITE);
+ DWORD exitStatus;
+ GetExitCodeProcess(procinfo.hProcess,&exitStatus);
+ exit(exitStatus);
}
diff --git a/pyuno/zipcore/python.sh b/pyuno/zipcore/python.sh
index ef54c75ecccc..5195f68e24aa 100644
--- a/pyuno/zipcore/python.sh
+++ b/pyuno/zipcore/python.sh
@@ -48,7 +48,7 @@ PATH=$sd_prog${PATH+:$PATH}
export PATH
# Set LD_LIBRARY_PATH so that "import pyuno" finds libpyuno.so:
-LD_LIBRARY_PATH=$sd_prog/../basis-link/program${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
+LD_LIBRARY_PATH=$sd_prog/../basis-link/program:$sd_prog/../basis-link/ure-link/lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
# Set URE_BOOTSTRAP so that "uno.getComponentContext()" bootstraps a complete
diff --git a/sal/rtl/source/bootstrap.cxx b/sal/rtl/source/bootstrap.cxx
index d73b704cca60..23dab839d558 100644
--- a/sal/rtl/source/bootstrap.cxx
+++ b/sal/rtl/source/bootstrap.cxx
@@ -71,12 +71,18 @@ struct Bootstrap_Impl;
namespace {
+static char const VND_SUN_STAR_PATHNAME[] = "vnd.sun.star.pathname:";
+
+bool isPathnameUrl(rtl::OUString const & url) {
+ return url.matchIgnoreAsciiCaseAsciiL(
+ RTL_CONSTASCII_STRINGPARAM(VND_SUN_STAR_PATHNAME));
+}
+
bool resolvePathnameUrl(rtl::OUString * url) {
OSL_ASSERT(url != NULL);
- static char const schema[] = "vnd.sun.star.pathname:";
- if (!url->matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM(schema)) ||
+ if (!isPathnameUrl(*url) ||
(osl::FileBase::getFileURLFromSystemPath(
- url->copy(RTL_CONSTASCII_LENGTH(schema)), *url) ==
+ url->copy(RTL_CONSTASCII_LENGTH(VND_SUN_STAR_PATHNAME)), *url) ==
osl::FileBase::E_None))
{
return true;
@@ -86,29 +92,9 @@ bool resolvePathnameUrl(rtl::OUString * url) {
}
}
-static char const URE_BOOTSTRAP[] = "URE_BOOTSTRAP";
-
-struct FundamentalIniData {
- rtlBootstrapHandle ini;
-
- FundamentalIniData() {
- OUString uri;
- ini =
- (rtl::Bootstrap::get(
- OUString(RTL_CONSTASCII_USTRINGPARAM(URE_BOOTSTRAP)), uri) &&
- resolvePathnameUrl(&uri))
- ? rtl_bootstrap_args_open(uri.pData) : NULL;
- }
-
- ~FundamentalIniData() { rtl_bootstrap_args_close(ini); }
-
-private:
- FundamentalIniData(FundamentalIniData &); // not defined
- void operator =(FundamentalIniData &); // not defined
-};
-
-struct FundamentalIni: public rtl::Static< FundamentalIniData, FundamentalIni >
-{};
+enum LookupMode {
+ LOOKUP_MODE_NORMAL, LOOKUP_MODE_URE_BOOTSTRAP,
+ LOOKUP_MODE_URE_BOOTSTRAP_EXPANSION };
struct ExpandRequestLink {
ExpandRequestLink const * next;
@@ -117,11 +103,11 @@ struct ExpandRequestLink {
};
rtl::OUString expandMacros(
- Bootstrap_Impl const * file, rtl::OUString const & text,
+ Bootstrap_Impl const * file, rtl::OUString const & text, LookupMode mode,
ExpandRequestLink const * requestStack);
rtl::OUString recursivelyExpandMacros(
- Bootstrap_Impl const * file, rtl::OUString const & text,
+ Bootstrap_Impl const * file, rtl::OUString const & text, LookupMode mode,
Bootstrap_Impl const * requestFile, rtl::OUString const & requestKey,
ExpandRequestLink const * requestStack)
{
@@ -134,7 +120,7 @@ rtl::OUString recursivelyExpandMacros(
}
}
ExpandRequestLink link = { requestStack, requestFile, requestKey };
- return expandMacros(file, text, &link);
+ return expandMacros(file, text, mode, &link);
}
}
@@ -353,13 +339,17 @@ struct Bootstrap_Impl
bool getValue(
rtl::OUString const & key, rtl_uString ** value,
- rtl_uString * defaultValue, bool override,
+ rtl_uString * defaultValue, LookupMode mode, bool override,
ExpandRequestLink const * requestStack) const;
bool getDirectValue(
- rtl::OUString const & key, rtl_uString ** value,
+ rtl::OUString const & key, rtl_uString ** value, LookupMode mode,
ExpandRequestLink const * requestStack) const;
bool getAmbienceValue(
- rtl::OUString const & key, rtl_uString ** value,
+ rtl::OUString const & key, rtl_uString ** value, LookupMode mode,
+ ExpandRequestLink const * requestStack) const;
+ void expandValue(
+ rtl_uString ** value, rtl::OUString const & text, LookupMode mode,
+ Bootstrap_Impl const * requestFile, rtl::OUString const & requestKey,
ExpandRequestLink const * requestStack) const;
};
@@ -440,11 +430,65 @@ Bootstrap_Impl::~Bootstrap_Impl()
//----------------------------------------------------------------------------
+namespace {
+
+Bootstrap_Impl * get_static_bootstrap_handle() SAL_THROW(())
+{
+ osl::MutexGuard guard( osl::Mutex::getGlobalMutex() );
+ static Bootstrap_Impl * s_handle = 0;
+ if (s_handle == 0)
+ {
+ OUString iniName (getIniFileName_Impl());
+ s_handle = static_cast< Bootstrap_Impl * >(
+ rtl_bootstrap_args_open( iniName.pData ) );
+ if (s_handle == 0)
+ {
+ Bootstrap_Impl * that = new Bootstrap_Impl( iniName );
+ ++that->_nRefCount;
+ s_handle = that;
+ }
+ }
+ return s_handle;
+}
+
+struct FundamentalIniData {
+ rtlBootstrapHandle ini;
+
+ FundamentalIniData() {
+ OUString uri;
+ ini =
+ ((static_cast< Bootstrap_Impl * >(get_static_bootstrap_handle())->
+ getValue(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("URE_BOOTSTRAP")),
+ &uri.pData, 0, LOOKUP_MODE_NORMAL, false, 0)) &&
+ resolvePathnameUrl(&uri))
+ ? rtl_bootstrap_args_open(uri.pData) : NULL;
+ }
+
+ ~FundamentalIniData() { rtl_bootstrap_args_close(ini); }
+
+private:
+ FundamentalIniData(FundamentalIniData &); // not defined
+ void operator =(FundamentalIniData &); // not defined
+};
+
+struct FundamentalIni: public rtl::Static< FundamentalIniData, FundamentalIni >
+{};
+
+}
+
bool Bootstrap_Impl::getValue(
rtl::OUString const & key, rtl_uString ** value, rtl_uString * defaultValue,
- bool override, ExpandRequestLink const * requestStack) const
+ LookupMode mode, bool override, ExpandRequestLink const * requestStack)
+ const
{
- if (override && getDirectValue(key, value, requestStack)) {
+ if (mode == LOOKUP_MODE_NORMAL &&
+ key.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("URE_BOOTSTRAP")))
+ {
+ mode = LOOKUP_MODE_URE_BOOTSTRAP;
+ }
+ if (override && getDirectValue(key, value, mode, requestStack)) {
return true;
}
if (key.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("_OS"))) {
@@ -471,7 +515,7 @@ bool Bootstrap_Impl::getValue(
0, std::max<sal_Int32>(0, _iniName.lastIndexOf('/'))).pData);
return true;
}
- if (getAmbienceValue(key, value, requestStack)) {
+ if (getAmbienceValue(key, value, mode, requestStack)) {
return true;
}
if (key.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SYSUSERCONFIG"))) {
@@ -493,18 +537,18 @@ bool Bootstrap_Impl::getValue(
return true;
}
if (_base_ini != NULL &&
- _base_ini->getDirectValue(key, value, requestStack))
+ _base_ini->getDirectValue(key, value, mode, requestStack))
{
return true;
}
- if (!override && getDirectValue(key, value, requestStack)) {
+ if (!override && getDirectValue(key, value, mode, requestStack)) {
return true;
}
- if (!key.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(URE_BOOTSTRAP))) {
+ if (mode == LOOKUP_MODE_NORMAL) {
FundamentalIniData const & d = FundamentalIni::get();
Bootstrap_Impl const * b = static_cast<Bootstrap_Impl const *>(d.ini);
if (b != NULL && b != this &&
- b->getDirectValue(key, value, requestStack))
+ b->getDirectValue(key, value, mode, requestStack))
{
return true;
}
@@ -518,14 +562,12 @@ bool Bootstrap_Impl::getValue(
}
bool Bootstrap_Impl::getDirectValue(
- rtl::OUString const & key, rtl_uString ** value,
+ rtl::OUString const & key, rtl_uString ** value, LookupMode mode,
ExpandRequestLink const * requestStack) const
{
rtl::OUString v;
if (find(_nameValueList, key, &v)) {
- rtl_uString_assign(
- value,
- recursivelyExpandMacros(this, v, this, key, requestStack).pData);
+ expandValue(value, v, mode, this, key, requestStack);
return true;
} else {
return false;
@@ -533,7 +575,7 @@ bool Bootstrap_Impl::getDirectValue(
}
bool Bootstrap_Impl::getAmbienceValue(
- rtl::OUString const & key, rtl_uString ** value,
+ rtl::OUString const & key, rtl_uString ** value, LookupMode mode,
ExpandRequestLink const * requestStack) const
{
rtl::OUString v;
@@ -545,15 +587,29 @@ bool Bootstrap_Impl::getAmbienceValue(
if (f || getFromCommandLineArgs(key, &v) ||
osl_getEnvironment(key.pData, &v.pData) == osl_Process_E_None)
{
- rtl_uString_assign(
- value,
- recursivelyExpandMacros(this, v, NULL, key, requestStack).pData);
+ expandValue(value, v, mode, NULL, key, requestStack);
return true;
} else {
return false;
}
}
+void Bootstrap_Impl::expandValue(
+ rtl_uString ** value, rtl::OUString const & text, LookupMode mode,
+ Bootstrap_Impl const * requestFile, rtl::OUString const & requestKey,
+ ExpandRequestLink const * requestStack) const
+{
+ rtl_uString_assign(
+ value,
+ (mode == LOOKUP_MODE_URE_BOOTSTRAP && isPathnameUrl(text) ?
+ text :
+ recursivelyExpandMacros(
+ this, text,
+ (mode == LOOKUP_MODE_URE_BOOTSTRAP ?
+ LOOKUP_MODE_URE_BOOTSTRAP_EXPANSION : mode),
+ requestFile, requestKey, requestStack)).pData);
+}
+
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
@@ -692,28 +748,7 @@ void SAL_CALL rtl_bootstrap_args_close (
//----------------------------------------------------------------------------
-static Bootstrap_Impl * get_static_bootstrap_handle() SAL_THROW(())
-{
- osl::MutexGuard guard( osl::Mutex::getGlobalMutex() );
- static Bootstrap_Impl * s_handle = 0;
- if (s_handle == 0)
- {
- OUString iniName (getIniFileName_Impl());
- s_handle = static_cast< Bootstrap_Impl * >(
- rtl_bootstrap_args_open( iniName.pData ) );
- if (s_handle == 0)
- {
- Bootstrap_Impl * that = new Bootstrap_Impl( iniName );
- ++that->_nRefCount;
- s_handle = that;
- }
- }
- return s_handle;
-}
-
-//----------------------------------------------------------------------------
-
-sal_Bool SAL_CALL rtl_bootstrap_get_from_handle (
+sal_Bool SAL_CALL rtl_bootstrap_get_from_handle(
rtlBootstrapHandle handle,
rtl_uString * pName,
rtl_uString ** ppValue,
@@ -728,7 +763,7 @@ sal_Bool SAL_CALL rtl_bootstrap_get_from_handle (
if (handle == 0)
handle = get_static_bootstrap_handle();
found = static_cast< Bootstrap_Impl * >( handle )->getValue(
- pName, ppValue, pDefault, false, NULL );
+ pName, ppValue, pDefault, LOOKUP_MODE_NORMAL, false, NULL );
}
return found;
@@ -825,7 +860,7 @@ void SAL_CALL rtl_bootstrap_expandMacros_from_handle (
}
OUString expanded( expandMacros( static_cast< Bootstrap_Impl * >( handle ),
* reinterpret_cast< OUString const * >( macro ),
- NULL ) );
+ LOOKUP_MODE_NORMAL, NULL ) );
rtl_uString_assign( macro, expanded.pData );
}
@@ -888,17 +923,17 @@ sal_Unicode read(rtl::OUString const & text, sal_Int32 * pos, bool * escaped) {
}
rtl::OUString lookup(
- Bootstrap_Impl const * file, bool override, rtl::OUString const & key,
- ExpandRequestLink const * requestStack)
+ Bootstrap_Impl const * file, LookupMode mode, bool override,
+ rtl::OUString const & key, ExpandRequestLink const * requestStack)
{
rtl::OUString v;
(file == NULL ? get_static_bootstrap_handle() : file)->getValue(
- key, &v.pData, NULL, override, requestStack);
+ key, &v.pData, NULL, mode, override, requestStack);
return v;
}
rtl::OUString expandMacros(
- Bootstrap_Impl const * file, rtl::OUString const & text,
+ Bootstrap_Impl const * file, rtl::OUString const & text, LookupMode mode,
ExpandRequestLink const * requestStack)
{
rtl::OUStringBuffer buf;
@@ -941,7 +976,7 @@ rtl::OUString expandMacros(
}
done:
for (int j = 0; j < n; ++j) {
- seg[j] = expandMacros(file, seg[j], requestStack);
+ seg[j] = expandMacros(file, seg[j], mode, requestStack);
}
if (n == 3 && seg[1].getLength() == 0) {
// For backward compatibility, treat ${file::key} the same
@@ -950,7 +985,7 @@ rtl::OUString expandMacros(
n = 2;
}
if (n == 1) {
- buf.append(lookup(file, false, seg[0], requestStack));
+ buf.append(lookup(file, mode, false, seg[0], requestStack));
} else if (n == 2) {
if (seg[0].equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM(".link")))
@@ -983,7 +1018,7 @@ rtl::OUString expandMacros(
lookup(
static_cast< Bootstrap_Impl * >(
rtl::Bootstrap(seg[0]).getHandle()),
- false, seg[1], requestStack));
+ mode, false, seg[1], requestStack));
}
} else if (seg[0].equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM(".override")))
@@ -991,7 +1026,8 @@ rtl::OUString expandMacros(
rtl::Bootstrap b(seg[1]);
Bootstrap_Impl * f = static_cast< Bootstrap_Impl * >(
b.getHandle());
- buf.append(lookup(f, f != NULL, seg[2], requestStack));
+ buf.append(
+ lookup(f, mode, f != NULL, seg[2], requestStack));
} else {
// Going through osl::Profile, this code erroneously does
// not recursively expand macros in the resulting
@@ -1023,7 +1059,8 @@ rtl::OUString expandMacros(
}
buf.append(
lookup(
- file, false, kbuf.makeStringAndClear(), requestStack));
+ file, mode, false, kbuf.makeStringAndClear(),
+ requestStack));
}
}
}