@@ -31,7 +31,7 @@ GetCalendarName
31
31
32
32
Gets the associated ICU calendar name for the CalendarId.
33
33
*/
34
- const char * GetCalendarName (CalendarId calendarId )
34
+ static const char * GetCalendarName (CalendarId calendarId )
35
35
{
36
36
switch (calendarId )
37
37
{
@@ -79,7 +79,7 @@ GetCalendarId
79
79
80
80
Gets the associated CalendarId for the ICU calendar name.
81
81
*/
82
- CalendarId GetCalendarId (const char * calendarName )
82
+ static CalendarId GetCalendarId (const char * calendarName )
83
83
{
84
84
if (strcasecmp (calendarName , GREGORIAN_NAME ) == 0 )
85
85
// TODO: what about the other gregorian types?
@@ -115,7 +115,7 @@ int32_t GlobalizationNative_GetCalendars(
115
115
{
116
116
UErrorCode err = U_ZERO_ERROR ;
117
117
char locale [ULOC_FULLNAME_CAPACITY ];
118
- GetLocale (localeName , locale , ULOC_FULLNAME_CAPACITY , false , & err );
118
+ GetLocale (localeName , locale , ULOC_FULLNAME_CAPACITY , FALSE , & err );
119
119
UEnumeration * pEnum = ucal_getKeywordValuesForLocale ("calendar" , locale , TRUE, & err );
120
120
int stringEnumeratorCount = uenum_count (pEnum , & err );
121
121
int calendarsReturned = 0 ;
@@ -143,7 +143,9 @@ GetMonthDayPattern
143
143
144
144
Gets the Month-Day DateTime pattern for the specified locale.
145
145
*/
146
- ResultCode GetMonthDayPattern (const char * locale , UChar * sMonthDay , int32_t stringCapacity )
146
+ static ResultCode GetMonthDayPattern (const char * locale ,
147
+ UChar * sMonthDay ,
148
+ int32_t stringCapacity )
147
149
{
148
150
UErrorCode err = U_ZERO_ERROR ;
149
151
UDateTimePatternGenerator * pGenerator = udatpg_open (locale , & err );
@@ -158,7 +160,10 @@ GetNativeCalendarName
158
160
159
161
Gets the native calendar name.
160
162
*/
161
- ResultCode GetNativeCalendarName (const char * locale , CalendarId calendarId , UChar * nativeName , int32_t stringCapacity )
163
+ static ResultCode GetNativeCalendarName (const char * locale ,
164
+ CalendarId calendarId ,
165
+ UChar * nativeName ,
166
+ int32_t stringCapacity )
162
167
{
163
168
UErrorCode err = U_ZERO_ERROR ;
164
169
ULocaleDisplayNames * pDisplayNames = uldn_open (locale , ULDN_STANDARD_NAMES , & err );
@@ -181,7 +186,7 @@ ResultCode GlobalizationNative_GetCalendarInfo(
181
186
{
182
187
UErrorCode err = U_ZERO_ERROR ;
183
188
char locale [ULOC_FULLNAME_CAPACITY ];
184
- GetLocale (localeName , locale , ULOC_FULLNAME_CAPACITY , false , & err );
189
+ GetLocale (localeName , locale , ULOC_FULLNAME_CAPACITY , FALSE , & err );
185
190
186
191
if (U_FAILURE (err ))
187
192
return UnknownError ;
@@ -193,7 +198,7 @@ ResultCode GlobalizationNative_GetCalendarInfo(
193
198
case MonthDay :
194
199
return GetMonthDayPattern (locale , result , resultCapacity );
195
200
default :
196
- assert (false );
201
+ assert (FALSE );
197
202
return UnknownError ;
198
203
}
199
204
}
@@ -205,28 +210,28 @@ InvokeCallbackForDatePattern
205
210
Gets the ICU date pattern for the specified locale and EStyle and invokes the
206
211
callback with the result.
207
212
*/
208
- bool InvokeCallbackForDatePattern (const char * locale ,
209
- UDateFormatStyle style ,
210
- EnumCalendarInfoCallback callback ,
211
- const void * context )
213
+ static int InvokeCallbackForDatePattern (const char * locale ,
214
+ UDateFormatStyle style ,
215
+ EnumCalendarInfoCallback callback ,
216
+ const void * context )
212
217
{
213
218
UErrorCode err = U_ZERO_ERROR ;
214
219
UDateFormat * pFormat = udat_open (UDAT_NONE , style , locale , NULL , 0 , NULL , 0 , & err );
215
220
216
221
if (U_FAILURE (err ))
217
- return false ;
222
+ return FALSE ;
218
223
219
224
UErrorCode ignore = U_ZERO_ERROR ;
220
- int32_t patternLen = udat_toPattern (pFormat , false , NULL , 0 , & ignore ) + 1 ;
225
+ int32_t patternLen = udat_toPattern (pFormat , FALSE , NULL , 0 , & ignore ) + 1 ;
221
226
222
227
UChar * pattern = calloc (patternLen , sizeof (UChar ));
223
228
if (pattern == NULL )
224
229
{
225
230
udat_close (pFormat );
226
- return false ;
231
+ return FALSE ;
227
232
}
228
233
229
- udat_toPattern (pFormat , false , pattern , patternLen , & err );
234
+ udat_toPattern (pFormat , FALSE , pattern , patternLen , & err );
230
235
udat_close (pFormat );
231
236
232
237
if (U_SUCCESS (err ))
@@ -235,7 +240,7 @@ bool InvokeCallbackForDatePattern(const char* locale,
235
240
}
236
241
237
242
free (pattern );
238
- return U_SUCCESS (err );
243
+ return UErrorCodeToBool (err );
239
244
}
240
245
241
246
/*
@@ -245,16 +250,16 @@ InvokeCallbackForDateTimePattern
245
250
Gets the DateTime pattern for the specified skeleton and invokes the callback
246
251
with the retrieved value.
247
252
*/
248
- bool InvokeCallbackForDateTimePattern (const char * locale ,
249
- const UChar * patternSkeleton ,
250
- EnumCalendarInfoCallback callback ,
251
- const void * context )
253
+ static int InvokeCallbackForDateTimePattern (const char * locale ,
254
+ const UChar * patternSkeleton ,
255
+ EnumCalendarInfoCallback callback ,
256
+ const void * context )
252
257
{
253
258
UErrorCode err = U_ZERO_ERROR ;
254
259
UDateTimePatternGenerator * pGenerator = udatpg_open (locale , & err );
255
260
256
261
if (U_FAILURE (err ))
257
- return false ;
262
+ return FALSE ;
258
263
259
264
UErrorCode ignore = U_ZERO_ERROR ;
260
265
int32_t patternLen = udatpg_getBestPattern (pGenerator , patternSkeleton , -1 , NULL , 0 , & ignore ) + 1 ;
@@ -263,7 +268,7 @@ bool InvokeCallbackForDateTimePattern(const char* locale,
263
268
if (bestPattern == NULL )
264
269
{
265
270
udatpg_close (pGenerator );
266
- return false ;
271
+ return FALSE ;
267
272
}
268
273
269
274
udatpg_getBestPattern (pGenerator , patternSkeleton , -1 , bestPattern , patternLen , & err );
@@ -275,7 +280,7 @@ bool InvokeCallbackForDateTimePattern(const char* locale,
275
280
}
276
281
277
282
free (bestPattern );
278
- return U_SUCCESS (err );
283
+ return UErrorCodeToBool (err );
279
284
}
280
285
281
286
/*
@@ -285,35 +290,29 @@ EnumSymbols
285
290
Enumerates all of the symbols of a type for a locale and calendar and invokes a callback
286
291
for each value.
287
292
*/
288
- bool EnumSymbols (const char * locale ,
289
- CalendarId calendarId ,
290
- UDateFormatSymbolType type ,
291
- int32_t startIndex ,
292
- EnumCalendarInfoCallback callback ,
293
- const void * context )
293
+ static int32_t EnumSymbols (const char * locale ,
294
+ CalendarId calendarId ,
295
+ UDateFormatSymbolType type ,
296
+ int32_t startIndex ,
297
+ EnumCalendarInfoCallback callback ,
298
+ const void * context )
294
299
{
295
300
UErrorCode err = U_ZERO_ERROR ;
296
301
UDateFormat * pFormat = udat_open (UDAT_DEFAULT , UDAT_DEFAULT , locale , NULL , 0 , NULL , 0 , & err );
297
302
298
303
if (U_FAILURE (err ))
299
- return false ;
304
+ return FALSE ;
300
305
301
306
char localeWithCalendarName [ULOC_FULLNAME_CAPACITY ];
302
307
strncpy (localeWithCalendarName , locale , ULOC_FULLNAME_CAPACITY );
303
308
uloc_setKeywordValue ("calendar" , GetCalendarName (calendarId ), localeWithCalendarName , ULOC_FULLNAME_CAPACITY , & err );
304
309
305
- if (U_FAILURE (err ))
306
- {
307
- udat_close (pFormat );
308
- return false;
309
- }
310
-
311
310
UCalendar * pCalendar = ucal_open (NULL , 0 , localeWithCalendarName , UCAL_DEFAULT , & err );
312
311
313
312
if (U_FAILURE (err ))
314
313
{
315
314
udat_close (pFormat );
316
- return false ;
315
+ return FALSE ;
317
316
}
318
317
319
318
udat_setCalendar (pFormat , pCalendar );
@@ -356,10 +355,12 @@ bool EnumSymbols(const char* locale,
356
355
357
356
udat_close (pFormat );
358
357
ucal_close (pCalendar );
359
- return U_SUCCESS (err );
358
+ return UErrorCodeToBool (err );
360
359
}
361
360
362
- bool EnumUResourceBundle (const UResourceBundle * bundle , EnumCalendarInfoCallback callback , const void * context )
361
+ static void EnumUResourceBundle (const UResourceBundle * bundle ,
362
+ EnumCalendarInfoCallback callback ,
363
+ const void * context )
363
364
{
364
365
int32_t eraNameCount = ures_getSize (bundle );
365
366
@@ -374,15 +375,13 @@ bool EnumUResourceBundle(const UResourceBundle* bundle, EnumCalendarInfoCallback
374
375
callback (eraName , context );
375
376
}
376
377
}
377
-
378
- return true;
379
378
}
380
379
381
- void CloseResBundle (const UResourceBundle * rootResBundle ,
382
- const UResourceBundle * calResBundle ,
383
- const UResourceBundle * targetCalResBundle ,
384
- const UResourceBundle * erasColResBundle ,
385
- const UResourceBundle * erasResBundle )
380
+ static void CloseResBundle (const UResourceBundle * rootResBundle ,
381
+ const UResourceBundle * calResBundle ,
382
+ const UResourceBundle * targetCalResBundle ,
383
+ const UResourceBundle * erasColResBundle ,
384
+ const UResourceBundle * erasResBundle )
386
385
{
387
386
ures_close (rootResBundle );
388
387
ures_close (calResBundle );
@@ -398,10 +397,10 @@ EnumAbbrevEraNames
398
397
Enumerates all the abbreviated era names of the specified locale and calendar, invoking the
399
398
callback function for each era name.
400
399
*/
401
- bool EnumAbbrevEraNames (const char * locale ,
402
- CalendarId calendarId ,
403
- EnumCalendarInfoCallback callback ,
404
- const void * context )
400
+ static int32_t EnumAbbrevEraNames (const char * locale ,
401
+ CalendarId calendarId ,
402
+ EnumCalendarInfoCallback callback ,
403
+ const void * context )
405
404
{
406
405
// The C-API for ICU provides no way to get at the abbreviated era names for a calendar (so we can't use EnumSymbols
407
406
// here). Instead we will try to walk the ICU resource tables directly and fall back to regular era names if can't
@@ -414,7 +413,7 @@ bool EnumAbbrevEraNames(const char* locale,
414
413
415
414
strncpy (localeNamePtr , locale , ULOC_FULLNAME_CAPACITY );
416
415
417
- while (true )
416
+ while (TRUE )
418
417
{
419
418
UErrorCode status = U_ZERO_ERROR ;
420
419
char * name = GetCalendarName (calendarId );
@@ -429,7 +428,7 @@ bool EnumAbbrevEraNames(const char* locale,
429
428
{
430
429
EnumUResourceBundle (erasResBundle , callback , context );
431
430
CloseResBundle (rootResBundle , calResBundle , targetCalResBundle , erasColResBundle , erasResBundle );
432
- return true ;
431
+ return TRUE ;
433
432
}
434
433
435
434
// Couldn't find the data we need for this locale, we should fallback.
@@ -474,19 +473,18 @@ Allows for a collection of calendar string data to be retrieved by invoking
474
473
the callback for each value in the collection.
475
474
The context parameter is passed through to the callback along with each string.
476
475
*/
477
- int32_t GlobalizationNative_EnumCalendarInfo (
478
- EnumCalendarInfoCallback callback ,
479
- const UChar * localeName ,
480
- CalendarId calendarId ,
481
- CalendarDataType dataType ,
482
- const void * context )
476
+ int32_t GlobalizationNative_EnumCalendarInfo (EnumCalendarInfoCallback callback ,
477
+ const UChar * localeName ,
478
+ CalendarId calendarId ,
479
+ CalendarDataType dataType ,
480
+ const void * context )
483
481
{
484
482
UErrorCode err = U_ZERO_ERROR ;
485
483
char locale [ULOC_FULLNAME_CAPACITY ];
486
- GetLocale (localeName , locale , ULOC_FULLNAME_CAPACITY , false , & err );
484
+ GetLocale (localeName , locale , ULOC_FULLNAME_CAPACITY , FALSE , & err );
487
485
488
486
if (U_FAILURE (err ))
489
- return false ;
487
+ return FALSE ;
490
488
491
489
switch (dataType )
492
490
{
@@ -527,8 +525,8 @@ int32_t GlobalizationNative_EnumCalendarInfo(
527
525
case AbbrevEraNames :
528
526
return EnumAbbrevEraNames (locale , calendarId , callback , context );
529
527
default :
530
- assert (false );
531
- return false ;
528
+ assert (FALSE );
529
+ return FALSE ;
532
530
}
533
531
}
534
532
@@ -559,8 +557,10 @@ GetJapaneseEraInfo
559
557
560
558
Gets the starting Gregorian date of the specified Japanese Era.
561
559
*/
562
- int32_t GlobalizationNative_GetJapaneseEraStartDate (
563
- int32_t era , int32_t * startYear , int32_t * startMonth , int32_t * startDay )
560
+ int32_t GlobalizationNative_GetJapaneseEraStartDate (int32_t era ,
561
+ int32_t * startYear ,
562
+ int32_t * startMonth ,
563
+ int32_t * startDay )
564
564
{
565
565
* startYear = -1 ;
566
566
* startMonth = -1 ;
@@ -570,7 +570,7 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate(
570
570
UCalendar * pCal = ucal_open (NULL , 0 , JAPANESE_LOCALE_AND_CALENDAR , UCAL_TRADITIONAL , & err );
571
571
572
572
if (U_FAILURE (err ))
573
- return false ;
573
+ return FALSE ;
574
574
575
575
ucal_set (pCal , UCAL_ERA , era );
576
576
ucal_set (pCal , UCAL_YEAR , 1 );
@@ -580,7 +580,7 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate(
580
580
if (U_FAILURE (err ))
581
581
{
582
582
ucal_close (pCal );
583
- return false ;
583
+ return FALSE ;
584
584
}
585
585
586
586
// set the date to Jan 1
@@ -607,7 +607,7 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate(
607
607
* startDay = ucal_get (pCal , UCAL_DATE , & err );
608
608
ucal_close (pCal );
609
609
610
- return U_SUCCESS (err );
610
+ return UErrorCodeToBool (err );
611
611
}
612
612
}
613
613
}
@@ -617,5 +617,5 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate(
617
617
}
618
618
619
619
ucal_close (pCal );
620
- return false ;
620
+ return FALSE ;
621
621
}
0 commit comments