OLD | NEW |
1 /* | 1 /* |
2 ********************************************************************** | 2 ********************************************************************** |
3 * Copyright (C) 1999-2011, International Business Machines | 3 * Copyright (C) 1999-2015, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ********************************************************************** | 5 ********************************************************************** |
6 * Date Name Description | 6 * Date Name Description |
7 * 11/17/99 aliu Creation. | 7 * 11/17/99 aliu Creation. |
8 ********************************************************************** | 8 ********************************************************************** |
9 */ | 9 */ |
10 | 10 |
11 #include "unicode/utypes.h" | 11 #include "unicode/utypes.h" |
12 | 12 |
13 #if !UCONFIG_NO_TRANSLITERATION | 13 #if !UCONFIG_NO_TRANSLITERATION |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 // NULL pointer check | 1095 // NULL pointer check |
1096 if (data->variables == NULL) { | 1096 if (data->variables == NULL) { |
1097 status = U_MEMORY_ALLOCATION_ERROR; | 1097 status = U_MEMORY_ALLOCATION_ERROR; |
1098 return; | 1098 return; |
1099 } | 1099 } |
1100 data->variablesAreOwned = (i == 0); | 1100 data->variablesAreOwned = (i == 0); |
1101 } | 1101 } |
1102 | 1102 |
1103 for (int32_t j = 0; j < data->variablesLength; j++) { | 1103 for (int32_t j = 0; j < data->variablesLength; j++) { |
1104 data->variables[j] = | 1104 data->variables[j] = |
1105 ((UnicodeFunctor*)variablesVector.elementAt(j)); | 1105 ((UnicodeSet*)variablesVector.elementAt(j)); |
1106 } | 1106 } |
1107 | 1107 |
1108 data->variableNames.removeAll(); | 1108 data->variableNames.removeAll(); |
1109 int32_t pos = -1; | 1109 int32_t pos = UHASH_FIRST; |
1110 const UHashElement* he = variableNames.nextElement(pos); | 1110 const UHashElement* he = variableNames.nextElement(pos); |
1111 while (he != NULL) { | 1111 while (he != NULL) { |
1112 UnicodeString* tempus = (UnicodeString*)(((UnicodeString*)(he->v
alue.pointer))->clone()); | 1112 UnicodeString* tempus = (UnicodeString*)(((UnicodeString*)(he->v
alue.pointer))->clone()); |
1113 if (tempus == NULL) { | 1113 if (tempus == NULL) { |
1114 status = U_MEMORY_ALLOCATION_ERROR; | 1114 status = U_MEMORY_ALLOCATION_ERROR; |
1115 return; | 1115 return; |
1116 } | 1116 } |
1117 data->variableNames.put(*((UnicodeString*)(he->key.pointer)), | 1117 data->variableNames.put(*((UnicodeString*)(he->key.pointer)), |
1118 tempus, status); | 1118 tempus, status); |
1119 he = variableNames.nextElement(pos); | 1119 he = variableNames.nextElement(pos); |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 if(c == QUOTE) { | 1667 if(c == QUOTE) { |
1668 quoted = (UBool)!quoted; | 1668 quoted = (UBool)!quoted; |
1669 } | 1669 } |
1670 else if (!quoted) { | 1670 else if (!quoted) { |
1671 if (c == RULE_COMMENT_CHAR) { | 1671 if (c == RULE_COMMENT_CHAR) { |
1672 /* skip comments and all preceding spaces */ | 1672 /* skip comments and all preceding spaces */ |
1673 while (targetStart < target && *(target - 1) == 0x0020) { | 1673 while (targetStart < target && *(target - 1) == 0x0020) { |
1674 target--; | 1674 target--; |
1675 } | 1675 } |
1676 do { | 1676 do { |
| 1677 if (source == sourceLimit) { |
| 1678 c = U_SENTINEL; |
| 1679 break; |
| 1680 } |
1677 c = *(source++); | 1681 c = *(source++); |
1678 } | 1682 } |
1679 while (c != CR && c != LF); | 1683 while (c != CR && c != LF); |
| 1684 if (c < 0) { |
| 1685 break; |
| 1686 } |
1680 } | 1687 } |
1681 else if (c == ESCAPE) { | 1688 else if (c == ESCAPE && source < sourceLimit) { |
1682 UChar32 c2 = *source; | 1689 UChar32 c2 = *source; |
1683 if (c2 == CR || c2 == LF) { | 1690 if (c2 == CR || c2 == LF) { |
1684 /* A backslash at the end of a line. */ | 1691 /* A backslash at the end of a line. */ |
1685 /* Since we're stripping lines, ignore the backslash. */ | 1692 /* Since we're stripping lines, ignore the backslash. */ |
1686 source++; | 1693 source++; |
1687 continue; | 1694 continue; |
1688 } | 1695 } |
1689 if (c2 == 0x0075 && source+5 < sourceLimit) { /* \u seen. \U isn
't unescaped. */ | 1696 if (c2 == 0x0075 && source+5 < sourceLimit) { /* \u seen. \U isn
't unescaped. */ |
1690 int32_t escapeOffset = 0; | 1697 int32_t escapeOffset = 0; |
1691 UnicodeString escapedStr(source, 5); | 1698 UnicodeString escapedStr(source, 5); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 U16_APPEND_UNSAFE(target, index, c); | 1736 U16_APPEND_UNSAFE(target, index, c); |
1730 target+=index; | 1737 target+=index; |
1731 } | 1738 } |
1732 if (target < targetLimit) { | 1739 if (target < targetLimit) { |
1733 *target = 0; | 1740 *target = 0; |
1734 } | 1741 } |
1735 return (int32_t)(target-targetStart); | 1742 return (int32_t)(target-targetStart); |
1736 } | 1743 } |
1737 | 1744 |
1738 #endif /* #if !UCONFIG_NO_TRANSLITERATION */ | 1745 #endif /* #if !UCONFIG_NO_TRANSLITERATION */ |
OLD | NEW |