| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrAutoLocaleSetter_DEFINED | 8 #ifndef GrAutoLocaleSetter_DEFINED |
| 9 #define GrAutoLocaleSetter_DEFINED | 9 #define GrAutoLocaleSetter_DEFINED |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } else { | 35 } else { |
| 36 fOldLocale = static_cast<locale_t>(0); | 36 fOldLocale = static_cast<locale_t>(0); |
| 37 } | 37 } |
| 38 #else | 38 #else |
| 39 (void) name; // suppress unused param warning. | 39 (void) name; // suppress unused param warning. |
| 40 #endif | 40 #endif |
| 41 } | 41 } |
| 42 | 42 |
| 43 ~GrAutoLocaleSetter () { | 43 ~GrAutoLocaleSetter () { |
| 44 #if defined(SK_BUILD_FOR_WIN) | 44 #if defined(SK_BUILD_FOR_WIN) |
| 45 setlocale(LC_ALL, fOldLocale); | 45 if (fOldLocale) { |
| 46 setlocale(LC_ALL, fOldLocale); |
| 47 } |
| 46 _configthreadlocale(fOldPerThreadLocale); | 48 _configthreadlocale(fOldPerThreadLocale); |
| 47 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) | 49 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) |
| 48 if (fLocale) { | 50 if (fLocale) { |
| 49 uselocale(fOldLocale); | 51 uselocale(fOldLocale); |
| 50 freelocale(fLocale); | 52 freelocale(fLocale); |
| 51 } | 53 } |
| 52 #endif | 54 #endif |
| 53 } | 55 } |
| 54 | 56 |
| 55 private: | 57 private: |
| 56 #if defined(SK_BUILD_FOR_WIN) | 58 #if defined(SK_BUILD_FOR_WIN) |
| 57 int fOldPerThreadLocale; | 59 int fOldPerThreadLocale; |
| 58 const char* fOldLocale; | 60 const char* fOldLocale; |
| 59 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) | 61 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) |
| 60 locale_t fOldLocale; | 62 locale_t fOldLocale; |
| 61 locale_t fLocale; | 63 locale_t fLocale; |
| 62 #endif | 64 #endif |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 #endif | 67 #endif |
| 66 | 68 |
| OLD | NEW |