| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * | 3 * |
| 4 * Copyright (C) 2009-2010, International Business Machines | 4 * Copyright (C) 2009-2010, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 ******************************************************************************* | 7 ******************************************************************************* |
| 8 * file name: normalizer2.cpp | 8 * file name: normalizer2.cpp |
| 9 * encoding: US-ASCII | 9 * encoding: US-ASCII |
| 10 * tab size: 8 (not used) | 10 * tab size: 8 (not used) |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 (dest==NULL ? capacity!=0 : capacity<0) || | 653 (dest==NULL ? capacity!=0 : capacity<0) || |
| 654 (src==dest && src!=NULL) | 654 (src==dest && src!=NULL) |
| 655 ) { | 655 ) { |
| 656 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; | 656 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; |
| 657 return 0; | 657 return 0; |
| 658 } | 658 } |
| 659 UnicodeString destString(dest, 0, capacity); | 659 UnicodeString destString(dest, 0, capacity); |
| 660 // length==0: Nothing to do, and n2wi->normalize(NULL, NULL, buffer, ...) wo
uld crash. | 660 // length==0: Nothing to do, and n2wi->normalize(NULL, NULL, buffer, ...) wo
uld crash. |
| 661 if(length!=0) { | 661 if(length!=0) { |
| 662 const Normalizer2 *n2=(const Normalizer2 *)norm2; | 662 const Normalizer2 *n2=(const Normalizer2 *)norm2; |
| 663 const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *
>(n2); | 663 const Normalizer2WithImpl *n2wi=CR_DYNAMIC_CAST<const Normalizer2WithImp
l *>(n2); |
| 664 if(n2wi!=NULL) { | 664 if(n2wi!=NULL) { |
| 665 // Avoid duplicate argument checking and support NUL-terminated src. | 665 // Avoid duplicate argument checking and support NUL-terminated src. |
| 666 ReorderingBuffer buffer(n2wi->impl, destString); | 666 ReorderingBuffer buffer(n2wi->impl, destString); |
| 667 if(buffer.init(length, *pErrorCode)) { | 667 if(buffer.init(length, *pErrorCode)) { |
| 668 n2wi->normalize(src, length>=0 ? src+length : NULL, buffer, *pEr
rorCode); | 668 n2wi->normalize(src, length>=0 ? src+length : NULL, buffer, *pEr
rorCode); |
| 669 } | 669 } |
| 670 } else { | 670 } else { |
| 671 UnicodeString srcString(length<0, src, length); | 671 UnicodeString srcString(length<0, src, length); |
| 672 n2->normalize(srcString, destString, *pErrorCode); | 672 n2->normalize(srcString, destString, *pErrorCode); |
| 673 } | 673 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 689 (firstCapacity<0 || firstLength<-1)) || | 689 (firstCapacity<0 || firstLength<-1)) || |
| 690 (first==second && first!=NULL) | 690 (first==second && first!=NULL) |
| 691 ) { | 691 ) { |
| 692 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; | 692 *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; |
| 693 return 0; | 693 return 0; |
| 694 } | 694 } |
| 695 UnicodeString firstString(first, firstLength, firstCapacity); | 695 UnicodeString firstString(first, firstLength, firstCapacity); |
| 696 // secondLength==0: Nothing to do, and n2wi->normalizeAndAppend(NULL, NULL,
buffer, ...) would crash. | 696 // secondLength==0: Nothing to do, and n2wi->normalizeAndAppend(NULL, NULL,
buffer, ...) would crash. |
| 697 if(secondLength!=0) { | 697 if(secondLength!=0) { |
| 698 const Normalizer2 *n2=(const Normalizer2 *)norm2; | 698 const Normalizer2 *n2=(const Normalizer2 *)norm2; |
| 699 const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *
>(n2); | 699 const Normalizer2WithImpl *n2wi=CR_DYNAMIC_CAST<const Normalizer2WithImp
l *>(n2); |
| 700 if(n2wi!=NULL) { | 700 if(n2wi!=NULL) { |
| 701 // Avoid duplicate argument checking and support NUL-terminated src. | 701 // Avoid duplicate argument checking and support NUL-terminated src. |
| 702 ReorderingBuffer buffer(n2wi->impl, firstString); | 702 ReorderingBuffer buffer(n2wi->impl, firstString); |
| 703 if(buffer.init(firstLength+secondLength+1, *pErrorCode)) { // destC
apacity>=-1 | 703 if(buffer.init(firstLength+secondLength+1, *pErrorCode)) { // destC
apacity>=-1 |
| 704 n2wi->normalizeAndAppend(second, secondLength>=0 ? second+second
Length : NULL, | 704 n2wi->normalizeAndAppend(second, secondLength>=0 ? second+second
Length : NULL, |
| 705 doNormalize, buffer, *pErrorCode); | 705 doNormalize, buffer, *pErrorCode); |
| 706 } | 706 } |
| 707 } else { | 707 } else { |
| 708 UnicodeString secondString(secondLength<0, second, secondLength); | 708 UnicodeString secondString(secondLength<0, second, secondLength); |
| 709 if(doNormalize) { | 709 if(doNormalize) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 const UTrie2 *trie=Normalizer2Factory::getFCDTrie(*pErrorCode); | 838 const UTrie2 *trie=Normalizer2Factory::getFCDTrie(*pErrorCode); |
| 839 if(U_SUCCESS(*pErrorCode)) { | 839 if(U_SUCCESS(*pErrorCode)) { |
| 840 fcdHighStart=trie->highStart; | 840 fcdHighStart=trie->highStart; |
| 841 return trie->index; | 841 return trie->index; |
| 842 } else { | 842 } else { |
| 843 return NULL; | 843 return NULL; |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 | 846 |
| 847 #endif // !UCONFIG_NO_NORMALIZATION | 847 #endif // !UCONFIG_NO_NORMALIZATION |
| OLD | NEW |