summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/i18n/regeximp.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /intl/icu/source/i18n/regeximp.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'intl/icu/source/i18n/regeximp.cpp')
-rw-r--r--intl/icu/source/i18n/regeximp.cpp122
1 files changed, 122 insertions, 0 deletions
diff --git a/intl/icu/source/i18n/regeximp.cpp b/intl/icu/source/i18n/regeximp.cpp
new file mode 100644
index 000000000..6c476e733
--- /dev/null
+++ b/intl/icu/source/i18n/regeximp.cpp
@@ -0,0 +1,122 @@
+// Copyright (C) 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+//
+// Copyright (C) 2012 International Business Machines Corporation
+// and others. All rights reserved.
+//
+// file: regeximp.cpp
+//
+// ICU Regular Expressions,
+// miscellaneous implementation functions.
+//
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_REGULAR_EXPRESSIONS
+#include "regeximp.h"
+#include "unicode/utf16.h"
+
+U_NAMESPACE_BEGIN
+
+CaseFoldingUTextIterator::CaseFoldingUTextIterator(UText &text) :
+ fUText(text), fcsp(NULL), fFoldChars(NULL), fFoldLength(0) {
+ fcsp = ucase_getSingleton();
+}
+
+CaseFoldingUTextIterator::~CaseFoldingUTextIterator() {}
+
+UChar32 CaseFoldingUTextIterator::next() {
+ UChar32 foldedC;
+ UChar32 originalC;
+ if (fFoldChars == NULL) {
+ // We are not in a string folding of an earlier character.
+ // Start handling the next char from the input UText.
+ originalC = UTEXT_NEXT32(&fUText);
+ if (originalC == U_SENTINEL) {
+ return originalC;
+ }
+ fFoldLength = ucase_toFullFolding(fcsp, originalC, &fFoldChars, U_FOLD_CASE_DEFAULT);
+ if (fFoldLength >= UCASE_MAX_STRING_LENGTH || fFoldLength < 0) {
+ // input code point folds to a single code point, possibly itself.
+ // See comment in ucase.h for explanation of return values from ucase_toFullFoldings.
+ if (fFoldLength < 0) {
+ fFoldLength = ~fFoldLength;
+ }
+ foldedC = (UChar32)fFoldLength;
+ fFoldChars = NULL;
+ return foldedC;
+ }
+ // String foldings fall through here.
+ fFoldIndex = 0;
+ }
+
+ U16_NEXT(fFoldChars, fFoldIndex, fFoldLength, foldedC);
+ if (fFoldIndex >= fFoldLength) {
+ fFoldChars = NULL;
+ }
+ return foldedC;
+}
+
+
+UBool CaseFoldingUTextIterator::inExpansion() {
+ return fFoldChars != NULL;
+}
+
+
+
+CaseFoldingUCharIterator::CaseFoldingUCharIterator(const UChar *chars, int64_t start, int64_t limit) :
+ fChars(chars), fIndex(start), fLimit(limit), fcsp(NULL), fFoldChars(NULL), fFoldLength(0) {
+ fcsp = ucase_getSingleton();
+}
+
+
+CaseFoldingUCharIterator::~CaseFoldingUCharIterator() {}
+
+
+UChar32 CaseFoldingUCharIterator::next() {
+ UChar32 foldedC;
+ UChar32 originalC;
+ if (fFoldChars == NULL) {
+ // We are not in a string folding of an earlier character.
+ // Start handling the next char from the input UText.
+ if (fIndex >= fLimit) {
+ return U_SENTINEL;
+ }
+ U16_NEXT(fChars, fIndex, fLimit, originalC);
+
+ fFoldLength = ucase_toFullFolding(fcsp, originalC, &fFoldChars, U_FOLD_CASE_DEFAULT);
+ if (fFoldLength >= UCASE_MAX_STRING_LENGTH || fFoldLength < 0) {
+ // input code point folds to a single code point, possibly itself.
+ // See comment in ucase.h for explanation of return values from ucase_toFullFoldings.
+ if (fFoldLength < 0) {
+ fFoldLength = ~fFoldLength;
+ }
+ foldedC = (UChar32)fFoldLength;
+ fFoldChars = NULL;
+ return foldedC;
+ }
+ // String foldings fall through here.
+ fFoldIndex = 0;
+ }
+
+ U16_NEXT(fFoldChars, fFoldIndex, fFoldLength, foldedC);
+ if (fFoldIndex >= fFoldLength) {
+ fFoldChars = NULL;
+ }
+ return foldedC;
+}
+
+
+UBool CaseFoldingUCharIterator::inExpansion() {
+ return fFoldChars != NULL;
+}
+
+int64_t CaseFoldingUCharIterator::getIndex() {
+ return fIndex;
+}
+
+
+U_NAMESPACE_END
+
+#endif
+