13
13
{
14
14
NSLocale *currentLocale = [NSLocale currentLocale ];
15
15
NSString *localeName = @" " ;
16
-
16
+
17
17
if (!currentLocale)
18
18
{
19
19
return strdup ([localeName UTF8String ]);
27
27
{
28
28
localeName = currentLocale.localeIdentifier ;
29
29
}
30
-
30
+
31
31
return strdup ([localeName UTF8String ]);
32
32
}
33
33
143
143
case LocaleString_MonetaryThousandSeparator:
144
144
case LocaleString_Iso639LanguageThreeLetterName:
145
145
case LocaleString_ParentName:
146
- case LocaleString_Iso3166CountryName2:
146
+ case LocaleString_Iso3166CountryName2:
147
147
default :
148
148
value = " " ;
149
149
break ;
169
169
Returns a numeric string pattern in a format that we can match against the
170
170
appropriate managed pattern. Examples:
171
171
For PositiveMonetaryNumberFormat "¤#,##0.00" becomes "Cn"
172
- For NegativeNumberFormat "#,##0.00;(#,##0.00)" becomes "(n)"
172
+ For NegativeNumberFormat "#,##0.00;(#,##0.00)" becomes "(n)"
173
173
*/
174
174
static char * NormalizeNumericPattern (const char * srcPattern, int isNegative)
175
175
{
176
176
int iStart = 0 ;
177
177
int iEnd = strlen (srcPattern);
178
178
179
- // ';' separates positive and negative subpatterns.
179
+ // ';' separates positive and negative subpatterns.
180
180
// When there is no explicit negative subpattern,
181
181
// an implicit negative subpattern is formed from the positive pattern with a prefixed '-'.
182
182
char * ptrNegativePattern = strrchr (srcPattern,' ;' );
@@ -328,7 +328,7 @@ static int GetPatternIndex(char* normalizedPattern,const char* patterns[], int p
328
328
329
329
static int32_t GetValueForNumberFormat (NSLocale *currentLocale, LocaleNumberData localeNumberData)
330
330
{
331
- NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
331
+ NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
332
332
numberFormatter.locale = currentLocale;
333
333
const char *pFormat;
334
334
int32_t value;
@@ -390,7 +390,9 @@ static int32_t GetValueForNumberFormat(NSLocale *currentLocale, LocaleNumberData
390
390
391
391
int32_t GlobalizationNative_GetLocaleInfoIntNative (const char * localeName, LocaleNumberData localeNumberData)
392
392
{
393
+ #ifndef NDEBUG
393
394
bool isSuccess = true ;
395
+ #endif
394
396
int32_t value;
395
397
NSString *locName = [NSString stringWithFormat: @" %s " , localeName];
396
398
NSLocale *currentLocale = [[NSLocale alloc ] initWithLocaleIdentifier: locName];
@@ -402,36 +404,38 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local
402
404
const char *measurementSystem = [[currentLocale objectForKey: NSLocaleMeasurementSystem ] UTF8String ];
403
405
NSLocale *usLocale = [[NSLocale alloc ] initWithLocaleIdentifier: @" en_US" ];
404
406
const char *us_measurementSystem = [[usLocale objectForKey: NSLocaleMeasurementSystem ] UTF8String ];
405
- value = (measurementSystem == us_measurementSystem) ? 1 : 0 ;
407
+ value = (measurementSystem == us_measurementSystem) ? 1 : 0 ;
406
408
break ;
407
409
}
408
410
case LocaleNumber_FractionalDigitsCount:
409
411
{
410
- NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
412
+ NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
411
413
numberFormatter.locale = currentLocale;
412
414
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
413
415
value = (int32_t )numberFormatter.maximumFractionDigits ;
414
416
break ;
415
417
}
416
418
case LocaleNumber_MonetaryFractionalDigitsCount:
417
419
{
418
- NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
420
+ NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
419
421
numberFormatter.locale = currentLocale;
420
422
numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
421
423
value = (int32_t )numberFormatter.maximumFractionDigits ;
422
424
break ;
423
- }
425
+ }
424
426
case LocaleNumber_PositiveMonetaryNumberFormat:
425
427
case LocaleNumber_NegativeMonetaryNumberFormat:
426
428
case LocaleNumber_NegativeNumberFormat:
427
429
case LocaleNumber_NegativePercentFormat:
428
430
case LocaleNumber_PositivePercentFormat:
429
431
{
430
432
value = GetValueForNumberFormat (currentLocale, localeNumberData);
433
+ #ifndef NDEBUG
431
434
if (value < 0 )
432
435
{
433
436
isSuccess = false ;
434
437
}
438
+ #endif
435
439
break ;
436
440
}
437
441
case LocaleNumber_FirstWeekOfYear:
@@ -451,12 +455,14 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local
451
455
value = WeekRule_FirstFourDayWeek;
452
456
}
453
457
else
454
- {
458
+ {
455
459
value = -1 ;
460
+ #ifndef NDEBUG
456
461
isSuccess = false ;
462
+ #endif
457
463
}
458
464
break ;
459
- }
465
+ }
460
466
case LocaleNumber_ReadingLayout:
461
467
{
462
468
NSLocaleLanguageDirection langDir = [NSLocale characterDirectionForLanguage: [currentLocale objectForKey: NSLocaleLanguageCode ]];
@@ -473,7 +479,9 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local
473
479
}
474
480
default :
475
481
value = -1 ;
482
+ #ifndef NDEBUG
476
483
isSuccess = false ;
484
+ #endif
477
485
break ;
478
486
}
479
487
@@ -490,11 +498,10 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local
490
498
*/
491
499
int32_t GlobalizationNative_GetLocaleInfoPrimaryGroupingSizeNative (const char * localeName, LocaleNumberData localeGroupingData)
492
500
{
493
- bool isSuccess = true ;
494
501
NSString *locName = [NSString stringWithFormat: @" %s " , localeName];
495
502
NSLocale *currentLocale = [[NSLocale alloc ] initWithLocaleIdentifier: locName];
496
- NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
497
- numberFormatter.locale = currentLocale;
503
+ NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
504
+ numberFormatter.locale = currentLocale;
498
505
499
506
switch (localeGroupingData)
500
507
{
@@ -505,11 +512,10 @@ int32_t GlobalizationNative_GetLocaleInfoPrimaryGroupingSizeNative(const char* l
505
512
numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
506
513
break ;
507
514
default :
508
- isSuccess = false ;
509
- assert (isSuccess);
515
+ assert (false );
510
516
break ;
511
517
}
512
- return [numberFormatter groupingSize ];
518
+ return [numberFormatter groupingSize ];
513
519
}
514
520
515
521
/*
@@ -520,11 +526,10 @@ int32_t GlobalizationNative_GetLocaleInfoPrimaryGroupingSizeNative(const char* l
520
526
*/
521
527
int32_t GlobalizationNative_GetLocaleInfoSecondaryGroupingSizeNative (const char * localeName, LocaleNumberData localeGroupingData)
522
528
{
523
- bool isSuccess = true ;
524
529
NSString *locName = [NSString stringWithFormat: @" %s " , localeName];
525
530
NSLocale *currentLocale = [[NSLocale alloc ] initWithLocaleIdentifier: locName];
526
- NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
527
- numberFormatter.locale = currentLocale;
531
+ NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc ] init ];
532
+ numberFormatter.locale = currentLocale;
528
533
529
534
switch (localeGroupingData)
530
535
{
@@ -535,8 +540,7 @@ int32_t GlobalizationNative_GetLocaleInfoSecondaryGroupingSizeNative(const char*
535
540
numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
536
541
break ;
537
542
default :
538
- isSuccess = false ;
539
- assert (isSuccess);
543
+ assert (false );
540
544
break ;
541
545
}
542
546
0 commit comments