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 20 matching lines...) Expand all Loading... | |
31 GrAutoLocaleSetter (const char* name) { | 31 GrAutoLocaleSetter (const char* name) { |
32 #if defined(SK_BUILD_FOR_WIN) | 32 #if defined(SK_BUILD_FOR_WIN) |
33 fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); | 33 fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); |
34 char* oldLocale = setlocale(LC_ALL, name); | 34 char* oldLocale = setlocale(LC_ALL, name); |
35 if (oldLocale) { | 35 if (oldLocale) { |
36 fOldLocale = oldLocale; | 36 fOldLocale = oldLocale; |
37 fShouldRestoreLocale = true; | 37 fShouldRestoreLocale = true; |
38 } else { | 38 } else { |
39 fShouldRestoreLocale = false; | 39 fShouldRestoreLocale = false; |
40 } | 40 } |
41 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) | 41 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) && !defined(_NEWLIB _VERSION) |
Mark Seaborn
2015/12/15 00:27:03
This line is >80 chars. Can you wrap it, please?
Sean Klein
2015/12/15 01:05:51
Done.
| |
42 fLocale = newlocale(LC_ALL, name, 0); | 42 fLocale = newlocale(LC_ALL, name, 0); |
43 if (fLocale) { | 43 if (fLocale) { |
44 fOldLocale = uselocale(fLocale); | 44 fOldLocale = uselocale(fLocale); |
45 } else { | 45 } else { |
46 fOldLocale = static_cast<locale_t>(0); | 46 fOldLocale = static_cast<locale_t>(0); |
47 } | 47 } |
48 #else | 48 #else |
49 (void) name; // suppress unused param warning. | 49 (void) name; // suppress unused param warning. |
50 #endif | 50 #endif |
51 } | 51 } |
52 | 52 |
53 ~GrAutoLocaleSetter () { | 53 ~GrAutoLocaleSetter () { |
54 #if defined(SK_BUILD_FOR_WIN) | 54 #if defined(SK_BUILD_FOR_WIN) |
55 if (fShouldRestoreLocale) { | 55 if (fShouldRestoreLocale) { |
56 setlocale(LC_ALL, fOldLocale.c_str()); | 56 setlocale(LC_ALL, fOldLocale.c_str()); |
57 } | 57 } |
58 _configthreadlocale(fOldPerThreadLocale); | 58 _configthreadlocale(fOldPerThreadLocale); |
59 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) | 59 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) && !defined(_NEWLIB _VERSION) |
60 if (fLocale) { | 60 if (fLocale) { |
61 uselocale(fOldLocale); | 61 uselocale(fOldLocale); |
62 freelocale(fLocale); | 62 freelocale(fLocale); |
63 } | 63 } |
64 #endif | 64 #endif |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 #if defined(SK_BUILD_FOR_WIN) | 68 #if defined(SK_BUILD_FOR_WIN) |
69 int fOldPerThreadLocale; | 69 int fOldPerThreadLocale; |
70 bool fShouldRestoreLocale; | 70 bool fShouldRestoreLocale; |
71 SkString fOldLocale; | 71 SkString fOldLocale; |
72 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) | 72 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) && !defined(_NEWLIB _VERSION) |
73 locale_t fOldLocale; | 73 locale_t fOldLocale; |
74 locale_t fLocale; | 74 locale_t fLocale; |
75 #endif | 75 #endif |
76 }; | 76 }; |
77 | 77 |
78 #endif | 78 #endif |
79 | 79 |
OLD | NEW |