From 3829892dbc5475a49250729541be369ea9532d28 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 29 Aug 2011 00:36:22 +0100 Subject: merge together 5 or ascii isalpha/isalnum/isdigit implementations --- ucb/source/regexp/regexp.cxx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'ucb/source') diff --git a/ucb/source/regexp/regexp.cxx b/ucb/source/regexp/regexp.cxx index 18136bc16b5d..695c8bf9a74e 100644 --- a/ucb/source/regexp/regexp.cxx +++ b/ucb/source/regexp/regexp.cxx @@ -36,6 +36,7 @@ #include #include #include +#include namespace unnamed_ucb_regexp {} using namespace unnamed_ucb_regexp; // unnamed namespaces don't work well yet... @@ -186,29 +187,21 @@ bool Regexp::matches(rtl::OUString const & rString, //============================================================================ namespace unnamed_ucb_regexp { -inline bool isAlpha(sal_Unicode c) -{ - return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); -} - -inline bool isDigit(sal_Unicode c) -{ - return c >= '0' && c <= '9'; -} - bool isScheme(rtl::OUString const & rString, bool bColon) { + using comphelper::string::isalphaAscii; + using comphelper::string::isdigitAscii; // 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)) + if (p != pEnd && isalphaAscii(*p)) for (++p;;) { if (p == pEnd) return !bColon; sal_Unicode c = *p++; - if (!(isAlpha(c) || isDigit(c) + if (!(isalphaAscii(c) || isdigitAscii(c) || c == '+' || c == '-' || c == '.')) return bColon && c == ':' && p == pEnd; } -- cgit