diff options
author | Arnaud Versini <arnaud.versini@gmail.com> | 2013-04-07 15:54:39 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-04-10 10:43:38 +0200 |
commit | 4976dd85fa6ecc279ac80d86a27636ce64d3a3ac (patch) | |
tree | ec4a2416ca13803d7643953ab36522bf6694c7e5 | |
parent | Kill the ToolBar class, move the needed bits directly to ToolBox. (diff) | |
download | core-4976dd85fa6ecc279ac80d86a27636ce64d3a3ac.tar.gz core-4976dd85fa6ecc279ac80d86a27636ce64d3a3ac.zip |
Introduce characters utilities in rtl/character.hxx
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>, with slight modifications
to sal/inc/rtl/character.hxx:
* Replaced "#pragma once" with explicit include guard for now.
* Missing includes.
* Cosmetic clean-up.
Change-Id: I94d01cd4e766f92c70f941839a67101fa2c97654
-rw-r--r-- | basic/source/sbx/sbxexec.cxx | 31 | ||||
-rw-r--r-- | sal/ZipPackage_sal_odk_headers.mk | 1 | ||||
-rw-r--r-- | sal/inc/rtl/character.hxx | 144 | ||||
-rw-r--r-- | sal/rtl/math.cxx | 20 | ||||
-rw-r--r-- | sal/rtl/uri.cxx | 19 | ||||
-rw-r--r-- | stoc/source/uriproc/UriReferenceFactory.cxx | 35 | ||||
-rw-r--r-- | tools/inc/tools/inetmime.hxx | 33 | ||||
-rw-r--r-- | tools/source/fsys/urlobj.cxx | 99 |
8 files changed, 236 insertions, 146 deletions
diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx index 905b3a290831..9d34b7f935c1 100644 --- a/basic/source/sbx/sbxexec.cxx +++ b/basic/source/sbx/sbxexec.cxx @@ -20,26 +20,7 @@ #include <tools/errcode.hxx> #include <vcl/svapp.hxx> #include <basic/sbx.hxx> - - - -static bool isAlpha( sal_Unicode c ) -{ - bool bRet = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); - return bRet; -} - -static bool isDigit( sal_Unicode c ) -{ - bool bRet = (c >= '0' && c <= '9'); - return bRet; -} - -static bool isAlphaNumeric( sal_Unicode c ) -{ - bool bRet = isDigit( c ) || isAlpha( c ); - return bRet; -} +#include <rtl/character.hxx> static SbxVariable* Element @@ -72,7 +53,7 @@ static const sal_Unicode* Symbol( const sal_Unicode* p, OUString& rSym ) else { // A symbol had to begin with a alphabetic character or an underline - if( !isAlpha( *p ) && *p != '_' ) + if( !rtl::isAsciiAlpha( *p ) && *p != '_' ) { SbxBase::SetError( SbxERR_SYNTAX ); } @@ -80,7 +61,7 @@ static const sal_Unicode* Symbol( const sal_Unicode* p, OUString& rSym ) { rSym = p; // The it can contain alphabetic characters, numbers or underlines - while( *p && (isAlphaNumeric( *p ) || *p == '_') ) + while( *p && (rtl::isAsciiAlphanumeric( *p ) || *p == '_') ) { p++, nLen++; } @@ -103,7 +84,7 @@ static SbxVariable* QualifiedName SbxVariableRef refVar; const sal_Unicode* p = SkipWhitespace( *ppBuf ); - if( isAlpha( *p ) || *p == '_' || *p == '[' ) + if( rtl::isAsciiAlpha( *p ) || *p == '_' || *p == '[' ) { // Read in the element refVar = Element( pObj, pGbl, &p, t ); @@ -139,8 +120,8 @@ static SbxVariable* Operand { SbxVariableRef refVar( new SbxVariable ); const sal_Unicode* p = SkipWhitespace( *ppBuf ); - if( !bVar && ( isDigit( *p ) - || ( *p == '.' && isDigit( *( p+1 ) ) ) + if( !bVar && ( rtl::isAsciiDigit( *p ) + || ( *p == '.' && rtl::isAsciiDigit( *( p+1 ) ) ) || *p == '-' || *p == '&' ) ) { diff --git a/sal/ZipPackage_sal_odk_headers.mk b/sal/ZipPackage_sal_odk_headers.mk index 458dbe5f03ca..696bc60c899a 100644 --- a/sal/ZipPackage_sal_odk_headers.mk +++ b/sal/ZipPackage_sal_odk_headers.mk @@ -32,6 +32,7 @@ $(eval $(call gb_ZipPackage_add_files,sal_odk_headers,inc/rtl,include/rtl,\ rtl/bootstrap.hxx \ rtl/byteseq.h \ rtl/byteseq.hxx \ + rtl/character.hxx \ rtl/cipher.h \ rtl/crc.h \ rtl/digest.h \ diff --git a/sal/inc/rtl/character.hxx b/sal/inc/rtl/character.hxx new file mode 100644 index 000000000000..5e3a8ff4234e --- /dev/null +++ b/sal/inc/rtl/character.hxx @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_RTL_CHARACTER_HXX +#define INCLUDED_RTL_CHARACTER_HXX + +#include "sal/config.h" + +#include "sal/types.h" + +namespace rtl +{ +/** Check for ASCII character. + + @param nUtf32 Some UCS-4 character. + + @return True if nChar is a ASCII character (0x00--0x7F). + + @since LibreOffice 4.1 + */ +inline bool isAscii(sal_uInt32 nUtf32) +{ + return nUtf32 <= 0x7F; +} + +/** Check for ASCII lower case character. + + @param nUtf32 Some UCS-4 character. + + @return True if nChar is a US-ASCII lower case alphabetic character + (ASCII 'a'--'z'). + + @since LibreOffice 4.1 + */ +inline bool isAsciiLowerCase(sal_uInt32 nUtf32) +{ + return nUtf32 >= 'a' && nUtf32 <= 'z'; +} + +/** Check for US-ASCII upper case character. + + @param nUtf32 Some UCS-4 character. + + @return True if nChar is a US-ASCII upper case alphabetic character + (US-ASCII 'A'--'Z'). + + @since LibreOffice 4.1 + */ +inline bool isAsciiUpperCase(sal_uInt32 nUtf32) +{ + return nUtf32 >= 'A' && nUtf32 <= 'Z'; +} + +/** Check for ASCII alphanumeric character. + + @param nUtf32 Some UCS-4 character. + + @return True if nUtf32 is a US-ASCII alphanumeric character + (ASCII '0'--'9', 'A'--'Z' or 'a'--'z'). + + @since LibreOffice 4.1 + */ +inline bool isAsciiAlpha(sal_uInt32 nUtf32) +{ + return isAsciiLowerCase(nUtf32) || isAsciiUpperCase(nUtf32); +} + +/** Check for ASCII digit character. + + @param nUtf32 Some UCS-4 character. + + @return True if nChar is a ASCII (decimal) digit character + (ASCII '0'--'9'). + + @since LibreOffice 4.1 + */ +inline bool isAsciiDigit(sal_uInt32 nUtf32) +{ + return nUtf32 >= '0' && nUtf32 <= '9'; +} + +/** Check for US-ASCII alphanumeric character. + + @param nUtf32 Some UCS-4 character. + + @return True if nChar is a US-ASCII alphanumeric character (US-ASCII + '0'--'9', 'A'--'Z' or 'a'--'z'). + + @since LibreOffice 4.1 + */ +inline bool isAsciiAlphanumeric(sal_uInt32 nUtf32) +{ + return isAsciiDigit(nUtf32) || isAsciiAlpha(nUtf32); +} + +/** Check for US-ASCII canonic hexadecimal digit character. + + @param nUtf32 Some UCS-4 character. + + @return True if nChar is a US-ASCII canonic (i.e., upper case) + hexadecimal digit character (US-ASCII '0'--'9' or 'A'--'F'). + + @since LibreOffice 4.1 + */ +inline bool isAsciiCanonicHexDigit(sal_uInt32 nUtf32) +{ + return isAsciiDigit(nUtf32) || (nUtf32 >= 'A' && nUtf32 <= 'F'); +} + +/** Check for US-ASCII hexadecimal digit character. + + @param nUtf32 Some UCS-4 character. + + @return True if nChar is a US-ASCII hexadecimal digit character (US- + ASCII '0'--'9', 'A'--'F', 'a'--'f'). + + @since LibreOffice 4.1 + */ +inline bool isAsciiHexDigit(sal_uInt32 nUtf32) +{ + return isAsciiCanonicHexDigit(nUtf32) || (nUtf32 >= 'a' && nUtf32 <= 'f'); +} + +}//rtl namespace + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index c0d93b6a85af..590ea0ee46b0 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -22,6 +22,7 @@ #include "osl/diagnose.h" #include "rtl/alloc.h" +#include "rtl/character.hxx" #include "rtl/math.hxx" #include "rtl/strbuf.h" #include "rtl/string.h" @@ -689,13 +690,6 @@ inline bool long10Overflow( long& nExp, int nAdd ) return false; } -// We are only concerned about ASCII arabic numerical digits here -template< typename CharT > -inline bool isDigit( CharT c ) -{ - return 0x30 <= c && c <= 0x39; -} - template< typename CharT > inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, CharT cDecSeparator, CharT cGroupSeparator, @@ -755,7 +749,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, for (; p != pEnd; ++p) { CharT c = *p; - if (isDigit(c)) + if (rtl::isAsciiDigit(c)) { fVal = fVal * 10.0 + static_cast< double >( c - CharT('0') ); ++nValExp; @@ -783,7 +777,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, for (; p != pEnd; ++p) { CharT c = *p; - if (!isDigit(c)) + if (!rtl::isAsciiDigit(c)) break; if ( nDigs < nSigs ) { // further digits (more than nSigs) don't have any @@ -821,7 +815,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, if ( fVal == 0.0 ) { // no matter what follows, zero stays zero, but carry on the // offset - while (p != pEnd && isDigit(*p)) + while (p != pEnd && rtl::isAsciiDigit(*p)) ++p; } else @@ -831,7 +825,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, for (; p != pEnd; ++p) { CharT c = *p; - if (!isDigit(c)) + if (!rtl::isAsciiDigit(c)) break; int i = c - CharT('0'); if ( long10Overflow( nExp, i ) ) @@ -876,7 +870,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, fVal = HUGE_VAL; eStatus = rtl_math_ConversionStatus_OutOfRange; // Eat any further digits: - while (p != pEnd && isDigit(*p)) + while (p != pEnd && rtl::isAsciiDigit(*p)) ++p; } else if (pEnd - p >= 4 && p[1] == CharT('N') && p[2] == CharT('A') @@ -897,7 +891,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, bSign = false; // don't negate again } // Eat any further digits: - while (p != pEnd && isDigit(*p)) + while (p != pEnd && rtl::isAsciiDigit(*p)) ++p; } } diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx index 9edd087ca335..7e4402f785c8 100644 --- a/sal/rtl/uri.cxx +++ b/sal/rtl/uri.cxx @@ -20,6 +20,7 @@ #include "surrogates.hxx" #include "osl/diagnose.h" +#include "rtl/character.hxx" #include "rtl/strbuf.hxx" #include "rtl/textenc.h" #include "rtl/textcvt.h" @@ -39,20 +40,6 @@ std::size_t const nCharClassSize = 128; sal_Unicode const cEscapePrefix = 0x25; // '%' -inline bool isDigit(sal_uInt32 nUtf32) -{ - return nUtf32 >= 0x30 && nUtf32 <= 0x39; // '0'--'9' -} - -inline bool isAlpha(sal_uInt32 nUtf32) -{ - // 'A'--'Z', 'a'--'z' - return ( - (nUtf32 >= 0x41 && nUtf32 <= 0x5A) || - (nUtf32 >= 0x61 && nUtf32 <= 0x7A) - ); -} - inline bool isHighSurrogate(sal_uInt32 nUtf16) { return SAL_RTL_IS_HIGH_SURROGATE(nUtf16); @@ -376,7 +363,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents) sal_Unicode const * pEnd = pBegin + pUriRef->length; sal_Unicode const * pPos = pBegin; - if (pPos != pEnd && isAlpha(*pPos)) + if (pPos != pEnd && rtl::isAsciiAlpha(*pPos)) { for (sal_Unicode const * p = pPos + 1; p != pEnd; ++p) { @@ -387,7 +374,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents) pPos = p; break; } - else if (!isAlpha(*p) && !isDigit(*p) && *p != '+' && *p != '-' + else if (!rtl::isAsciiAlphanumeric(*p) && *p != '+' && *p != '-' && *p != '.') { break; diff --git a/stoc/source/uriproc/UriReferenceFactory.cxx b/stoc/source/uriproc/UriReferenceFactory.cxx index 26b693e96651..6d42c49011dc 100644 --- a/stoc/source/uriproc/UriReferenceFactory.cxx +++ b/stoc/source/uriproc/UriReferenceFactory.cxx @@ -41,6 +41,7 @@ #include "cppuhelper/implbase2.hxx" #include "cppuhelper/weak.hxx" #include "osl/diagnose.h" +#include "rtl/character.hxx" #include "rtl/string.h" #include "rtl/ustrbuf.hxx" #include "rtl/ustring.hxx" @@ -56,28 +57,8 @@ namespace { //TODO: move comphelper::string::misc into something like //sal/salhelper and use those instead -bool isDigit(sal_Unicode c) { - return c >= '0' && c <= '9'; -} - -bool isUpperCase(sal_Unicode c) { - return c >= 'A' && c <= 'Z'; -} - -bool isLowerCase(sal_Unicode c) { - return c >= 'a' && c <= 'z'; -} - -bool isAlpha(sal_Unicode c) { - return isUpperCase(c) || isLowerCase(c); -} - -bool isHexDigit(sal_Unicode c) { - return isDigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); -} - sal_Unicode toLowerCase(sal_Unicode c) { - return isUpperCase(c) ? c + ('a' - 'A') : c; + return rtl::isAsciiUpperCase(c) ? c + ('a' - 'A') : c; } bool equalIgnoreCase(sal_Unicode c1, sal_Unicode c2) { @@ -88,8 +69,8 @@ bool equalIgnoreEscapeCase(OUString const & s1, OUString const & s2) { if (s1.getLength() == s2.getLength()) { for (sal_Int32 i = 0; i < s1.getLength();) { if (s1[i] == '%' && s2[i] == '%' && s1.getLength() - i > 2 - && isHexDigit(s1[i + 1]) && isHexDigit(s1[i + 2]) - && isHexDigit(s2[i + 1]) && isHexDigit(s2[i + 2]) + && rtl::isAsciiHexDigit(s1[i + 1]) && rtl::isAsciiHexDigit(s1[i + 2]) + && rtl::isAsciiHexDigit(s2[i + 1]) && rtl::isAsciiHexDigit(s2[i + 2]) && equalIgnoreCase(s1[i + 1], s2[i + 1]) && equalIgnoreCase(s1[i + 2], s2[i + 2])) { @@ -107,12 +88,12 @@ bool equalIgnoreEscapeCase(OUString const & s1, OUString const & s2) { } sal_Int32 parseScheme(OUString const & uriReference) { - if (uriReference.getLength() >= 2 && isAlpha(uriReference[0])) { + if (uriReference.getLength() >= 2 && rtl::isAsciiAlpha(uriReference[0])) { for (sal_Int32 i = 0; i < uriReference.getLength(); ++i) { sal_Unicode c = uriReference[i]; if (c == ':') { return i; - } else if (!isAlpha(c) && !isDigit(c) && c != '+' && c != '-' + } else if (!rtl::isAsciiAlpha(c) && !rtl::isAsciiDigit(c) && c != '+' && c != '-' && c != '.') { break; @@ -381,7 +362,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uri.UriSchemeParser_")); for (sal_Int32 i = 0; i < scheme.getLength(); ++i) { sal_Unicode c = scheme[i]; - if (isUpperCase(c)) { + if (rtl::isAsciiUpperCase(c)) { buf.append(toLowerCase(c)); } else if (c == '+') { buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("PLUS")); @@ -390,7 +371,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse( } else if (c == '.') { buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("DOT")); } else { - OSL_ASSERT(isLowerCase(c) || isDigit(c)); + OSL_ASSERT(rtl::isAsciiLowerCase(c) || rtl::isAsciiDigit(c)); buf.append(c); } } diff --git a/tools/inc/tools/inetmime.hxx b/tools/inc/tools/inetmime.hxx index ad04f9e12445..7f4c5aa98679 100644 --- a/tools/inc/tools/inetmime.hxx +++ b/tools/inc/tools/inetmime.hxx @@ -23,6 +23,7 @@ #include "tools/toolsdllapi.h" #include <rtl/alloc.h> +#include <rtl/character.hxx> #include <rtl/string.hxx> #include <rtl/strbuf.hxx> #include <rtl/tencinfo.h> @@ -537,7 +538,7 @@ public: // static inline bool INetMIME::isUSASCII(sal_uInt32 nChar) { - return nChar <= 0x7F; + return rtl::isAscii(nChar); } // static @@ -567,74 +568,74 @@ inline bool INetMIME::isVisible(sal_uInt32 nChar) // static inline bool INetMIME::isDigit(sal_uInt32 nChar) { - return nChar >= '0' && nChar <= '9'; + return rtl::isAsciiDigit(nChar); } // static inline bool INetMIME::isCanonicHexDigit(sal_uInt32 nChar) { - return isDigit(nChar) || (nChar >= 'A' && nChar <= 'F'); + return rtl::isAsciiCanonicHexDigit(nChar); } // static inline bool INetMIME::isHexDigit(sal_uInt32 nChar) { - return isCanonicHexDigit(nChar) || (nChar >= 'a' && nChar <= 'f'); + return rtl::isAsciiHexDigit(nChar); } // static inline bool INetMIME::isUpperCase(sal_uInt32 nChar) { - return nChar >= 'A' && nChar <= 'Z'; + return rtl::isAsciiUpperCase(nChar); } // static inline bool INetMIME::isLowerCase(sal_uInt32 nChar) { - return nChar >= 'a' && nChar <= 'z'; + return rtl::isAsciiLowerCase(nChar); } // static inline bool INetMIME::isAlpha(sal_uInt32 nChar) { - return isUpperCase(nChar) || isLowerCase(nChar); + return rtl::isAsciiAlpha(nChar); } // static inline bool INetMIME::isAlphanumeric(sal_uInt32 nChar) { - return isAlpha(nChar) || isDigit(nChar); + return rtl::isAsciiAlphanumeric(nChar); } // static inline bool INetMIME::isBase64Digit(sal_uInt32 nChar) { - return isUpperCase(nChar) || isLowerCase(nChar) || isDigit(nChar) + return rtl::isAsciiUpperCase(nChar) || rtl::isAsciiLowerCase(nChar) || rtl::isAsciiDigit(nChar) || nChar == '+' || nChar == '/'; } // static inline sal_uInt32 INetMIME::toUpperCase(sal_uInt32 nChar) { - return isLowerCase(nChar) ? nChar - ('a' - 'A') : nChar; + return rtl::isAsciiLowerCase(nChar) ? nChar - ('a' - 'A') : nChar; } // static inline sal_uInt32 INetMIME::toLowerCase(sal_uInt32 nChar) { - return isUpperCase(nChar) ? nChar + ('a' - 'A') : nChar; + return rtl::isAsciiUpperCase(nChar) ? nChar + ('a' - 'A') : nChar; } // static inline int INetMIME::getWeight(sal_uInt32 nChar) { - return isDigit(nChar) ? int(nChar - '0') : -1; + return rtl::isAsciiDigit(nChar) ? int(nChar - '0') : -1; } // static inline int INetMIME::getHexWeight(sal_uInt32 nChar) { - return isDigit(nChar) ? int(nChar - '0') : + return rtl::isAsciiDigit(nChar) ? int(nChar - '0') : nChar >= 'A' && nChar <= 'F' ? int(nChar - 'A' + 10) : nChar >= 'a' && nChar <= 'f' ? int(nChar - 'a' + 10) : -1; } @@ -642,9 +643,9 @@ inline int INetMIME::getHexWeight(sal_uInt32 nChar) // static inline int INetMIME::getBase64Weight(sal_uInt32 nChar) { - return isUpperCase(nChar) ? int(nChar - 'A') : - isLowerCase(nChar) ? int(nChar - 'a' + 26) : - isDigit(nChar) ? int(nChar - '0' + 52) : + return rtl::isAsciiUpperCase(nChar) ? int(nChar - 'A') : + rtl::isAsciiLowerCase(nChar) ? int(nChar - 'a' + 26) : + rtl::isAsciiDigit(nChar) ? int(nChar - '0' + 52) : nChar == '+' ? 62 : nChar == '/' ? 63 : nChar == '=' ? -1 : -2; diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 93d4febe4bab..2724b715d684 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -24,6 +24,7 @@ #include "com/sun/star/util/XStringWidth.hpp" #include "osl/diagnose.h" #include "osl/file.hxx" +#include "rtl/character.hxx" #include "rtl/string.h" #include "rtl/textenc.h" #include "rtl/ustring.hxx" @@ -630,11 +631,11 @@ OUString parseScheme( sal_uInt32 fragmentDelimiter) { sal_Unicode const * p = *begin; - if (p != end && INetMIME::isAlpha(*p)) { + if (p != end && rtl::isAsciiAlpha(*p)) { do { ++p; } while (p != end - && (INetMIME::isAlphanumeric(*p) || *p == '+' || *p == '-' + && (rtl::isAsciiAlphanumeric(*p) || *p == '+' || *p == '-' || *p == '.')); // #i34835# To avoid problems with Windows file paths like "C:\foo", // do not accept generic schemes that are only one character long: @@ -730,7 +731,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef, sal_Unicode const * p1 = pPos; if (eStyle & FSYS_DOS && pEnd - p1 >= 2 - && INetMIME::isAlpha(p1[0]) + && rtl::isAsciiAlpha(p1[0]) && p1[1] == ':' && (pEnd - p1 == 2 || p1[2] == '/' || p1[2] == '\\')) { @@ -1043,7 +1044,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef, bSkippedInitialSlash = true; if ((eStyle & FSYS_DOS) != 0 && pEnd - pPos >= 2 - && INetMIME::isAlpha(pPos[0]) + && rtl::isAsciiAlpha(pPos[0]) && pPos[1] == ':' && (pEnd - pPos == 2 || pPos[2] == '/' || pPos[2] == '\\')) @@ -1106,7 +1107,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef, // replacing "\" by "/" within <*path> if (eStyle & FSYS_DOS && pEnd - pPos >= 2 - && INetMIME::isAlpha(pPos[0]) + && rtl::isAsciiAlpha(pPos[0]) && pPos[1] == ':' && (pEnd - pPos == 2 || pPos[2] == '/' @@ -1317,7 +1318,7 @@ bool INetURLObject::setAbsURIRef(OUString const & rTheAbsURIRef, if ( getSchemeInfo().m_bPort && pHostPortBegin < pHostPortEnd ) { sal_Unicode const * p1 = pHostPortEnd - 1; - while (p1 > pHostPortBegin && INetMIME::isDigit(*p1)) + while (p1 > pHostPortBegin && rtl::isAsciiDigit(*p1)) --p1; if (*p1 == ':') pPort = p1; @@ -1519,7 +1520,7 @@ bool INetURLObject::convertRelToAbs(OUString const & rTheRelURIRef, bool bFSys = false; sal_Unicode const * q = p; if (pEnd - q >= 2 - && INetMIME::isAlpha(q[0]) + && rtl::isAsciiAlpha(q[0]) && q[1] == ':' && (pEnd - q == 2 || q[2] == '/' || q[2] == '\\')) bFSys = true; // 2nd, 3rd @@ -2398,9 +2399,9 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p aTheCanonic.append(sal_Unicode('[')); eState = STATE_IP6; } - else if (INetMIME::isAlpha(*p) || *p == '_') + else if (rtl::isAsciiAlpha(*p) || *p == '_') eState = STATE_TOPLABEL; - else if (INetMIME::isDigit(*p)) + else if (rtl::isAsciiDigit(*p)) { nNumber = INetMIME::getWeight(*p); nDigits = 1; @@ -2416,21 +2417,21 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p eState = STATE_LABEL_DOT; else if (*p == '-') eState = STATE_LABEL_HYPHEN; - else if (!INetMIME::isAlphanumeric(*p) && *p != '_') + else if (!rtl::isAsciiAlphanumeric(*p) && *p != '_') goto done; break; case STATE_LABEL_HYPHEN: - if (INetMIME::isAlphanumeric(*p) || *p == '_') + if (rtl::isAsciiAlphanumeric(*p) || *p == '_') eState = STATE_LABEL; else if (*p != '-') goto done; break; case STATE_LABEL_DOT: - if (INetMIME::isAlpha(*p) || *p == '_') + if (rtl::isAsciiAlpha(*p) || *p == '_') eState = STATE_TOPLABEL; - else if (INetMIME::isDigit(*p)) + else if (rtl::isAsciiDigit(*p)) eState = STATE_LABEL; else goto done; @@ -2441,21 +2442,21 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p eState = STATE_TOPLABEL_DOT; else if (*p == '-') eState = STATE_TOPLABEL_HYPHEN; - else if (!INetMIME::isAlphanumeric(*p) && *p != '_') + else if (!rtl::isAsciiAlphanumeric(*p) && *p != '_') goto done; break; case STATE_TOPLABEL_HYPHEN: - if (INetMIME::isAlphanumeric(*p) || *p == '_') + if (rtl::isAsciiAlphanumeric(*p) || *p == '_') eState = STATE_TOPLABEL; else if (*p != '-') goto done; break; case STATE_TOPLABEL_DOT: - if (INetMIME::isAlpha(*p) || *p == '_') + if (rtl::isAsciiAlpha(*p) || *p == '_') eState = STATE_TOPLABEL; - else if (INetMIME::isDigit(*p)) + else if (rtl::isAsciiDigit(*p)) eState = STATE_LABEL; else goto done; @@ -2475,9 +2476,9 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p eState = STATE_LABEL_DOT; else if (*p == '-') eState = STATE_LABEL_HYPHEN; - else if (INetMIME::isAlpha(*p) || *p == '_') + else if (rtl::isAsciiAlpha(*p) || *p == '_') eState = STATE_LABEL; - else if (INetMIME::isDigit(*p)) + else if (rtl::isAsciiDigit(*p)) if (nDigits < 3) { nNumber = 10 * nNumber + INetMIME::getWeight(*p); @@ -2490,9 +2491,9 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p break; case STATE_IP4_DOT: - if (INetMIME::isAlpha(*p) || *p == '_') + if (rtl::isAsciiAlpha(*p) || *p == '_') eState = STATE_TOPLABEL; - else if (INetMIME::isDigit(*p)) + else if (rtl::isAsciiDigit(*p)) { nNumber = INetMIME::getWeight(*p); nDigits = 1; @@ -2505,7 +2506,7 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p case STATE_IP6: if (*p == ':') eState = STATE_IP6_COLON; - else if (INetMIME::isHexDigit(*p)) + else if (rtl::isAsciiHexDigit(*p)) { nNumber = INetMIME::getHexWeight(*p); nDigits = 1; @@ -2533,13 +2534,13 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p aTheCanonic.append(sal_Unicode(':')); eState = STATE_IP6_3COLON; } - else if (INetMIME::isDigit(*p)) + else if (rtl::isAsciiDigit(*p)) { nNumber = INetMIME::getWeight(*p); nDigits = 1; eState = STATE_IP6_HEXSEQ2_MAYBE_IP4; } - else if (INetMIME::isHexDigit(*p)) + else if (rtl::isAsciiHexDigit(*p)) { nNumber = INetMIME::getHexWeight(*p); nDigits = 1; @@ -2550,7 +2551,7 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p break; case STATE_IP6_3COLON: - if (INetMIME::isDigit(*p)) + if (rtl::isAsciiDigit(*p)) { nNumber = INetMIME::getWeight(*p); nDigits = 1; @@ -2575,7 +2576,7 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p aTheCanonic.append(sal_Unicode(':')); eState = STATE_IP6_HEXSEQ1_COLON; } - else if (INetMIME::isHexDigit(*p) && nDigits < 4) + else if (rtl::isAsciiHexDigit(*p) && nDigits < 4) { nNumber = 16 * nNumber + INetMIME::getHexWeight(*p); ++nDigits; @@ -2590,13 +2591,13 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p aTheCanonic.append(sal_Unicode(':')); eState = STATE_IP6_2COLON; } - else if (INetMIME::isDigit(*p)) + else if (rtl::isAsciiDigit(*p)) { nNumber = INetMIME::getWeight(*p); nDigits = 1; eState = STATE_IP6_HEXSEQ1_MAYBE_IP4; } - else if (INetMIME::isHexDigit(*p)) + else if (rtl::isAsciiHexDigit(*p)) { nNumber = INetMIME::getHexWeight(*p); nDigits = 1; @@ -2630,12 +2631,12 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p nOctets = 2; eState = STATE_IP6_IP4_DOT; } - else if (INetMIME::isDigit(*p) && nDigits < 3) + else if (rtl::isAsciiDigit(*p) && nDigits < 3) { nNumber = 16 * nNumber + INetMIME::getWeight(*p); ++nDigits; } - else if (INetMIME::isHexDigit(*p) && nDigits < 4) + else if (rtl::isAsciiHexDigit(*p) && nDigits < 4) { nNumber = 16 * nNumber + INetMIME::getHexWeight(*p); ++nDigits; @@ -2659,7 +2660,7 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p aTheCanonic.append(sal_Unicode(':')); eState = STATE_IP6_HEXSEQ2_COLON; } - else if (INetMIME::isHexDigit(*p) && nDigits < 4) + else if (rtl::isAsciiHexDigit(*p) && nDigits < 4) { nNumber = 16 * nNumber + INetMIME::getHexWeight(*p); ++nDigits; @@ -2669,13 +2670,13 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p break; case STATE_IP6_HEXSEQ2_COLON: - if (INetMIME::isDigit(*p)) + if (rtl::isAsciiDigit(*p)) { nNumber = INetMIME::getWeight(*p); nDigits = 1; eState = STATE_IP6_HEXSEQ2_MAYBE_IP4; } - else if (INetMIME::isHexDigit(*p)) + else if (rtl::isAsciiHexDigit(*p)) { nNumber = INetMIME::getHexWeight(*p); nDigits = 1; @@ -2709,12 +2710,12 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p nOctets = 2; eState = STATE_IP6_IP4_DOT; } - else if (INetMIME::isDigit(*p) && nDigits < 3) + else if (rtl::isAsciiDigit(*p) && nDigits < 3) { nNumber = 16 * nNumber + INetMIME::getWeight(*p); ++nDigits; } - else if (INetMIME::isHexDigit(*p) && nDigits < 4) + else if (rtl::isAsciiHexDigit(*p) && nDigits < 4) { nNumber = 16 * nNumber + INetMIME::getHexWeight(*p); ++nDigits; @@ -2745,7 +2746,7 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p } else goto done; - else if (INetMIME::isDigit(*p) && nDigits < 3) + else if (rtl::isAsciiDigit(*p) && nDigits < 3) { nNumber = 10 * nNumber + INetMIME::getWeight(*p); ++nDigits; @@ -2755,7 +2756,7 @@ bool INetURLObject::parseHost(sal_Unicode const *& rBegin, sal_Unicode const * p break; case STATE_IP6_IP4_DOT: - if (INetMIME::isDigit(*p)) + if (rtl::isAsciiDigit(*p)) { nNumber = INetMIME::getWeight(*p); nDigits = 1; @@ -2825,7 +2826,7 @@ bool INetURLObject::parseHostOrNetBiosName( eEscapeType); if (!INetMIME::isVisible(nUTF32)) return false; - if (!INetMIME::isAlphanumeric(nUTF32)) + if (!rtl::isAsciiAlphanumeric(nUTF32)) switch (nUTF32) { case '"': @@ -2996,7 +2997,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, || *pPos == nSegmentDelimiter || *pPos == nAltSegmentDelimiter) && aTheSynPath.getLength() == 2 - && INetMIME::isAlpha(aTheSynPath[1])) + && rtl::isAsciiAlpha(aTheSynPath[1])) { // A first segment of <ALPHA "|"> is translated to // <ALPHA ":">: @@ -3041,7 +3042,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, } // Match <group>: - if (INetMIME::isAlpha(*pPos)) + if (rtl::isAsciiAlpha(*pPos)) { for (sal_Unicode const * p = pPos + 1;; ++p) { @@ -3053,7 +3054,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, pPos = p; goto done; } - else if (!INetMIME::isAlphanumeric(*p) && *p != '+' + else if (!rtl::isAsciiAlphanumeric(*p) && *p != '+' && *p != '-' && *p != '.' && *p != '_') { break; @@ -3291,7 +3292,7 @@ bool INetURLObject::parsePath(INetProtocol eScheme, sal_uInt32 nUTF32 = getUTF32(pPos, pPathEnd, bOctets, '=', eMechanism, eCharset, eEscapeType); - if (!INetMIME::isDigit(nUTF32)) + if (!rtl::isAsciiDigit(nUTF32)) return false; aTheSynPath.append(sal_Unicode(nUTF32)); bEmpty = false; @@ -3614,7 +3615,7 @@ bool INetURLObject::hasDosVolume(FSysStyle eStyle) const return (eStyle & FSYS_DOS) != 0 && m_aPath.getLength() >= 3 && p[0] == '/' - && INetMIME::isAlpha(p[1]) + && rtl::isAsciiAlpha(p[1]) && p[2] == ':' && (m_aPath.getLength() == 3 || p[3] == '/'); } @@ -4628,7 +4629,7 @@ bool INetURLObject::setFSysPath(OUString const & rFSysPath, if (eStyle & FSYS_DOS && pFSysEnd - pFSysBegin >= 2 - && INetMIME::isAlpha(pFSysBegin[0]) + && rtl::isAsciiAlpha(pFSysBegin[0]) && pFSysBegin[1] == ':' && (pFSysEnd - pFSysBegin == 2 || pFSysBegin[2] == '/' @@ -4704,7 +4705,7 @@ bool INetURLObject::setFSysPath(OUString const & rFSysPath, { aSynAbsURIRef.append(sal_Unicode('/')); if (pFSysEnd - p >= 2 - && INetMIME::isAlpha(p[0]) + && rtl::isAsciiAlpha(p[0]) && p[1] == ':' && (pFSysEnd - p == 2 || p[2] == '\\' || p[2] == '/')) nAltDelimiter = '/'; @@ -5162,7 +5163,7 @@ sal_uInt32 INetURLObject::scanDomain(sal_Unicode const *& rBegin, switch (eState) { case STATE_DOT: - if (p != pEnd && (INetMIME::isAlphanumeric(*p) || *p == '_')) + if (p != pEnd && (rtl::isAsciiAlphanumeric(*p) || *p == '_')) { ++nLabels; eState = STATE_LABEL; @@ -5176,7 +5177,7 @@ sal_uInt32 INetURLObject::scanDomain(sal_Unicode const *& rBegin, case STATE_LABEL: if (p != pEnd) { - if (INetMIME::isAlphanumeric(*p) || *p == '_') + if (rtl::isAsciiAlphanumeric(*p) || *p == '_') break; else if (*p == '.') { @@ -5196,7 +5197,7 @@ sal_uInt32 INetURLObject::scanDomain(sal_Unicode const *& rBegin, case STATE_HYPHEN: if (p != pEnd) { - if (INetMIME::isAlphanumeric(*p) || *p == '_') + if (rtl::isAsciiAlphanumeric(*p) || *p == '_') { eState = STATE_LABEL; break; @@ -5218,7 +5219,7 @@ bool INetURLObject::scanIPv6reference(sal_Unicode const *& rBegin, if (rBegin != pEnd && *rBegin == '[') { sal_Unicode const * p = rBegin + 1; //TODO: check for valid IPv6address (RFC 2373): - while (p != pEnd && (INetMIME::isHexDigit(*p) || *p == ':' || *p == '.')) + while (p != pEnd && (rtl::isAsciiHexDigit(*p) || *p == ':' || *p == '.')) { ++p; } |