compilerplugins/clang/nullptr.cxx | 6 ++++ i18nutil/source/utility/paper.cxx | 56 ++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 26 deletions(-)
New commits: commit a7cdba3a0e48360e2ed549e9d8996fe41460df70 Author: Stephan Bergmann <sberg...@redhat.com> Date: Wed Mar 22 08:44:14 2017 +0100 Use nl_langinfo_l with an explicitly created locale (where empty string arg to newlocale, per SUSv4, means "an implementation- defined native environment. This correspons to the value of the associated environment variables, LC_* and LANG") instead of relying on whatever setlocale would be in effect here. Also, nl_langinfo_l is less of an MT nightmare than nl_langinfo, which is of benefit once the last remaining use of nl_langinfo in sal/osl/unx/nlsupport.cxx will also have been changed to nl_langinfo_l. loplugin:nullptr needs a little hack, as SUSv4 locale_t could be anything from an integer type to a pointer type. Change-Id: Ic35dcbc2e0a4f650694b48df12470dd89476dff5 diff --git a/compilerplugins/clang/nullptr.cxx b/compilerplugins/clang/nullptr.cxx index 3ab32031e6f2..577a95715118 100644 --- a/compilerplugins/clang/nullptr.cxx +++ b/compilerplugins/clang/nullptr.cxx @@ -12,6 +12,7 @@ #include <limits> #include <set> +#include "check.hxx" #include "plugin.hxx" namespace { @@ -128,6 +129,11 @@ bool Nullptr::VisitImplicitCastExpr(CastExpr const * expr) { case Expr::NPCK_CXX11_nullptr: break; default: + if (loplugin::TypeCheck(expr->getType()).Typedef("locale_t") + .GlobalNamespace()) + { + break; // POSIX locale_t is left unspecified + } handleNull(expr->getSubExpr(), expr->getCastKindName(), k); break; } diff --git a/i18nutil/source/utility/paper.cxx b/i18nutil/source/utility/paper.cxx index 09440f46be6d..3a6e98a28d4f 100644 --- a/i18nutil/source/utility/paper.cxx +++ b/i18nutil/source/utility/paper.cxx @@ -290,39 +290,43 @@ PaperInfo PaperInfo::getSystemDefaultPaper() } #if defined(LC_PAPER) && defined(_GNU_SOURCE) - - union paperword { char *string; int word; }; - // try LC_PAPER - paperword w, h; - w.string = nl_langinfo(_NL_PAPER_WIDTH); - h.string = nl_langinfo(_NL_PAPER_HEIGHT); - - //glibc stores sizes as integer mm units - w.word *= 100; - h.word *= 100; - - for ( size_t i = 0; i < nTabSize; ++i ) + locale_t loc = newlocale(LC_PAPER_MASK, "", static_cast<locale_t>(0)); + if (loc != static_cast<locale_t>(0)) { - if (i == PAPER_USER) continue; + union paperword { char *string; int word; }; + paperword w, h; + w.string = nl_langinfo_l(_NL_PAPER_WIDTH, loc); + h.string = nl_langinfo_l(_NL_PAPER_HEIGHT, loc); + + freelocale(loc); - //glibc stores sizes as integer mm units, and so is inaccurate. To - //find a standard paper size we calculate the standard paper sizes - //into equally inaccurate mm and compare - long width = (aDinTab[i].m_nWidth + 50) / 100; - long height = (aDinTab[i].m_nHeight + 50) / 100; + //glibc stores sizes as integer mm units + w.word *= 100; + h.word *= 100; - if (width == w.word/100 && height == h.word/100) + for ( size_t i = 0; i < nTabSize; ++i ) { - w.word = aDinTab[i].m_nWidth; - h.word = aDinTab[i].m_nHeight; - break; + if (i == PAPER_USER) continue; + + //glibc stores sizes as integer mm units, and so is inaccurate. + //To find a standard paper size we calculate the standard paper + //sizes into equally inaccurate mm and compare + long width = (aDinTab[i].m_nWidth + 50) / 100; + long height = (aDinTab[i].m_nHeight + 50) / 100; + + if (width == w.word/100 && height == h.word/100) + { + w.word = aDinTab[i].m_nWidth; + h.word = aDinTab[i].m_nHeight; + break; + } } - } - aInstance = PaperInfo(w.word, h.word); - bInitialized = true; - return aInstance; + aInstance = PaperInfo(w.word, h.word); + bInitialized = true; + return aInstance; + } #endif } #endif _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits