| OLD | NEW |
| 1 /* | 1 /* |
| 2 ********************************************************************** | 2 ********************************************************************** |
| 3 * Copyright (C) 2009-2014, International Business Machines | 3 * Copyright (C) 2009-2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ********************************************************************** | 5 ********************************************************************** |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "unicode/utypes.h" | 8 #include "unicode/utypes.h" |
| 9 #include "unicode/ures.h" | 9 #include "unicode/ures.h" |
| 10 #include "unicode/putil.h" | 10 #include "unicode/putil.h" |
| 11 #include "unicode/uloc.h" | 11 #include "unicode/uloc.h" |
| 12 #include "ustr_imp.h" | 12 #include "ustr_imp.h" |
| 13 #include "cmemory.h" | 13 #include "cmemory.h" |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 const char *pBcpKey = NULL; /* u extenstion key subtag */ | 1313 const char *pBcpKey = NULL; /* u extenstion key subtag */ |
| 1314 const char *pBcpType = NULL; /* beginning of u extension type subtag(
s) */ | 1314 const char *pBcpType = NULL; /* beginning of u extension type subtag(
s) */ |
| 1315 int32_t bcpKeyLen = 0; | 1315 int32_t bcpKeyLen = 0; |
| 1316 int32_t bcpTypeLen = 0; | 1316 int32_t bcpTypeLen = 0; |
| 1317 UBool isDone = FALSE; | 1317 UBool isDone = FALSE; |
| 1318 | 1318 |
| 1319 pTag = pKwds; | 1319 pTag = pKwds; |
| 1320 /* BCP47 representation of LDML key/type pairs */ | 1320 /* BCP47 representation of LDML key/type pairs */ |
| 1321 while (!isDone) { | 1321 while (!isDone) { |
| 1322 const char *pNextBcpKey = NULL; | 1322 const char *pNextBcpKey = NULL; |
| 1323 int32_t nextBcpKeyLen; | 1323 int32_t nextBcpKeyLen = 0; |
| 1324 UBool emitKeyword = FALSE; | 1324 UBool emitKeyword = FALSE; |
| 1325 | 1325 |
| 1326 if (*pTag) { | 1326 if (*pTag) { |
| 1327 /* locate next separator char */ | 1327 /* locate next separator char */ |
| 1328 for (len = 0; *(pTag + len) && *(pTag + len) != SEP; len++); | 1328 for (len = 0; *(pTag + len) && *(pTag + len) != SEP; len++); |
| 1329 | 1329 |
| 1330 if (ultag_isUnicodeLocaleKey(pTag, len)) { | 1330 if (ultag_isUnicodeLocaleKey(pTag, len)) { |
| 1331 if (pBcpKey) { | 1331 if (pBcpKey) { |
| 1332 emitKeyword = TRUE; | 1332 emitKeyword = TRUE; |
| 1333 pNextBcpKey = pTag; | 1333 pNextBcpKey = pTag; |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 if (uprv_stricmp(GRANDFATHERED[i], tagBuf) == 0) { | 1826 if (uprv_stricmp(GRANDFATHERED[i], tagBuf) == 0) { |
| 1827 int32_t newTagLength; | 1827 int32_t newTagLength; |
| 1828 | 1828 |
| 1829 grandfatheredLen = tagLen; /* back up for output parsedLen */ | 1829 grandfatheredLen = tagLen; /* back up for output parsedLen */ |
| 1830 newTagLength = uprv_strlen(GRANDFATHERED[i+1]); | 1830 newTagLength = uprv_strlen(GRANDFATHERED[i+1]); |
| 1831 if (tagLen < newTagLength) { | 1831 if (tagLen < newTagLength) { |
| 1832 uprv_free(tagBuf); | 1832 uprv_free(tagBuf); |
| 1833 tagBuf = (char*)uprv_malloc(newTagLength + 1); | 1833 tagBuf = (char*)uprv_malloc(newTagLength + 1); |
| 1834 if (tagBuf == NULL) { | 1834 if (tagBuf == NULL) { |
| 1835 *status = U_MEMORY_ALLOCATION_ERROR; | 1835 *status = U_MEMORY_ALLOCATION_ERROR; |
| 1836 ultag_close(t); |
| 1836 return NULL; | 1837 return NULL; |
| 1837 } | 1838 } |
| 1838 t->buf = tagBuf; | 1839 t->buf = tagBuf; |
| 1839 tagLen = newTagLength; | 1840 tagLen = newTagLength; |
| 1840 } | 1841 } |
| 1841 uprv_strcpy(t->buf, GRANDFATHERED[i + 1]); | 1842 uprv_strcpy(t->buf, GRANDFATHERED[i + 1]); |
| 1842 break; | 1843 break; |
| 1843 } | 1844 } |
| 1844 } | 1845 } |
| 1845 | 1846 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 } | 2123 } |
| 2123 } | 2124 } |
| 2124 | 2125 |
| 2125 if (parsedLen != NULL) { | 2126 if (parsedLen != NULL) { |
| 2126 *parsedLen = (grandfatheredLen > 0) ? grandfatheredLen : (int32_t)(pLast
GoodPosition - t->buf); | 2127 *parsedLen = (grandfatheredLen > 0) ? grandfatheredLen : (int32_t)(pLast
GoodPosition - t->buf); |
| 2127 } | 2128 } |
| 2128 | 2129 |
| 2129 return t; | 2130 return t; |
| 2130 | 2131 |
| 2131 error: | 2132 error: |
| 2132 uprv_free(t); | 2133 ultag_close(t); |
| 2133 return NULL; | 2134 return NULL; |
| 2134 } | 2135 } |
| 2135 | 2136 |
| 2136 static void | 2137 static void |
| 2137 ultag_close(ULanguageTag* langtag) { | 2138 ultag_close(ULanguageTag* langtag) { |
| 2138 | 2139 |
| 2139 if (langtag == NULL) { | 2140 if (langtag == NULL) { |
| 2140 return; | 2141 return; |
| 2141 } | 2142 } |
| 2142 | 2143 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 } | 2502 } |
| 2502 len = _appendKeywords(lt, localeID + reslen, localeIDCapacity - reslen,
status); | 2503 len = _appendKeywords(lt, localeID + reslen, localeIDCapacity - reslen,
status); |
| 2503 reslen += len; | 2504 reslen += len; |
| 2504 } | 2505 } |
| 2505 | 2506 |
| 2506 ultag_close(lt); | 2507 ultag_close(lt); |
| 2507 return u_terminateChars(localeID, localeIDCapacity, reslen, status); | 2508 return u_terminateChars(localeID, localeIDCapacity, reslen, status); |
| 2508 } | 2509 } |
| 2509 | 2510 |
| 2510 | 2511 |
| OLD | NEW |