[Libreoffice-commits] core.git: include/osl sal/osl

Stephan Bergmann sbergman at redhat.com
Wed Mar 22 12:47:58 UTC 2017


 include/osl/process.h        |    8 ++----
 sal/osl/unx/nlsupport.cxx    |   57 -------------------------------------------
 sal/osl/unx/nlsupport.hxx    |    1 
 sal/osl/unx/process_impl.cxx |   10 +------
 4 files changed, 5 insertions(+), 71 deletions(-)

New commits:
commit 6a3cfd330550ee558a546fb0808577b56ae04400
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Mar 22 13:43:20 2017 +0100

    Don't actually change OS-level locale with (unused) osl_setSystemLocale
    
    osl_setSystemLocale was introduced with af2938348bb539ccb27c92fe286b768d4143f662
    "#88460# added osl_getProcessLocale and osl_setProcessLocale" but never actually
    used.  So mark it as deprecated and, in the sal/osl/unx/ case, don't make it
    set the OS-level locale via imp_setProcessLocale (calling setlocale or setting
    the LC_ALL/LC_CTYPE/LANG env vars), same as in the sal/osl/w32/ case.
    
    Change-Id: I33348dba5de8ca80ca6fca210043286c0cfa9145

diff --git a/include/osl/process.h b/include/osl/process.h
index ee7b401703fa..49fe59264059 100644
--- a/include/osl/process.h
+++ b/include/osl/process.h
@@ -396,11 +396,7 @@ SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getProcessWorkingDir(
 
 /** Get the locale the process is currently running in.
 
-    The unix implementation caches the value it returns, so if you have to change the locale
-    your are running in, you will have to use osl_setProcessLocale
-
     @param  ppLocale [out] a pointer that receives the currently selected locale structure
-    @see osl_setProcessLocale
 */
 
 SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getProcessLocale(
@@ -409,7 +405,9 @@ SAL_DLLPUBLIC oslProcessError SAL_CALL osl_getProcessLocale(
 /** Change the locale of the process.
 
     @param  pLocale [in] a pointer to the locale to be set
-    @see osl_getProcessLocale
+
+    @deprecated  LibreOffice itself does not use this, and client code should
+    not have good use for it either.  It may eventually be removed.
 */
 
 SAL_DLLPUBLIC oslProcessError SAL_CALL osl_setProcessLocale(
diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index b9cd621b8a6b..589439fffe94 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -28,7 +28,6 @@
 #if defined(LINUX) || defined(__sun) || defined(NETBSD) || \
     defined(FREEBSD) || defined(MACOSX)  || defined(IOS) || defined(OPENBSD) || \
     defined(DRAGONFLY)
-#include <pthread.h>
 #if !defined(MACOSX) && !defined(IOS)
 #include <locale.h>
 #include <langinfo.h>
@@ -555,8 +554,6 @@ static const Pair nl_language_list[] = {
 
 #endif /* ifdef __sun LINUX FREEBSD NETBSD OPENBSD */
 
-static pthread_mutex_t aLocalMutex = PTHREAD_MUTEX_INITIALIZER;
-
 /*****************************************************************************
  return the text encoding corresponding to the given locale
  *****************************************************************************/
@@ -640,29 +637,6 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
     *ppLocale = parse_locale(locale);
 }
 
-/*****************************************************************************
- set the current process locale
- *****************************************************************************/
-
-int imp_setProcessLocale( rtl_Locale * pLocale )
-{
-    char  locale_buf[64] = "";
-    int   ret = 0;
-
-    /* convert rtl_Locale to locale string */
-    compose_locale( pLocale, locale_buf, 64 );
-
-    /* basic thread safeness */
-    pthread_mutex_lock( &aLocalMutex );
-
-    /* try to set LC_ALL locale */
-    if( nullptr == setlocale( LC_ALL, locale_buf ) )
-        ret = -1;
-
-    pthread_mutex_unlock( &aLocalMutex );
-    return ret;
-}
-
 #else /* ifdef LINUX || __sun || MACOSX || NETBSD */
 
 /*
@@ -891,37 +865,6 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
 }
 #endif
 
-/*****************************************************************************
- set the current process locale
- *****************************************************************************/
-
-static int
-imp_setenv (const char* name, const char* value)
-{
-    return setenv (name, value, 1);
-}
-
-int imp_setProcessLocale( rtl_Locale * pLocale )
-{
-    char locale_buf[64];
-
-    /* convert rtl_Locale to locale string */
-    if( nullptr != compose_locale( pLocale, locale_buf, 64 ) )
-    {
-        /* only change env vars that exist already */
-        if( getenv( "LC_ALL" ) )
-            imp_setenv( "LC_ALL", locale_buf );
-
-        if( getenv( "LC_CTYPE" ) )
-            imp_setenv("LC_CTYPE", locale_buf );
-
-        if( getenv( "LANG" ) )
-            imp_setenv( "LANG", locale_buf );
-    }
-
-    return 0;
-}
-
 #endif /* ifdef LINUX || __sun || MACOSX || NETBSD || AIX */
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/unx/nlsupport.hxx b/sal/osl/unx/nlsupport.hxx
index abcf42498fa7..53a132487c82 100644
--- a/sal/osl/unx/nlsupport.hxx
+++ b/sal/osl/unx/nlsupport.hxx
@@ -27,7 +27,6 @@
 namespace rtl { class OUString; }
 
 void imp_getProcessLocale( rtl_Locale ** );
-int  imp_setProcessLocale( rtl_Locale * );
 
 #if defined IOS || defined MACOSX
 rtl::OUString macosx_getLocale();
diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx
index 2e27154668a0..9a3663298b76 100644
--- a/sal/osl/unx/process_impl.cxx
+++ b/sal/osl/unx/process_impl.cxx
@@ -460,19 +460,13 @@ oslProcessError SAL_CALL osl_getProcessLocale( rtl_Locale ** ppLocale )
  *********************************************/
 oslProcessError SAL_CALL osl_setProcessLocale( rtl_Locale * pLocale )
 {
-    oslProcessError result = osl_Process_E_Unknown;
-
     OSL_PRECOND(pLocale, "osl_setProcessLocale(): Invalid parameter.");
 
     pthread_mutex_lock(&(g_process_locale.m_mutex));
-    if (imp_setProcessLocale (pLocale) == 0)
-    {
-        g_process_locale.m_pLocale = pLocale;
-        result = osl_Process_E_None;
-    }
+    g_process_locale.m_pLocale = pLocale;
     pthread_mutex_unlock (&(g_process_locale.m_mutex));
 
-    return result;
+    return osl_Process_E_None;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list