From 4a3d1757b1f300237f5b18424874f5d3e89c6135 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 5 Jul 2010 19:02:56 +0200 Subject: ooo33gsl02: #i112857# do not mess up the resource stack if a string is not found --- tools/source/string/strucvt.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools') diff --git a/tools/source/string/strucvt.cxx b/tools/source/string/strucvt.cxx index 7198d0e8f98c..9c9ef1dc4b5a 100644 --- a/tools/source/string/strucvt.cxx +++ b/tools/source/string/strucvt.cxx @@ -201,6 +201,8 @@ UniString::UniString( const ResId& rResId ) Append( UniString::CreateFromInt32( rResId.GetId() ) ); AppendAscii( " not found>" ); #endif + if( pResMgr ) + pResMgr->PopContext(); } -- cgit v1.2.3 From d315e8bee6e680a5f7a6f4df067e07e58bc8b61d Mon Sep 17 00:00:00 2001 From: Caol?n McNamara Date: Thu, 24 Jun 2010 20:59:17 +0100 Subject: cmcfixes76: #i112656# osl_setEnvironment/osl_clearEnvironment --- tools/source/misc/extendapplicationenvironment.cxx | 19 +++----------- vcl/unx/gtk/app/gtkdata.cxx | 7 ++--- vcl/unx/source/app/i18n_im.cxx | 30 ++++++++-------------- vcl/unx/source/app/saldata.cxx | 6 ++--- 4 files changed, 20 insertions(+), 42 deletions(-) (limited to 'tools') diff --git a/tools/source/misc/extendapplicationenvironment.cxx b/tools/source/misc/extendapplicationenvironment.cxx index fe76e5329cbb..440f5a5cb207 100644 --- a/tools/source/misc/extendapplicationenvironment.cxx +++ b/tools/source/misc/extendapplicationenvironment.cxx @@ -29,8 +29,6 @@ #include "sal/config.h" #include - // not as putenv is POSIX-only; setenv instead of putenv would be - // better but is not supported by Solaris 9 and earlier #if defined UNX #include @@ -63,10 +61,9 @@ void extendApplicationEnvironment() { // Make sure URE_BOOTSTRAP environment variable is set (failure is fatal): rtl::OUStringBuffer env; - env.appendAscii(RTL_CONSTASCII_STRINGPARAM("URE_BOOTSTRAP=")); + rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("URE_BOOTSTRAP")); rtl::OUString uri; - if (rtl::Bootstrap::get( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URE_BOOTSTRAP")), uri)) + if (rtl::Bootstrap::get(envVar, uri)) { if (!uri.matchIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.pathname:"))) @@ -86,16 +83,8 @@ void extendApplicationEnvironment() { env.appendAscii( RTL_CONSTASCII_STRINGPARAM(SAL_CONFIGFILE("fundamental"))); } - rtl::OString s; - if (!env.makeStringAndClear().convertToString( - &s, osl_getThreadTextEncoding(), - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR - | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)) - { - abort(); - } - rtl_string_acquire(s.pData); // argument to putenv must leak - if (putenv(const_cast< char * >(s.getStr())) != 0) { + rtl::OUString envValue(env.makeStringAndClear()); + if (osl_setEnvironment(envVar.pData, envValue.pData) != osl_Process_E_None) { abort(); } } diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index 2679f4a29c02..1f1c469bf9a1 100644 --- a/vcl/unx/gtk/app/gtkdata.cxx +++ b/vcl/unx/gtk/app/gtkdata.cxx @@ -630,9 +630,10 @@ void GtkXLib::Init() * the clipboard build another connection * to the xserver using $DISPLAY */ - char *pPutEnvIsBroken = g_strdup_printf( "DISPLAY=%s", - gdk_display_get_name( pGdkDisp ) ); - putenv( pPutEnvIsBroken ); + rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("DISPLAY")); + const gchar *name = gdk_display_get_name( pGdkDisp ); + rtl::OUString envValue(name, strlen(name), aEnc); + osl_setEnvironment(envVar.pData, envValue.pData); Display *pDisp = gdk_x11_display_get_xdisplay( pGdkDisp ); diff --git a/vcl/unx/source/app/i18n_im.cxx b/vcl/unx/source/app/i18n_im.cxx index 9f1ffee3d1c4..c797da34e76c 100644 --- a/vcl/unx/source/app/i18n_im.cxx +++ b/vcl/unx/source/app/i18n_im.cxx @@ -36,10 +36,6 @@ # endif #endif #include -#ifdef SOLARIS -// for SetSystemEnvironment() -#include -#endif #include #include @@ -53,6 +49,7 @@ #include #include +#include using namespace vcl; #include "i18n_cb.hxx" @@ -179,21 +176,13 @@ SetSystemLocale( const char* p_inlocale ) #ifdef SOLARIS static void -SetSystemEnvironment( const char* p_locale ) +SetSystemEnvironment( const rtl::OUString& rLocale ) { - const char *lc_all = "LC_ALL=%s"; - const char *lang = "LANG=%s"; - - char *p_buffer; + rtl::OUString LC_ALL_Var(RTL_CONSTASCII_USTRINGPARAM("LC_ALL")); + osl_setEnvironment(LC_ALL_Var.pData, rLocale.pData); - if (p_locale != NULL) - { - p_buffer = (char*)alloca(10 + strlen(p_locale)); - sprintf(p_buffer, lc_all, p_locale); - putenv(strdup(p_buffer)); - sprintf(p_buffer, lang, p_locale); - putenv(strdup(p_buffer)); - } + rtl::OUString LANG_Var(RTL_CONSTASCII_USTRINGPARAM("LANG")); + osl_setEnvironment(LANG_Var.pData, rLocale.pData); } #endif @@ -249,13 +238,13 @@ SalI18N_InputMethod::SetLocale( const char* pLocale ) osl_setThreadTextEncoding (RTL_TEXTENCODING_ISO_8859_1); locale = SetSystemLocale( "en_US" ); #ifdef SOLARIS - SetSystemEnvironment( "en_US" ); + SetSystemEnvironment( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en_US")) ); #endif if (! IsXWindowCompatibleLocale(locale)) { locale = SetSystemLocale( "C" ); #ifdef SOLARIS - SetSystemEnvironment( "C" ); + SetSystemEnvironment( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C")) ); #endif if (! IsXWindowCompatibleLocale(locale)) mbUseable = False; @@ -440,7 +429,8 @@ SalI18N_InputMethod::CreateMethod ( Display *pDisplay ) if ((maMethod == (XIM)NULL) && (getenv("XMODIFIERS") != NULL)) { - putenv (strdup("XMODIFIERS")); + rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("XMODIFIERS")); + osl_clearEnvironment(envVar.pData); XSetLocaleModifiers(""); maMethod = XOpenIM(pDisplay, NULL, NULL, NULL); mbMultiLingual = False; diff --git a/vcl/unx/source/app/saldata.cxx b/vcl/unx/source/app/saldata.cxx index 50ef71df8619..beb7b60a551c 100644 --- a/vcl/unx/source/app/saldata.cxx +++ b/vcl/unx/source/app/saldata.cxx @@ -425,10 +425,8 @@ void SalXLib::Init() * the clipboard build another connection * to the xserver using $DISPLAY */ - const char envpre[] = "DISPLAY="; - char *envstr = new char[sizeof(envpre)+aDisplay.getLength()]; - snprintf(envstr, sizeof(envpre)+aDisplay.getLength(), "DISPLAY=%s", aDisplay.getStr()); - putenv(envstr); + rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("DISPLAY")); + osl_setEnvironment(envVar.pData, aParam.pData); } break; } -- cgit v1.2.3