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
This commit is contained in:
Stephan Bergmann
2017-03-22 08:44:14 +01:00
parent 7299481834
commit a7cdba3a0e
2 changed files with 37 additions and 27 deletions

View File

@@ -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;
}