configmgr/source/components.cxx | 13 ++----- configmgr/source/components.hxx | 7 +--- sal/CppunitTest_sal_rtl_bootstrap.mk | 21 ++++++++++++ sal/Module_sal.mk | 1 sal/qa/rtl/bootstrap/expand.cxx | 60 +++++++++++++++++++++++++++++++++++ sal/rtl/source/bootstrap.cxx | 20 +++++------ 6 files changed, 99 insertions(+), 23 deletions(-)
New commits: commit 8246bdb500a6d83ea9b61f58fb74e051432e32d7 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Nov 6 16:15:57 2012 +0100 fdo#55138: Do not double-expand bootstrap variables For some reason that escapes me now, the old code double-expanded URLs in CONFIGURATION_LAYERS and in extension layer's configmgr.ini SCHEMA/DATA. That produced wrong results when the pathnames represented by those URLs contain any "$" characters, as apparently routinely happens on Windows with roaming profiles. Change-Id: Iff149e7d8736cbcda579376cdc89e24cf99ccc97 diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 2a0bffc..6476cd8 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -527,7 +527,7 @@ Components::Components( n = conf.getLength(); } rtl::OUString type(conf.copy(i, c - i)); - rtl::OUString url(expand(conf.copy(c + 1, n - c - 1))); + rtl::OUString url(conf.copy(c + 1, n - c - 1)); if ( type == "xcsxcu" ) { parseXcsXcuLayer(layer, url); layer += 2; //TODO: overflow @@ -684,12 +684,11 @@ void Components::parseFiles( void Components::parseFileList( int layer, FileParser * parseFile, rtl::OUString const & urls, - rtl::Bootstrap const & ini, bool recordAdditions) + bool recordAdditions) { for (sal_Int32 i = 0;;) { rtl::OUString url(urls.getToken(0, ' ', i)); if (!url.isEmpty()) { - ini.expandMacrosFrom(url); //TODO: detect failure Additions * adds = 0; if (recordAdditions) { adds = data_.addExtensionXcuAdditions(url, layer); @@ -819,9 +818,7 @@ void Components::parseXcsXcuIniLayer( // Check if ini file exists (otherwise .override would still read global // SCHEMA/DATA variables, which could interfere with unrelated environment // variables): - rtl::Bootstrap ini(url); - if (ini.getHandle() != 0) - { + if (rtl::Bootstrap(url).getHandle() != 0) { rtl::OUStringBuffer prefix("${.override:"); for (sal_Int32 i = 0; i != url.getLength(); ++i) { sal_Unicode c = url[i]; @@ -840,13 +837,13 @@ void Components::parseXcsXcuIniLayer( rtl::Bootstrap::expandMacros(urls); if (!urls.isEmpty()) { - parseFileList(layer, &parseXcsFile, urls, ini, false); + parseFileList(layer, &parseXcsFile, urls, false); } urls = prefix.makeStringAndClear() + rtl::OUString("DATA}"); rtl::Bootstrap::expandMacros(urls); if (!urls.isEmpty()) { - parseFileList(layer + 1, &parseXcuFile, urls, ini, recordAdditions); + parseFileList(layer + 1, &parseXcuFile, urls, recordAdditions); } } } diff --git a/configmgr/source/components.hxx b/configmgr/source/components.hxx index c898a84..70f7669 100644 --- a/configmgr/source/components.hxx +++ b/configmgr/source/components.hxx @@ -43,10 +43,7 @@ namespace com { namespace sun { namespace star { class XComponentContext; } } } } -namespace rtl { - class Bootstrap; - class OUString; -} +namespace rtl { class OUString; } namespace configmgr { @@ -132,7 +129,7 @@ private: void parseFileList( int layer, FileParser * parseFile, rtl::OUString const & urls, - rtl::Bootstrap const & ini, bool recordAdditions); + bool recordAdditions); void parseXcdFiles(int layer, rtl::OUString const & url); commit 4de42d02f865464057ca5681c67f63fece355173 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Nov 6 16:13:57 2012 +0100 Add some rtl::Bootstrap unit test ...there is still additional old cruft in sal/qa/rtl/bootstrap/, some of it might be worthwhile to resurrect. Change-Id: Ie334431abc8de839fa2e655cbd3dc4d014c38f15 diff --git a/sal/CppunitTest_sal_rtl_bootstrap.mk b/sal/CppunitTest_sal_rtl_bootstrap.mk new file mode 100644 index 0000000..f5771ea --- /dev/null +++ b/sal/CppunitTest_sal_rtl_bootstrap.mk @@ -0,0 +1,21 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,sal_rtl_bootstrap)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sal_rtl_bootstrap, \ + sal/qa/rtl/bootstrap/expand \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sal_rtl_bootstrap, \ + sal \ + $(gb_UWINAPI) \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sal/Module_sal.mk b/sal/Module_sal.mk index a2c937d..8bb3c73 100644 --- a/sal/Module_sal.mk +++ b/sal/Module_sal.mk @@ -63,6 +63,7 @@ $(eval $(call gb_Module_add_check_targets,sal,\ CppunitTest_sal_osl_security \ CppunitTest_sal_osl_thread \ CppunitTest_sal_rtl_alloc \ + CppunitTest_sal_rtl_bootstrap \ CppunitTest_sal_rtl_cipher \ CppunitTest_sal_rtl_crc32 \ CppunitTest_sal_rtl_doublelock \ diff --git a/sal/qa/rtl/bootstrap/expand.cxx b/sal/qa/rtl/bootstrap/expand.cxx new file mode 100644 index 0000000..9aad9dd --- /dev/null +++ b/sal/qa/rtl/bootstrap/expand.cxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "sal/config.h" + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "rtl/bootstrap.hxx" +#include "rtl/ustring.hxx" + +namespace { + +class Test: public CppUnit::TestFixture { +public: + virtual void setUp(); + +private: + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testDollar); + CPPUNIT_TEST(testIndirectDollar); + CPPUNIT_TEST_SUITE_END(); + + void testDollar(); + + void testIndirectDollar(); +}; + +void Test::setUp() { + rtl::Bootstrap::set("TEST", "<expanded TEST>"); + rtl::Bootstrap::set("WITH_DOLLAR", "foo\\$TEST"); + rtl::Bootstrap::set("INDIRECT", "$WITH_DOLLAR"); +} + +void Test::testDollar() { + rtl::OUString s("$WITH_DOLLAR"); + rtl::Bootstrap::expandMacros(s); + CPPUNIT_ASSERT_EQUAL(rtl::OUString("foo$TEST"), s); +} + +void Test::testIndirectDollar() { + rtl::OUString s("$INDIRECT"); + rtl::Bootstrap::expandMacros(s); + CPPUNIT_ASSERT_EQUAL(rtl::OUString("foo$TEST"), s); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit c6d03e72014d15825a47aab3c2a1bc73cbba2df8 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Nov 6 12:54:39 2012 +0100 Some white-space clean-up Change-Id: Ice25e13891865c2c7a223a3708d200272645140d diff --git a/sal/rtl/source/bootstrap.cxx b/sal/rtl/source/bootstrap.cxx index 7bdc82c..e455853 100644 --- a/sal/rtl/source/bootstrap.cxx +++ b/sal/rtl/source/bootstrap.cxx @@ -291,14 +291,14 @@ Bootstrap_Impl::Bootstrap_Impl( OUString const & rIniName ) line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 ); #if OSL_DEBUG_LEVEL > 1 - OString name_tmp = OUStringToOString(sName, RTL_TEXTENCODING_ASCII_US); - OString value_tmp = OUStringToOString(sValue, RTL_TEXTENCODING_UTF8); + OString name_tmp = OUStringToOString(sName, RTL_TEXTENCODING_ASCII_US); + OString value_tmp = OUStringToOString(sValue, RTL_TEXTENCODING_UTF8); OSL_TRACE( "pushing: name=%s value=%s", name_tmp.getStr(), value_tmp.getStr() ); #endif /* OSL_DEBUG_LEVEL > 1 */ - map_[sName] = sValue; + map_[sName] = sValue; } } osl_closeFile(handle); @@ -473,24 +473,24 @@ bool Bootstrap_Impl::getValue( if (override && getDirectValue(key, value, mode, requestStack)) { return true; } - if ( key == "_OS" ) { + if (key == "_OS") { rtl_uString_assign( value, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(RTL_OS)).pData); return true; } - if ( key == "_ARCH" ) { + if (key == "_ARCH") { rtl_uString_assign( value, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(RTL_ARCH)).pData); return true; } - if ( key == "_CPPU_ENV" ) { + if (key == "_CPPU_ENV") { rtl_uString_assign( value, (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(MY_STRING(CPPU_ENV))). pData)); return true; } - if ( key == "ORIGIN" ) { + if (key == "ORIGIN") { rtl_uString_assign( value, _iniName.copy( @@ -500,21 +500,21 @@ bool Bootstrap_Impl::getValue( if (getAmbienceValue(key, value, mode, requestStack)) { return true; } - if ( key == "SYSUSERCONFIG" ) { + if (key == "SYSUSERCONFIG") { rtl::OUString v; bool b = osl::Security().getConfigDir(v); EnsureNoFinalSlash(v); rtl_uString_assign(value, v.pData); return b; } - if ( key == "SYSUSERHOME" ) { + if (key == "SYSUSERHOME") { rtl::OUString v; bool b = osl::Security().getHomeDir(v); EnsureNoFinalSlash(v); rtl_uString_assign(value, v.pData); return b; } - if ( key == "SYSBINDIR" ) { + if (key == "SYSBINDIR") { getExecutableDirectory_Impl(value); return true; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits