@@ -192,7 +192,7 @@ RuleBasedBreakIterator::~RuleBasedBreakIterator() {
192
192
}
193
193
fCharIter = NULL ;
194
194
195
- utext_close (fText );
195
+ utext_close (& fText );
196
196
197
197
if (fData != NULL ) {
198
198
fData ->removeReference ();
@@ -229,12 +229,12 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
229
229
}
230
230
// TODO: clone fLanguageBreakEngines from "that"
231
231
UErrorCode status = U_ZERO_ERROR;
232
- fText = utext_clone (fText , that.fText , FALSE , TRUE , &status);
232
+ utext_clone (& fText , & that.fText , FALSE , TRUE , &status);
233
233
234
234
if (fCharIter != &fSCharIter ) {
235
235
delete fCharIter ;
236
236
}
237
- fCharIter = NULL ;
237
+ fCharIter = & fSCharIter ;
238
238
239
239
if (that.fCharIter != NULL && that.fCharIter != &that.fSCharIter ) {
240
240
// This is a little bit tricky - it will intially appear that
@@ -278,7 +278,7 @@ RuleBasedBreakIterator::operator=(const RuleBasedBreakIterator& that) {
278
278
//
279
279
// -----------------------------------------------------------------------------
280
280
void RuleBasedBreakIterator::init (UErrorCode &status) {
281
- fText = NULL ;
281
+ fText = UTEXT_INITIALIZER ;
282
282
fCharIter = NULL ;
283
283
fData = NULL ;
284
284
fPosition = 0 ;
@@ -299,10 +299,10 @@ void RuleBasedBreakIterator::init(UErrorCode &status) {
299
299
return ;
300
300
}
301
301
302
- fText = utext_openUChars (NULL , NULL , 0 , &status);
302
+ utext_openUChars (& fText , NULL , 0 , &status);
303
303
fDictionaryCache = new DictionaryCache (this , status);
304
304
fBreakCache = new BreakCache (this , status);
305
- if (U_SUCCESS (status) && (fText == NULL || fDictionaryCache == NULL || fBreakCache == NULL )) {
305
+ if (U_SUCCESS (status) && (fDictionaryCache == NULL || fBreakCache == NULL )) {
306
306
status = U_MEMORY_ALLOCATION_ERROR;
307
307
}
308
308
@@ -351,7 +351,7 @@ RuleBasedBreakIterator::operator==(const BreakIterator& that) const {
351
351
352
352
const RuleBasedBreakIterator& that2 = (const RuleBasedBreakIterator&) that;
353
353
354
- if (!utext_equals (fText , that2.fText )) {
354
+ if (!utext_equals (& fText , & that2.fText )) {
355
355
// The two break iterators are operating on different text,
356
356
// or have a different iteration position.
357
357
// Note that fText's position is always the same as the break iterator's position.
@@ -392,7 +392,7 @@ void RuleBasedBreakIterator::setText(UText *ut, UErrorCode &status) {
392
392
}
393
393
fBreakCache ->reset ();
394
394
fDictionaryCache ->reset ();
395
- fText = utext_clone (fText , ut, FALSE , TRUE , &status);
395
+ utext_clone (& fText , ut, FALSE , TRUE , &status);
396
396
397
397
// Set up a dummy CharacterIterator to be returned if anyone
398
398
// calls getText(). With input from UText, there is no reasonable
@@ -413,7 +413,7 @@ void RuleBasedBreakIterator::setText(UText *ut, UErrorCode &status) {
413
413
414
414
415
415
UText *RuleBasedBreakIterator::getUText (UText *fillIn, UErrorCode &status) const {
416
- UText *result = utext_clone (fillIn, fText , FALSE , TRUE , &status);
416
+ UText *result = utext_clone (fillIn, & fText , FALSE , TRUE , &status);
417
417
return result;
418
418
}
419
419
@@ -450,9 +450,9 @@ RuleBasedBreakIterator::adoptText(CharacterIterator* newText) {
450
450
if (newText==NULL || newText->startIndex () != 0 ) {
451
451
// startIndex !=0 wants to be an error, but there's no way to report it.
452
452
// Make the iterator text be an empty string.
453
- fText = utext_openUChars (fText , NULL , 0 , &status);
453
+ utext_openUChars (& fText , NULL , 0 , &status);
454
454
} else {
455
- fText = utext_openCharacterIterator (fText , newText, &status);
455
+ utext_openCharacterIterator (& fText , newText, &status);
456
456
}
457
457
this ->first ();
458
458
}
@@ -467,7 +467,7 @@ RuleBasedBreakIterator::setText(const UnicodeString& newText) {
467
467
UErrorCode status = U_ZERO_ERROR;
468
468
fBreakCache ->reset ();
469
469
fDictionaryCache ->reset ();
470
- fText = utext_openConstUnicodeString (fText , &newText, &status);
470
+ utext_openConstUnicodeString (& fText , &newText, &status);
471
471
472
472
// Set up a character iterator on the string.
473
473
// Needed in case someone calls getText().
@@ -499,14 +499,14 @@ RuleBasedBreakIterator &RuleBasedBreakIterator::refreshInputText(UText *input, U
499
499
status = U_ILLEGAL_ARGUMENT_ERROR;
500
500
return *this ;
501
501
}
502
- int64_t pos = utext_getNativeIndex (fText );
502
+ int64_t pos = utext_getNativeIndex (& fText );
503
503
// Shallow read-only clone of the new UText into the existing input UText
504
- fText = utext_clone (fText , input, FALSE , TRUE , &status);
504
+ utext_clone (& fText , input, FALSE , TRUE , &status);
505
505
if (U_FAILURE (status)) {
506
506
return *this ;
507
507
}
508
- utext_setNativeIndex (fText , pos);
509
- if (utext_getNativeIndex (fText ) != pos) {
508
+ utext_setNativeIndex (& fText , pos);
509
+ if (utext_getNativeIndex (& fText ) != pos) {
510
510
// Sanity check. The new input utext is supposed to have the exact same
511
511
// contents as the old. If we can't set to the same position, it doesn't.
512
512
// The contents underlying the old utext might be invalid at this point,
@@ -536,7 +536,7 @@ int32_t RuleBasedBreakIterator::first(void) {
536
536
* @return The text's past-the-end offset.
537
537
*/
538
538
int32_t RuleBasedBreakIterator::last (void ) {
539
- int32_t endPos = (int32_t )utext_nativeLength (fText );
539
+ int32_t endPos = (int32_t )utext_nativeLength (& fText );
540
540
UBool endShouldBeBoundary = isBoundary (endPos); // Has side effect of setting iterator position.
541
541
(void )endShouldBeBoundary;
542
542
U_ASSERT (endShouldBeBoundary);
@@ -607,8 +607,8 @@ int32_t RuleBasedBreakIterator::following(int32_t startPos) {
607
607
608
608
// Move requested offset to a code point start. It might be on a trail surrogate,
609
609
// or on a trail byte if the input is UTF-8. Or it may be beyond the end of the text.
610
- utext_setNativeIndex (fText , startPos);
611
- startPos = (int32_t )utext_getNativeIndex (fText );
610
+ utext_setNativeIndex (& fText , startPos);
611
+ startPos = (int32_t )utext_getNativeIndex (& fText );
612
612
613
613
UErrorCode status = U_ZERO_ERROR;
614
614
fBreakCache ->following (startPos, status);
@@ -622,15 +622,15 @@ int32_t RuleBasedBreakIterator::following(int32_t startPos) {
622
622
* @return The position of the last boundary before the starting position.
623
623
*/
624
624
int32_t RuleBasedBreakIterator::preceding (int32_t offset) {
625
- if (fText == NULL || offset > utext_nativeLength (fText )) {
625
+ if (offset > utext_nativeLength (& fText )) {
626
626
return last ();
627
627
}
628
628
629
629
// Move requested offset to a code point start. It might be on a trail surrogate,
630
630
// or on a trail byte if the input is UTF-8.
631
631
632
- utext_setNativeIndex (fText , offset);
633
- int32_t adjustedOffset = utext_getNativeIndex (fText );
632
+ utext_setNativeIndex (& fText , offset);
633
+ int32_t adjustedOffset = utext_getNativeIndex (& fText );
634
634
635
635
UErrorCode status = U_ZERO_ERROR;
636
636
fBreakCache ->preceding (adjustedOffset, status);
@@ -656,16 +656,16 @@ UBool RuleBasedBreakIterator::isBoundary(int32_t offset) {
656
656
// Note that isBoundary() is always be false for offsets that are not on code point boundaries.
657
657
// But we still need the side effect of leaving iteration at the following boundary.
658
658
659
- utext_setNativeIndex (fText , offset);
660
- int32_t adjustedOffset = utext_getNativeIndex (fText );
659
+ utext_setNativeIndex (& fText , offset);
660
+ int32_t adjustedOffset = utext_getNativeIndex (& fText );
661
661
662
662
bool result = false ;
663
663
UErrorCode status = U_ZERO_ERROR;
664
664
if (fBreakCache ->seek (adjustedOffset) || fBreakCache ->populateNear (adjustedOffset, status)) {
665
665
result = (fBreakCache ->current () == offset);
666
666
}
667
667
668
- if (result && adjustedOffset < offset && utext_char32At (fText , offset) == U_SENTINEL) {
668
+ if (result && adjustedOffset < offset && utext_char32At (& fText , offset) == U_SENTINEL) {
669
669
// Original offset is beyond the end of the text. Return FALSE, it's not a boundary,
670
670
// but the iteration position remains set to the end of the text, which is a boundary.
671
671
return FALSE ;
@@ -785,9 +785,9 @@ int32_t RuleBasedBreakIterator::handleNext() {
785
785
786
786
// if we're already at the end of the text, return DONE.
787
787
initialPosition = fPosition ;
788
- UTEXT_SETNATIVEINDEX (fText , initialPosition);
788
+ UTEXT_SETNATIVEINDEX (& fText , initialPosition);
789
789
result = initialPosition;
790
- c = UTEXT_NEXT32 (fText );
790
+ c = UTEXT_NEXT32 (& fText );
791
791
if (c==U_SENTINEL) {
792
792
fDone = TRUE ;
793
793
return UBRK_DONE;
@@ -850,7 +850,7 @@ int32_t RuleBasedBreakIterator::handleNext() {
850
850
851
851
#ifdef RBBI_DEBUG
852
852
if (gTrace ) {
853
- RBBIDebugPrintf (" %4ld " , utext_getNativeIndex (fText ));
853
+ RBBIDebugPrintf (" %4ld " , utext_getNativeIndex (& fText ));
854
854
if (0x20 <=c && c<0x7f ) {
855
855
RBBIDebugPrintf (" \" %c\" " , c);
856
856
} else {
@@ -874,7 +874,7 @@ int32_t RuleBasedBreakIterator::handleNext() {
874
874
if (row->fAccepting == -1 ) {
875
875
// Match found, common case.
876
876
if (mode != RBBI_START) {
877
- result = (int32_t )UTEXT_GETNATIVEINDEX (fText );
877
+ result = (int32_t )UTEXT_GETNATIVEINDEX (& fText );
878
878
}
879
879
fRuleStatusIndex = row->fTagIdx ; // Remember the break status (tag) values.
880
880
}
@@ -892,7 +892,7 @@ int32_t RuleBasedBreakIterator::handleNext() {
892
892
int16_t rule = row->fLookAhead ;
893
893
if (rule != 0 ) {
894
894
// At the position of a '/' in a look-ahead match. Record it.
895
- int32_t pos = (int32_t )UTEXT_GETNATIVEINDEX (fText );
895
+ int32_t pos = (int32_t )UTEXT_GETNATIVEINDEX (& fText );
896
896
lookAheadMatches.setPosition (rule, pos);
897
897
}
898
898
@@ -908,7 +908,7 @@ int32_t RuleBasedBreakIterator::handleNext() {
908
908
// the input position. The next iteration will be processing the
909
909
// first real input character.
910
910
if (mode == RBBI_RUN) {
911
- c = UTEXT_NEXT32 (fText );
911
+ c = UTEXT_NEXT32 (& fText );
912
912
} else {
913
913
if (mode == RBBI_START) {
914
914
mode = RBBI_RUN;
@@ -922,9 +922,9 @@ int32_t RuleBasedBreakIterator::handleNext() {
922
922
// (This really indicates a defect in the break rules. They should always match
923
923
// at least one character.)
924
924
if (result == initialPosition) {
925
- utext_setNativeIndex (fText , initialPosition);
926
- utext_next32 (fText );
927
- result = (int32_t )utext_getNativeIndex (fText );
925
+ utext_setNativeIndex (& fText , initialPosition);
926
+ utext_next32 (& fText );
927
+ result = (int32_t )utext_getNativeIndex (& fText );
928
928
fRuleStatusIndex = 0 ;
929
929
}
930
930
@@ -959,22 +959,22 @@ int32_t RuleBasedBreakIterator::handlePrevious(int32_t fromPosition) {
959
959
int32_t initialPosition = 0 ;
960
960
961
961
const RBBIStateTable *stateTable = fData ->fSafeRevTable ;
962
- UTEXT_SETNATIVEINDEX (fText , fromPosition);
962
+ UTEXT_SETNATIVEINDEX (& fText , fromPosition);
963
963
#ifdef RBBI_DEBUG
964
964
if (gTrace ) {
965
965
RBBIDebugPuts (" Handle Previous pos char state category" );
966
966
}
967
967
#endif
968
968
969
969
// if we're already at the start of the text, return DONE.
970
- if (fText == NULL || fData == NULL || UTEXT_GETNATIVEINDEX (fText )==0 ) {
970
+ if (fData == NULL || UTEXT_GETNATIVEINDEX (& fText )==0 ) {
971
971
return BreakIterator::DONE;
972
972
}
973
973
974
974
// Set up the starting char.
975
- initialPosition = (int32_t )UTEXT_GETNATIVEINDEX (fText );
975
+ initialPosition = (int32_t )UTEXT_GETNATIVEINDEX (& fText );
976
976
result = initialPosition;
977
- c = UTEXT_PREVIOUS32 (fText );
977
+ c = UTEXT_PREVIOUS32 (& fText );
978
978
979
979
// Set the initial state for the state machine
980
980
state = START_STATE;
@@ -1022,7 +1022,7 @@ int32_t RuleBasedBreakIterator::handlePrevious(int32_t fromPosition) {
1022
1022
1023
1023
#ifdef RBBI_DEBUG
1024
1024
if (gTrace ) {
1025
- RBBIDebugPrintf (" %4d " , (int32_t )utext_getNativeIndex (fText ));
1025
+ RBBIDebugPrintf (" %4d " , (int32_t )utext_getNativeIndex (& fText ));
1026
1026
if (0x20 <=c && c<0x7f ) {
1027
1027
RBBIDebugPrintf (" \" %c\" " , c);
1028
1028
} else {
@@ -1043,22 +1043,22 @@ int32_t RuleBasedBreakIterator::handlePrevious(int32_t fromPosition) {
1043
1043
1044
1044
if (row->fAccepting == -1 ) {
1045
1045
// Match found, common case.
1046
- result = (int32_t )UTEXT_GETNATIVEINDEX (fText );
1046
+ result = (int32_t )UTEXT_GETNATIVEINDEX (& fText );
1047
1047
}
1048
1048
1049
1049
int16_t completedRule = row->fAccepting ;
1050
1050
if (completedRule > 0 ) {
1051
1051
// Lookahead match is completed.
1052
1052
int32_t lookaheadResult = lookAheadMatches.getPosition (completedRule);
1053
1053
if (lookaheadResult >= 0 ) {
1054
- UTEXT_SETNATIVEINDEX (fText , lookaheadResult);
1054
+ UTEXT_SETNATIVEINDEX (& fText , lookaheadResult);
1055
1055
return lookaheadResult;
1056
1056
}
1057
1057
}
1058
1058
int16_t rule = row->fLookAhead ;
1059
1059
if (rule != 0 ) {
1060
1060
// At the position of a '/' in a look-ahead match. Record it.
1061
- int32_t pos = (int32_t )UTEXT_GETNATIVEINDEX (fText );
1061
+ int32_t pos = (int32_t )UTEXT_GETNATIVEINDEX (& fText );
1062
1062
lookAheadMatches.setPosition (rule, pos);
1063
1063
}
1064
1064
@@ -1074,7 +1074,7 @@ int32_t RuleBasedBreakIterator::handlePrevious(int32_t fromPosition) {
1074
1074
// the input position. The next iteration will be processing the
1075
1075
// first real input character.
1076
1076
if (mode == RBBI_RUN) {
1077
- c = UTEXT_PREVIOUS32 (fText );
1077
+ c = UTEXT_PREVIOUS32 (& fText );
1078
1078
} else {
1079
1079
if (mode == RBBI_START) {
1080
1080
mode = RBBI_RUN;
@@ -1088,9 +1088,9 @@ int32_t RuleBasedBreakIterator::handlePrevious(int32_t fromPosition) {
1088
1088
// (This really indicates a defect in the break rules. They should always match
1089
1089
// at least one character.)
1090
1090
if (result == initialPosition) {
1091
- UTEXT_SETNATIVEINDEX (fText , initialPosition);
1092
- UTEXT_PREVIOUS32 (fText );
1093
- result = (int32_t )UTEXT_GETNATIVEINDEX (fText );
1091
+ UTEXT_SETNATIVEINDEX (& fText , initialPosition);
1092
+ UTEXT_PREVIOUS32 (& fText );
1093
+ result = (int32_t )UTEXT_GETNATIVEINDEX (& fText );
1094
1094
}
1095
1095
1096
1096
#ifdef RBBI_DEBUG
0 commit comments