OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * | 3 * |
4 * Copyright (C) 2005-2014, International Business Machines | 4 * Copyright (C) 2005-2015, International Business Machines |
5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
6 * | 6 * |
7 ******************************************************************************* | 7 ******************************************************************************* |
8 * file name: utext.cpp | 8 * file name: utext.cpp |
9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
11 * indentation:4 | 11 * indentation:4 |
12 * | 12 * |
13 * created on: 2005apr12 | 13 * created on: 2005apr12 |
14 * created by: Markus W. Scherer | 14 * created by: Markus W. Scherer |
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 utext_openReplaceable(UText *ut, Replaceable *rep, UErrorCode *status) | 2021 utext_openReplaceable(UText *ut, Replaceable *rep, UErrorCode *status) |
2022 { | 2022 { |
2023 if(U_FAILURE(*status)) { | 2023 if(U_FAILURE(*status)) { |
2024 return NULL; | 2024 return NULL; |
2025 } | 2025 } |
2026 if(rep==NULL) { | 2026 if(rep==NULL) { |
2027 *status=U_ILLEGAL_ARGUMENT_ERROR; | 2027 *status=U_ILLEGAL_ARGUMENT_ERROR; |
2028 return NULL; | 2028 return NULL; |
2029 } | 2029 } |
2030 ut = utext_setup(ut, sizeof(ReplExtra), status); | 2030 ut = utext_setup(ut, sizeof(ReplExtra), status); |
| 2031 if(U_FAILURE(*status)) { |
| 2032 return ut; |
| 2033 } |
2031 | 2034 |
2032 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_WRITABLE); | 2035 ut->providerProperties = I32_FLAG(UTEXT_PROVIDER_WRITABLE); |
2033 if(rep->hasMetaData()) { | 2036 if(rep->hasMetaData()) { |
2034 ut->providerProperties |=I32_FLAG(UTEXT_PROVIDER_HAS_META_DATA); | 2037 ut->providerProperties |=I32_FLAG(UTEXT_PROVIDER_HAS_META_DATA); |
2035 } | 2038 } |
2036 | 2039 |
2037 ut->pFuncs = &repFuncs; | 2040 ut->pFuncs = &repFuncs; |
2038 ut->context = rep; | 2041 ut->context = rep; |
2039 return ut; | 2042 return ut; |
2040 } | 2043 } |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2726 } | 2729 } |
2727 | 2730 |
2728 if (deep) { | 2731 if (deep) { |
2729 // There is no CharacterIterator API for cloning the underlying text sto
rage. | 2732 // There is no CharacterIterator API for cloning the underlying text sto
rage. |
2730 *status = U_UNSUPPORTED_ERROR; | 2733 *status = U_UNSUPPORTED_ERROR; |
2731 return NULL; | 2734 return NULL; |
2732 } else { | 2735 } else { |
2733 CharacterIterator *srcCI =(CharacterIterator *)src->context; | 2736 CharacterIterator *srcCI =(CharacterIterator *)src->context; |
2734 srcCI = srcCI->clone(); | 2737 srcCI = srcCI->clone(); |
2735 dest = utext_openCharacterIterator(dest, srcCI, status); | 2738 dest = utext_openCharacterIterator(dest, srcCI, status); |
| 2739 if (U_FAILURE(*status)) { |
| 2740 return dest; |
| 2741 } |
2736 // cast off const on getNativeIndex. | 2742 // cast off const on getNativeIndex. |
2737 // For CharacterIterator based UTexts, this is safe, the operation is
const. | 2743 // For CharacterIterator based UTexts, this is safe, the operation is
const. |
2738 int64_t ix = utext_getNativeIndex((UText *)src); | 2744 int64_t ix = utext_getNativeIndex((UText *)src); |
2739 utext_setNativeIndex(dest, ix); | 2745 utext_setNativeIndex(dest, ix); |
2740 dest->r = srcCI; // flags that this UText owns the CharacterIterator | 2746 dest->r = srcCI; // flags that this UText owns the CharacterIterator |
2741 } | 2747 } |
2742 return dest; | 2748 return dest; |
2743 } | 2749 } |
2744 | 2750 |
2745 static int32_t U_CALLCONV | 2751 static int32_t U_CALLCONV |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2839 // zero without Access() thinking that the chunk is valid. | 2845 // zero without Access() thinking that the chunk is valid. |
2840 ut->chunkContents = (UChar *)ut->p; | 2846 ut->chunkContents = (UChar *)ut->p; |
2841 ut->chunkNativeStart = -1; | 2847 ut->chunkNativeStart = -1; |
2842 ut->chunkOffset = 1; | 2848 ut->chunkOffset = 1; |
2843 ut->chunkNativeLimit = 0; | 2849 ut->chunkNativeLimit = 0; |
2844 ut->chunkLength = 0; | 2850 ut->chunkLength = 0; |
2845 ut->nativeIndexingLimit = ut->chunkOffset; // enables native indexing | 2851 ut->nativeIndexingLimit = ut->chunkOffset; // enables native indexing |
2846 } | 2852 } |
2847 return ut; | 2853 return ut; |
2848 } | 2854 } |
OLD | NEW |