Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: src/gpu/GrAutoLocaleSetter.h

Issue 1526703003: Porting Skia for newlib compatibility. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ports/SkTime_Unix.cpp » ('j') | src/ports/SkTime_Unix.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkTime_Unix.cpp » ('j') | src/ports/SkTime_Unix.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698