Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  SkAutoLocaleSetter.h

  Sprache: C
 

/*
 * Copyright 2015 Google LLC
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#ifndef SkAutoLocaleSetter_DEFINED
#define SkAutoLocaleSetter_DEFINED

#include "include/private/base/SkNoncopyable.h"

#if defined(SK_BUILD_FOR_WIN)
#include <optional>
#include <string>
#endif

#if !defined(SK_BUILD_FOR_ANDROID)
#include <locale.h>
#endif

#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
#include <xlocale.h>
#include <cstring>
#define HAVE_XLOCALE 1
#else
#define HAVE_XLOCALE 0
#endif

#if defined(SK_BUILD_FOR_ANDROID) || defined(__UCLIBC__) || defined(_NEWLIB_VERSION)
#define HAVE_LOCALE_T 0
#else
#define HAVE_LOCALE_T 1
#endif

/**
 * Helper class for ensuring that we don't use the wrong locale when building shaders. Android
 * doesn't support locale in the NDK, so this is a no-op there.
 */

class SkAutoLocaleSetter : public SkNoncopyable {
public:
    SkAutoLocaleSetter (const char* name) {
#if defined(SK_BUILD_FOR_WIN)
        fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
        char* oldLocale = setlocale(LC_ALL, name);
        if (oldLocale) {
            fOldLocale.emplace(oldLocale);
        }
#elif HAVE_LOCALE_T
#if HAVE_XLOCALE
        // In xlocale nullptr means the C locale.
        if (0 == strcmp(name, "C")) {
            name = nullptr;
        }
#endif
        fLocale = newlocale(LC_ALL_MASK, name, nullptr);
        if (fLocale) {
            fOldLocale = uselocale(fLocale);
        } else {
            fOldLocale = static_cast<locale_t>(nullptr);
        }
#else
        (void) name; // suppress unused param warning.
#endif
    }

    ~SkAutoLocaleSetter () {
#if defined(SK_BUILD_FOR_WIN)
        if (fOldLocale) {
            setlocale(LC_ALL, fOldLocale->c_str());
        }
        _configthreadlocale(fOldPerThreadLocale);
#elif HAVE_LOCALE_T
        if (fLocale) {
             uselocale(fOldLocale);
             freelocale(fLocale);
        }
#endif
    }

private:
#if defined(SK_BUILD_FOR_WIN)
    int fOldPerThreadLocale;
    std::optional<std::string> fOldLocale;
#elif HAVE_LOCALE_T
    locale_t fOldLocale;
    locale_t fLocale;
#endif
};

#undef HAVE_LOCALE_T
#undef HAVE_XLOCALE

#endif

Messung V0.5 in Prozent
C=93 H=95 G=93

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002