summaryrefslogtreecommitdiff
path: root/sal/osl
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2022-01-10 11:41:25 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2022-01-10 15:33:37 +0100
commit1bb08a227ca4854a7d1960ca61a5b0de9fe9363d (patch)
tree70796e323139e1e8996f1bcf16cbf4e3731878d1 /sal/osl
parent3914ca68e05d31eec4df03db50a4c0c258d2704b (diff)
Use one define for the common NLS archs
Just some refactoring. Change-Id: I9edae9bce381dcd9fdcb98471d461d00220fea57 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128218 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'sal/osl')
-rw-r--r--sal/osl/unx/nlsupport.cxx50
1 files changed, 25 insertions, 25 deletions
diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index 28d367c11ae9..b1b1af706491 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -31,19 +31,20 @@
#include "nlsupport.hxx"
-#if defined(LINUX) || defined(__sun) || defined(NETBSD) || \
- defined(FREEBSD) || defined(MACOSX) || defined(IOS) || defined(OPENBSD) || \
- defined(DRAGONFLY)
-#if !defined(MACOSX) && !defined(IOS)
+// these share a lot, so use one define
+#if defined(LINUX) || defined(__sun) || \
+ defined(FREEBSD) || defined(OPENBSD) || defined(DRAGONFLY) || defined(NETBSD)
+#define LO_COMMON_NLS_ARCHS 1
+#else
+#define LO_COMMON_NLS_ARCHS 0
+#endif
+
+#if LO_COMMON_NLS_ARCHS
#include <locale.h>
#include <langinfo.h>
-#else
+#elif defined(MACOSX) || defined(IOS)
#include <osl/module.h>
#include <osl/thread.h>
-#endif /* !MACOSX && !IOS */
-#endif /* LINUX || __sun || NETBSD || MACOSX || IOS */
-
-#if defined(MACOSX) || defined(IOS)
#include "system.hxx"
#endif
@@ -226,23 +227,14 @@ static rtl_Locale * parse_locale( const char * locale )
return ret;
}
-#if defined(LINUX) || defined(__sun) || defined(NETBSD) || \
- defined(FREEBSD) || defined(OPENBSD) || defined(DRAGONFLY)
+#if LO_COMMON_NLS_ARCHS
/*
* This implementation of osl_getTextEncodingFromLocale maps
* from nl_langinfo_l(CODESET) to rtl_textencoding defines.
* nl_langinfo() is supported only on Linux, Solaris,
* >= NetBSD 1.6 and >= FreeBSD 4.4
- */
-
-#ifdef LINUX
-#if !defined(CODESET)
-#define CODESET _NL_CTYPE_CODESET_NAME
-#endif
-#endif
-
-/*
+ *
* _nl_language_list[] is an array list of supported encodings. Because
* we are using a binary search, the list has to be in ascending order.
* We are comparing the encodings case insensitive, so the list has
@@ -294,6 +286,10 @@ static const Pair nl_language_list[] = {
#elif defined(LINUX)
+#if !defined(CODESET)
+#define CODESET _NL_CTYPE_CODESET_NAME
+#endif
+
const Pair nl_language_list[] = {
{ "ANSI_X3.110-1983", RTL_TEXTENCODING_DONTKNOW }, /* ISO-IR-99 NAPLPS */
{ "ANSI_X3.4-1968", RTL_TEXTENCODING_ISO_8859_1 }, /* fake: ASCII_US */
@@ -557,7 +553,9 @@ static const Pair nl_language_list[] = {
{ "UTF-8", RTL_TEXTENCODING_UTF8 } /* ISO-10646/UTF-8 */
};
-#endif /* ifdef __sun LINUX FREEBSD NETBSD OPENBSD */
+#else
+#error Unhandled individual LO_COMMON_NLS_ARCHS
+#endif // individual common NLS archs
/*****************************************************************************
return the text encoding corresponding to the given locale
@@ -643,7 +641,7 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
*ppLocale = parse_locale(locale);
}
-#else /* ifdef LINUX || __sun || MACOSX || NETBSD */
+#else // !LO_COMMON_NLS_ARCHS
/*
* This implementation of osl_getTextEncodingFromLocale maps
@@ -837,7 +835,9 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
/* return the locale */
*ppLocale = parse_locale( locale.getStr() );
}
-#else
+
+#else // !MACOSX && !IOS
+
/*****************************************************************************
return the current process locale
*****************************************************************************/
@@ -865,8 +865,8 @@ void imp_getProcessLocale( rtl_Locale ** ppLocale )
#endif
*ppLocale = parse_locale( locale );
}
-#endif
-#endif /* ifdef LINUX || __sun || MACOSX || NETBSD || AIX */
+#endif // !MACOSX && !IOS
+#endif // !LO_COMMON_NLS_ARCHS
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */