OLD | NEW |
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html | 2 // License & terms of use: http://www.unicode.org/copyright.html |
3 /* | 3 /* |
4 ******************************************************************************* | 4 ******************************************************************************* |
5 * Copyright (C) 2010-2015, International Business Machines Corporation and | 5 * Copyright (C) 2010-2015, International Business Machines Corporation and |
6 * others. All Rights Reserved. | 6 * others. All Rights Reserved. |
7 ******************************************************************************* | 7 ******************************************************************************* |
8 * | 8 * |
9 * | 9 * |
10 * File NUMSYS.CPP | 10 * File NUMSYS.CPP |
11 * | 11 * |
12 * Modification History:* | 12 * Modification History:* |
13 * Date Name Description | 13 * Date Name Description |
14 * | 14 * |
15 ******************************************************************************** | 15 ******************************************************************************** |
16 */ | 16 */ |
17 | 17 |
| 18 #include <uassert.h> |
18 #include "unicode/utypes.h" | 19 #include "unicode/utypes.h" |
19 #include "unicode/localpointer.h" | 20 #include "unicode/localpointer.h" |
20 #include "unicode/uchar.h" | 21 #include "unicode/uchar.h" |
21 #include "unicode/unistr.h" | 22 #include "unicode/unistr.h" |
22 #include "unicode/ures.h" | 23 #include "unicode/ures.h" |
23 #include "unicode/ustring.h" | 24 #include "unicode/ustring.h" |
24 #include "unicode/uloc.h" | 25 #include "unicode/uloc.h" |
25 #include "unicode/schriter.h" | 26 #include "unicode/schriter.h" |
26 #include "unicode/numsys.h" | 27 #include "unicode/numsys.h" |
27 #include "cstring.h" | 28 #include "cstring.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) { | 109 NumberingSystem::createInstance(const Locale & inLocale, UErrorCode& status) { |
109 | 110 |
110 if (U_FAILURE(status)) { | 111 if (U_FAILURE(status)) { |
111 return NULL; | 112 return NULL; |
112 } | 113 } |
113 | 114 |
114 UBool nsResolved = TRUE; | 115 UBool nsResolved = TRUE; |
115 UBool usingFallback = FALSE; | 116 UBool usingFallback = FALSE; |
116 char buffer[ULOC_KEYWORDS_CAPACITY]; | 117 char buffer[ULOC_KEYWORDS_CAPACITY]; |
117 int32_t count = inLocale.getKeywordValue("numbers",buffer, sizeof(buffer),st
atus); | 118 int32_t count = inLocale.getKeywordValue("numbers",buffer, sizeof(buffer),st
atus); |
| 119 if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING) { |
| 120 // the "numbers" keyword exceeds ULOC_KEYWORDS_CAPACITY; ignore and use
default. |
| 121 count = 0; |
| 122 status = U_ZERO_ERROR; |
| 123 } |
118 if ( count > 0 ) { // @numbers keyword was specified in the locale | 124 if ( count > 0 ) { // @numbers keyword was specified in the locale |
| 125 U_ASSERT(count < ULOC_KEYWORDS_CAPACITY); |
119 buffer[count] = '\0'; // Make sure it is null terminated. | 126 buffer[count] = '\0'; // Make sure it is null terminated. |
120 if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) ||· | 127 if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) ||· |
121 !uprv_strcmp(buffer,gTraditional) || !uprv_strcmp(buffer,gFinance))
{ | 128 !uprv_strcmp(buffer,gTraditional) || !uprv_strcmp(buffer,gFinance))
{ |
122 nsResolved = FALSE; | 129 nsResolved = FALSE; |
123 } | 130 } |
124 } else { | 131 } else { |
125 uprv_strcpy(buffer,gDefault); | 132 uprv_strcpy(buffer,gDefault); |
126 nsResolved = FALSE; | 133 nsResolved = FALSE; |
127 } | 134 } |
128 | 135 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 322 } |
316 | 323 |
317 NumsysNameEnumeration::~NumsysNameEnumeration() { | 324 NumsysNameEnumeration::~NumsysNameEnumeration() { |
318 delete fNumsysNames; | 325 delete fNumsysNames; |
319 } | 326 } |
320 U_NAMESPACE_END | 327 U_NAMESPACE_END |
321 | 328 |
322 #endif /* #if !UCONFIG_NO_FORMATTING */ | 329 #endif /* #if !UCONFIG_NO_FORMATTING */ |
323 | 330 |
324 //eof | 331 //eof |
OLD | NEW |