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

Unified Diff: fusl/src/locale/newlocale.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: fusl/src/locale/newlocale.c
diff --git a/fusl/src/locale/newlocale.c b/fusl/src/locale/newlocale.c
index f50bbe9132df39445c642ea3215428b4b2b960d5..10b78cda80aba2686d71b4550a6709a4d641aa1c 100644
--- a/fusl/src/locale/newlocale.c
+++ b/fusl/src/locale/newlocale.c
@@ -3,47 +3,47 @@
#include "locale_impl.h"
#include "libc.h"
-int __loc_is_allocated(locale_t loc)
-{
- return loc && loc != C_LOCALE && loc != UTF8_LOCALE;
+int __loc_is_allocated(locale_t loc) {
+ return loc && loc != C_LOCALE && loc != UTF8_LOCALE;
}
-locale_t __newlocale(int mask, const char *name, locale_t loc)
-{
- int i, j;
- struct __locale_struct tmp;
- const struct __locale_map *lm;
-
- /* For locales with allocated storage, modify in-place. */
- if (__loc_is_allocated(loc)) {
- for (i=0; i<LC_ALL; i++)
- if (mask & (1<<i))
- loc->cat[i] = __get_locale(i, name);
- return loc;
- }
-
- /* Otherwise, build a temporary locale object, which will only
- * be instantiated in allocated storage if it does not match
- * one of the built-in static locales. This makes the common
- * usage case for newlocale, getting a C locale with predictable
- * behavior, very fast, and more importantly, fail-safe. */
- for (j=i=0; i<LC_ALL; i++) {
- if (loc && !(mask & (1<<i)))
- lm = loc->cat[i];
- else
- lm = __get_locale(i, mask & (1<<i) ? name : "");
- if (lm) j++;
- tmp.cat[i] = lm;
- }
-
- if (!j)
- return C_LOCALE;
- if (j==1 && tmp.cat[LC_CTYPE]==&__c_dot_utf8)
- return UTF8_LOCALE;
-
- if ((loc = malloc(sizeof *loc))) *loc = tmp;
-
- return loc;
+locale_t __newlocale(int mask, const char* name, locale_t loc) {
+ int i, j;
+ struct __locale_struct tmp;
+ const struct __locale_map* lm;
+
+ /* For locales with allocated storage, modify in-place. */
+ if (__loc_is_allocated(loc)) {
+ for (i = 0; i < LC_ALL; i++)
+ if (mask & (1 << i))
+ loc->cat[i] = __get_locale(i, name);
+ return loc;
+ }
+
+ /* Otherwise, build a temporary locale object, which will only
+ * be instantiated in allocated storage if it does not match
+ * one of the built-in static locales. This makes the common
+ * usage case for newlocale, getting a C locale with predictable
+ * behavior, very fast, and more importantly, fail-safe. */
+ for (j = i = 0; i < LC_ALL; i++) {
+ if (loc && !(mask & (1 << i)))
+ lm = loc->cat[i];
+ else
+ lm = __get_locale(i, mask & (1 << i) ? name : "");
+ if (lm)
+ j++;
+ tmp.cat[i] = lm;
+ }
+
+ if (!j)
+ return C_LOCALE;
+ if (j == 1 && tmp.cat[LC_CTYPE] == &__c_dot_utf8)
+ return UTF8_LOCALE;
+
+ if ((loc = malloc(sizeof *loc)))
+ *loc = tmp;
+
+ return loc;
}
weak_alias(__newlocale, newlocale);

Powered by Google App Engine
This is Rietveld 408576698