| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 2004-2013, International Business Machines | 3 * Copyright (C) 2004-2014, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 * file name: uregex.cpp | 6 * file name: uregex.cpp |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "unicode/utypes.h" | 9 #include "unicode/utypes.h" |
| 10 | 10 |
| 11 #if !UCONFIG_NO_REGULAR_EXPRESSIONS | 11 #if !UCONFIG_NO_REGULAR_EXPRESSIONS |
| 12 | 12 |
| 13 #include "unicode/regex.h" | 13 #include "unicode/regex.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 // | 138 // |
| 139 // Make a copy of the pattern string, so we can return it later if asked. | 139 // Make a copy of the pattern string, so we can return it later if asked. |
| 140 // For compiling the pattern, we will use a UText wrapper around | 140 // For compiling the pattern, we will use a UText wrapper around |
| 141 // this local copy, to avoid making even more copies. | 141 // this local copy, to avoid making even more copies. |
| 142 // | 142 // |
| 143 re->fPatString = patBuf; | 143 re->fPatString = patBuf; |
| 144 re->fPatStringLen = patternLength; | 144 re->fPatStringLen = patternLength; |
| 145 u_memcpy(patBuf, pattern, actualPatLen); | 145 u_memcpy(patBuf, pattern, actualPatLen); |
| 146 patBuf[actualPatLen] = 0; | 146 patBuf[actualPatLen] = 0; |
| 147 | 147 |
| 148 UText patText = UTEXT_INITIALIZER; | 148 UText patText = UTEXT_INITIALIZER; |
| 149 utext_openUChars(&patText, patBuf, patternLength, status); | 149 utext_openUChars(&patText, patBuf, patternLength, status); |
| 150 | 150 |
| 151 // | 151 // |
| 152 // Compile the pattern | 152 // Compile the pattern |
| 153 // | 153 // |
| 154 if (pe != NULL) { | 154 if (pe != NULL) { |
| 155 re->fPat = RegexPattern::compile(&patText, flags, *pe, *status); | 155 re->fPat = RegexPattern::compile(&patText, flags, *pe, *status); |
| 156 } else { | 156 } else { |
| 157 re->fPat = RegexPattern::compile(&patText, flags, *status); | 157 re->fPat = RegexPattern::compile(&patText, flags, *status); |
| 158 } | 158 } |
| 159 utext_close(&patText); | 159 utext_close(&patText); |
| 160 | 160 |
| 161 if (U_FAILURE(*status)) { | 161 if (U_FAILURE(*status)) { |
| 162 goto ErrorExit; | 162 goto ErrorExit; |
| 163 } | 163 } |
| 164 | 164 |
| 165 // | 165 // |
| 166 // Create the matcher object | 166 // Create the matcher object |
| 167 // | 167 // |
| 168 re->fMatcher = re->fPat->matcher(*status); | 168 re->fMatcher = re->fPat->matcher(*status); |
| 169 if (U_SUCCESS(*status)) { | 169 if (U_SUCCESS(*status)) { |
| 170 return (URegularExpression*)re; | 170 return (URegularExpression*)re; |
| 171 } | 171 } |
| 172 | 172 |
| 173 ErrorExit: | 173 ErrorExit: |
| 174 delete re; | 174 delete re; |
| 175 return NULL; | 175 return NULL; |
| 176 | 176 |
| 177 } | 177 } |
| 178 | 178 |
| 179 //------------------------------------------------------------------------------
---------- | 179 //------------------------------------------------------------------------------
---------- |
| 180 // | 180 // |
| 181 // uregex_openUText | 181 // uregex_openUText |
| 182 // | 182 // |
| 183 //------------------------------------------------------------------------------
---------- | 183 //------------------------------------------------------------------------------
---------- |
| 184 U_CAPI URegularExpression * U_EXPORT2 | 184 U_CAPI URegularExpression * U_EXPORT2 |
| 185 uregex_openUText(UText *pattern, | 185 uregex_openUText(UText *pattern, |
| 186 uint32_t flags, | 186 uint32_t flags, |
| 187 UParseError *pe, | 187 UParseError *pe, |
| 188 UErrorCode *status) { | 188 UErrorCode *status) { |
| 189 | 189 |
| 190 if (U_FAILURE(*status)) { | 190 if (U_FAILURE(*status)) { |
| 191 return NULL; | 191 return NULL; |
| 192 } | 192 } |
| 193 if (pattern == NULL) { | 193 if (pattern == NULL) { |
| 194 *status = U_ILLEGAL_ARGUMENT_ERROR; | 194 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 195 return NULL; | 195 return NULL; |
| 196 } | 196 } |
| 197 | 197 |
| 198 int64_t patternNativeLength = utext_nativeLength(pattern); | 198 int64_t patternNativeLength = utext_nativeLength(pattern); |
| 199 | 199 |
| 200 if (patternNativeLength == 0) { | 200 if (patternNativeLength == 0) { |
| 201 *status = U_ILLEGAL_ARGUMENT_ERROR; | 201 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 202 return NULL; | 202 return NULL; |
| 203 } | 203 } |
| 204 | 204 |
| 205 RegularExpression *re = new RegularExpression; | 205 RegularExpression *re = new RegularExpression; |
| 206 | 206 |
| 207 UErrorCode lengthStatus = U_ZERO_ERROR; | 207 UErrorCode lengthStatus = U_ZERO_ERROR; |
| 208 int32_t pattern16Length = utext_extract(pattern, 0, patternNativeLength, NUL
L, 0, &lengthStatus); | 208 int32_t pattern16Length = utext_extract(pattern, 0, patternNativeLength, NUL
L, 0, &lengthStatus); |
| 209 | 209 |
| 210 u_atomic_int32_t *refC = (u_atomic_int32_t *)uprv_malloc(sizeof(int32_t)
); | 210 u_atomic_int32_t *refC = (u_atomic_int32_t *)uprv_malloc(sizeof(int32_t)
); |
| 211 UChar *patBuf = (UChar *)uprv_malloc(sizeof(UChar)*(pattern16Le
ngth+1)); | 211 UChar *patBuf = (UChar *)uprv_malloc(sizeof(UChar)*(pattern16Le
ngth+1)); |
| 212 if (re == NULL || refC == NULL || patBuf == NULL) { | 212 if (re == NULL || refC == NULL || patBuf == NULL) { |
| 213 *status = U_MEMORY_ALLOCATION_ERROR; | 213 *status = U_MEMORY_ALLOCATION_ERROR; |
| 214 delete re; | 214 delete re; |
| 215 uprv_free((void *)refC); | 215 uprv_free((void *)refC); |
| 216 uprv_free(patBuf); | 216 uprv_free(patBuf); |
| 217 return NULL; | 217 return NULL; |
| 218 } | 218 } |
| 219 re->fPatRefCount = refC; | 219 re->fPatRefCount = refC; |
| 220 *re->fPatRefCount = 1; | 220 *re->fPatRefCount = 1; |
| 221 | 221 |
| 222 // | 222 // |
| 223 // Make a copy of the pattern string, so we can return it later if asked. | 223 // Make a copy of the pattern string, so we can return it later if asked. |
| 224 // For compiling the pattern, we will use a read-only UText wrapper | 224 // For compiling the pattern, we will use a read-only UText wrapper |
| 225 // around this local copy, to avoid making even more copies. | 225 // around this local copy, to avoid making even more copies. |
| 226 // | 226 // |
| 227 re->fPatString = patBuf; | 227 re->fPatString = patBuf; |
| 228 re->fPatStringLen = pattern16Length; | 228 re->fPatStringLen = pattern16Length; |
| 229 utext_extract(pattern, 0, patternNativeLength, patBuf, pattern16Length+1, st
atus); | 229 utext_extract(pattern, 0, patternNativeLength, patBuf, pattern16Length+1, st
atus); |
| 230 | 230 |
| 231 UText patText = UTEXT_INITIALIZER; | 231 UText patText = UTEXT_INITIALIZER; |
| 232 utext_openUChars(&patText, patBuf, pattern16Length, status); | 232 utext_openUChars(&patText, patBuf, pattern16Length, status); |
| 233 | 233 |
| 234 // | 234 // |
| 235 // Compile the pattern | 235 // Compile the pattern |
| 236 // | 236 // |
| 237 if (pe != NULL) { | 237 if (pe != NULL) { |
| 238 re->fPat = RegexPattern::compile(&patText, flags, *pe, *status); | 238 re->fPat = RegexPattern::compile(&patText, flags, *pe, *status); |
| 239 } else { | 239 } else { |
| 240 re->fPat = RegexPattern::compile(&patText, flags, *status); | 240 re->fPat = RegexPattern::compile(&patText, flags, *status); |
| 241 } | 241 } |
| 242 utext_close(&patText); | 242 utext_close(&patText); |
| 243 | 243 |
| 244 if (U_FAILURE(*status)) { | 244 if (U_FAILURE(*status)) { |
| 245 goto ErrorExit; | 245 goto ErrorExit; |
| 246 } | 246 } |
| 247 | 247 |
| 248 // | 248 // |
| 249 // Create the matcher object | 249 // Create the matcher object |
| 250 // | 250 // |
| 251 re->fMatcher = re->fPat->matcher(*status); | 251 re->fMatcher = re->fPat->matcher(*status); |
| 252 if (U_SUCCESS(*status)) { | 252 if (U_SUCCESS(*status)) { |
| 253 return (URegularExpression*)re; | 253 return (URegularExpression*)re; |
| 254 } | 254 } |
| 255 | 255 |
| 256 ErrorExit: | 256 ErrorExit: |
| 257 delete re; | 257 delete re; |
| 258 return NULL; | 258 return NULL; |
| 259 | 259 |
| 260 } | 260 } |
| 261 | 261 |
| 262 //------------------------------------------------------------------------------
---------- | 262 //------------------------------------------------------------------------------
---------- |
| 263 // | 263 // |
| 264 // uregex_close | 264 // uregex_close |
| 265 // | 265 // |
| 266 //------------------------------------------------------------------------------
---------- | 266 //------------------------------------------------------------------------------
---------- |
| 267 U_CAPI void U_EXPORT2 | 267 U_CAPI void U_EXPORT2 |
| 268 uregex_close(URegularExpression *re2) { | 268 uregex_close(URegularExpression *re2) { |
| 269 RegularExpression *re = (RegularExpression*)re2; | 269 RegularExpression *re = (RegularExpression*)re2; |
| 270 UErrorCode status = U_ZERO_ERROR; | 270 UErrorCode status = U_ZERO_ERROR; |
| 271 if (validateRE(re, FALSE, &status) == FALSE) { | 271 if (validateRE(re, FALSE, &status) == FALSE) { |
| 272 return; | 272 return; |
| 273 } | 273 } |
| 274 delete re; | 274 delete re; |
| 275 } | 275 } |
| 276 | 276 |
| 277 | 277 |
| 278 //------------------------------------------------------------------------------
---------- | 278 //------------------------------------------------------------------------------
---------- |
| 279 // | 279 // |
| 280 // uregex_clone | 280 // uregex_clone |
| 281 // | 281 // |
| 282 //------------------------------------------------------------------------------
---------- | 282 //------------------------------------------------------------------------------
---------- |
| 283 U_CAPI URegularExpression * U_EXPORT2 | 283 U_CAPI URegularExpression * U_EXPORT2 |
| 284 uregex_clone(const URegularExpression *source2, UErrorCode *status) { | 284 uregex_clone(const URegularExpression *source2, UErrorCode *status) { |
| 285 RegularExpression *source = (RegularExpression*)source2; | 285 RegularExpression *source = (RegularExpression*)source2; |
| 286 if (validateRE(source, FALSE, status) == FALSE) { | 286 if (validateRE(source, FALSE, status) == FALSE) { |
| 287 return NULL; | 287 return NULL; |
| 288 } | 288 } |
| 289 | 289 |
| 290 RegularExpression *clone = new RegularExpression; | 290 RegularExpression *clone = new RegularExpression; |
| 291 if (clone == NULL) { | 291 if (clone == NULL) { |
| 292 *status = U_MEMORY_ALLOCATION_ERROR; | 292 *status = U_MEMORY_ALLOCATION_ERROR; |
| 293 return NULL; | 293 return NULL; |
| 294 } | 294 } |
| 295 | 295 |
| 296 clone->fMatcher = source->fPat->matcher(*status); | 296 clone->fMatcher = source->fPat->matcher(*status); |
| 297 if (U_FAILURE(*status)) { | 297 if (U_FAILURE(*status)) { |
| 298 delete clone; | 298 delete clone; |
| 299 return NULL; | 299 return NULL; |
| 300 } | 300 } |
| 301 | 301 |
| 302 clone->fPat = source->fPat; | 302 clone->fPat = source->fPat; |
| 303 clone->fPatRefCount = source->fPatRefCount; | 303 clone->fPatRefCount = source->fPatRefCount; |
| 304 clone->fPatString = source->fPatString; | 304 clone->fPatString = source->fPatString; |
| 305 clone->fPatStringLen = source->fPatStringLen; | 305 clone->fPatStringLen = source->fPatStringLen; |
| 306 umtx_atomic_inc(source->fPatRefCount); | 306 umtx_atomic_inc(source->fPatRefCount); |
| 307 // Note: fText is not cloned. | 307 // Note: fText is not cloned. |
| 308 | 308 |
| 309 return (URegularExpression*)clone; | 309 return (URegularExpression*)clone; |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 | 313 |
| 314 | 314 |
| 315 //------------------------------------------------------------------------------ | 315 //------------------------------------------------------------------------------ |
| 316 // | 316 // |
| 317 // uregex_pattern | 317 // uregex_pattern |
| 318 // | 318 // |
| 319 //------------------------------------------------------------------------------ | 319 //------------------------------------------------------------------------------ |
| 320 U_CAPI const UChar * U_EXPORT2 | 320 U_CAPI const UChar * U_EXPORT2 |
| 321 uregex_pattern(const URegularExpression *regexp2, | 321 uregex_pattern(const URegularExpression *regexp2, |
| 322 int32_t *patLength, | 322 int32_t *patLength, |
| 323 UErrorCode *status) { | 323 UErrorCode *status) { |
| 324 RegularExpression *regexp = (RegularExpression*)regexp2; | 324 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 325 | 325 |
| 326 if (validateRE(regexp, FALSE, status) == FALSE) { | 326 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 327 return NULL; | 327 return NULL; |
| 328 } | 328 } |
| 329 if (patLength != NULL) { | 329 if (patLength != NULL) { |
| 330 *patLength = regexp->fPatStringLen; | 330 *patLength = regexp->fPatStringLen; |
| 331 } | 331 } |
| 332 return regexp->fPatString; | 332 return regexp->fPatString; |
| 333 } | 333 } |
| 334 | 334 |
| 335 | 335 |
| 336 //------------------------------------------------------------------------------ | 336 //------------------------------------------------------------------------------ |
| 337 // | 337 // |
| 338 // uregex_patternUText | 338 // uregex_patternUText |
| 339 // | 339 // |
| 340 //------------------------------------------------------------------------------ | 340 //------------------------------------------------------------------------------ |
| 341 U_CAPI UText * U_EXPORT2 | 341 U_CAPI UText * U_EXPORT2 |
| 342 uregex_patternUText(const URegularExpression *regexp2, | 342 uregex_patternUText(const URegularExpression *regexp2, |
| 343 UErrorCode *status) { | 343 UErrorCode *status) { |
| 344 RegularExpression *regexp = (RegularExpression*)regexp2; | 344 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 345 return regexp->fPat->patternText(*status); | 345 return regexp->fPat->patternText(*status); |
| 346 } | 346 } |
| 347 | 347 |
| 348 | 348 |
| 349 //------------------------------------------------------------------------------ | 349 //------------------------------------------------------------------------------ |
| 350 // | 350 // |
| 351 // uregex_flags | 351 // uregex_flags |
| 352 // | 352 // |
| 353 //------------------------------------------------------------------------------ | 353 //------------------------------------------------------------------------------ |
| 354 U_CAPI int32_t U_EXPORT2 | 354 U_CAPI int32_t U_EXPORT2 |
| 355 uregex_flags(const URegularExpression *regexp2, UErrorCode *status) { | 355 uregex_flags(const URegularExpression *regexp2, UErrorCode *status) { |
| 356 RegularExpression *regexp = (RegularExpression*)regexp2; | 356 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 357 if (validateRE(regexp, FALSE, status) == FALSE) { | 357 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 358 return 0; | 358 return 0; |
| 359 } | 359 } |
| 360 int32_t flags = regexp->fPat->flags(); | 360 int32_t flags = regexp->fPat->flags(); |
| 361 return flags; | 361 return flags; |
| 362 } | 362 } |
| 363 | 363 |
| 364 | 364 |
| 365 //------------------------------------------------------------------------------ | 365 //------------------------------------------------------------------------------ |
| 366 // | 366 // |
| 367 // uregex_setText | 367 // uregex_setText |
| 368 // | 368 // |
| 369 //------------------------------------------------------------------------------ | 369 //------------------------------------------------------------------------------ |
| 370 U_CAPI void U_EXPORT2 | 370 U_CAPI void U_EXPORT2 |
| 371 uregex_setText(URegularExpression *regexp2, | 371 uregex_setText(URegularExpression *regexp2, |
| 372 const UChar *text, | 372 const UChar *text, |
| 373 int32_t textLength, | 373 int32_t textLength, |
| 374 UErrorCode *status) { | 374 UErrorCode *status) { |
| 375 RegularExpression *regexp = (RegularExpression*)regexp2; | 375 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 376 if (validateRE(regexp, FALSE, status) == FALSE) { | 376 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 377 return; | 377 return; |
| 378 } | 378 } |
| 379 if (text == NULL || textLength < -1) { | 379 if (text == NULL || textLength < -1) { |
| 380 *status = U_ILLEGAL_ARGUMENT_ERROR; | 380 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 381 return; | 381 return; |
| 382 } | 382 } |
| 383 | 383 |
| 384 if (regexp->fOwnsText && regexp->fText != NULL) { | 384 if (regexp->fOwnsText && regexp->fText != NULL) { |
| 385 uprv_free((void *)regexp->fText); | 385 uprv_free((void *)regexp->fText); |
| 386 } | 386 } |
| 387 | 387 |
| 388 regexp->fText = text; | 388 regexp->fText = text; |
| 389 regexp->fTextLength = textLength; | 389 regexp->fTextLength = textLength; |
| 390 regexp->fOwnsText = FALSE; | 390 regexp->fOwnsText = FALSE; |
| 391 | 391 |
| 392 UText input = UTEXT_INITIALIZER; | 392 UText input = UTEXT_INITIALIZER; |
| 393 utext_openUChars(&input, text, textLength, status); | 393 utext_openUChars(&input, text, textLength, status); |
| 394 regexp->fMatcher->reset(&input); | 394 regexp->fMatcher->reset(&input); |
| 395 utext_close(&input); // reset() made a shallow clone, so we don't need this
copy | 395 utext_close(&input); // reset() made a shallow clone, so we don't need this
copy |
| 396 } | 396 } |
| 397 | 397 |
| 398 | 398 |
| 399 //------------------------------------------------------------------------------ | 399 //------------------------------------------------------------------------------ |
| 400 // | 400 // |
| 401 // uregex_setUText | 401 // uregex_setUText |
| 402 // | 402 // |
| 403 //------------------------------------------------------------------------------ | 403 //------------------------------------------------------------------------------ |
| 404 U_CAPI void U_EXPORT2 | 404 U_CAPI void U_EXPORT2 |
| 405 uregex_setUText(URegularExpression *regexp2, | 405 uregex_setUText(URegularExpression *regexp2, |
| 406 UText *text, | 406 UText *text, |
| 407 UErrorCode *status) { | 407 UErrorCode *status) { |
| 408 RegularExpression *regexp = (RegularExpression*)regexp2; | 408 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 409 if (validateRE(regexp, FALSE, status) == FALSE) { | 409 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 410 return; | 410 return; |
| 411 } | 411 } |
| 412 if (text == NULL) { | 412 if (text == NULL) { |
| 413 *status = U_ILLEGAL_ARGUMENT_ERROR; | 413 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 414 return; | 414 return; |
| 415 } | 415 } |
| 416 | 416 |
| 417 if (regexp->fOwnsText && regexp->fText != NULL) { | 417 if (regexp->fOwnsText && regexp->fText != NULL) { |
| 418 uprv_free((void *)regexp->fText); | 418 uprv_free((void *)regexp->fText); |
| 419 } | 419 } |
| 420 | 420 |
| 421 regexp->fText = NULL; // only fill it in on request | 421 regexp->fText = NULL; // only fill it in on request |
| 422 regexp->fTextLength = -1; | 422 regexp->fTextLength = -1; |
| 423 regexp->fOwnsText = TRUE; | 423 regexp->fOwnsText = TRUE; |
| 424 regexp->fMatcher->reset(text); | 424 regexp->fMatcher->reset(text); |
| 425 } | 425 } |
| 426 | 426 |
| 427 | 427 |
| 428 | 428 |
| 429 //------------------------------------------------------------------------------ | 429 //------------------------------------------------------------------------------ |
| 430 // | 430 // |
| 431 // uregex_getText | 431 // uregex_getText |
| 432 // | 432 // |
| 433 //------------------------------------------------------------------------------ | 433 //------------------------------------------------------------------------------ |
| 434 U_CAPI const UChar * U_EXPORT2 | 434 U_CAPI const UChar * U_EXPORT2 |
| 435 uregex_getText(URegularExpression *regexp2, | 435 uregex_getText(URegularExpression *regexp2, |
| 436 int32_t *textLength, | 436 int32_t *textLength, |
| 437 UErrorCode *status) { | 437 UErrorCode *status) { |
| 438 RegularExpression *regexp = (RegularExpression*)regexp2; | 438 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 439 if (validateRE(regexp, FALSE, status) == FALSE) { | 439 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 440 return NULL; | 440 return NULL; |
| 441 } | 441 } |
| 442 | 442 |
| 443 if (regexp->fText == NULL) { | 443 if (regexp->fText == NULL) { |
| 444 // need to fill in the text | 444 // need to fill in the text |
| 445 UText *inputText = regexp->fMatcher->inputText(); | 445 UText *inputText = regexp->fMatcher->inputText(); |
| 446 int64_t inputNativeLength = utext_nativeLength(inputText); | 446 int64_t inputNativeLength = utext_nativeLength(inputText); |
| 447 if (UTEXT_FULL_TEXT_IN_CHUNK(inputText, inputNativeLength)) { | 447 if (UTEXT_FULL_TEXT_IN_CHUNK(inputText, inputNativeLength)) { |
| 448 regexp->fText = inputText->chunkContents; | 448 regexp->fText = inputText->chunkContents; |
| 449 regexp->fTextLength = (int32_t)inputNativeLength; | 449 regexp->fTextLength = (int32_t)inputNativeLength; |
| 450 regexp->fOwnsText = FALSE; // because the UText owns it | 450 regexp->fOwnsText = FALSE; // because the UText owns it |
| 451 } else { | 451 } else { |
| 452 UErrorCode lengthStatus = U_ZERO_ERROR; | 452 UErrorCode lengthStatus = U_ZERO_ERROR; |
| 453 regexp->fTextLength = utext_extract(inputText, 0, inputNativeLength,
NULL, 0, &lengthStatus); // buffer overflow error | 453 regexp->fTextLength = utext_extract(inputText, 0, inputNativeLength,
NULL, 0, &lengthStatus); // buffer overflow error |
| 454 UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(regexp->fTex
tLength+1)); | 454 UChar *inputChars = (UChar *)uprv_malloc(sizeof(UChar)*(regexp->fTex
tLength+1)); |
| 455 | 455 |
| 456 utext_extract(inputText, 0, inputNativeLength, inputChars, regexp->f
TextLength+1, status); | 456 utext_extract(inputText, 0, inputNativeLength, inputChars, regexp->f
TextLength+1, status); |
| 457 regexp->fText = inputChars; | 457 regexp->fText = inputChars; |
| 458 regexp->fOwnsText = TRUE; // should already be set but just in case | 458 regexp->fOwnsText = TRUE; // should already be set but just in case |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 if (textLength != NULL) { | 462 if (textLength != NULL) { |
| 463 *textLength = regexp->fTextLength; | 463 *textLength = regexp->fTextLength; |
| 464 } | 464 } |
| 465 return regexp->fText; | 465 return regexp->fText; |
| 466 } | 466 } |
| 467 | 467 |
| 468 | 468 |
| 469 //------------------------------------------------------------------------------ | 469 //------------------------------------------------------------------------------ |
| 470 // | 470 // |
| 471 // uregex_getUText | 471 // uregex_getUText |
| 472 // | 472 // |
| 473 //------------------------------------------------------------------------------ | 473 //------------------------------------------------------------------------------ |
| 474 U_CAPI UText * U_EXPORT2 | 474 U_CAPI UText * U_EXPORT2 |
| 475 uregex_getUText(URegularExpression *regexp2, | 475 uregex_getUText(URegularExpression *regexp2, |
| 476 UText *dest, | 476 UText *dest, |
| 477 UErrorCode *status) { | 477 UErrorCode *status) { |
| 478 RegularExpression *regexp = (RegularExpression*)regexp2; | 478 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 479 if (validateRE(regexp, FALSE, status) == FALSE) { | 479 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 480 return dest; | 480 return dest; |
| 481 } | 481 } |
| 482 return regexp->fMatcher->getInput(dest, *status); | 482 return regexp->fMatcher->getInput(dest, *status); |
| 483 } | 483 } |
| 484 | 484 |
| 485 | 485 |
| 486 //------------------------------------------------------------------------------ | 486 //------------------------------------------------------------------------------ |
| 487 // | 487 // |
| 488 // uregex_refreshUText | 488 // uregex_refreshUText |
| 489 // | 489 // |
| 490 //------------------------------------------------------------------------------ | 490 //------------------------------------------------------------------------------ |
| 491 U_CAPI void U_EXPORT2 | 491 U_CAPI void U_EXPORT2 |
| 492 uregex_refreshUText(URegularExpression *regexp2, | 492 uregex_refreshUText(URegularExpression *regexp2, |
| 493 UText *text, | 493 UText *text, |
| 494 UErrorCode *status) { | 494 UErrorCode *status) { |
| 495 RegularExpression *regexp = (RegularExpression*)regexp2; | 495 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 496 if (validateRE(regexp, FALSE, status) == FALSE) { | 496 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 497 return; | 497 return; |
| 498 } | 498 } |
| 499 regexp->fMatcher->refreshInputText(text, *status); | 499 regexp->fMatcher->refreshInputText(text, *status); |
| 500 } | 500 } |
| 501 | 501 |
| 502 | 502 |
| 503 //------------------------------------------------------------------------------ | 503 //------------------------------------------------------------------------------ |
| 504 // | 504 // |
| 505 // uregex_matches | 505 // uregex_matches |
| 506 // | 506 // |
| 507 //------------------------------------------------------------------------------ | 507 //------------------------------------------------------------------------------ |
| 508 U_CAPI UBool U_EXPORT2 | 508 U_CAPI UBool U_EXPORT2 |
| 509 uregex_matches(URegularExpression *regexp2, | 509 uregex_matches(URegularExpression *regexp2, |
| 510 int32_t startIndex, | 510 int32_t startIndex, |
| 511 UErrorCode *status) { | 511 UErrorCode *status) { |
| 512 return uregex_matches64( regexp2, (int64_t)startIndex, status); | 512 return uregex_matches64( regexp2, (int64_t)startIndex, status); |
| 513 } | 513 } |
| 514 | 514 |
| 515 U_CAPI UBool U_EXPORT2 | 515 U_CAPI UBool U_EXPORT2 |
| 516 uregex_matches64(URegularExpression *regexp2, | 516 uregex_matches64(URegularExpression *regexp2, |
| 517 int64_t startIndex, | 517 int64_t startIndex, |
| 518 UErrorCode *status) { | 518 UErrorCode *status) { |
| 519 RegularExpression *regexp = (RegularExpression*)regexp2; | 519 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 520 UBool result = FALSE; | 520 UBool result = FALSE; |
| 521 if (validateRE(regexp, TRUE, status) == FALSE) { | 521 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 522 return result; | 522 return result; |
| 523 } | 523 } |
| 524 if (startIndex == -1) { | 524 if (startIndex == -1) { |
| 525 result = regexp->fMatcher->matches(*status); | 525 result = regexp->fMatcher->matches(*status); |
| 526 } else { | 526 } else { |
| 527 result = regexp->fMatcher->matches(startIndex, *status); | 527 result = regexp->fMatcher->matches(startIndex, *status); |
| 528 } | 528 } |
| 529 return result; | 529 return result; |
| 530 } | 530 } |
| 531 | 531 |
| 532 | 532 |
| 533 //------------------------------------------------------------------------------ | 533 //------------------------------------------------------------------------------ |
| 534 // | 534 // |
| 535 // uregex_lookingAt | 535 // uregex_lookingAt |
| 536 // | 536 // |
| 537 //------------------------------------------------------------------------------ | 537 //------------------------------------------------------------------------------ |
| 538 U_CAPI UBool U_EXPORT2 | 538 U_CAPI UBool U_EXPORT2 |
| 539 uregex_lookingAt(URegularExpression *regexp2, | 539 uregex_lookingAt(URegularExpression *regexp2, |
| 540 int32_t startIndex, | 540 int32_t startIndex, |
| 541 UErrorCode *status) { | 541 UErrorCode *status) { |
| 542 return uregex_lookingAt64( regexp2, (int64_t)startIndex, status); | 542 return uregex_lookingAt64( regexp2, (int64_t)startIndex, status); |
| 543 } | 543 } |
| 544 | 544 |
| 545 U_CAPI UBool U_EXPORT2 | 545 U_CAPI UBool U_EXPORT2 |
| 546 uregex_lookingAt64(URegularExpression *regexp2, | 546 uregex_lookingAt64(URegularExpression *regexp2, |
| 547 int64_t startIndex, | 547 int64_t startIndex, |
| 548 UErrorCode *status) { | 548 UErrorCode *status) { |
| 549 RegularExpression *regexp = (RegularExpression*)regexp2; | 549 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 550 UBool result = FALSE; | 550 UBool result = FALSE; |
| 551 if (validateRE(regexp, TRUE, status) == FALSE) { | 551 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 552 return result; | 552 return result; |
| 553 } | 553 } |
| 554 if (startIndex == -1) { | 554 if (startIndex == -1) { |
| 555 result = regexp->fMatcher->lookingAt(*status); | 555 result = regexp->fMatcher->lookingAt(*status); |
| 556 } else { | 556 } else { |
| 557 result = regexp->fMatcher->lookingAt(startIndex, *status); | 557 result = regexp->fMatcher->lookingAt(startIndex, *status); |
| 558 } | 558 } |
| 559 return result; | 559 return result; |
| 560 } | 560 } |
| 561 | 561 |
| 562 | 562 |
| 563 | 563 |
| 564 //------------------------------------------------------------------------------ | 564 //------------------------------------------------------------------------------ |
| 565 // | 565 // |
| 566 // uregex_find | 566 // uregex_find |
| 567 // | 567 // |
| 568 //------------------------------------------------------------------------------ | 568 //------------------------------------------------------------------------------ |
| 569 U_CAPI UBool U_EXPORT2 | 569 U_CAPI UBool U_EXPORT2 |
| 570 uregex_find(URegularExpression *regexp2, | 570 uregex_find(URegularExpression *regexp2, |
| 571 int32_t startIndex, | 571 int32_t startIndex, |
| 572 UErrorCode *status) { | 572 UErrorCode *status) { |
| 573 return uregex_find64( regexp2, (int64_t)startIndex, status); | 573 return uregex_find64( regexp2, (int64_t)startIndex, status); |
| 574 } | 574 } |
| 575 | 575 |
| 576 U_CAPI UBool U_EXPORT2 | 576 U_CAPI UBool U_EXPORT2 |
| 577 uregex_find64(URegularExpression *regexp2, | 577 uregex_find64(URegularExpression *regexp2, |
| 578 int64_t startIndex, | 578 int64_t startIndex, |
| 579 UErrorCode *status) { | 579 UErrorCode *status) { |
| 580 RegularExpression *regexp = (RegularExpression*)regexp2; | 580 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 581 UBool result = FALSE; | 581 UBool result = FALSE; |
| 582 if (validateRE(regexp, TRUE, status) == FALSE) { | 582 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 583 return result; | 583 return result; |
| 584 } | 584 } |
| 585 if (startIndex == -1) { | 585 if (startIndex == -1) { |
| 586 regexp->fMatcher->resetPreserveRegion(); | 586 regexp->fMatcher->resetPreserveRegion(); |
| 587 result = regexp->fMatcher->find(); | 587 result = regexp->fMatcher->find(*status); |
| 588 } else { | 588 } else { |
| 589 result = regexp->fMatcher->find(startIndex, *status); | 589 result = regexp->fMatcher->find(startIndex, *status); |
| 590 } | 590 } |
| 591 return result; | 591 return result; |
| 592 } | 592 } |
| 593 | 593 |
| 594 | 594 |
| 595 //------------------------------------------------------------------------------ | 595 //------------------------------------------------------------------------------ |
| 596 // | 596 // |
| 597 // uregex_findNext | 597 // uregex_findNext |
| 598 // | 598 // |
| 599 //------------------------------------------------------------------------------ | 599 //------------------------------------------------------------------------------ |
| 600 U_CAPI UBool U_EXPORT2 | 600 U_CAPI UBool U_EXPORT2 |
| 601 uregex_findNext(URegularExpression *regexp2, | 601 uregex_findNext(URegularExpression *regexp2, |
| 602 UErrorCode *status) { | 602 UErrorCode *status) { |
| 603 RegularExpression *regexp = (RegularExpression*)regexp2; | 603 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 604 if (validateRE(regexp, TRUE, status) == FALSE) { | 604 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 605 return FALSE; | 605 return FALSE; |
| 606 } | 606 } |
| 607 UBool result = regexp->fMatcher->find(); | 607 UBool result = regexp->fMatcher->find(*status); |
| 608 return result; | 608 return result; |
| 609 } | 609 } |
| 610 | 610 |
| 611 //------------------------------------------------------------------------------ | 611 //------------------------------------------------------------------------------ |
| 612 // | 612 // |
| 613 // uregex_groupCount | 613 // uregex_groupCount |
| 614 // | 614 // |
| 615 //------------------------------------------------------------------------------ | 615 //------------------------------------------------------------------------------ |
| 616 U_CAPI int32_t U_EXPORT2 | 616 U_CAPI int32_t U_EXPORT2 |
| 617 uregex_groupCount(URegularExpression *regexp2, | 617 uregex_groupCount(URegularExpression *regexp2, |
| 618 UErrorCode *status) { | 618 UErrorCode *status) { |
| 619 RegularExpression *regexp = (RegularExpression*)regexp2; | 619 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 620 if (validateRE(regexp, FALSE, status) == FALSE) { | 620 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 621 return 0; | 621 return 0; |
| 622 } | 622 } |
| 623 int32_t result = regexp->fMatcher->groupCount(); | 623 int32_t result = regexp->fMatcher->groupCount(); |
| 624 return result; | 624 return result; |
| 625 } | 625 } |
| 626 | 626 |
| 627 | 627 |
| 628 //------------------------------------------------------------------------------ | 628 //------------------------------------------------------------------------------ |
| 629 // | 629 // |
| 630 // uregex_group | 630 // uregex_group |
| 631 // | 631 // |
| 632 //------------------------------------------------------------------------------ | 632 //------------------------------------------------------------------------------ |
| 633 U_CAPI int32_t U_EXPORT2 | 633 U_CAPI int32_t U_EXPORT2 |
| 634 uregex_group(URegularExpression *regexp2, | 634 uregex_group(URegularExpression *regexp2, |
| 635 int32_t groupNum, | 635 int32_t groupNum, |
| 636 UChar *dest, | 636 UChar *dest, |
| 637 int32_t destCapacity, | 637 int32_t destCapacity, |
| 638 UErrorCode *status) { | 638 UErrorCode *status) { |
| 639 RegularExpression *regexp = (RegularExpression*)regexp2; | 639 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 640 if (validateRE(regexp, TRUE, status) == FALSE) { | 640 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 641 return 0; | 641 return 0; |
| 642 } | 642 } |
| 643 if (destCapacity < 0 || (destCapacity > 0 && dest == NULL)) { | 643 if (destCapacity < 0 || (destCapacity > 0 && dest == NULL)) { |
| 644 *status = U_ILLEGAL_ARGUMENT_ERROR; | 644 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 645 return 0; | 645 return 0; |
| 646 } | 646 } |
| 647 | 647 |
| 648 if (destCapacity == 0 || regexp->fText != NULL) { | 648 if (destCapacity == 0 || regexp->fText != NULL) { |
| 649 // If preflighting or if we already have the text as UChars, | 649 // If preflighting or if we already have the text as UChars, |
| 650 // this is a little cheaper than going through uregex_groupUTextDeep() | 650 // this is a little cheaper than going through uregex_groupUTextDeep() |
| 651 | 651 |
| 652 // | 652 // |
| 653 // Pick up the range of characters from the matcher | 653 // Pick up the range of characters from the matcher |
| 654 // | 654 // |
| 655 int32_t startIx = regexp->fMatcher->start(groupNum, *status); | 655 int32_t startIx = regexp->fMatcher->start(groupNum, *status); |
| 656 int32_t endIx = regexp->fMatcher->end (groupNum, *status); | 656 int32_t endIx = regexp->fMatcher->end (groupNum, *status); |
| 657 if (U_FAILURE(*status)) { | 657 if (U_FAILURE(*status)) { |
| 658 return 0; | 658 return 0; |
| 659 } | 659 } |
| 660 | 660 |
| 661 // | 661 // |
| 662 // Trim length based on buffer capacity | 662 // Trim length based on buffer capacity |
| 663 // | 663 // |
| 664 int32_t fullLength = endIx - startIx; | 664 int32_t fullLength = endIx - startIx; |
| 665 int32_t copyLength = fullLength; | 665 int32_t copyLength = fullLength; |
| 666 if (copyLength < destCapacity) { | 666 if (copyLength < destCapacity) { |
| 667 dest[copyLength] = 0; | 667 dest[copyLength] = 0; |
| 668 } else if (copyLength == destCapacity) { | 668 } else if (copyLength == destCapacity) { |
| 669 *status = U_STRING_NOT_TERMINATED_WARNING; | 669 *status = U_STRING_NOT_TERMINATED_WARNING; |
| 670 } else { | 670 } else { |
| 671 copyLength = destCapacity; | 671 copyLength = destCapacity; |
| 672 *status = U_BUFFER_OVERFLOW_ERROR; | 672 *status = U_BUFFER_OVERFLOW_ERROR; |
| 673 } | 673 } |
| 674 | 674 |
| 675 // | 675 // |
| 676 // Copy capture group to user's buffer | 676 // Copy capture group to user's buffer |
| 677 // | 677 // |
| 678 if (copyLength > 0) { | 678 if (copyLength > 0) { |
| 679 u_memcpy(dest, ®exp->fText[startIx], copyLength); | 679 u_memcpy(dest, ®exp->fText[startIx], copyLength); |
| 680 } | 680 } |
| 681 return fullLength; | 681 return fullLength; |
| 682 } else { | 682 } else { |
| 683 int32_t result = 0; |
| 683 UText *groupText = uregex_groupUTextDeep(regexp2, groupNum, NULL, status
); | 684 UText *groupText = uregex_groupUTextDeep(regexp2, groupNum, NULL, status
); |
| 684 int32_t result = utext_extract(groupText, 0, utext_nativeLength(groupTex
t), dest, destCapacity, status); | 685 if (U_SUCCESS(*status)) { |
| 686 result = utext_extract(groupText, 0, utext_nativeLength(groupText),
dest, destCapacity, status); |
| 687 } |
| 685 utext_close(groupText); | 688 utext_close(groupText); |
| 686 return result; | 689 return result; |
| 687 } | 690 } |
| 688 } | 691 } |
| 689 | 692 |
| 690 | 693 |
| 691 //------------------------------------------------------------------------------ | 694 //------------------------------------------------------------------------------ |
| 692 // | 695 // |
| 693 // uregex_groupUText | 696 // uregex_groupUText |
| 694 // | 697 // |
| 695 //------------------------------------------------------------------------------ | 698 //------------------------------------------------------------------------------ |
| 696 U_CAPI UText * U_EXPORT2 | 699 U_CAPI UText * U_EXPORT2 |
| 697 uregex_groupUText(URegularExpression *regexp2, | 700 uregex_groupUText(URegularExpression *regexp2, |
| 698 int32_t groupNum, | 701 int32_t groupNum, |
| 699 UText *dest, | 702 UText *dest, |
| 700 int64_t *groupLength, | 703 int64_t *groupLength, |
| 701 UErrorCode *status) { | 704 UErrorCode *status) { |
| 702 RegularExpression *regexp = (RegularExpression*)regexp2; | 705 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 703 if (validateRE(regexp, TRUE, status) == FALSE) { | 706 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 704 UErrorCode emptyTextStatus = U_ZERO_ERROR; | 707 UErrorCode emptyTextStatus = U_ZERO_ERROR; |
| 705 return (dest ? dest : utext_openUChars(NULL, NULL, 0, &emptyTextStatus))
; | 708 return (dest ? dest : utext_openUChars(NULL, NULL, 0, &emptyTextStatus))
; |
| 706 } | 709 } |
| 707 | 710 |
| 708 return regexp->fMatcher->group(groupNum, dest, *groupLength, *status); | 711 return regexp->fMatcher->group(groupNum, dest, *groupLength, *status); |
| 709 } | 712 } |
| 710 | 713 |
| 711 //------------------------------------------------------------------------------ | 714 //------------------------------------------------------------------------------ |
| 712 // | 715 // |
| 713 // uregex_groupUTextDeep | 716 // uregex_groupUTextDeep |
| 714 // | 717 // |
| 715 //------------------------------------------------------------------------------ | 718 //------------------------------------------------------------------------------ |
| 716 U_CAPI UText * U_EXPORT2 | 719 U_CAPI UText * U_EXPORT2 |
| 717 uregex_groupUTextDeep(URegularExpression *regexp2, | 720 uregex_groupUTextDeep(URegularExpression *regexp2, |
| 718 int32_t groupNum, | 721 int32_t groupNum, |
| 719 UText *dest, | 722 UText *dest, |
| 720 UErrorCode *status) { | 723 UErrorCode *status) { |
| 721 RegularExpression *regexp = (RegularExpression*)regexp2; | 724 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 722 if (validateRE(regexp, TRUE, status) == FALSE) { | 725 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 723 UErrorCode emptyTextStatus = U_ZERO_ERROR; | 726 UErrorCode emptyTextStatus = U_ZERO_ERROR; |
| 724 return (dest ? dest : utext_openUChars(NULL, NULL, 0, &emptyTextStatus))
; | 727 return (dest ? dest : utext_openUChars(NULL, NULL, 0, &emptyTextStatus))
; |
| 725 } | 728 } |
| 726 | 729 |
| 727 if (regexp->fText != NULL) { | 730 if (regexp->fText != NULL) { |
| 728 // | 731 // |
| 729 // Pick up the range of characters from the matcher | 732 // Pick up the range of characters from the matcher |
| 730 // and use our already-extracted characters | 733 // and use our already-extracted characters |
| 731 // | 734 // |
| 732 int32_t startIx = regexp->fMatcher->start(groupNum, *status); | 735 int32_t startIx = regexp->fMatcher->start(groupNum, *status); |
| 733 int32_t endIx = regexp->fMatcher->end (groupNum, *status); | 736 int32_t endIx = regexp->fMatcher->end (groupNum, *status); |
| 734 if (U_FAILURE(*status)) { | 737 if (U_FAILURE(*status)) { |
| 735 UErrorCode emptyTextStatus = U_ZERO_ERROR; | 738 UErrorCode emptyTextStatus = U_ZERO_ERROR; |
| 736 return (dest ? dest : utext_openUChars(NULL, NULL, 0, &emptyTextStat
us)); | 739 return (dest ? dest : utext_openUChars(NULL, NULL, 0, &emptyTextStat
us)); |
| 737 } | 740 } |
| 738 | 741 |
| 739 if (dest) { | 742 if (dest) { |
| 740 utext_replace(dest, 0, utext_nativeLength(dest), ®exp->fText[star
tIx], endIx - startIx, status); | 743 utext_replace(dest, 0, utext_nativeLength(dest), ®exp->fText[star
tIx], endIx - startIx, status); |
| 741 } else { | 744 } else { |
| 742 UText groupText = UTEXT_INITIALIZER; | 745 UText groupText = UTEXT_INITIALIZER; |
| 743 utext_openUChars(&groupText, ®exp->fText[startIx], endIx - startI
x, status); | 746 utext_openUChars(&groupText, ®exp->fText[startIx], endIx - startI
x, status); |
| 744 dest = utext_clone(NULL, &groupText, TRUE, FALSE, status); | 747 dest = utext_clone(NULL, &groupText, TRUE, FALSE, status); |
| 745 utext_close(&groupText); | 748 utext_close(&groupText); |
| 746 } | 749 } |
| 747 | 750 |
| 748 return dest; | 751 return dest; |
| 749 } else { | 752 } else { |
| 750 return regexp->fMatcher->group(groupNum, dest, *status); | 753 return regexp->fMatcher->group(groupNum, dest, *status); |
| 751 } | 754 } |
| 752 } | 755 } |
| 753 | 756 |
| 754 //------------------------------------------------------------------------------ | 757 //------------------------------------------------------------------------------ |
| 755 // | 758 // |
| 756 // uregex_start | 759 // uregex_start |
| 757 // | 760 // |
| 758 //------------------------------------------------------------------------------ | 761 //------------------------------------------------------------------------------ |
| 759 U_CAPI int32_t U_EXPORT2 | 762 U_CAPI int32_t U_EXPORT2 |
| 760 uregex_start(URegularExpression *regexp2, | 763 uregex_start(URegularExpression *regexp2, |
| 761 int32_t groupNum, | 764 int32_t groupNum, |
| 762 UErrorCode *status) { | 765 UErrorCode *status) { |
| 763 return (int32_t)uregex_start64( regexp2, groupNum, status); | 766 return (int32_t)uregex_start64( regexp2, groupNum, status); |
| 764 } | 767 } |
| 765 | 768 |
| 766 U_CAPI int64_t U_EXPORT2 | 769 U_CAPI int64_t U_EXPORT2 |
| 767 uregex_start64(URegularExpression *regexp2, | 770 uregex_start64(URegularExpression *regexp2, |
| 768 int32_t groupNum, | 771 int32_t groupNum, |
| 769 UErrorCode *status) { | 772 UErrorCode *status) { |
| 770 RegularExpression *regexp = (RegularExpression*)regexp2; | 773 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 771 if (validateRE(regexp, TRUE, status) == FALSE) { | 774 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 772 return 0; | 775 return 0; |
| 773 } | 776 } |
| 774 int32_t result = regexp->fMatcher->start(groupNum, *status); | 777 int32_t result = regexp->fMatcher->start(groupNum, *status); |
| 775 return result; | 778 return result; |
| 776 } | 779 } |
| 777 | 780 |
| 778 //------------------------------------------------------------------------------ | 781 //------------------------------------------------------------------------------ |
| 779 // | 782 // |
| 780 // uregex_end | 783 // uregex_end |
| 781 // | 784 // |
| 782 //------------------------------------------------------------------------------ | 785 //------------------------------------------------------------------------------ |
| 783 U_CAPI int32_t U_EXPORT2 | 786 U_CAPI int32_t U_EXPORT2 |
| 784 uregex_end(URegularExpression *regexp2, | 787 uregex_end(URegularExpression *regexp2, |
| 785 int32_t groupNum, | 788 int32_t groupNum, |
| 786 UErrorCode *status) { | 789 UErrorCode *status) { |
| 787 return (int32_t)uregex_end64( regexp2, groupNum, status); | 790 return (int32_t)uregex_end64( regexp2, groupNum, status); |
| 788 } | 791 } |
| 789 | 792 |
| 790 U_CAPI int64_t U_EXPORT2 | 793 U_CAPI int64_t U_EXPORT2 |
| 791 uregex_end64(URegularExpression *regexp2, | 794 uregex_end64(URegularExpression *regexp2, |
| 792 int32_t groupNum, | 795 int32_t groupNum, |
| 793 UErrorCode *status) { | 796 UErrorCode *status) { |
| 794 RegularExpression *regexp = (RegularExpression*)regexp2; | 797 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 795 if (validateRE(regexp, TRUE, status) == FALSE) { | 798 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 796 return 0; | 799 return 0; |
| 797 } | 800 } |
| 798 int32_t result = regexp->fMatcher->end(groupNum, *status); | 801 int32_t result = regexp->fMatcher->end(groupNum, *status); |
| 799 return result; | 802 return result; |
| 800 } | 803 } |
| 801 | 804 |
| 802 //------------------------------------------------------------------------------ | 805 //------------------------------------------------------------------------------ |
| 803 // | 806 // |
| 804 // uregex_reset | 807 // uregex_reset |
| 805 // | 808 // |
| 806 //------------------------------------------------------------------------------ | 809 //------------------------------------------------------------------------------ |
| 807 U_CAPI void U_EXPORT2 | 810 U_CAPI void U_EXPORT2 |
| 808 uregex_reset(URegularExpression *regexp2, | 811 uregex_reset(URegularExpression *regexp2, |
| 809 int32_t index, | 812 int32_t index, |
| 810 UErrorCode *status) { | 813 UErrorCode *status) { |
| 811 uregex_reset64( regexp2, (int64_t)index, status); | 814 uregex_reset64( regexp2, (int64_t)index, status); |
| 812 } | 815 } |
| 813 | 816 |
| 814 U_CAPI void U_EXPORT2 | 817 U_CAPI void U_EXPORT2 |
| 815 uregex_reset64(URegularExpression *regexp2, | 818 uregex_reset64(URegularExpression *regexp2, |
| 816 int64_t index, | 819 int64_t index, |
| 817 UErrorCode *status) { | 820 UErrorCode *status) { |
| 818 RegularExpression *regexp = (RegularExpression*)regexp2; | 821 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 819 if (validateRE(regexp, TRUE, status) == FALSE) { | 822 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 820 return; | 823 return; |
| 821 } | 824 } |
| 822 regexp->fMatcher->reset(index, *status); | 825 regexp->fMatcher->reset(index, *status); |
| 823 } | 826 } |
| 824 | 827 |
| 825 | 828 |
| 826 //------------------------------------------------------------------------------ | 829 //------------------------------------------------------------------------------ |
| 827 // | 830 // |
| 828 // uregex_setRegion | 831 // uregex_setRegion |
| 829 // | 832 // |
| 830 //------------------------------------------------------------------------------ | 833 //------------------------------------------------------------------------------ |
| 831 U_CAPI void U_EXPORT2 | 834 U_CAPI void U_EXPORT2 |
| 832 uregex_setRegion(URegularExpression *regexp2, | 835 uregex_setRegion(URegularExpression *regexp2, |
| 833 int32_t regionStart, | 836 int32_t regionStart, |
| 834 int32_t regionLimit, | 837 int32_t regionLimit, |
| 835 UErrorCode *status) { | 838 UErrorCode *status) { |
| 836 uregex_setRegion64( regexp2, (int64_t)regionStart, (int64_t)regionLimit, sta
tus); | 839 uregex_setRegion64( regexp2, (int64_t)regionStart, (int64_t)regionLimit, sta
tus); |
| 837 } | 840 } |
| 838 | 841 |
| 839 U_CAPI void U_EXPORT2 | 842 U_CAPI void U_EXPORT2 |
| 840 uregex_setRegion64(URegularExpression *regexp2, | 843 uregex_setRegion64(URegularExpression *regexp2, |
| 841 int64_t regionStart, | 844 int64_t regionStart, |
| 842 int64_t regionLimit, | 845 int64_t regionLimit, |
| 843 UErrorCode *status) { | 846 UErrorCode *status) { |
| 844 RegularExpression *regexp = (RegularExpression*)regexp2; | 847 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 845 if (validateRE(regexp, TRUE, status) == FALSE) { | 848 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 846 return; | 849 return; |
| 847 } | 850 } |
| 848 regexp->fMatcher->region(regionStart, regionLimit, *status); | 851 regexp->fMatcher->region(regionStart, regionLimit, *status); |
| 849 } | 852 } |
| 850 | 853 |
| 851 | 854 |
| 852 //------------------------------------------------------------------------------ | 855 //------------------------------------------------------------------------------ |
| 853 // | 856 // |
| 854 // uregex_setRegionAndStart | 857 // uregex_setRegionAndStart |
| 855 // | 858 // |
| 856 //------------------------------------------------------------------------------ | 859 //------------------------------------------------------------------------------ |
| 857 U_CAPI void U_EXPORT2 | 860 U_CAPI void U_EXPORT2 |
| 858 uregex_setRegionAndStart(URegularExpression *regexp2, | 861 uregex_setRegionAndStart(URegularExpression *regexp2, |
| 859 int64_t regionStart, | 862 int64_t regionStart, |
| 860 int64_t regionLimit, | 863 int64_t regionLimit, |
| 861 int64_t startIndex, | 864 int64_t startIndex, |
| 862 UErrorCode *status) { | 865 UErrorCode *status) { |
| 863 RegularExpression *regexp = (RegularExpression*)regexp2; | 866 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 864 if (validateRE(regexp, TRUE, status) == FALSE) { | 867 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 865 return; | 868 return; |
| 866 } | 869 } |
| 867 regexp->fMatcher->region(regionStart, regionLimit, startIndex, *status); | 870 regexp->fMatcher->region(regionStart, regionLimit, startIndex, *status); |
| 868 } | 871 } |
| 869 | 872 |
| 870 //------------------------------------------------------------------------------ | 873 //------------------------------------------------------------------------------ |
| 871 // | 874 // |
| 872 // uregex_regionStart | 875 // uregex_regionStart |
| 873 // | 876 // |
| 874 //------------------------------------------------------------------------------ | 877 //------------------------------------------------------------------------------ |
| 875 U_CAPI int32_t U_EXPORT2 | 878 U_CAPI int32_t U_EXPORT2 |
| 876 uregex_regionStart(const URegularExpression *regexp2, | 879 uregex_regionStart(const URegularExpression *regexp2, |
| 877 UErrorCode *status) { | 880 UErrorCode *status) { |
| 878 return (int32_t)uregex_regionStart64(regexp2, status); | 881 return (int32_t)uregex_regionStart64(regexp2, status); |
| 879 } | 882 } |
| 880 | 883 |
| 881 U_CAPI int64_t U_EXPORT2 | 884 U_CAPI int64_t U_EXPORT2 |
| 882 uregex_regionStart64(const URegularExpression *regexp2, | 885 uregex_regionStart64(const URegularExpression *regexp2, |
| 883 UErrorCode *status) { | 886 UErrorCode *status) { |
| 884 RegularExpression *regexp = (RegularExpression*)regexp2; | 887 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 885 if (validateRE(regexp, TRUE, status) == FALSE) { | 888 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 886 return 0; | 889 return 0; |
| 887 } | 890 } |
| 888 return regexp->fMatcher->regionStart(); | 891 return regexp->fMatcher->regionStart(); |
| 889 } | 892 } |
| 890 | 893 |
| 891 | 894 |
| 892 //------------------------------------------------------------------------------ | 895 //------------------------------------------------------------------------------ |
| 893 // | 896 // |
| 894 // uregex_regionEnd | 897 // uregex_regionEnd |
| 895 // | 898 // |
| 896 //------------------------------------------------------------------------------ | 899 //------------------------------------------------------------------------------ |
| 897 U_CAPI int32_t U_EXPORT2 | 900 U_CAPI int32_t U_EXPORT2 |
| 898 uregex_regionEnd(const URegularExpression *regexp2, | 901 uregex_regionEnd(const URegularExpression *regexp2, |
| 899 UErrorCode *status) { | 902 UErrorCode *status) { |
| 900 return (int32_t)uregex_regionEnd64(regexp2, status); | 903 return (int32_t)uregex_regionEnd64(regexp2, status); |
| 901 } | 904 } |
| 902 | 905 |
| 903 U_CAPI int64_t U_EXPORT2 | 906 U_CAPI int64_t U_EXPORT2 |
| 904 uregex_regionEnd64(const URegularExpression *regexp2, | 907 uregex_regionEnd64(const URegularExpression *regexp2, |
| 905 UErrorCode *status) { | 908 UErrorCode *status) { |
| 906 RegularExpression *regexp = (RegularExpression*)regexp2; | 909 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 907 if (validateRE(regexp, TRUE, status) == FALSE) { | 910 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 908 return 0; | 911 return 0; |
| 909 } | 912 } |
| 910 return regexp->fMatcher->regionEnd(); | 913 return regexp->fMatcher->regionEnd(); |
| 911 } | 914 } |
| 912 | 915 |
| 913 | 916 |
| 914 //------------------------------------------------------------------------------ | 917 //------------------------------------------------------------------------------ |
| 915 // | 918 // |
| 916 // uregex_hasTransparentBounds | 919 // uregex_hasTransparentBounds |
| 917 // | 920 // |
| 918 //------------------------------------------------------------------------------ | 921 //------------------------------------------------------------------------------ |
| 919 U_CAPI UBool U_EXPORT2 | 922 U_CAPI UBool U_EXPORT2 |
| 920 uregex_hasTransparentBounds(const URegularExpression *regexp2, | 923 uregex_hasTransparentBounds(const URegularExpression *regexp2, |
| 921 UErrorCode *status) { | 924 UErrorCode *status) { |
| 922 RegularExpression *regexp = (RegularExpression*)regexp2; | 925 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 923 if (validateRE(regexp, FALSE, status) == FALSE) { | 926 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 924 return FALSE; | 927 return FALSE; |
| 925 } | 928 } |
| 926 return regexp->fMatcher->hasTransparentBounds(); | 929 return regexp->fMatcher->hasTransparentBounds(); |
| 927 } | 930 } |
| 928 | 931 |
| 929 | 932 |
| 930 //------------------------------------------------------------------------------ | 933 //------------------------------------------------------------------------------ |
| 931 // | 934 // |
| 932 // uregex_useTransparentBounds | 935 // uregex_useTransparentBounds |
| 933 // | 936 // |
| 934 //------------------------------------------------------------------------------ | 937 //------------------------------------------------------------------------------ |
| 935 U_CAPI void U_EXPORT2 | 938 U_CAPI void U_EXPORT2 |
| 936 uregex_useTransparentBounds(URegularExpression *regexp2, | 939 uregex_useTransparentBounds(URegularExpression *regexp2, |
| 937 UBool b, | 940 UBool b, |
| 938 UErrorCode *status) { | 941 UErrorCode *status) { |
| 939 RegularExpression *regexp = (RegularExpression*)regexp2; | 942 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 940 if (validateRE(regexp, FALSE, status) == FALSE) { | 943 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 941 return; | 944 return; |
| 942 } | 945 } |
| 943 regexp->fMatcher->useTransparentBounds(b); | 946 regexp->fMatcher->useTransparentBounds(b); |
| 944 } | 947 } |
| 945 | 948 |
| 946 | 949 |
| 947 //------------------------------------------------------------------------------ | 950 //------------------------------------------------------------------------------ |
| 948 // | 951 // |
| 949 // uregex_hasAnchoringBounds | 952 // uregex_hasAnchoringBounds |
| 950 // | 953 // |
| 951 //------------------------------------------------------------------------------ | 954 //------------------------------------------------------------------------------ |
| 952 U_CAPI UBool U_EXPORT2 | 955 U_CAPI UBool U_EXPORT2 |
| 953 uregex_hasAnchoringBounds(const URegularExpression *regexp2, | 956 uregex_hasAnchoringBounds(const URegularExpression *regexp2, |
| 954 UErrorCode *status) { | 957 UErrorCode *status) { |
| 955 RegularExpression *regexp = (RegularExpression*)regexp2; | 958 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 956 if (validateRE(regexp, FALSE, status) == FALSE) { | 959 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 957 return FALSE; | 960 return FALSE; |
| 958 } | 961 } |
| 959 return regexp->fMatcher->hasAnchoringBounds(); | 962 return regexp->fMatcher->hasAnchoringBounds(); |
| 960 } | 963 } |
| 961 | 964 |
| 962 | 965 |
| 963 //------------------------------------------------------------------------------ | 966 //------------------------------------------------------------------------------ |
| 964 // | 967 // |
| 965 // uregex_useAnchoringBounds | 968 // uregex_useAnchoringBounds |
| 966 // | 969 // |
| 967 //------------------------------------------------------------------------------ | 970 //------------------------------------------------------------------------------ |
| 968 U_CAPI void U_EXPORT2 | 971 U_CAPI void U_EXPORT2 |
| 969 uregex_useAnchoringBounds(URegularExpression *regexp2, | 972 uregex_useAnchoringBounds(URegularExpression *regexp2, |
| 970 UBool b, | 973 UBool b, |
| 971 UErrorCode *status) { | 974 UErrorCode *status) { |
| 972 RegularExpression *regexp = (RegularExpression*)regexp2; | 975 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 973 if (validateRE(regexp, FALSE, status) == FALSE) { | 976 if (validateRE(regexp, FALSE, status) == FALSE) { |
| 974 return; | 977 return; |
| 975 } | 978 } |
| 976 regexp->fMatcher->useAnchoringBounds(b); | 979 regexp->fMatcher->useAnchoringBounds(b); |
| 977 } | 980 } |
| 978 | 981 |
| 979 | 982 |
| 980 //------------------------------------------------------------------------------ | 983 //------------------------------------------------------------------------------ |
| 981 // | 984 // |
| 982 // uregex_hitEnd | 985 // uregex_hitEnd |
| 983 // | 986 // |
| 984 //------------------------------------------------------------------------------ | 987 //------------------------------------------------------------------------------ |
| 985 U_CAPI UBool U_EXPORT2 | 988 U_CAPI UBool U_EXPORT2 |
| 986 uregex_hitEnd(const URegularExpression *regexp2, | 989 uregex_hitEnd(const URegularExpression *regexp2, |
| 987 UErrorCode *status) { | 990 UErrorCode *status) { |
| 988 RegularExpression *regexp = (RegularExpression*)regexp2; | 991 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 989 if (validateRE(regexp, TRUE, status) == FALSE) { | 992 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 990 return FALSE; | 993 return FALSE; |
| 991 } | 994 } |
| 992 return regexp->fMatcher->hitEnd(); | 995 return regexp->fMatcher->hitEnd(); |
| 993 } | 996 } |
| 994 | 997 |
| 995 | 998 |
| 996 //------------------------------------------------------------------------------ | 999 //------------------------------------------------------------------------------ |
| 997 // | 1000 // |
| 998 // uregex_requireEnd | 1001 // uregex_requireEnd |
| 999 // | 1002 // |
| 1000 //------------------------------------------------------------------------------ | 1003 //------------------------------------------------------------------------------ |
| 1001 U_CAPI UBool U_EXPORT2 | 1004 U_CAPI UBool U_EXPORT2 |
| 1002 uregex_requireEnd(const URegularExpression *regexp2, | 1005 uregex_requireEnd(const URegularExpression *regexp2, |
| 1003 UErrorCode *status) { | 1006 UErrorCode *status) { |
| 1004 RegularExpression *regexp = (RegularExpression*)regexp2; | 1007 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1005 if (validateRE(regexp, TRUE, status) == FALSE) { | 1008 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 1006 return FALSE; | 1009 return FALSE; |
| 1007 } | 1010 } |
| 1008 return regexp->fMatcher->requireEnd(); | 1011 return regexp->fMatcher->requireEnd(); |
| 1009 } | 1012 } |
| 1010 | 1013 |
| 1011 | 1014 |
| 1012 //------------------------------------------------------------------------------ | 1015 //------------------------------------------------------------------------------ |
| 1013 // | 1016 // |
| 1014 // uregex_setTimeLimit | 1017 // uregex_setTimeLimit |
| 1015 // | 1018 // |
| 1016 //------------------------------------------------------------------------------ | 1019 //------------------------------------------------------------------------------ |
| 1017 U_CAPI void U_EXPORT2 | 1020 U_CAPI void U_EXPORT2 |
| 1018 uregex_setTimeLimit(URegularExpression *regexp2, | 1021 uregex_setTimeLimit(URegularExpression *regexp2, |
| 1019 int32_t limit, | 1022 int32_t limit, |
| 1020 UErrorCode *status) { | 1023 UErrorCode *status) { |
| 1021 RegularExpression *regexp = (RegularExpression*)regexp2; | 1024 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1022 if (validateRE(regexp, FALSE, status)) { | 1025 if (validateRE(regexp, FALSE, status)) { |
| 1023 regexp->fMatcher->setTimeLimit(limit, *status); | 1026 regexp->fMatcher->setTimeLimit(limit, *status); |
| 1024 } | 1027 } |
| 1025 } | 1028 } |
| 1026 | 1029 |
| 1027 | 1030 |
| 1028 | 1031 |
| 1029 //------------------------------------------------------------------------------ | 1032 //------------------------------------------------------------------------------ |
| 1030 // | 1033 // |
| 1031 // uregex_getTimeLimit | 1034 // uregex_getTimeLimit |
| 1032 // | 1035 // |
| 1033 //------------------------------------------------------------------------------ | 1036 //------------------------------------------------------------------------------ |
| 1034 U_CAPI int32_t U_EXPORT2 | 1037 U_CAPI int32_t U_EXPORT2 |
| 1035 uregex_getTimeLimit(const URegularExpression *regexp2, | 1038 uregex_getTimeLimit(const URegularExpression *regexp2, |
| 1036 UErrorCode *status) { | 1039 UErrorCode *status) { |
| 1037 int32_t retVal = 0; | 1040 int32_t retVal = 0; |
| 1038 RegularExpression *regexp = (RegularExpression*)regexp2; | 1041 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1039 if (validateRE(regexp, FALSE, status)) { | 1042 if (validateRE(regexp, FALSE, status)) { |
| 1040 retVal = regexp->fMatcher->getTimeLimit(); | 1043 retVal = regexp->fMatcher->getTimeLimit(); |
| 1041 } | 1044 } |
| 1042 return retVal; | 1045 return retVal; |
| 1043 } | 1046 } |
| 1044 | 1047 |
| 1045 | 1048 |
| 1046 | 1049 |
| 1047 //------------------------------------------------------------------------------ | 1050 //------------------------------------------------------------------------------ |
| 1048 // | 1051 // |
| 1049 // uregex_setStackLimit | 1052 // uregex_setStackLimit |
| 1050 // | 1053 // |
| 1051 //------------------------------------------------------------------------------ | 1054 //------------------------------------------------------------------------------ |
| 1052 U_CAPI void U_EXPORT2 | 1055 U_CAPI void U_EXPORT2 |
| 1053 uregex_setStackLimit(URegularExpression *regexp2, | 1056 uregex_setStackLimit(URegularExpression *regexp2, |
| 1054 int32_t limit, | 1057 int32_t limit, |
| 1055 UErrorCode *status) { | 1058 UErrorCode *status) { |
| 1056 RegularExpression *regexp = (RegularExpression*)regexp2; | 1059 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1057 if (validateRE(regexp, FALSE, status)) { | 1060 if (validateRE(regexp, FALSE, status)) { |
| 1058 regexp->fMatcher->setStackLimit(limit, *status); | 1061 regexp->fMatcher->setStackLimit(limit, *status); |
| 1059 } | 1062 } |
| 1060 } | 1063 } |
| 1061 | 1064 |
| 1062 | 1065 |
| 1063 | 1066 |
| 1064 //------------------------------------------------------------------------------ | 1067 //------------------------------------------------------------------------------ |
| 1065 // | 1068 // |
| 1066 // uregex_getStackLimit | 1069 // uregex_getStackLimit |
| 1067 // | 1070 // |
| 1068 //------------------------------------------------------------------------------ | 1071 //------------------------------------------------------------------------------ |
| 1069 U_CAPI int32_t U_EXPORT2 | 1072 U_CAPI int32_t U_EXPORT2 |
| 1070 uregex_getStackLimit(const URegularExpression *regexp2, | 1073 uregex_getStackLimit(const URegularExpression *regexp2, |
| 1071 UErrorCode *status) { | 1074 UErrorCode *status) { |
| 1072 int32_t retVal = 0; | 1075 int32_t retVal = 0; |
| 1073 RegularExpression *regexp = (RegularExpression*)regexp2; | 1076 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1074 if (validateRE(regexp, FALSE, status)) { | 1077 if (validateRE(regexp, FALSE, status)) { |
| 1075 retVal = regexp->fMatcher->getStackLimit(); | 1078 retVal = regexp->fMatcher->getStackLimit(); |
| 1076 } | 1079 } |
| 1077 return retVal; | 1080 return retVal; |
| 1078 } | 1081 } |
| 1079 | 1082 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1093 regexp->fMatcher->setMatchCallback(callback, context, *status); | 1096 regexp->fMatcher->setMatchCallback(callback, context, *status); |
| 1094 } | 1097 } |
| 1095 } | 1098 } |
| 1096 | 1099 |
| 1097 | 1100 |
| 1098 //------------------------------------------------------------------------------ | 1101 //------------------------------------------------------------------------------ |
| 1099 // | 1102 // |
| 1100 // uregex_getMatchCallback | 1103 // uregex_getMatchCallback |
| 1101 // | 1104 // |
| 1102 //------------------------------------------------------------------------------ | 1105 //------------------------------------------------------------------------------ |
| 1103 U_CAPI void U_EXPORT2 | 1106 U_CAPI void U_EXPORT2 |
| 1104 uregex_getMatchCallback(const URegularExpression *regexp2, | 1107 uregex_getMatchCallback(const URegularExpression *regexp2, |
| 1105 URegexMatchCallback **callback, | 1108 URegexMatchCallback **callback, |
| 1106 const void **context, | 1109 const void **context, |
| 1107 UErrorCode *status) { | 1110 UErrorCode *status) { |
| 1108 RegularExpression *regexp = (RegularExpression*)regexp2; | 1111 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1109 if (validateRE(regexp, FALSE, status)) { | 1112 if (validateRE(regexp, FALSE, status)) { |
| 1110 regexp->fMatcher->getMatchCallback(*callback, *context, *status); | 1113 regexp->fMatcher->getMatchCallback(*callback, *context, *status); |
| 1111 } | 1114 } |
| 1112 } | 1115 } |
| 1113 | 1116 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1127 regexp->fMatcher->setFindProgressCallback(callback, context, *status); | 1130 regexp->fMatcher->setFindProgressCallback(callback, context, *status); |
| 1128 } | 1131 } |
| 1129 } | 1132 } |
| 1130 | 1133 |
| 1131 | 1134 |
| 1132 //------------------------------------------------------------------------------ | 1135 //------------------------------------------------------------------------------ |
| 1133 // | 1136 // |
| 1134 // uregex_getMatchCallback | 1137 // uregex_getMatchCallback |
| 1135 // | 1138 // |
| 1136 //------------------------------------------------------------------------------ | 1139 //------------------------------------------------------------------------------ |
| 1137 U_CAPI void U_EXPORT2 | 1140 U_CAPI void U_EXPORT2 |
| 1138 uregex_getFindProgressCallback(const URegularExpression *regexp2, | 1141 uregex_getFindProgressCallback(const URegularExpression *regexp2, |
| 1139 URegexFindProgressCallback **callback, | 1142 URegexFindProgressCallback **callback, |
| 1140 const void **context, | 1143 const void **context, |
| 1141 UErrorCode *status) { | 1144 UErrorCode *status) { |
| 1142 RegularExpression *regexp = (RegularExpression*)regexp2; | 1145 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1143 if (validateRE(regexp, FALSE, status)) { | 1146 if (validateRE(regexp, FALSE, status)) { |
| 1144 regexp->fMatcher->getFindProgressCallback(*callback, *context, *status)
; | 1147 regexp->fMatcher->getFindProgressCallback(*callback, *context, *status)
; |
| 1145 } | 1148 } |
| 1146 } | 1149 } |
| 1147 | 1150 |
| 1148 | 1151 |
| 1149 //------------------------------------------------------------------------------ | 1152 //------------------------------------------------------------------------------ |
| 1150 // | 1153 // |
| 1151 // uregex_replaceAll | 1154 // uregex_replaceAll |
| 1152 // | 1155 // |
| 1153 //------------------------------------------------------------------------------ | 1156 //------------------------------------------------------------------------------ |
| 1154 U_CAPI int32_t U_EXPORT2 | 1157 U_CAPI int32_t U_EXPORT2 |
| 1155 uregex_replaceAll(URegularExpression *regexp2, | 1158 uregex_replaceAll(URegularExpression *regexp2, |
| 1156 const UChar *replacementText, | 1159 const UChar *replacementText, |
| 1157 int32_t replacementLength, | 1160 int32_t replacementLength, |
| 1158 UChar *destBuf, | 1161 UChar *destBuf, |
| 1159 int32_t destCapacity, | 1162 int32_t destCapacity, |
| 1160 UErrorCode *status) { | 1163 UErrorCode *status) { |
| 1161 RegularExpression *regexp = (RegularExpression*)regexp2; | 1164 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1162 if (validateRE(regexp, TRUE, status) == FALSE) { | 1165 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 1163 return 0; | 1166 return 0; |
| 1164 } | 1167 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1177 // are used so that destination buffer overflow errors | 1180 // are used so that destination buffer overflow errors |
| 1178 // in appendReplacement won't stop findNext() from working. | 1181 // in appendReplacement won't stop findNext() from working. |
| 1179 // appendReplacement() and appendTail() special case incoming buffer | 1182 // appendReplacement() and appendTail() special case incoming buffer |
| 1180 // overflow errors, continuing to return the correct length. | 1183 // overflow errors, continuing to return the correct length. |
| 1181 UErrorCode findStatus = *status; | 1184 UErrorCode findStatus = *status; |
| 1182 while (uregex_findNext(regexp2, &findStatus)) { | 1185 while (uregex_findNext(regexp2, &findStatus)) { |
| 1183 len += uregex_appendReplacement(regexp2, replacementText, replacementLen
gth, | 1186 len += uregex_appendReplacement(regexp2, replacementText, replacementLen
gth, |
| 1184 &destBuf, &destCapacity, status); | 1187 &destBuf, &destCapacity, status); |
| 1185 } | 1188 } |
| 1186 len += uregex_appendTail(regexp2, &destBuf, &destCapacity, status); | 1189 len += uregex_appendTail(regexp2, &destBuf, &destCapacity, status); |
| 1187 | 1190 |
| 1188 if (U_FAILURE(findStatus)) { | 1191 if (U_FAILURE(findStatus)) { |
| 1189 // If anything went wrong with the findNext(), make that error trump | 1192 // If anything went wrong with the findNext(), make that error trump |
| 1190 // whatever may have happened with the append() operations. | 1193 // whatever may have happened with the append() operations. |
| 1191 // Errors in findNext() are not expected. | 1194 // Errors in findNext() are not expected. |
| 1192 *status = findStatus; | 1195 *status = findStatus; |
| 1193 } | 1196 } |
| 1194 | 1197 |
| 1195 return len; | 1198 return len; |
| 1196 } | 1199 } |
| 1197 | 1200 |
| 1198 | 1201 |
| 1199 //------------------------------------------------------------------------------ | 1202 //------------------------------------------------------------------------------ |
| 1200 // | 1203 // |
| 1201 // uregex_replaceAllUText | 1204 // uregex_replaceAllUText |
| 1202 // | 1205 // |
| 1203 //------------------------------------------------------------------------------ | 1206 //------------------------------------------------------------------------------ |
| 1204 U_CAPI UText * U_EXPORT2 | 1207 U_CAPI UText * U_EXPORT2 |
| 1205 uregex_replaceAllUText(URegularExpression *regexp2, | 1208 uregex_replaceAllUText(URegularExpression *regexp2, |
| 1206 UText *replacementText, | 1209 UText *replacementText, |
| 1207 UText *dest, | 1210 UText *dest, |
| 1208 UErrorCode *status) { | 1211 UErrorCode *status) { |
| 1209 RegularExpression *regexp = (RegularExpression*)regexp2; | 1212 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1210 if (validateRE(regexp, TRUE, status) == FALSE) { | 1213 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 1211 return 0; | 1214 return 0; |
| 1212 } | 1215 } |
| 1213 if (replacementText == NULL) { | 1216 if (replacementText == NULL) { |
| 1214 *status = U_ILLEGAL_ARGUMENT_ERROR; | 1217 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 1215 return 0; | 1218 return 0; |
| 1216 } | 1219 } |
| 1217 | 1220 |
| 1218 dest = regexp->fMatcher->replaceAll(replacementText, dest, *status); | 1221 dest = regexp->fMatcher->replaceAll(replacementText, dest, *status); |
| 1219 return dest; | 1222 return dest; |
| 1220 } | 1223 } |
| 1221 | 1224 |
| 1222 | 1225 |
| 1223 //------------------------------------------------------------------------------ | 1226 //------------------------------------------------------------------------------ |
| 1224 // | 1227 // |
| 1225 // uregex_replaceFirst | 1228 // uregex_replaceFirst |
| 1226 // | 1229 // |
| 1227 //------------------------------------------------------------------------------ | 1230 //------------------------------------------------------------------------------ |
| 1228 U_CAPI int32_t U_EXPORT2 | 1231 U_CAPI int32_t U_EXPORT2 |
| 1229 uregex_replaceFirst(URegularExpression *regexp2, | 1232 uregex_replaceFirst(URegularExpression *regexp2, |
| 1230 const UChar *replacementText, | 1233 const UChar *replacementText, |
| 1231 int32_t replacementLength, | 1234 int32_t replacementLength, |
| 1232 UChar *destBuf, | 1235 UChar *destBuf, |
| 1233 int32_t destCapacity, | 1236 int32_t destCapacity, |
| 1234 UErrorCode *status) { | 1237 UErrorCode *status) { |
| 1235 RegularExpression *regexp = (RegularExpression*)regexp2; | 1238 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1236 if (validateRE(regexp, TRUE, status) == FALSE) { | 1239 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 1237 return 0; | 1240 return 0; |
| 1238 } | 1241 } |
| 1239 if (replacementText == NULL || replacementLength < -1 || | 1242 if (replacementText == NULL || replacementLength < -1 || |
| 1240 (destBuf == NULL && destCapacity > 0) || | 1243 (destBuf == NULL && destCapacity > 0) || |
| 1241 destCapacity < 0) { | 1244 destCapacity < 0) { |
| 1242 *status = U_ILLEGAL_ARGUMENT_ERROR; | 1245 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 1243 return 0; | 1246 return 0; |
| 1244 } | 1247 } |
| 1245 | 1248 |
| 1246 int32_t len = 0; | 1249 int32_t len = 0; |
| 1247 UBool findSucceeded; | 1250 UBool findSucceeded; |
| 1248 uregex_reset(regexp2, 0, status); | 1251 uregex_reset(regexp2, 0, status); |
| 1249 findSucceeded = uregex_find(regexp2, 0, status); | 1252 findSucceeded = uregex_find(regexp2, 0, status); |
| 1250 if (findSucceeded) { | 1253 if (findSucceeded) { |
| 1251 len = uregex_appendReplacement(regexp2, replacementText, replacementLeng
th, | 1254 len = uregex_appendReplacement(regexp2, replacementText, replacementLeng
th, |
| 1252 &destBuf, &destCapacity, status); | 1255 &destBuf, &destCapacity, status); |
| 1253 } | 1256 } |
| 1254 len += uregex_appendTail(regexp2, &destBuf, &destCapacity, status); | 1257 len += uregex_appendTail(regexp2, &destBuf, &destCapacity, status); |
| 1255 | 1258 |
| 1256 return len; | 1259 return len; |
| 1257 } | 1260 } |
| 1258 | 1261 |
| 1259 | 1262 |
| 1260 //------------------------------------------------------------------------------ | 1263 //------------------------------------------------------------------------------ |
| 1261 // | 1264 // |
| 1262 // uregex_replaceFirstUText | 1265 // uregex_replaceFirstUText |
| 1263 // | 1266 // |
| 1264 //------------------------------------------------------------------------------ | 1267 //------------------------------------------------------------------------------ |
| 1265 U_CAPI UText * U_EXPORT2 | 1268 U_CAPI UText * U_EXPORT2 |
| 1266 uregex_replaceFirstUText(URegularExpression *regexp2, | 1269 uregex_replaceFirstUText(URegularExpression *regexp2, |
| 1267 UText *replacementText, | 1270 UText *replacementText, |
| 1268 UText *dest, | 1271 UText *dest, |
| 1269 UErrorCode *status) { | 1272 UErrorCode *status) { |
| 1270 RegularExpression *regexp = (RegularExpression*)regexp2; | 1273 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1271 if (validateRE(regexp, TRUE, status) == FALSE) { | 1274 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 1272 return 0; | 1275 return 0; |
| 1273 } | 1276 } |
| 1274 if (replacementText == NULL) { | 1277 if (replacementText == NULL) { |
| 1275 *status = U_ILLEGAL_ARGUMENT_ERROR; | 1278 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 1276 return 0; | 1279 return 0; |
| 1277 } | 1280 } |
| 1278 | 1281 |
| 1279 dest = regexp->fMatcher->replaceFirst(replacementText, dest, *status); | 1282 dest = regexp->fMatcher->replaceFirst(replacementText, dest, *status); |
| 1280 return dest; | 1283 return dest; |
| 1281 } | 1284 } |
| 1282 | 1285 |
| 1283 | 1286 |
| 1284 //------------------------------------------------------------------------------ | 1287 //------------------------------------------------------------------------------ |
| 1285 // | 1288 // |
| 1286 // uregex_appendReplacement | 1289 // uregex_appendReplacement |
| 1287 // | 1290 // |
| 1288 //------------------------------------------------------------------------------ | 1291 //------------------------------------------------------------------------------ |
| 1289 | 1292 |
| 1290 U_NAMESPACE_BEGIN | 1293 U_NAMESPACE_BEGIN |
| 1291 // | 1294 // |
| 1292 // Dummy class, because these functions need to be friends of class RegexMatche
r, | 1295 // Dummy class, because these functions need to be friends of class RegexMatche
r, |
| 1293 // and stand-alone C functions don't work as friends | 1296 // and stand-alone C functions don't work as friends |
| 1294 // | 1297 // |
| 1295 class RegexCImpl { | 1298 class RegexCImpl { |
| 1296 public: | 1299 public: |
| 1297 inline static int32_t appendReplacement(RegularExpression *regexp, | 1300 inline static int32_t appendReplacement(RegularExpression *regexp, |
| 1298 const UChar *replacementText, | 1301 const UChar *replacementText, |
| 1299 int32_t replacementLength, | 1302 int32_t replacementLength, |
| 1300 UChar **destBuf, | 1303 UChar **destBuf, |
| 1301 int32_t *destCapacity, | 1304 int32_t *destCapacity, |
| 1302 UErrorCode *status); | 1305 UErrorCode *status); |
| 1303 | 1306 |
| 1304 inline static int32_t appendTail(RegularExpression *regexp, | 1307 inline static int32_t appendTail(RegularExpression *regexp, |
| 1305 UChar **destBuf, | 1308 UChar **destBuf, |
| 1306 int32_t *destCapacity, | 1309 int32_t *destCapacity, |
| 1307 UErrorCode *status); | 1310 UErrorCode *status); |
| 1308 | 1311 |
| 1309 inline static int32_t split(RegularExpression *regexp, | 1312 inline static int32_t split(RegularExpression *regexp, |
| 1310 UChar *destBuf, | 1313 UChar *destBuf, |
| 1311 int32_t destCapacity, | 1314 int32_t destCapacity, |
| 1312 int32_t *requiredCapacity, | 1315 int32_t *requiredCapacity, |
| 1313 UChar *destFields[], | 1316 UChar *destFields[], |
| 1314 int32_t destFieldsCapacity, | 1317 int32_t destFieldsCapacity, |
| 1315 UErrorCode *status); | 1318 UErrorCode *status); |
| 1316 }; | 1319 }; |
| 1317 | 1320 |
| 1318 U_NAMESPACE_END | 1321 U_NAMESPACE_END |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 *status = U_ZERO_ERROR; | 1357 *status = U_ZERO_ERROR; |
| 1355 } | 1358 } |
| 1356 | 1359 |
| 1357 // | 1360 // |
| 1358 // Validate all paramters | 1361 // Validate all paramters |
| 1359 // | 1362 // |
| 1360 if (validateRE(regexp, TRUE, status) == FALSE) { | 1363 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 1361 return 0; | 1364 return 0; |
| 1362 } | 1365 } |
| 1363 if (replacementText == NULL || replacementLength < -1 || | 1366 if (replacementText == NULL || replacementLength < -1 || |
| 1364 destCapacity == NULL || destBuf == NULL || | 1367 destCapacity == NULL || destBuf == NULL || |
| 1365 (*destBuf == NULL && *destCapacity > 0) || | 1368 (*destBuf == NULL && *destCapacity > 0) || |
| 1366 *destCapacity < 0) { | 1369 *destCapacity < 0) { |
| 1367 *status = U_ILLEGAL_ARGUMENT_ERROR; | 1370 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 1368 return 0; | 1371 return 0; |
| 1369 } | 1372 } |
| 1370 | 1373 |
| 1371 RegexMatcher *m = regexp->fMatcher; | 1374 RegexMatcher *m = regexp->fMatcher; |
| 1372 if (m->fMatch == FALSE) { | 1375 if (m->fMatch == FALSE) { |
| 1373 *status = U_REGEX_INVALID_STATE; | 1376 *status = U_REGEX_INVALID_STATE; |
| 1374 return 0; | 1377 return 0; |
| 1375 } | 1378 } |
| 1376 | 1379 |
| 1377 UChar *dest = *destBuf; | 1380 UChar *dest = *destBuf; |
| 1378 int32_t capacity = *destCapacity; | 1381 int32_t capacity = *destCapacity; |
| 1379 int32_t destIdx = 0; | 1382 int32_t destIdx = 0; |
| 1380 int32_t i; | 1383 int32_t i; |
| 1381 | 1384 |
| 1382 // If it wasn't supplied by the caller, get the length of the replacement t
ext. | 1385 // If it wasn't supplied by the caller, get the length of the replacement t
ext. |
| 1383 // TODO: slightly smarter logic in the copy loop could watch for the NUL
on | 1386 // TODO: slightly smarter logic in the copy loop could watch for the NUL
on |
| 1384 // the fly and avoid this step. | 1387 // the fly and avoid this step. |
| 1385 if (replacementLength == -1) { | 1388 if (replacementLength == -1) { |
| 1386 replacementLength = u_strlen(replacementText); | 1389 replacementLength = u_strlen(replacementText); |
| 1387 } | 1390 } |
| 1388 | 1391 |
| 1389 // Copy input string from the end of previous match to start of current matc
h | 1392 // Copy input string from the end of previous match to start of current matc
h |
| 1390 if (regexp->fText != NULL) { | 1393 if (regexp->fText != NULL) { |
| 1391 int32_t matchStart; | 1394 int32_t matchStart; |
| 1392 int32_t lastMatchEnd; | 1395 int32_t lastMatchEnd; |
| 1393 if (UTEXT_USES_U16(m->fInputText)) { | 1396 if (UTEXT_USES_U16(m->fInputText)) { |
| 1394 lastMatchEnd = (int32_t)m->fLastMatchEnd; | 1397 lastMatchEnd = (int32_t)m->fLastMatchEnd; |
| 1395 matchStart = (int32_t)m->fMatchStart; | 1398 matchStart = (int32_t)m->fMatchStart; |
| 1396 } else { | 1399 } else { |
| 1397 // !!!: Would like a better way to do this! | 1400 // !!!: Would like a better way to do this! |
| 1398 UErrorCode status = U_ZERO_ERROR; | 1401 UErrorCode status = U_ZERO_ERROR; |
| 1399 lastMatchEnd = utext_extract(m->fInputText, 0, m->fLastMatchEnd, NUL
L, 0, &status); | 1402 lastMatchEnd = utext_extract(m->fInputText, 0, m->fLastMatchEnd, NUL
L, 0, &status); |
| 1400 status = U_ZERO_ERROR; | 1403 status = U_ZERO_ERROR; |
| 1401 matchStart = lastMatchEnd + utext_extract(m->fInputText, m->fLastMat
chEnd, m->fMatchStart, NULL, 0, &status); | 1404 matchStart = lastMatchEnd + utext_extract(m->fInputText, m->fLastMat
chEnd, m->fMatchStart, NULL, 0, &status); |
| 1402 } | 1405 } |
| 1403 for (i=lastMatchEnd; i<matchStart; i++) { | 1406 for (i=lastMatchEnd; i<matchStart; i++) { |
| 1404 appendToBuf(regexp->fText[i], &destIdx, dest, capacity); | 1407 appendToBuf(regexp->fText[i], &destIdx, dest, capacity); |
| 1405 } | 1408 } |
| 1406 } else { | 1409 } else { |
| 1407 UErrorCode possibleOverflowError = U_ZERO_ERROR; // ignore | 1410 UErrorCode possibleOverflowError = U_ZERO_ERROR; // ignore |
| 1408 destIdx += utext_extract(m->fInputText, m->fLastMatchEnd, m->fMatchStart
, | 1411 destIdx += utext_extract(m->fInputText, m->fLastMatchEnd, m->fMatchStart
, |
| 1409 dest==NULL?NULL:&dest[destIdx], REMAINING_CAPAC
ITY(destIdx, capacity), | 1412 dest==NULL?NULL:&dest[destIdx], REMAINING_CAPAC
ITY(destIdx, capacity), |
| 1410 &possibleOverflowError); | 1413 &possibleOverflowError); |
| 1411 } | 1414 } |
| 1412 U_ASSERT(destIdx >= 0); | 1415 U_ASSERT(destIdx >= 0); |
| 1413 | 1416 |
| 1414 // scan the replacement text, looking for substitutions ($n) and \escapes. | 1417 // scan the replacement text, looking for substitutions ($n) and \escapes. |
| 1415 int32_t replIdx = 0; | 1418 int32_t replIdx = 0; |
| 1416 while (replIdx < replacementLength) { | 1419 while (replIdx < replacementLength) { |
| 1417 UChar c = replacementText[replIdx]; | 1420 UChar c = replacementText[replIdx]; |
| 1418 replIdx++; | 1421 replIdx++; |
| 1419 if (c != DOLLARSIGN && c != BACKSLASH) { | 1422 if (c != DOLLARSIGN && c != BACKSLASH) { |
| 1420 // Common case, no substitution, no escaping, | 1423 // Common case, no substitution, no escaping, |
| 1421 // just copy the char to the dest buf. | 1424 // just copy the char to the dest buf. |
| 1422 appendToBuf(c, &destIdx, dest, capacity); | 1425 appendToBuf(c, &destIdx, dest, capacity); |
| 1423 continue; | 1426 continue; |
| 1424 } | 1427 } |
| 1425 | 1428 |
| 1426 if (c == BACKSLASH) { | 1429 if (c == BACKSLASH) { |
| 1427 // Backslash Escape. Copy the following char out without further ch
ecks. | 1430 // Backslash Escape. Copy the following char out without further ch
ecks. |
| 1428 // Note: Surrogate pairs don't need any special
handling | 1431 // Note: Surrogate pairs don't need any special
handling |
| 1429 // The second half wont be a '$' or a '\',
and | 1432 // The second half wont be a '$' or a '\',
and |
| 1430 // will move to the dest normally on the n
ext | 1433 // will move to the dest normally on the n
ext |
| 1431 // loop iteration. | 1434 // loop iteration. |
| 1432 if (replIdx >= replacementLength) { | 1435 if (replIdx >= replacementLength) { |
| 1433 break; | 1436 break; |
| 1434 } | 1437 } |
| 1435 c = replacementText[replIdx]; | 1438 c = replacementText[replIdx]; |
| 1436 | 1439 |
| 1437 if (c==0x55/*U*/ || c==0x75/*u*/) { | 1440 if (c==0x55/*U*/ || c==0x75/*u*/) { |
| 1438 // We have a \udddd or \Udddddddd escape sequence. | 1441 // We have a \udddd or \Udddddddd escape sequence. |
| 1439 UChar32 escapedChar = | 1442 UChar32 escapedChar = |
| 1440 u_unescapeAt(uregex_ucstr_unescape_charAt, | 1443 u_unescapeAt(uregex_ucstr_unescape_charAt, |
| 1441 &replIdx, // Index is updated by unesca
peAt | 1444 &replIdx, // Index is updated by unesca
peAt |
| 1442 replacementLength, // Length of replacement text | 1445 replacementLength, // Length of replacement text |
| 1443 (void *)replacementText); | 1446 (void *)replacementText); |
| 1444 | 1447 |
| 1445 if (escapedChar != (UChar32)0xFFFFFFFF) { | 1448 if (escapedChar != (UChar32)0xFFFFFFFF) { |
| 1446 if (escapedChar <= 0xffff) { | 1449 if (escapedChar <= 0xffff) { |
| 1447 appendToBuf((UChar)escapedChar, &destIdx, dest, capacity
); | 1450 appendToBuf((UChar)escapedChar, &destIdx, dest, capacity
); |
| 1448 } else { | 1451 } else { |
| 1449 appendToBuf(U16_LEAD(escapedChar), &destIdx, dest, capac
ity); | 1452 appendToBuf(U16_LEAD(escapedChar), &destIdx, dest, capac
ity); |
| 1450 appendToBuf(U16_TRAIL(escapedChar), &destIdx, dest, capa
city); | 1453 appendToBuf(U16_TRAIL(escapedChar), &destIdx, dest, capa
city); |
| 1451 } | 1454 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 // Nul Terminate the dest buffer if possible. | 1520 // Nul Terminate the dest buffer if possible. |
| 1518 // Set the appropriate buffer overflow or not terminated error, if needed. | 1521 // Set the appropriate buffer overflow or not terminated error, if needed. |
| 1519 // | 1522 // |
| 1520 if (destIdx < capacity) { | 1523 if (destIdx < capacity) { |
| 1521 dest[destIdx] = 0; | 1524 dest[destIdx] = 0; |
| 1522 } else if (destIdx == *destCapacity) { | 1525 } else if (destIdx == *destCapacity) { |
| 1523 *status = U_STRING_NOT_TERMINATED_WARNING; | 1526 *status = U_STRING_NOT_TERMINATED_WARNING; |
| 1524 } else { | 1527 } else { |
| 1525 *status = U_BUFFER_OVERFLOW_ERROR; | 1528 *status = U_BUFFER_OVERFLOW_ERROR; |
| 1526 } | 1529 } |
| 1527 | 1530 |
| 1528 // | 1531 // |
| 1529 // Return an updated dest buffer and capacity to the caller. | 1532 // Return an updated dest buffer and capacity to the caller. |
| 1530 // | 1533 // |
| 1531 if (destIdx > 0 && *destCapacity > 0) { | 1534 if (destIdx > 0 && *destCapacity > 0) { |
| 1532 if (destIdx < capacity) { | 1535 if (destIdx < capacity) { |
| 1533 *destBuf += destIdx; | 1536 *destBuf += destIdx; |
| 1534 *destCapacity -= destIdx; | 1537 *destCapacity -= destIdx; |
| 1535 } else { | 1538 } else { |
| 1536 *destBuf += capacity; | 1539 *destBuf += capacity; |
| 1537 *destCapacity = 0; | 1540 *destCapacity = 0; |
| 1538 } | 1541 } |
| 1539 } | 1542 } |
| 1540 | 1543 |
| 1541 // If we came in with a buffer overflow, make sure we go out with one also. | 1544 // If we came in with a buffer overflow, make sure we go out with one also. |
| 1542 // (A zero length match right at the end of the previous match could | 1545 // (A zero length match right at the end of the previous match could |
| 1543 // make this function succeed even though a previous call had overflowed
the buf) | 1546 // make this function succeed even though a previous call had overflowed
the buf) |
| 1544 if (pendingBufferOverflow && U_SUCCESS(*status)) { | 1547 if (pendingBufferOverflow && U_SUCCESS(*status)) { |
| 1545 *status = U_BUFFER_OVERFLOW_ERROR; | 1548 *status = U_BUFFER_OVERFLOW_ERROR; |
| 1546 } | 1549 } |
| 1547 | 1550 |
| 1548 return destIdx; | 1551 return destIdx; |
| 1549 } | 1552 } |
| 1550 | 1553 |
| 1551 // | 1554 // |
| 1552 // appendReplacement the actual API function, | 1555 // appendReplacement the actual API function, |
| 1553 // | 1556 // |
| 1554 U_CAPI int32_t U_EXPORT2 | 1557 U_CAPI int32_t U_EXPORT2 |
| 1555 uregex_appendReplacement(URegularExpression *regexp2, | 1558 uregex_appendReplacement(URegularExpression *regexp2, |
| 1556 const UChar *replacementText, | 1559 const UChar *replacementText, |
| 1557 int32_t replacementLength, | 1560 int32_t replacementLength, |
| 1558 UChar **destBuf, | 1561 UChar **destBuf, |
| 1559 int32_t *destCapacity, | 1562 int32_t *destCapacity, |
| 1560 UErrorCode *status) { | 1563 UErrorCode *status) { |
| 1561 | 1564 |
| 1562 RegularExpression *regexp = (RegularExpression*)regexp2; | 1565 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1563 return RegexCImpl::appendReplacement( | 1566 return RegexCImpl::appendReplacement( |
| 1564 regexp, replacementText, replacementLength,destBuf, destCapacity, status
); | 1567 regexp, replacementText, replacementLength,destBuf, destCapacity, status
); |
| 1565 } | 1568 } |
| 1566 | 1569 |
| 1567 // | 1570 // |
| 1568 // uregex_appendReplacementUText...can just use the normal C++ method | 1571 // uregex_appendReplacementUText...can just use the normal C++ method |
| 1569 // | 1572 // |
| 1570 U_CAPI void U_EXPORT2 | 1573 U_CAPI void U_EXPORT2 |
| 1571 uregex_appendReplacementUText(URegularExpression *regexp2, | 1574 uregex_appendReplacementUText(URegularExpression *regexp2, |
| 1572 UText *replText, | 1575 UText *replText, |
| 1573 UText *dest, | 1576 UText *dest, |
| 1574 UErrorCode *status) { | 1577 UErrorCode *status) { |
| 1575 RegularExpression *regexp = (RegularExpression*)regexp2; | 1578 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1576 regexp->fMatcher->appendReplacement(dest, replText, *status); | 1579 regexp->fMatcher->appendReplacement(dest, replText, *status); |
| 1577 } | 1580 } |
| 1578 | 1581 |
| 1579 | 1582 |
| 1580 //------------------------------------------------------------------------------ | 1583 //------------------------------------------------------------------------------ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1593 // the buffer size when an overflow happens somewhere in the middle. | 1596 // the buffer size when an overflow happens somewhere in the middle. |
| 1594 UBool pendingBufferOverflow = FALSE; | 1597 UBool pendingBufferOverflow = FALSE; |
| 1595 if (*status == U_BUFFER_OVERFLOW_ERROR && destCapacity != NULL && *destCapac
ity == 0) { | 1598 if (*status == U_BUFFER_OVERFLOW_ERROR && destCapacity != NULL && *destCapac
ity == 0) { |
| 1596 pendingBufferOverflow = TRUE; | 1599 pendingBufferOverflow = TRUE; |
| 1597 *status = U_ZERO_ERROR; | 1600 *status = U_ZERO_ERROR; |
| 1598 } | 1601 } |
| 1599 | 1602 |
| 1600 if (validateRE(regexp, TRUE, status) == FALSE) { | 1603 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 1601 return 0; | 1604 return 0; |
| 1602 } | 1605 } |
| 1603 | 1606 |
| 1604 if (destCapacity == NULL || destBuf == NULL || | 1607 if (destCapacity == NULL || destBuf == NULL || |
| 1605 (*destBuf == NULL && *destCapacity > 0) || | 1608 (*destBuf == NULL && *destCapacity > 0) || |
| 1606 *destCapacity < 0) | 1609 *destCapacity < 0) |
| 1607 { | 1610 { |
| 1608 *status = U_ILLEGAL_ARGUMENT_ERROR; | 1611 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 1609 return 0; | 1612 return 0; |
| 1610 } | 1613 } |
| 1611 | 1614 |
| 1612 RegexMatcher *m = regexp->fMatcher; | 1615 RegexMatcher *m = regexp->fMatcher; |
| 1613 | 1616 |
| 1614 int32_t destIdx = 0; | 1617 int32_t destIdx = 0; |
| 1615 int32_t destCap = *destCapacity; | 1618 int32_t destCap = *destCapacity; |
| 1616 UChar *dest = *destBuf; | 1619 UChar *dest = *destBuf; |
| 1617 | 1620 |
| 1618 if (regexp->fText != NULL) { | 1621 if (regexp->fText != NULL) { |
| 1619 int32_t srcIdx; | 1622 int32_t srcIdx; |
| 1620 int64_t nativeIdx = (m->fMatch ? m->fMatchEnd : m->fLastMatchEnd); | 1623 int64_t nativeIdx = (m->fMatch ? m->fMatchEnd : m->fLastMatchEnd); |
| 1621 if (nativeIdx == -1) { | 1624 if (nativeIdx == -1) { |
| 1622 srcIdx = 0; | 1625 srcIdx = 0; |
| 1623 } else if (UTEXT_USES_U16(m->fInputText)) { | 1626 } else if (UTEXT_USES_U16(m->fInputText)) { |
| 1624 srcIdx = (int32_t)nativeIdx; | 1627 srcIdx = (int32_t)nativeIdx; |
| 1625 } else { | 1628 } else { |
| 1626 UErrorCode status = U_ZERO_ERROR; | 1629 UErrorCode status = U_ZERO_ERROR; |
| 1627 srcIdx = utext_extract(m->fInputText, 0, nativeIdx, NULL, 0, &status
); | 1630 srcIdx = utext_extract(m->fInputText, 0, nativeIdx, NULL, 0, &status
); |
| 1628 } | 1631 } |
| 1629 | 1632 |
| 1630 for (;;) { | 1633 for (;;) { |
| 1631 U_ASSERT(destIdx >= 0); | 1634 U_ASSERT(destIdx >= 0); |
| 1632 | 1635 |
| 1633 if (srcIdx == regexp->fTextLength) { | 1636 if (srcIdx == regexp->fTextLength) { |
| 1634 break; | 1637 break; |
| 1635 } | 1638 } |
| 1636 UChar c = regexp->fText[srcIdx]; | 1639 UChar c = regexp->fText[srcIdx]; |
| 1637 if (c == 0 && regexp->fTextLength == -1) { | 1640 if (c == 0 && regexp->fTextLength == -1) { |
| 1638 regexp->fTextLength = srcIdx; | 1641 regexp->fTextLength = srcIdx; |
| 1639 break; | 1642 break; |
| 1640 } | 1643 } |
| 1641 | 1644 |
| 1642 if (destIdx < destCap) { | 1645 if (destIdx < destCap) { |
| 1643 dest[destIdx] = c; | 1646 dest[destIdx] = c; |
| 1644 } else { | 1647 } else { |
| 1645 // We've overflowed the dest buffer. | 1648 // We've overflowed the dest buffer. |
| 1646 // If the total input string length is known, we can | 1649 // If the total input string length is known, we can |
| 1647 // compute the total buffer size needed without scanning thro
ugh the string. | 1650 // compute the total buffer size needed without scanning thro
ugh the string. |
| 1648 if (regexp->fTextLength > 0) { | 1651 if (regexp->fTextLength > 0) { |
| 1649 destIdx += (regexp->fTextLength - srcIdx); | 1652 destIdx += (regexp->fTextLength - srcIdx); |
| 1650 break; | 1653 break; |
| 1651 } | 1654 } |
| 1652 } | 1655 } |
| 1653 srcIdx++; | 1656 srcIdx++; |
| 1654 destIdx++; | 1657 destIdx++; |
| 1655 } | 1658 } |
| 1656 } else { | 1659 } else { |
| 1657 int64_t srcIdx; | 1660 int64_t srcIdx; |
| 1658 if (m->fMatch) { | 1661 if (m->fMatch) { |
| 1659 // The most recent call to find() succeeded. | 1662 // The most recent call to find() succeeded. |
| 1660 srcIdx = m->fMatchEnd; | 1663 srcIdx = m->fMatchEnd; |
| 1661 } else { | 1664 } else { |
| 1662 // The last call to find() on this matcher failed(). | 1665 // The last call to find() on this matcher failed(). |
| 1663 // Look back to the end of the last find() that succeeded for src
index. | 1666 // Look back to the end of the last find() that succeeded for src
index. |
| 1664 srcIdx = m->fLastMatchEnd; | 1667 srcIdx = m->fLastMatchEnd; |
| 1665 if (srcIdx == -1) { | 1668 if (srcIdx == -1) { |
| 1666 // There has been no successful match with this matcher. | 1669 // There has been no successful match with this matcher. |
| 1667 // We want to copy the whole string. | 1670 // We want to copy the whole string. |
| 1668 srcIdx = 0; | 1671 srcIdx = 0; |
| 1669 } | 1672 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1700 *status = U_BUFFER_OVERFLOW_ERROR; | 1703 *status = U_BUFFER_OVERFLOW_ERROR; |
| 1701 } | 1704 } |
| 1702 | 1705 |
| 1703 return destIdx; | 1706 return destIdx; |
| 1704 } | 1707 } |
| 1705 | 1708 |
| 1706 | 1709 |
| 1707 // | 1710 // |
| 1708 // appendTail the actual API function | 1711 // appendTail the actual API function |
| 1709 // | 1712 // |
| 1710 U_CAPI int32_t U_EXPORT2 | 1713 U_CAPI int32_t U_EXPORT2 |
| 1711 uregex_appendTail(URegularExpression *regexp2, | 1714 uregex_appendTail(URegularExpression *regexp2, |
| 1712 UChar **destBuf, | 1715 UChar **destBuf, |
| 1713 int32_t *destCapacity, | 1716 int32_t *destCapacity, |
| 1714 UErrorCode *status) { | 1717 UErrorCode *status) { |
| 1715 RegularExpression *regexp = (RegularExpression*)regexp2; | 1718 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1716 return RegexCImpl::appendTail(regexp, destBuf, destCapacity, status); | 1719 return RegexCImpl::appendTail(regexp, destBuf, destCapacity, status); |
| 1717 } | 1720 } |
| 1718 | 1721 |
| 1719 | 1722 |
| 1720 // | 1723 // |
| 1721 // uregex_appendTailUText...can just use the normal C++ method | 1724 // uregex_appendTailUText...can just use the normal C++ method |
| 1722 // | 1725 // |
| 1723 U_CAPI UText * U_EXPORT2 | 1726 U_CAPI UText * U_EXPORT2 |
| 1724 uregex_appendTailUText(URegularExpression *regexp2, | 1727 uregex_appendTailUText(URegularExpression *regexp2, |
| 1725 UText *dest, | 1728 UText *dest, |
| 1726 UErrorCode *status) { | 1729 UErrorCode *status) { |
| 1727 RegularExpression *regexp = (RegularExpression*)regexp2; | 1730 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1728 return regexp->fMatcher->appendTail(dest, *status); | 1731 return regexp->fMatcher->appendTail(dest, *status); |
| 1729 } | 1732 } |
| 1730 | 1733 |
| 1731 | 1734 |
| 1732 //------------------------------------------------------------------------------ | 1735 //------------------------------------------------------------------------------ |
| 1733 // | 1736 // |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 // capture groups of the delimiter expression, in which case we w
ill discard the | 1808 // capture groups of the delimiter expression, in which case we w
ill discard the |
| 1806 // last capture group saved in favor of the unprocessed remainder
of the | 1809 // last capture group saved in favor of the unprocessed remainder
of the |
| 1807 // input string.) | 1810 // input string.) |
| 1808 if (inputLen > nextOutputStringStart) { | 1811 if (inputLen > nextOutputStringStart) { |
| 1809 if (i != destFieldsCapacity-1) { | 1812 if (i != destFieldsCapacity-1) { |
| 1810 // No fields are left. Recycle the last one for holding the
trailing part of | 1813 // No fields are left. Recycle the last one for holding the
trailing part of |
| 1811 // the input string. | 1814 // the input string. |
| 1812 i = destFieldsCapacity-1; | 1815 i = destFieldsCapacity-1; |
| 1813 destIdx = (int32_t)(destFields[i] - destFields[0]); | 1816 destIdx = (int32_t)(destFields[i] - destFields[0]); |
| 1814 } | 1817 } |
| 1815 | 1818 |
| 1816 destFields[i] = &destBuf[destIdx]; | 1819 destFields[i] = &destBuf[destIdx]; |
| 1817 destIdx += 1 + utext_extract(inputText, nextOutputStringStart, i
nputLen, | 1820 destIdx += 1 + utext_extract(inputText, nextOutputStringStart, i
nputLen, |
| 1818 &destBuf[destIdx], REMAINING_CAPACI
TY(destIdx, destCapacity), status); | 1821 &destBuf[destIdx], REMAINING_CAPACI
TY(destIdx, destCapacity), status); |
| 1819 } | 1822 } |
| 1820 break; | 1823 break; |
| 1821 } | 1824 } |
| 1822 | 1825 |
| 1823 if (regexp->fMatcher->find()) { | 1826 if (regexp->fMatcher->find()) { |
| 1824 // We found another delimiter. Move everything from where we starte
d looking | 1827 // We found another delimiter. Move everything from where we starte
d looking |
| 1825 // up until the start of the delimiter into the next output string. | 1828 // up until the start of the delimiter into the next output string. |
| 1826 destFields[i] = &destBuf[destIdx]; | 1829 destFields[i] = &destBuf[destIdx]; |
| 1827 | 1830 |
| 1828 destIdx += 1 + utext_extract(inputText, nextOutputStringStart, regex
p->fMatcher->fMatchStart, | 1831 destIdx += 1 + utext_extract(inputText, nextOutputStringStart, regex
p->fMatcher->fMatchStart, |
| 1829 &destBuf[destIdx], REMAINING_CAPACITY(d
estIdx, destCapacity), &tStatus); | 1832 &destBuf[destIdx], REMAINING_CAPACITY(d
estIdx, destCapacity), &tStatus); |
| 1830 if (tStatus == U_BUFFER_OVERFLOW_ERROR) { | 1833 if (tStatus == U_BUFFER_OVERFLOW_ERROR) { |
| 1831 tStatus = U_ZERO_ERROR; | 1834 tStatus = U_ZERO_ERROR; |
| 1832 } else { | 1835 } else { |
| 1833 *status = tStatus; | 1836 *status = tStatus; |
| 1834 } | 1837 } |
| 1835 nextOutputStringStart = regexp->fMatcher->fMatchEnd; | 1838 nextOutputStringStart = regexp->fMatcher->fMatchEnd; |
| 1836 | 1839 |
| 1837 // If the delimiter pattern has capturing parentheses, the captured | 1840 // If the delimiter pattern has capturing parentheses, the captured |
| 1838 // text goes out into the next n destination strings. | 1841 // text goes out into the next n destination strings. |
| 1839 int32_t groupNum; | 1842 int32_t groupNum; |
| 1840 for (groupNum=1; groupNum<=numCaptureGroups; groupNum++) { | 1843 for (groupNum=1; groupNum<=numCaptureGroups; groupNum++) { |
| 1841 // If we've run out of output string slots, bail out. | 1844 // If we've run out of output string slots, bail out. |
| 1842 if (i==destFieldsCapacity-1) { | 1845 if (i==destFieldsCapacity-1) { |
| 1843 break; | 1846 break; |
| 1844 } | 1847 } |
| 1845 i++; | 1848 i++; |
| 1846 | 1849 |
| 1847 // Set up to extract the capture group contents into the dest bu
ffer. | 1850 // Set up to extract the capture group contents into the dest bu
ffer. |
| 1848 destFields[i] = &destBuf[destIdx]; | 1851 destFields[i] = &destBuf[destIdx]; |
| 1849 tStatus = U_ZERO_ERROR; | 1852 tStatus = U_ZERO_ERROR; |
| 1850 int32_t t = uregex_group((URegularExpression*)regexp, | 1853 int32_t t = uregex_group((URegularExpression*)regexp, |
| 1851 groupNum, | 1854 groupNum, |
| 1852 destFields[i], | 1855 destFields[i], |
| 1853 REMAINING_CAPACITY(destIdx, destCapacit
y), | 1856 REMAINING_CAPACITY(destIdx, destCapacit
y), |
| 1854 &tStatus); | 1857 &tStatus); |
| 1855 destIdx += t + 1; // Record the space used in the output stri
ng buffer. | 1858 destIdx += t + 1; // Record the space used in the output stri
ng buffer. |
| 1856 // +1 for the NUL that terminates the stri
ng. | 1859 // +1 for the NUL that terminates the stri
ng. |
| 1857 if (tStatus == U_BUFFER_OVERFLOW_ERROR) { | 1860 if (tStatus == U_BUFFER_OVERFLOW_ERROR) { |
| 1858 tStatus = U_ZERO_ERROR; | 1861 tStatus = U_ZERO_ERROR; |
| 1859 } else { | 1862 } else { |
| 1860 *status = tStatus; | 1863 *status = tStatus; |
| 1861 } | 1864 } |
| 1862 } | 1865 } |
| 1863 | 1866 |
| 1864 if (nextOutputStringStart == inputLen) { | 1867 if (nextOutputStringStart == inputLen) { |
| 1865 // The delimiter was at the end of the string. | 1868 // The delimiter was at the end of the string. |
| 1866 // Output an empty string, and then we are done. | 1869 // Output an empty string, and then we are done. |
| 1867 if (destIdx < destCapacity) { | 1870 if (destIdx < destCapacity) { |
| 1868 destBuf[destIdx] = 0; | 1871 destBuf[destIdx] = 0; |
| 1869 } | 1872 } |
| 1870 if (i < destFieldsCapacity-1) { | 1873 if (i < destFieldsCapacity-1) { |
| 1871 ++i; | 1874 ++i; |
| 1872 } | 1875 } |
| 1873 if (destIdx < destCapacity) { | 1876 if (destIdx < destCapacity) { |
| 1874 destFields[i] = destBuf + destIdx; | 1877 destFields[i] = destBuf + destIdx; |
| 1875 } | 1878 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1900 } | 1903 } |
| 1901 if (destIdx > destCapacity) { | 1904 if (destIdx > destCapacity) { |
| 1902 *status = U_BUFFER_OVERFLOW_ERROR; | 1905 *status = U_BUFFER_OVERFLOW_ERROR; |
| 1903 } | 1906 } |
| 1904 return i+1; | 1907 return i+1; |
| 1905 } | 1908 } |
| 1906 | 1909 |
| 1907 // | 1910 // |
| 1908 // uregex_split The actual API function | 1911 // uregex_split The actual API function |
| 1909 // | 1912 // |
| 1910 U_CAPI int32_t U_EXPORT2 | 1913 U_CAPI int32_t U_EXPORT2 |
| 1911 uregex_split(URegularExpression *regexp2, | 1914 uregex_split(URegularExpression *regexp2, |
| 1912 UChar *destBuf, | 1915 UChar *destBuf, |
| 1913 int32_t destCapacity, | 1916 int32_t destCapacity, |
| 1914 int32_t *requiredCapacity, | 1917 int32_t *requiredCapacity, |
| 1915 UChar *destFields[], | 1918 UChar *destFields[], |
| 1916 int32_t destFieldsCapacity, | 1919 int32_t destFieldsCapacity, |
| 1917 UErrorCode *status) { | 1920 UErrorCode *status) { |
| 1918 RegularExpression *regexp = (RegularExpression*)regexp2; | 1921 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1919 if (validateRE(regexp, TRUE, status) == FALSE) { | 1922 if (validateRE(regexp, TRUE, status) == FALSE) { |
| 1920 return 0; | 1923 return 0; |
| 1921 } | 1924 } |
| 1922 if ((destBuf == NULL && destCapacity > 0) || | 1925 if ((destBuf == NULL && destCapacity > 0) || |
| 1923 destCapacity < 0 || | 1926 destCapacity < 0 || |
| 1924 destFields == NULL || | 1927 destFields == NULL || |
| 1925 destFieldsCapacity < 1 ) { | 1928 destFieldsCapacity < 1 ) { |
| 1926 *status = U_ILLEGAL_ARGUMENT_ERROR; | 1929 *status = U_ILLEGAL_ARGUMENT_ERROR; |
| 1927 return 0; | 1930 return 0; |
| 1928 } | 1931 } |
| 1929 | 1932 |
| 1930 return RegexCImpl::split(regexp, destBuf, destCapacity, requiredCapacity, de
stFields, destFieldsCapacity, status); | 1933 return RegexCImpl::split(regexp, destBuf, destCapacity, requiredCapacity, de
stFields, destFieldsCapacity, status); |
| 1931 } | 1934 } |
| 1932 | 1935 |
| 1933 | 1936 |
| 1934 // | 1937 // |
| 1935 // uregex_splitUText...can just use the normal C++ method | 1938 // uregex_splitUText...can just use the normal C++ method |
| 1936 // | 1939 // |
| 1937 U_CAPI int32_t U_EXPORT2 | 1940 U_CAPI int32_t U_EXPORT2 |
| 1938 uregex_splitUText(URegularExpression *regexp2, | 1941 uregex_splitUText(URegularExpression *regexp2, |
| 1939 UText *destFields[], | 1942 UText *destFields[], |
| 1940 int32_t destFieldsCapacity, | 1943 int32_t destFieldsCapacity, |
| 1941 UErrorCode *status) { | 1944 UErrorCode *status) { |
| 1942 RegularExpression *regexp = (RegularExpression*)regexp2; | 1945 RegularExpression *regexp = (RegularExpression*)regexp2; |
| 1943 return regexp->fMatcher->split(regexp->fMatcher->inputText(), destFields, de
stFieldsCapacity, *status); | 1946 return regexp->fMatcher->split(regexp->fMatcher->inputText(), destFields, de
stFieldsCapacity, *status); |
| 1944 } | 1947 } |
| 1945 | 1948 |
| 1946 | 1949 |
| 1947 #endif // !UCONFIG_NO_REGULAR_EXPRESSIONS | 1950 #endif // !UCONFIG_NO_REGULAR_EXPRESSIONS |
| 1948 | 1951 |
| OLD | NEW |