ICU-2628 Don't delete const objects on z/OS

X-SVN-Rev: 11713
This commit is contained in:
George Rhoten 2003-04-25 23:38:20 +00:00
parent bbf546a40e
commit 5cc89c0134
2 changed files with 14 additions and 12 deletions

View File

@ -35,7 +35,7 @@ U_NAMESPACE_BEGIN
//-----------------------------------------------------------------------------
RegexMatcher::RegexMatcher(const RegexPattern *pat) {
fPattern = pat;
fPatternOwned = FALSE;
fPatternOwned = NULL;
fInput = NULL;
fTraceDebug = FALSE;
fDeferredStatus = U_ZERO_ERROR;
@ -45,7 +45,7 @@ RegexMatcher::RegexMatcher(const RegexPattern *pat) {
fDeferredStatus = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
if (pat->fDataSize > sizeof(fSmallData)/sizeof(int32_t)) {
if (pat->fDataSize > (int32_t)(sizeof(fSmallData)/sizeof(int32_t))) {
fData = (int32_t *)uprv_malloc(pat->fDataSize * sizeof(int32_t));
}
if (fStack == NULL || fData == NULL) {
@ -60,8 +60,8 @@ RegexMatcher::RegexMatcher(const RegexPattern *pat) {
RegexMatcher::RegexMatcher(const UnicodeString &regexp, const UnicodeString &input,
uint32_t flags, UErrorCode &status) {
UParseError pe;
fPattern = RegexPattern::compile(regexp, flags, pe, status);
fPatternOwned = TRUE;
fPatternOwned = RegexPattern::compile(regexp, flags, pe, status);
fPattern = fPatternOwned;
fTraceDebug = FALSE;
fDeferredStatus = U_ZERO_ERROR;
fStack = new UVector32(status);
@ -69,7 +69,7 @@ RegexMatcher::RegexMatcher(const UnicodeString &regexp, const UnicodeString &inp
if (U_FAILURE(status)) {
return;
}
if (fPattern->fDataSize > sizeof(fSmallData)/sizeof(int32_t)) {
if (fPattern->fDataSize > (int32_t)(sizeof(fSmallData)/sizeof(int32_t))) {
fData = (int32_t *)uprv_malloc(fPattern->fDataSize * sizeof(int32_t));
}
if (fStack == NULL || fData == NULL) {
@ -82,17 +82,17 @@ RegexMatcher::RegexMatcher(const UnicodeString &regexp, const UnicodeString &inp
RegexMatcher::RegexMatcher(const UnicodeString &regexp,
uint32_t flags, UErrorCode &status) {
UParseError pe;
fPatternOwned = TRUE;
fTraceDebug = FALSE;
fDeferredStatus = U_ZERO_ERROR;
fStack = new UVector32(status);
fData = fSmallData;
fPattern = RegexPattern::compile(regexp, flags, pe, status);
fPatternOwned = RegexPattern::compile(regexp, flags, pe, status);
fPattern = fPatternOwned;
if (U_FAILURE(status)) {
return;
}
if (fPattern->fDataSize > sizeof(fSmallData)/sizeof(int32_t)) {
if (fPattern->fDataSize > (int32_t)(sizeof(fSmallData)/sizeof(int32_t))) {
fData = (int32_t *)uprv_malloc(fPattern->fDataSize * sizeof(int32_t));
}
if (fStack == NULL || fData == NULL) {
@ -110,7 +110,8 @@ RegexMatcher::~RegexMatcher() {
fData = NULL;
}
if (fPatternOwned) {
delete fPattern;
delete fPatternOwned;
fPatternOwned = NULL;
fPattern = NULL;
}
}
@ -2098,7 +2099,7 @@ breakFromLoop:
if (fTraceDebug) {
REGEX_RUN_DEBUG_PRINTF("Match. start=%d end=%d\n\n", fMatchStart, fMatchEnd);
}
}
}
else
{
if (fTraceDebug) {

View File

@ -459,6 +459,7 @@ public:
* its matcher() method to create the RegexMatcher objects.
*
* @param regexp The Regular Expression to be compiled.
* @param input The string to match
* @param flags Regular expression options, such as case insensitive matching.
* @see UREGEX_CASE_INSENSITIVE
* @param status Any errors are reported by setting this UErrorCode variable.
@ -544,7 +545,7 @@ public:
* Returns a string containing the text captured by the given group
* during the previous match operation. Group(0) is the entire match.
*
* @param group the capture group number
* @param groupNum the capture group number
* @param status A reference to a UErrorCode to receive any errors.
* Possible errors are U_REGEX_INVALID_STATE if no match
* has been attempted or the last match failed and
@ -816,7 +817,7 @@ private:
const RegexPattern *fPattern;
UBool fPatternOwned; // True if this matcher owns the pattern, and
RegexPattern *fPatternOwned; // Non-NULL if this matcher owns the pattern, and
// should delete it when through.
const UnicodeString *fInput;