Skip to content

Commit 54ef2e1

Browse files
committed
formatting
1 parent 7832978 commit 54ef2e1

File tree

1 file changed

+64
-68
lines changed

1 file changed

+64
-68
lines changed

libcxx/src/support/ibm/xlocale_zos.cpp

Lines changed: 64 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,58 @@
1414

1515
_LIBCPP_BEGIN_NAMESPACE_STD
1616

17-
#define CategoryList(pair, sep) \
18-
pair(LC_COLLATE, lc_collate) sep \
19-
pair(LC_CTYPE, lc_ctype) sep \
20-
pair(LC_MONETARY, lc_monetary) sep \
21-
pair(LC_NUMERIC, lc_numeric) sep \
22-
pair(LC_TIME, lc_time) sep \
23-
pair(LC_MESSAGES, lc_messages)
17+
#define CategoryList(pair, sep) \
18+
pair(LC_COLLATE, lc_collate) sep pair(LC_CTYPE, lc_ctype) \
19+
sep pair(LC_MONETARY, lc_monetary) \
20+
sep pair(LC_NUMERIC, lc_numeric) \
21+
sep pair(LC_TIME, lc_time) \
22+
sep pair(LC_MESSAGES, lc_messages)
2423

2524
// check ids and masks agree
26-
#define check_ids_and_masks_agree(id, _) \
27-
static_assert((1 << id) == id##_MASK, "id and mask do not agree for " #id); \
25+
#define check_ids_and_masks_agree(id, _) \
26+
static_assert((1 << id) == id##_MASK, "id and mask do not agree for " #id); \
2827
static_assert((1 << id) == _CATMASK(id), "mask does not have expected value for " #id);
29-
CategoryList(check_ids_and_masks_agree,)
28+
CategoryList(check_ids_and_masks_agree, )
3029
#undef check_ids_and_masks_agree
3130

3231
// check that LC_ALL_MASK is defined as expected
3332
#define get_mask(id, _) id##_MASK
34-
static_assert(LC_ALL_MASK == (CategoryList(get_mask, |)), "LC_ALL_MASK does not have the expected value. Check that its definition includes all supported categories");
33+
static_assert(
34+
LC_ALL_MASK == (CategoryList(get_mask, |)),
35+
"LC_ALL_MASK does not have the expected value. Check that its definition includes all supported categories");
3536
#undef get_mask
3637

37-
3838
// initialize c_locale
3939
#define init_clocale(id, locale_member) "C",
40-
static locale_struct c_locale = { LC_ALL_MASK, CategoryList(init_clocale, ) };
40+
static locale_struct c_locale = {LC_ALL_MASK, CategoryList(init_clocale, )};
4141
#undef init_clocale
4242

4343
static locale_t current_locale = _LIBCPP_LC_GLOBAL_LOCALE;
4444

45-
46-
locale_t __c_locale() {
47-
return &c_locale;
48-
}
45+
locale_t __c_locale() { return &c_locale; }
4946

5047
// locale
5148
locale_t newlocale(int category_mask, const char* locale, locale_t base) {
5249
// start with some basic checks
53-
if (! locale) {
50+
if (!locale) {
5451
errno = EINVAL;
55-
return (locale_t) 0;
52+
return (locale_t)0;
5653
}
5754
if (category_mask & ~LC_ALL_MASK) {
5855
// then there are bits in category_mask that does not correspond
5956
// to a valid category
6057
errno = EINVAL;
61-
return (locale_t) 0;
58+
return (locale_t)0;
6259
}
6360

64-
locale_t new_loc = new locale_struct;
61+
locale_t new_loc = new locale_struct;
6562
int num_locales_not_found = 0;
6663

6764
if (base && base != _LIBCPP_LC_GLOBAL_LOCALE)
6865
*new_loc = *base;
6966

70-
auto set_for_category = [&](int id, int mask, std::string &setting) {
71-
const char *setting_to_apply = nullptr;
67+
auto set_for_category = [&](int id, int mask, std::string& setting) {
68+
const char* setting_to_apply = nullptr;
7269

7370
if (category_mask & mask)
7471
setting_to_apply = locale;
@@ -77,7 +74,7 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
7774

7875
if (setting_to_apply) {
7976
// setlocale takes the id, not the mask
80-
const char *saved_setting = setlocale(id, nullptr);
77+
const char* saved_setting = setlocale(id, nullptr);
8178
if (setlocale(id, setting_to_apply)) {
8279
// then setting_to_apply is valid for this category
8380
// restore the saved setting
@@ -99,8 +96,8 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
9996

10097
if (num_locales_not_found != 0) {
10198
delete new_loc;
102-
errno = ENOENT;
103-
new_loc = (locale_t) 0;
99+
errno = ENOENT;
100+
new_loc = (locale_t)0;
104101
}
105102

106103
return new_loc;
@@ -117,12 +114,12 @@ locale_t uselocale(locale_t new_loc) {
117114
if (new_loc == _LIBCPP_LC_GLOBAL_LOCALE) {
118115
current_locale = _LIBCPP_LC_GLOBAL_LOCALE;
119116
} else if (new_loc != nullptr) {
120-
locale_struct saved_locale;
117+
locale_struct saved_locale;
121118
saved_locale.category_mask = 0;
122119

123-
auto apply_category = [&](int id, int mask, std::string &setting, std::string &save_setting)-> bool {
120+
auto apply_category = [&](int id, int mask, std::string& setting, std::string& save_setting) -> bool {
124121
if (new_loc->category_mask & mask) {
125-
const char *old_setting = setlocale(id, setting.c_str());
122+
const char* old_setting = setlocale(id, setting.c_str());
126123
if (old_setting) {
127124
// we were able to set for this category. Save the old setting
128125
// in case a subsequent category fails, and we need to restore
@@ -136,17 +133,17 @@ locale_t uselocale(locale_t new_loc) {
136133
return true;
137134
};
138135

139-
#define Apply(id, locale_member) apply_category(id, id##_MASK, new_loc->locale_member, saved_locale. locale_member)
136+
#define Apply(id, locale_member) apply_category(id, id##_MASK, new_loc->locale_member, saved_locale.locale_member)
140137
bool is_ok = CategoryList(Apply, &&);
141138
#undef Apply
142139

143140
if (!is_ok) {
144-
auto restore = [&](int id, int mask, std::string &setting) {
141+
auto restore = [&](int id, int mask, std::string& setting) {
145142
if (saved_locale.category_mask & mask)
146143
setlocale(id, setting.c_str());
147144
};
148-
#define Restore(id, locale_member) restore(id, id##_MASK, saved_locale. locale_member);
149-
CategoryList(Restore,);
145+
#define Restore(id, locale_member) restore(id, id##_MASK, saved_locale.locale_member);
146+
CategoryList(Restore, );
150147
#undef Restore
151148
errno = EINVAL;
152149
return nullptr;
@@ -157,174 +154,173 @@ locale_t uselocale(locale_t new_loc) {
157154
return prev_loc;
158155
}
159156

160-
int isdigit_l(int __c, locale_t __l) {
157+
int isdigit_l(int __c, locale_t __l) {
161158
__setAndRestore __newloc(__l);
162159
return ::isdigit(__c);
163160
}
164161

165-
int isxdigit_l(int __c, locale_t __l) {
162+
int isxdigit_l(int __c, locale_t __l) {
166163
__setAndRestore __newloc(__l);
167164
return ::isxdigit(__c);
168165
}
169166

170167
namespace __ibm {
171-
int isalnum_l(int __c, locale_t __l) {
168+
int isalnum_l(int __c, locale_t __l) {
172169
__setAndRestore __newloc(__l);
173170
return ::isalnum(__c);
174171
}
175172

176-
int isalpha_l(int __c, locale_t __l) {
173+
int isalpha_l(int __c, locale_t __l) {
177174
__setAndRestore __newloc(__l);
178175
return ::isalpha(__c);
179176
}
180177

181-
int isblank_l(int __c, locale_t __l) {
178+
int isblank_l(int __c, locale_t __l) {
182179
__setAndRestore __newloc(__l);
183180
return ::isblank(__c);
184181
}
185182

186-
int iscntrl_l(int __c, locale_t __l) {
183+
int iscntrl_l(int __c, locale_t __l) {
187184
__setAndRestore __newloc(__l);
188185
return ::iscntrl(__c);
189186
}
190187

191-
int isgraph_l(int __c, locale_t __l) {
188+
int isgraph_l(int __c, locale_t __l) {
192189
__setAndRestore __newloc(__l);
193190
return ::isgraph(__c);
194191
}
195192

196-
int islower_l(int __c, locale_t __l) {
193+
int islower_l(int __c, locale_t __l) {
197194
__setAndRestore __newloc(__l);
198195
return ::islower(__c);
199196
}
200197

201-
int isprint_l(int __c, locale_t __l) {
198+
int isprint_l(int __c, locale_t __l) {
202199
__setAndRestore __newloc(__l);
203200
return ::isprint(__c);
204201
}
205202

206-
int ispunct_l(int __c, locale_t __l) {
203+
int ispunct_l(int __c, locale_t __l) {
207204
__setAndRestore __newloc(__l);
208205
return ::ispunct(__c);
209206
}
210207

211-
int isspace_l(int __c, locale_t __l) {
208+
int isspace_l(int __c, locale_t __l) {
212209
__setAndRestore __newloc(__l);
213210
return ::isspace(__c);
214211
}
215212

216-
int isupper_l(int __c, locale_t __l) {
213+
int isupper_l(int __c, locale_t __l) {
217214
__setAndRestore __newloc(__l);
218215
return ::isupper(__c);
219216
}
220217

221-
int iswalnum_l(wint_t __c, locale_t __l) {
218+
int iswalnum_l(wint_t __c, locale_t __l) {
222219
__setAndRestore __newloc(__l);
223220
return ::iswalnum(__c);
224221
}
225222

226-
int iswalpha_l(wint_t __c, locale_t __l) {
223+
int iswalpha_l(wint_t __c, locale_t __l) {
227224
__setAndRestore __newloc(__l);
228225
return ::iswalpha(__c);
229226
}
230227

231-
int iswblank_l(wint_t __c, locale_t __l) {
228+
int iswblank_l(wint_t __c, locale_t __l) {
232229
__setAndRestore __newloc(__l);
233230
return ::iswblank(__c);
234231
}
235232

236-
int iswcntrl_l(wint_t __c, locale_t __l) {
233+
int iswcntrl_l(wint_t __c, locale_t __l) {
237234
__setAndRestore __newloc(__l);
238235
return ::iswcntrl(__c);
239236
}
240237

241-
int iswdigit_l(wint_t __c, locale_t __l) {
238+
int iswdigit_l(wint_t __c, locale_t __l) {
242239
__setAndRestore __newloc(__l);
243240
return ::iswdigit(__c);
244241
}
245242

246-
int iswgraph_l(wint_t __c, locale_t __l) {
243+
int iswgraph_l(wint_t __c, locale_t __l) {
247244
__setAndRestore __newloc(__l);
248245
return ::iswgraph(__c);
249246
}
250247

251-
int iswlower_l(wint_t __c, locale_t __l) {
248+
int iswlower_l(wint_t __c, locale_t __l) {
252249
__setAndRestore __newloc(__l);
253250
return ::iswlower(__c);
254251
}
255252

256-
int iswprint_l(wint_t __c, locale_t __l) {
253+
int iswprint_l(wint_t __c, locale_t __l) {
257254
__setAndRestore __newloc(__l);
258255
return ::iswprint(__c);
259256
}
260257

261-
int iswpunct_l(wint_t __c, locale_t __l) {
258+
int iswpunct_l(wint_t __c, locale_t __l) {
262259
__setAndRestore __newloc(__l);
263260
return ::iswpunct(__c);
264261
}
265262

266-
int iswspace_l(wint_t __c, locale_t __l) {
263+
int iswspace_l(wint_t __c, locale_t __l) {
267264
__setAndRestore __newloc(__l);
268265
return ::iswspace(__c);
269266
}
270267

271-
int iswupper_l(wint_t __c, locale_t __l) {
268+
int iswupper_l(wint_t __c, locale_t __l) {
272269
__setAndRestore __newloc(__l);
273270
return ::iswupper(__c);
274271
}
275272

276-
int iswxdigit_l(wint_t __c, locale_t __l) {
273+
int iswxdigit_l(wint_t __c, locale_t __l) {
277274
__setAndRestore __newloc(__l);
278275
return ::iswxdigit(__c);
279276
}
280277

281-
int toupper_l(int __c, locale_t __l) {
278+
int toupper_l(int __c, locale_t __l) {
282279
__setAndRestore __newloc(__l);
283280
return ::toupper(__c);
284281
}
285282

286-
int tolower_l(int __c, locale_t __l) {
283+
int tolower_l(int __c, locale_t __l) {
287284
__setAndRestore __newloc(__l);
288285
return ::tolower(__c);
289286
}
290287

291-
wint_t towupper_l(wint_t __c, locale_t __l) {
288+
wint_t towupper_l(wint_t __c, locale_t __l) {
292289
__setAndRestore __newloc(__l);
293290
return ::towupper(__c);
294291
}
295292

296-
wint_t towlower_l(wint_t __c, locale_t __l) {
293+
wint_t towlower_l(wint_t __c, locale_t __l) {
297294
__setAndRestore __newloc(__l);
298295
return ::towlower(__c);
299296
}
300297

301-
int strcoll_l(const char *__s1, const char *__s2, locale_t __l) {
298+
int strcoll_l(const char* __s1, const char* __s2, locale_t __l) {
302299
__setAndRestore __newloc(__l);
303300
return ::strcoll(__s1, __s2);
304301
}
305302

306-
size_t strxfrm_l(char *__dest, const char *__src, size_t __n, locale_t __l) {
303+
size_t strxfrm_l(char* __dest, const char* __src, size_t __n, locale_t __l) {
307304
__setAndRestore __newloc(__l);
308305
return ::strxfrm(__dest, __src, __n);
309306
}
310307

311-
size_t strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm,
312-
locale_t __l) {
308+
size_t strftime_l(char* __s, size_t __max, const char* __format, const struct tm* __tm, locale_t __l) {
313309
__setAndRestore __newloc(__l);
314310
return ::strftime(__s, __max, __format, __tm);
315311
}
316312

317-
int wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t __l) {
313+
int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t __l) {
318314
__setAndRestore __newloc(__l);
319315
return ::wcscoll(__ws1, __ws2);
320316
}
321317

322-
size_t wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t __l) {
318+
size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t __l) {
323319
__setAndRestore __newloc(__l);
324320
return ::wcsxfrm(__dest, __src, __n);
325321
}
326322

327-
int iswctype_l(wint_t __c, wctype_t __type, locale_t __l) {
323+
int iswctype_l(wint_t __c, wctype_t __type, locale_t __l) {
328324
__setAndRestore __newloc(__l);
329325
return ::iswctype(__c, __type);
330326
}

0 commit comments

Comments
 (0)