From 90ddb0c280ac959481c411ecfc640561a580a3d9 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 7 Nov 2001 07:15:54 +0000 Subject: #94096# Improved last fix (fixed Regexp::getRegexp()). --- ucb/source/regexp/regexp.cxx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'ucb/source/regexp') diff --git a/ucb/source/regexp/regexp.cxx b/ucb/source/regexp/regexp.cxx index c58d3163eadd..bfa48a08b8f1 100644 --- a/ucb/source/regexp/regexp.cxx +++ b/ucb/source/regexp/regexp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: regexp.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: sb $ $Date: 2001-11-02 12:34:11 $ + * last change: $Author: sb $ $Date: 2001-11-07 08:15:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -235,20 +235,21 @@ inline bool isDigit(sal_Unicode c) return c >= '0' && c <= '9'; } -bool isScheme(rtl::OUString const & rString) +bool isScheme(rtl::OUString const & rString, bool bColon) { - // Return true if rString matches from RFC 2396: + // Return true if rString matches (plus a trailing ":" if bColon + // is true) from RFC 2396: sal_Unicode const * p = rString.getStr(); sal_Unicode const * pEnd = p + rString.getLength(); if (p != pEnd && isAlpha(*p)) for (++p;;) { if (p == pEnd) - return true; + return !bColon; sal_Unicode c = *p++; if (!(isAlpha(c) || isDigit(c) || c == '+' || c == '-' || c == '.')) - break; + return bColon && c == ':' && p == pEnd; } return false; } @@ -322,8 +323,8 @@ rtl::OUString Regexp::getRegexp(bool bReverse) const aBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("\\1")); return aBuffer.makeStringAndClear(); } - else if (m_eKind == KIND_PREFIX && isScheme(m_aPrefix)) - return m_aPrefix; + else if (m_eKind == KIND_PREFIX && isScheme(m_aPrefix, true)) + return m_aPrefix.copy(0, m_aPrefix.getLength() - 1); else { rtl::OUStringBuffer aBuffer; @@ -415,7 +416,7 @@ Regexp Regexp::parse(rtl::OUString const & rRegexp) { // Detect an input of '' as an abbreviation of '":".*' // where is as defined in RFC 2396: - if (isScheme(rRegexp)) + if (isScheme(rRegexp, false)) return Regexp(Regexp::KIND_PREFIX, rRegexp + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":")), -- cgit