2002-10-22 00:09:32 +00:00
|
|
|
//
|
2007-12-11 21:30:10 +00:00
|
|
|
// file: repattrn.cpp
|
2002-10-22 00:09:32 +00:00
|
|
|
//
|
|
|
|
/*
|
2003-03-21 00:40:25 +00:00
|
|
|
***************************************************************************
|
2013-10-14 22:11:21 +00:00
|
|
|
* Copyright (C) 2002-2013 International Business Machines Corporation *
|
2003-03-21 00:40:25 +00:00
|
|
|
* and others. All rights reserved. *
|
|
|
|
***************************************************************************
|
2002-10-22 00:09:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
2002-11-07 02:34:46 +00:00
|
|
|
|
|
|
|
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
|
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
#include "unicode/regex.h"
|
2003-08-22 23:26:53 +00:00
|
|
|
#include "unicode/uclean.h"
|
2002-10-22 00:09:32 +00:00
|
|
|
#include "uassert.h"
|
|
|
|
#include "uvector.h"
|
2003-01-08 23:38:23 +00:00
|
|
|
#include "uvectr32.h"
|
2010-02-25 06:33:29 +00:00
|
|
|
#include "uvectr64.h"
|
2002-10-22 00:09:32 +00:00
|
|
|
#include "regexcmp.h"
|
|
|
|
#include "regeximp.h"
|
2003-05-02 21:33:17 +00:00
|
|
|
#include "regexst.h"
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2002-10-23 01:14:17 +00:00
|
|
|
// RegexPattern Default Constructor
|
2002-10-22 00:09:32 +00:00
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
RegexPattern::RegexPattern() {
|
2010-02-03 02:59:35 +00:00
|
|
|
// Init all of this instances data.
|
|
|
|
init();
|
2004-12-30 07:25:51 +00:00
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copy Constructor Note: This is a rather inefficient implementation,
|
|
|
|
// but it probably doesn't matter.
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
RegexPattern::RegexPattern(const RegexPattern &other) : UObject(other) {
|
2007-12-11 21:30:10 +00:00
|
|
|
init();
|
2002-10-23 01:14:17 +00:00
|
|
|
*this = other;
|
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2010-02-03 02:59:35 +00:00
|
|
|
// Assignment Operator
|
2002-10-23 01:14:17 +00:00
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
RegexPattern &RegexPattern::operator = (const RegexPattern &other) {
|
|
|
|
if (this == &other) {
|
|
|
|
// Source and destination are the same. Don't do anything.
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clean out any previous contents of object being assigned to.
|
|
|
|
zap();
|
|
|
|
|
|
|
|
// Give target object a default initialization
|
|
|
|
init();
|
|
|
|
|
|
|
|
// Copy simple fields
|
2010-02-11 06:57:20 +00:00
|
|
|
if ( other.fPatternString == NULL ) {
|
|
|
|
fPatternString = NULL;
|
|
|
|
fPattern = utext_clone(fPattern, other.fPattern, FALSE, TRUE, &fDeferredStatus);
|
|
|
|
} else {
|
|
|
|
fPatternString = new UnicodeString(*(other.fPatternString));
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
fPattern = utext_openConstUnicodeString(NULL, fPatternString, &status);
|
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
2002-10-23 01:14:17 +00:00
|
|
|
fFlags = other.fFlags;
|
|
|
|
fLiteralText = other.fLiteralText;
|
2003-03-21 00:40:25 +00:00
|
|
|
fDeferredStatus = other.fDeferredStatus;
|
2003-02-26 05:16:49 +00:00
|
|
|
fMinMatchLen = other.fMinMatchLen;
|
2004-01-08 00:40:59 +00:00
|
|
|
fFrameSize = other.fFrameSize;
|
|
|
|
fDataSize = other.fDataSize;
|
2002-10-24 22:16:07 +00:00
|
|
|
fMaxCaptureDigits = other.fMaxCaptureDigits;
|
2007-12-11 21:30:10 +00:00
|
|
|
fStaticSets = other.fStaticSets;
|
2004-01-08 00:40:59 +00:00
|
|
|
fStaticSets8 = other.fStaticSets8;
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2003-03-06 01:57:52 +00:00
|
|
|
fStartType = other.fStartType;
|
2003-03-13 01:56:01 +00:00
|
|
|
fInitialStringIdx = other.fInitialStringIdx;
|
|
|
|
fInitialStringLen = other.fInitialStringLen;
|
2003-03-28 02:31:17 +00:00
|
|
|
*fInitialChars = *other.fInitialChars;
|
2003-03-13 01:56:01 +00:00
|
|
|
fInitialChar = other.fInitialChar;
|
2004-01-08 00:40:59 +00:00
|
|
|
*fInitialChars8 = *other.fInitialChars8;
|
2010-02-03 02:59:35 +00:00
|
|
|
fNeedsAltInput = other.fNeedsAltInput;
|
2002-10-23 01:14:17 +00:00
|
|
|
|
|
|
|
// Copy the pattern. It's just values, nothing deep to copy.
|
2003-03-21 00:40:25 +00:00
|
|
|
fCompiledPat->assign(*other.fCompiledPat, fDeferredStatus);
|
|
|
|
fGroupMap->assign(*other.fGroupMap, fDeferredStatus);
|
2002-10-23 01:14:17 +00:00
|
|
|
|
2007-12-11 21:30:10 +00:00
|
|
|
// Copy the Unicode Sets.
|
2002-10-23 01:14:17 +00:00
|
|
|
// Could be made more efficient if the sets were reference counted and shared,
|
2007-12-11 21:30:10 +00:00
|
|
|
// but I doubt that pattern copying will be particularly common.
|
2002-11-14 18:27:00 +00:00
|
|
|
// Note: init() already added an empty element zero to fSets
|
2003-01-16 01:12:04 +00:00
|
|
|
int32_t i;
|
2003-03-28 02:31:17 +00:00
|
|
|
int32_t numSets = other.fSets->size();
|
|
|
|
fSets8 = new Regex8BitSet[numSets];
|
2008-01-14 23:25:13 +00:00
|
|
|
if (fSets8 == NULL) {
|
|
|
|
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return *this;
|
|
|
|
}
|
2003-03-28 02:31:17 +00:00
|
|
|
for (i=1; i<numSets; i++) {
|
2003-03-21 00:40:25 +00:00
|
|
|
if (U_FAILURE(fDeferredStatus)) {
|
|
|
|
return *this;
|
|
|
|
}
|
2002-10-23 01:14:17 +00:00
|
|
|
UnicodeSet *sourceSet = (UnicodeSet *)other.fSets->elementAt(i);
|
|
|
|
UnicodeSet *newSet = new UnicodeSet(*sourceSet);
|
|
|
|
if (newSet == NULL) {
|
2003-03-21 00:40:25 +00:00
|
|
|
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
|
2002-10-23 01:14:17 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-03-21 00:40:25 +00:00
|
|
|
fSets->addElement(newSet, fDeferredStatus);
|
2003-03-28 02:31:17 +00:00
|
|
|
fSets8[i] = other.fSets8[i];
|
2002-10-22 00:09:32 +00:00
|
|
|
}
|
2003-03-27 01:25:20 +00:00
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// init Shared initialization for use by constructors.
|
|
|
|
// Bring an uninitialized RegexPattern up to a default state.
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
void RegexPattern::init() {
|
|
|
|
fFlags = 0;
|
2004-01-08 00:40:59 +00:00
|
|
|
fCompiledPat = 0;
|
|
|
|
fLiteralText.remove();
|
|
|
|
fSets = NULL;
|
|
|
|
fSets8 = NULL;
|
2003-03-21 00:40:25 +00:00
|
|
|
fDeferredStatus = U_ZERO_ERROR;
|
2003-02-26 05:16:49 +00:00
|
|
|
fMinMatchLen = 0;
|
2003-01-16 01:12:04 +00:00
|
|
|
fFrameSize = 0;
|
2003-01-17 01:43:54 +00:00
|
|
|
fDataSize = 0;
|
2004-01-08 00:40:59 +00:00
|
|
|
fGroupMap = NULL;
|
2007-12-11 21:30:10 +00:00
|
|
|
fMaxCaptureDigits = 1;
|
2004-01-08 00:40:59 +00:00
|
|
|
fStaticSets = NULL;
|
|
|
|
fStaticSets8 = NULL;
|
2003-03-06 01:57:52 +00:00
|
|
|
fStartType = START_NO_INFO;
|
2003-03-13 01:56:01 +00:00
|
|
|
fInitialStringIdx = 0;
|
|
|
|
fInitialStringLen = 0;
|
|
|
|
fInitialChars = NULL;
|
|
|
|
fInitialChar = 0;
|
2004-01-08 00:40:59 +00:00
|
|
|
fInitialChars8 = NULL;
|
2010-02-03 02:59:35 +00:00
|
|
|
fNeedsAltInput = FALSE;
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
fPattern = NULL; // will be set later
|
2010-02-11 06:57:20 +00:00
|
|
|
fPatternString = NULL; // may be set later
|
2010-02-25 06:33:29 +00:00
|
|
|
fCompiledPat = new UVector64(fDeferredStatus);
|
2003-03-21 00:40:25 +00:00
|
|
|
fGroupMap = new UVector32(fDeferredStatus);
|
|
|
|
fSets = new UVector(fDeferredStatus);
|
|
|
|
fInitialChars = new UnicodeSet;
|
2003-03-27 01:25:20 +00:00
|
|
|
fInitialChars8 = new Regex8BitSet;
|
2003-03-21 00:40:25 +00:00
|
|
|
if (U_FAILURE(fDeferredStatus)) {
|
|
|
|
return;
|
|
|
|
}
|
2003-03-27 01:25:20 +00:00
|
|
|
if (fCompiledPat == NULL || fGroupMap == NULL || fSets == NULL ||
|
|
|
|
fInitialChars == NULL || fInitialChars8 == NULL) {
|
2003-03-21 00:40:25 +00:00
|
|
|
fDeferredStatus = U_MEMORY_ALLOCATION_ERROR;
|
2002-10-23 01:14:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Slot zero of the vector of sets is reserved. Fill it here.
|
2003-03-21 00:40:25 +00:00
|
|
|
fSets->addElement((int32_t)0, fDeferredStatus);
|
2002-10-23 01:14:17 +00:00
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2007-12-11 21:30:10 +00:00
|
|
|
// zap Delete everything owned by this RegexPattern.
|
2002-10-23 01:14:17 +00:00
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
void RegexPattern::zap() {
|
2002-10-22 00:09:32 +00:00
|
|
|
delete fCompiledPat;
|
2002-10-23 01:14:17 +00:00
|
|
|
fCompiledPat = NULL;
|
2002-10-22 00:09:32 +00:00
|
|
|
int i;
|
2002-11-14 18:27:00 +00:00
|
|
|
for (i=1; i<fSets->size(); i++) {
|
2002-10-22 00:09:32 +00:00
|
|
|
UnicodeSet *s;
|
|
|
|
s = (UnicodeSet *)fSets->elementAt(i);
|
|
|
|
if (s != NULL) {
|
|
|
|
delete s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete fSets;
|
|
|
|
fSets = NULL;
|
2004-01-08 00:40:59 +00:00
|
|
|
delete[] fSets8;
|
|
|
|
fSets8 = NULL;
|
2003-01-16 01:12:04 +00:00
|
|
|
delete fGroupMap;
|
|
|
|
fGroupMap = NULL;
|
2003-03-13 01:56:01 +00:00
|
|
|
delete fInitialChars;
|
|
|
|
fInitialChars = NULL;
|
2003-03-27 01:25:20 +00:00
|
|
|
delete fInitialChars8;
|
|
|
|
fInitialChars8 = NULL;
|
2010-02-03 02:59:35 +00:00
|
|
|
if (fPattern != NULL) {
|
|
|
|
utext_close(fPattern);
|
2010-02-11 06:57:20 +00:00
|
|
|
fPattern = NULL;
|
|
|
|
}
|
|
|
|
if (fPatternString != NULL) {
|
|
|
|
delete fPatternString;
|
|
|
|
fPatternString = NULL;
|
2010-02-03 02:59:35 +00:00
|
|
|
}
|
2002-10-23 01:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Destructor
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
RegexPattern::~RegexPattern() {
|
|
|
|
zap();
|
2004-12-30 07:25:51 +00:00
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Clone
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
2007-12-11 21:30:10 +00:00
|
|
|
RegexPattern *RegexPattern::clone() const {
|
2002-10-22 00:09:32 +00:00
|
|
|
RegexPattern *copy = new RegexPattern(*this);
|
|
|
|
return copy;
|
2004-12-30 07:25:51 +00:00
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// operator == (comparison) Consider to patterns to be == if the
|
|
|
|
// pattern strings and the flags are the same.
|
2010-02-03 02:59:35 +00:00
|
|
|
// Note that pattern strings with the same
|
|
|
|
// characters can still be considered different.
|
2002-10-23 01:14:17 +00:00
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
UBool RegexPattern::operator ==(const RegexPattern &other) const {
|
2010-02-11 06:57:20 +00:00
|
|
|
if (this->fFlags == other.fFlags && this->fDeferredStatus == other.fDeferredStatus) {
|
|
|
|
if (this->fPatternString != NULL && other.fPatternString != NULL) {
|
|
|
|
return *(this->fPatternString) == *(other.fPatternString);
|
|
|
|
} else if (this->fPattern == NULL) {
|
|
|
|
if (other.fPattern == NULL) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
} else if (other.fPattern != NULL) {
|
2010-02-03 02:59:35 +00:00
|
|
|
UTEXT_SETNATIVEINDEX(this->fPattern, 0);
|
|
|
|
UTEXT_SETNATIVEINDEX(other.fPattern, 0);
|
2010-02-11 06:57:20 +00:00
|
|
|
return utext_equals(this->fPattern, other.fPattern);
|
2010-02-03 02:59:35 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-11 06:57:20 +00:00
|
|
|
return FALSE;
|
2002-10-23 01:14:17 +00:00
|
|
|
}
|
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
2007-12-11 21:30:10 +00:00
|
|
|
// compile
|
2002-10-22 00:09:32 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
2004-08-24 17:38:33 +00:00
|
|
|
RegexPattern * U_EXPORT2
|
|
|
|
RegexPattern::compile(const UnicodeString ®ex,
|
|
|
|
uint32_t flags,
|
|
|
|
UParseError &pe,
|
|
|
|
UErrorCode &status)
|
|
|
|
{
|
2010-02-03 02:59:35 +00:00
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
const uint32_t allFlags = UREGEX_CANON_EQ | UREGEX_CASE_INSENSITIVE | UREGEX_COMMENTS |
|
|
|
|
UREGEX_DOTALL | UREGEX_MULTILINE | UREGEX_UWORD |
|
2010-02-27 03:40:56 +00:00
|
|
|
UREGEX_ERROR_ON_UNKNOWN_ESCAPES | UREGEX_UNIX_LINES | UREGEX_LITERAL;
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
if ((flags & ~allFlags) != 0) {
|
|
|
|
status = U_REGEX_INVALID_FLAG;
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2012-02-15 01:30:55 +00:00
|
|
|
if ((flags & UREGEX_CANON_EQ) != 0) {
|
2010-02-03 02:59:35 +00:00
|
|
|
status = U_REGEX_UNIMPLEMENTED;
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
RegexPattern *This = new RegexPattern;
|
|
|
|
if (This == NULL) {
|
|
|
|
status = U_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (U_FAILURE(This->fDeferredStatus)) {
|
|
|
|
status = This->fDeferredStatus;
|
|
|
|
delete This;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
This->fFlags = flags;
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
RegexCompile compiler(This, status);
|
|
|
|
compiler.compile(regex, pe, status);
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
delete This;
|
|
|
|
This = NULL;
|
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
return This;
|
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// compile, UText mode
|
|
|
|
//
|
|
|
|
RegexPattern * U_EXPORT2
|
|
|
|
RegexPattern::compile(UText *regex,
|
|
|
|
uint32_t flags,
|
|
|
|
UParseError &pe,
|
|
|
|
UErrorCode &status)
|
|
|
|
{
|
2002-11-14 18:27:00 +00:00
|
|
|
if (U_FAILURE(status)) {
|
2002-10-22 00:09:32 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-02-07 02:04:14 +00:00
|
|
|
|
|
|
|
const uint32_t allFlags = UREGEX_CANON_EQ | UREGEX_CASE_INSENSITIVE | UREGEX_COMMENTS |
|
2007-12-11 21:30:10 +00:00
|
|
|
UREGEX_DOTALL | UREGEX_MULTILINE | UREGEX_UWORD |
|
2010-02-27 03:40:56 +00:00
|
|
|
UREGEX_ERROR_ON_UNKNOWN_ESCAPES | UREGEX_UNIX_LINES | UREGEX_LITERAL;
|
2003-02-07 02:04:14 +00:00
|
|
|
|
|
|
|
if ((flags & ~allFlags) != 0) {
|
|
|
|
status = U_REGEX_INVALID_FLAG;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-02-15 01:30:55 +00:00
|
|
|
if ((flags & UREGEX_CANON_EQ) != 0) {
|
2002-11-14 18:27:00 +00:00
|
|
|
status = U_REGEX_UNIMPLEMENTED;
|
2002-11-11 18:49:49 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
RegexPattern *This = new RegexPattern;
|
|
|
|
if (This == NULL) {
|
2002-11-14 18:27:00 +00:00
|
|
|
status = U_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-03-21 00:40:25 +00:00
|
|
|
if (U_FAILURE(This->fDeferredStatus)) {
|
|
|
|
status = This->fDeferredStatus;
|
2008-02-17 18:26:39 +00:00
|
|
|
delete This;
|
2002-10-22 00:09:32 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-23 01:14:17 +00:00
|
|
|
This->fFlags = flags;
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2003-02-11 01:17:51 +00:00
|
|
|
RegexCompile compiler(This, status);
|
|
|
|
compiler.compile(regex, pe, status);
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2007-12-11 21:30:10 +00:00
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
delete This;
|
|
|
|
This = NULL;
|
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
return This;
|
2004-12-30 07:25:51 +00:00
|
|
|
}
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
//
|
|
|
|
// compile with default flags.
|
|
|
|
//
|
2004-08-24 17:38:33 +00:00
|
|
|
RegexPattern * U_EXPORT2
|
|
|
|
RegexPattern::compile(const UnicodeString ®ex,
|
|
|
|
UParseError &pe,
|
2007-12-11 21:30:10 +00:00
|
|
|
UErrorCode &err)
|
2002-10-23 01:14:17 +00:00
|
|
|
{
|
2007-12-11 21:30:10 +00:00
|
|
|
return compile(regex, 0, pe, err);
|
2002-10-23 01:14:17 +00:00
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
//
|
|
|
|
// compile with default flags, UText mode
|
|
|
|
//
|
|
|
|
RegexPattern * U_EXPORT2
|
|
|
|
RegexPattern::compile(UText *regex,
|
|
|
|
UParseError &pe,
|
|
|
|
UErrorCode &err)
|
|
|
|
{
|
|
|
|
return compile(regex, 0, pe, err);
|
|
|
|
}
|
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2003-03-24 05:23:07 +00:00
|
|
|
//
|
|
|
|
// compile with no UParseErr parameter.
|
|
|
|
//
|
2004-08-24 17:38:33 +00:00
|
|
|
RegexPattern * U_EXPORT2
|
2010-02-03 02:59:35 +00:00
|
|
|
RegexPattern::compile(const UnicodeString ®ex,
|
|
|
|
uint32_t flags,
|
|
|
|
UErrorCode &err)
|
2003-03-24 05:23:07 +00:00
|
|
|
{
|
|
|
|
UParseError pe;
|
2007-12-11 21:30:10 +00:00
|
|
|
return compile(regex, flags, pe, err);
|
2003-03-24 05:23:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
//
|
|
|
|
// compile with no UParseErr parameter, UText mode
|
|
|
|
//
|
|
|
|
RegexPattern * U_EXPORT2
|
|
|
|
RegexPattern::compile(UText *regex,
|
|
|
|
uint32_t flags,
|
|
|
|
UErrorCode &err)
|
|
|
|
{
|
|
|
|
UParseError pe;
|
|
|
|
return compile(regex, flags, pe, err);
|
|
|
|
}
|
|
|
|
|
2003-03-24 05:23:07 +00:00
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// flags
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
2002-11-19 19:31:03 +00:00
|
|
|
uint32_t RegexPattern::flags() const {
|
2002-10-22 00:09:32 +00:00
|
|
|
return fFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// matcher(UnicodeString, err)
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
RegexMatcher *RegexPattern::matcher(const UnicodeString &input,
|
2003-03-21 00:40:25 +00:00
|
|
|
UErrorCode &status) const {
|
2003-03-24 05:23:07 +00:00
|
|
|
RegexMatcher *retMatcher = matcher(status);
|
|
|
|
if (retMatcher != NULL) {
|
2010-02-03 02:59:35 +00:00
|
|
|
retMatcher->fDeferredStatus = status;
|
|
|
|
retMatcher->reset(input);
|
|
|
|
}
|
|
|
|
return retMatcher;
|
|
|
|
}
|
|
|
|
|
2003-03-24 05:23:07 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// matcher(status)
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
RegexMatcher *RegexPattern::matcher(UErrorCode &status) const {
|
2002-10-22 00:09:32 +00:00
|
|
|
RegexMatcher *retMatcher = NULL;
|
|
|
|
|
2003-03-21 00:40:25 +00:00
|
|
|
if (U_FAILURE(status)) {
|
2002-11-14 18:27:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-03-21 00:40:25 +00:00
|
|
|
if (U_FAILURE(fDeferredStatus)) {
|
|
|
|
status = fDeferredStatus;
|
2002-11-14 18:27:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2007-12-11 21:30:10 +00:00
|
|
|
retMatcher = new RegexMatcher(this);
|
2002-10-22 00:09:32 +00:00
|
|
|
if (retMatcher == NULL) {
|
2003-03-21 00:40:25 +00:00
|
|
|
status = U_MEMORY_ALLOCATION_ERROR;
|
2002-10-22 00:09:32 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return retMatcher;
|
2004-12-30 07:25:51 +00:00
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// matches Convenience function to test for a match, starting
|
|
|
|
// with a pattern string and a data string.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
2004-08-24 17:38:33 +00:00
|
|
|
UBool U_EXPORT2 RegexPattern::matches(const UnicodeString ®ex,
|
2002-10-23 01:14:17 +00:00
|
|
|
const UnicodeString &input,
|
|
|
|
UParseError &pe,
|
|
|
|
UErrorCode &status) {
|
|
|
|
|
2002-11-14 18:27:00 +00:00
|
|
|
if (U_FAILURE(status)) {return FALSE;}
|
|
|
|
|
|
|
|
UBool retVal;
|
2002-10-23 01:14:17 +00:00
|
|
|
RegexPattern *pat = NULL;
|
|
|
|
RegexMatcher *matcher = NULL;
|
|
|
|
|
2002-11-14 18:27:00 +00:00
|
|
|
pat = RegexPattern::compile(regex, 0, pe, status);
|
2002-10-23 01:14:17 +00:00
|
|
|
matcher = pat->matcher(input, status);
|
2002-11-14 18:27:00 +00:00
|
|
|
retVal = matcher->matches(status);
|
2002-10-23 01:14:17 +00:00
|
|
|
|
|
|
|
delete matcher;
|
|
|
|
delete pat;
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
//
|
|
|
|
// matches, UText mode
|
|
|
|
//
|
|
|
|
UBool U_EXPORT2 RegexPattern::matches(UText *regex,
|
|
|
|
UText *input,
|
|
|
|
UParseError &pe,
|
|
|
|
UErrorCode &status) {
|
|
|
|
|
|
|
|
if (U_FAILURE(status)) {return FALSE;}
|
|
|
|
|
2011-04-21 22:57:19 +00:00
|
|
|
UBool retVal = FALSE;
|
2010-02-03 02:59:35 +00:00
|
|
|
RegexPattern *pat = NULL;
|
|
|
|
RegexMatcher *matcher = NULL;
|
|
|
|
|
|
|
|
pat = RegexPattern::compile(regex, 0, pe, status);
|
2011-04-21 22:57:19 +00:00
|
|
|
matcher = pat->matcher(status);
|
|
|
|
if (U_SUCCESS(status)) {
|
|
|
|
matcher->reset(input);
|
|
|
|
retVal = matcher->matches(status);
|
|
|
|
}
|
2010-02-03 02:59:35 +00:00
|
|
|
|
|
|
|
delete matcher;
|
|
|
|
delete pat;
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-23 01:14:17 +00:00
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// pattern
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
UnicodeString RegexPattern::pattern() const {
|
2010-02-11 06:57:20 +00:00
|
|
|
if (fPatternString != NULL) {
|
|
|
|
return *fPatternString;
|
|
|
|
} else if (fPattern == NULL) {
|
2010-02-03 02:59:35 +00:00
|
|
|
return UnicodeString();
|
|
|
|
} else {
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
int64_t nativeLen = utext_nativeLength(fPattern);
|
|
|
|
int32_t len16 = utext_extract(fPattern, 0, nativeLen, NULL, 0, &status); // buffer overflow error
|
|
|
|
UnicodeString result;
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
status = U_ZERO_ERROR;
|
|
|
|
UChar *resultChars = result.getBuffer(len16);
|
|
|
|
utext_extract(fPattern, 0, nativeLen, resultChars, len16, &status); // unterminated warning
|
|
|
|
result.releaseBuffer(len16);
|
2013-10-14 22:11:21 +00:00
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
return result;
|
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// patternText
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
2010-09-18 03:07:17 +00:00
|
|
|
UText *RegexPattern::patternText(UErrorCode &status) const {
|
|
|
|
if (U_FAILURE(status)) {return NULL;}
|
|
|
|
status = U_ZERO_ERROR;
|
|
|
|
|
2010-02-03 02:59:35 +00:00
|
|
|
if (fPattern != NULL) {
|
|
|
|
return fPattern;
|
|
|
|
} else {
|
|
|
|
RegexStaticSets::initGlobals(&status);
|
|
|
|
return RegexStaticSets::gStaticSets->fEmptyText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-22 00:09:32 +00:00
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// split
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
2002-10-23 01:14:17 +00:00
|
|
|
int32_t RegexPattern::split(const UnicodeString &input,
|
2002-10-22 00:09:32 +00:00
|
|
|
UnicodeString dest[],
|
2002-10-23 16:38:10 +00:00
|
|
|
int32_t destCapacity,
|
2010-02-03 02:59:35 +00:00
|
|
|
UErrorCode &status) const
|
|
|
|
{
|
|
|
|
if (U_FAILURE(status)) {
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
RegexMatcher m(this);
|
|
|
|
int32_t r = 0;
|
|
|
|
// Check m's status to make sure all is ok.
|
|
|
|
if (U_SUCCESS(m.fDeferredStatus)) {
|
|
|
|
r = m.split(input, dest, destCapacity, status);
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// split, UText mode
|
|
|
|
//
|
|
|
|
int32_t RegexPattern::split(UText *input,
|
|
|
|
UText *dest[],
|
|
|
|
int32_t destCapacity,
|
|
|
|
UErrorCode &status) const
|
2002-10-22 00:09:32 +00:00
|
|
|
{
|
2002-10-23 16:38:10 +00:00
|
|
|
if (U_FAILURE(status)) {
|
2002-10-22 00:09:32 +00:00
|
|
|
return 0;
|
|
|
|
};
|
2002-10-23 16:38:10 +00:00
|
|
|
|
2003-03-24 05:23:07 +00:00
|
|
|
RegexMatcher m(this);
|
2008-01-14 23:25:13 +00:00
|
|
|
int32_t r = 0;
|
|
|
|
// Check m's status to make sure all is ok.
|
|
|
|
if (U_SUCCESS(m.fDeferredStatus)) {
|
|
|
|
r = m.split(input, dest, destCapacity, status);
|
|
|
|
}
|
2003-03-24 05:23:07 +00:00
|
|
|
return r;
|
2002-10-22 00:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// dump Output the compiled form of the pattern.
|
|
|
|
// Debugging function only.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------
|
2003-12-02 19:14:26 +00:00
|
|
|
void RegexPattern::dumpOp(int32_t index) const {
|
2013-10-14 22:11:21 +00:00
|
|
|
(void)index; // Suppress warnings in non-debug build.
|
|
|
|
#if defined(REGEX_DEBUG)
|
2003-04-18 21:43:25 +00:00
|
|
|
static const char * const opNames[] = {URX_OPCODE_NAMES};
|
2002-11-19 19:31:03 +00:00
|
|
|
int32_t op = fCompiledPat->elementAti(index);
|
|
|
|
int32_t val = URX_VAL(op);
|
|
|
|
int32_t type = URX_TYPE(op);
|
|
|
|
int32_t pinnedType = type;
|
2007-12-11 21:30:10 +00:00
|
|
|
if ((uint32_t)pinnedType >= sizeof(opNames)/sizeof(char *)) {
|
2002-11-19 19:31:03 +00:00
|
|
|
pinnedType = 0;
|
|
|
|
}
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%4d %08x %-15s ", index, op, opNames[pinnedType]);
|
2002-11-19 19:31:03 +00:00
|
|
|
switch (type) {
|
|
|
|
case URX_NOP:
|
|
|
|
case URX_DOTANY:
|
2003-03-26 01:17:16 +00:00
|
|
|
case URX_DOTANY_ALL:
|
2002-11-19 19:31:03 +00:00
|
|
|
case URX_FAIL:
|
2003-02-12 01:28:01 +00:00
|
|
|
case URX_CARET:
|
|
|
|
case URX_DOLLAR:
|
2002-11-19 19:31:03 +00:00
|
|
|
case URX_BACKSLASH_G:
|
|
|
|
case URX_BACKSLASH_X:
|
|
|
|
case URX_END:
|
2003-02-12 01:28:01 +00:00
|
|
|
case URX_DOLLAR_M:
|
|
|
|
case URX_CARET_M:
|
2002-11-19 19:31:03 +00:00
|
|
|
// Types with no operand field of interest.
|
|
|
|
break;
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2003-01-16 01:12:04 +00:00
|
|
|
case URX_RESERVED_OP:
|
2002-11-19 19:31:03 +00:00
|
|
|
case URX_START_CAPTURE:
|
|
|
|
case URX_END_CAPTURE:
|
|
|
|
case URX_STATE_SAVE:
|
|
|
|
case URX_JMP:
|
2003-03-18 01:51:36 +00:00
|
|
|
case URX_JMP_SAV:
|
2003-03-26 01:17:16 +00:00
|
|
|
case URX_JMP_SAV_X:
|
2002-11-19 19:31:03 +00:00
|
|
|
case URX_BACKSLASH_B:
|
2003-11-08 02:01:42 +00:00
|
|
|
case URX_BACKSLASH_BU:
|
2002-11-19 19:31:03 +00:00
|
|
|
case URX_BACKSLASH_D:
|
|
|
|
case URX_BACKSLASH_Z:
|
|
|
|
case URX_STRING_LEN:
|
2003-01-16 01:12:04 +00:00
|
|
|
case URX_CTR_INIT:
|
|
|
|
case URX_CTR_INIT_NG:
|
|
|
|
case URX_CTR_LOOP:
|
|
|
|
case URX_CTR_LOOP_NG:
|
|
|
|
case URX_RELOC_OPRND:
|
2003-01-17 01:43:54 +00:00
|
|
|
case URX_STO_SP:
|
|
|
|
case URX_LD_SP:
|
2003-01-25 18:57:42 +00:00
|
|
|
case URX_BACKREF:
|
|
|
|
case URX_STO_INP_LOC:
|
|
|
|
case URX_JMPX:
|
2003-02-07 02:04:14 +00:00
|
|
|
case URX_LA_START:
|
|
|
|
case URX_LA_END:
|
2003-02-12 01:28:01 +00:00
|
|
|
case URX_BACKREF_I:
|
2003-03-02 19:11:09 +00:00
|
|
|
case URX_LB_START:
|
|
|
|
case URX_LB_CONT:
|
|
|
|
case URX_LB_END:
|
|
|
|
case URX_LBN_CONT:
|
|
|
|
case URX_LBN_END:
|
2003-03-28 02:31:17 +00:00
|
|
|
case URX_LOOP_C:
|
2003-04-02 23:10:16 +00:00
|
|
|
case URX_LOOP_DOT_I:
|
2002-11-19 19:31:03 +00:00
|
|
|
// types with an integer operand field.
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%d", val);
|
2002-11-19 19:31:03 +00:00
|
|
|
break;
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2002-11-19 19:31:03 +00:00
|
|
|
case URX_ONECHAR:
|
2003-02-07 02:04:14 +00:00
|
|
|
case URX_ONECHAR_I:
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%c", val<256?val:'?');
|
2002-11-19 19:31:03 +00:00
|
|
|
break;
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2002-11-19 19:31:03 +00:00
|
|
|
case URX_STRING:
|
2003-02-07 02:04:14 +00:00
|
|
|
case URX_STRING_I:
|
2002-11-19 19:31:03 +00:00
|
|
|
{
|
|
|
|
int32_t lengthOp = fCompiledPat->elementAti(index+1);
|
|
|
|
U_ASSERT(URX_TYPE(lengthOp) == URX_STRING_LEN);
|
|
|
|
int32_t length = URX_VAL(lengthOp);
|
|
|
|
int32_t i;
|
|
|
|
for (i=val; i<val+length; i++) {
|
|
|
|
UChar c = fLiteralText[i];
|
|
|
|
if (c < 32 || c >= 256) {c = '.';}
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%c", c);
|
2002-11-19 19:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2002-11-19 19:31:03 +00:00
|
|
|
case URX_SETREF:
|
2003-03-28 02:31:17 +00:00
|
|
|
case URX_LOOP_SR_I:
|
2002-11-19 19:31:03 +00:00
|
|
|
{
|
|
|
|
UnicodeString s;
|
|
|
|
UnicodeSet *set = (UnicodeSet *)fSets->elementAt(val);
|
|
|
|
set->toPattern(s, TRUE);
|
|
|
|
for (int32_t i=0; i<s.length(); i++) {
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%c", s.charAt(i));
|
2002-11-19 19:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
2002-11-20 23:30:20 +00:00
|
|
|
break;
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2002-11-20 23:30:20 +00:00
|
|
|
case URX_STATIC_SETREF:
|
2003-03-27 01:25:20 +00:00
|
|
|
case URX_STAT_SETREF_N:
|
2002-11-20 23:30:20 +00:00
|
|
|
{
|
|
|
|
UnicodeString s;
|
|
|
|
if (val & URX_NEG_SET) {
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("NOT ");
|
2002-11-20 23:30:20 +00:00
|
|
|
val &= ~URX_NEG_SET;
|
|
|
|
}
|
|
|
|
UnicodeSet *set = fStaticSets[val];
|
|
|
|
set->toPattern(s, TRUE);
|
|
|
|
for (int32_t i=0; i<s.length(); i++) {
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%c", s.charAt(i));
|
2002-11-20 23:30:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-11-19 19:31:03 +00:00
|
|
|
|
2007-12-11 21:30:10 +00:00
|
|
|
|
2002-11-19 19:31:03 +00:00
|
|
|
default:
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("??????");
|
2002-11-19 19:31:03 +00:00
|
|
|
break;
|
2002-10-22 00:09:32 +00:00
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("\n");
|
2003-12-02 19:14:26 +00:00
|
|
|
#endif
|
2013-10-14 22:11:21 +00:00
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
|
2013-10-15 21:19:27 +00:00
|
|
|
void RegexPattern::dumpPattern() const {
|
2013-10-14 22:11:21 +00:00
|
|
|
#if defined(REGEX_DEBUG)
|
2002-11-19 19:31:03 +00:00
|
|
|
int index;
|
|
|
|
int i;
|
|
|
|
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("Original Pattern: ");
|
|
|
|
UChar32 c = utext_next32From(fPattern, 0);
|
2010-02-03 02:59:35 +00:00
|
|
|
while (c != U_SENTINEL) {
|
|
|
|
if (c<32 || c>256) {
|
|
|
|
c = '.';
|
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%c", c);
|
|
|
|
|
|
|
|
c = UTEXT_NEXT32(fPattern);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
printf(" Min Match Length: %d\n", fMinMatchLen);
|
|
|
|
printf(" Match Start Type: %s\n", START_OF_MATCH_STR(fStartType));
|
|
|
|
if (fStartType == START_STRING) {
|
|
|
|
printf(" Initial match string: \"");
|
|
|
|
for (i=fInitialStringIdx; i<fInitialStringIdx+fInitialStringLen; i++) {
|
|
|
|
printf("%c", fLiteralText[i]); // TODO: non-printables, surrogates.
|
2003-03-13 01:56:01 +00:00
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("\"\n");
|
2003-03-13 01:56:01 +00:00
|
|
|
|
2013-10-14 22:11:21 +00:00
|
|
|
} else if (fStartType == START_SET) {
|
|
|
|
int32_t numSetChars = fInitialChars->size();
|
2003-03-13 01:56:01 +00:00
|
|
|
if (numSetChars > 20) {
|
|
|
|
numSetChars = 20;
|
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
printf(" Match First Chars : ");
|
2003-03-13 01:56:01 +00:00
|
|
|
for (i=0; i<numSetChars; i++) {
|
2013-10-14 22:11:21 +00:00
|
|
|
UChar32 c = fInitialChars->charAt(i);
|
2007-12-11 21:30:10 +00:00
|
|
|
if (0x20<c && c <0x7e) {
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%c ", c);
|
2003-03-13 01:56:01 +00:00
|
|
|
} else {
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%#x ", c);
|
2003-03-13 01:56:01 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
if (numSetChars < fInitialChars->size()) {
|
|
|
|
printf(" ...");
|
2003-03-13 01:56:01 +00:00
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("\n");
|
2003-03-13 01:56:01 +00:00
|
|
|
|
2013-10-14 22:11:21 +00:00
|
|
|
} else if (fStartType == START_CHAR) {
|
|
|
|
printf(" First char of Match : ");
|
|
|
|
if (0x20 < fInitialChar && fInitialChar<0x7e) {
|
|
|
|
printf("%c\n", fInitialChar);
|
2003-03-13 01:56:01 +00:00
|
|
|
} else {
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("%#x\n", fInitialChar);
|
2003-03-13 01:56:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("\nIndex Binary Type Operand\n" \
|
|
|
|
"-------------------------------------------\n");
|
|
|
|
for (index = 0; index<fCompiledPat->size(); index++) {
|
|
|
|
dumpOp(index);
|
2002-10-22 00:09:32 +00:00
|
|
|
}
|
2013-10-14 22:11:21 +00:00
|
|
|
printf("\n\n");
|
2003-12-06 01:49:56 +00:00
|
|
|
#endif
|
2013-10-14 22:11:21 +00:00
|
|
|
}
|
2002-10-22 00:09:32 +00:00
|
|
|
|
2003-03-13 01:56:01 +00:00
|
|
|
|
|
|
|
|
2003-08-31 20:53:46 +00:00
|
|
|
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RegexPattern)
|
2002-10-22 00:09:32 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|
2002-11-07 02:34:46 +00:00
|
|
|
#endif // !UCONFIG_NO_REGULAR_EXPRESSIONS
|