[PATCH] Introduce characters utilities in rtl/character.hxx

Arnaud Versini (via Code Review) gerrit at gerrit.libreoffice.org
Sun Apr 7 06:56:01 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3224

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/24/3224/1

Introduce characters utilities in rtl/character.hxx

Change-Id: I94d01cd4e766f92c70f941839a67101fa2c97654
---
M basic/source/sbx/sbxexec.cxx
M sal/ZipPackage_sal_odk_headers.mk
A sal/inc/rtl/character.hxx
M sal/rtl/math.cxx
M sal/rtl/uri.cxx
M stoc/source/uriproc/UriReferenceFactory.cxx
M tools/inc/tools/inetmime.hxx
M tools/source/fsys/urlobj.cxx
8 files changed, 212 insertions(+), 146 deletions(-)



diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx
index 905b3a2..b6775ad 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 @@
     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 @@
         {
             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 @@
 
     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 @@
 {
     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 458dbe5..696bc60 100644
--- a/sal/ZipPackage_sal_odk_headers.mk
+++ b/sal/ZipPackage_sal_odk_headers.mk
@@ -32,6 +32,7 @@
 	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 0000000..fa2a41f
--- /dev/null
+++ b/sal/inc/rtl/character.hxx
@@ -0,0 +1,120 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+namespace rtl
+{
+/** Check for ASCII character.
+
+    @param nUtf32  Some UCS-4 character.
+
+    @return  True if nChar is a ASCII character (0x00--0x7F).
+ */
+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').
+ */
+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').
+ */
+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').
+ */
+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').
+ */
+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').
+ */
+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').
+ */
+inline bool isAsciiCanonicHexDigit(sal_uInt32 nUtf32)
+{
+    return rtl::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').
+ */
+inline bool isAsciiHexDigit(sal_uInt32 nUtf32)
+{
+    return isAsciiCanonicHexDigit(nUtf32) || (nUtf32 >= 'a' && nUtf32 <= 'f');
+}
+
+}//rtl namespace
+
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index c0d93b6..590ea0e 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 @@
     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 @@
         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 @@
             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 @@
             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 @@
                 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 @@
                 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 @@
                     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 9edd087..bed391e8 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"
@@ -38,20 +39,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)
 {
@@ -376,7 +363,7 @@
     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 @@
                 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 a5f6041..de7de91 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 @@
 //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 @@
     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 @@
 }
 
 sal_Int32 parseScheme(rtl::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 @@
             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 @@
             } 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 53f097f..b137704 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 @@
 // static
 inline bool INetMIME::isUSASCII(sal_uInt32 nChar)
 {
-    return nChar <= 0x7F;
+    return rtl::isAscii(nChar);
 }
 
 // static
@@ -567,74 +568,74 @@
 // 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 @@
 // 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 b839e6d..8bd3399 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 @@
     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 @@
             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 @@
                         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 @@
                     //  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 @@
             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 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 @@
                     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 @@
                     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 @@
                     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 @@
                         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 @@
                 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 @@
             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 @@
                     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 @@
                 break;
 
             case STATE_IP6_3COLON:
-                if (INetMIME::isDigit(*p))
+                if (rtl::isAsciiDigit(*p))
                 {
                     nNumber = INetMIME::getWeight(*p);
                     nDigits = 1;
@@ -2575,7 +2576,7 @@
                     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 @@
                     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 @@
                     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 @@
                     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 @@
                 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 @@
                     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 @@
                     }
                     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 @@
                 break;
 
             case STATE_IP6_IP4_DOT:
-                if (INetMIME::isDigit(*p))
+                if (rtl::isAsciiDigit(*p))
                 {
                     nNumber = INetMIME::getWeight(*p);
                     nDigits = 1;
@@ -2825,7 +2826,7 @@
                                                  eEscapeType);
                     if (!INetMIME::isVisible(nUTF32))
                         return false;
-                    if (!INetMIME::isAlphanumeric(nUTF32))
+                    if (!rtl::isAsciiAlphaNumeric(nUTF32))
                         switch (nUTF32)
                         {
                         case '"':
@@ -2996,7 +2997,7 @@
                                  || *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 @@
             }
 
             // Match <group>:
-            if (INetMIME::isAlpha(*pPos))
+            if (rtl::isAsciiAlpha(*pPos))
             {
                 for (sal_Unicode const * p = pPos + 1;; ++p)
                 {
@@ -3053,7 +3054,7 @@
                         pPos = p;
                         goto done;
                     }
-                    else if (!INetMIME::isAlphanumeric(*p) && *p != '+'
+                    else if (!rtl::isAsciiAlphaNumeric(*p) && *p != '+'
                              && *p != '-' && *p != '.' && *p != '_')
                     {
                         break;
@@ -3291,7 +3292,7 @@
                     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 @@
     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 @@
 
             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 @@
             {
                 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 @@
         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 @@
             case STATE_LABEL:
                 if (p != pEnd)
                 {
-                    if (INetMIME::isAlphanumeric(*p) || *p == '_')
+                    if (rtl::isAsciiAlphaNumeric(*p) || *p == '_')
                         break;
                     else if (*p == '.')
                     {
@@ -5196,7 +5197,7 @@
             case STATE_HYPHEN:
                 if (p != pEnd)
                 {
-                    if (INetMIME::isAlphanumeric(*p) || *p == '_')
+                    if (rtl::isAsciiAlphaNumeric(*p) || *p == '_')
                     {
                         eState = STATE_LABEL;
                         break;
@@ -5218,7 +5219,7 @@
     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;
         }

-- 
To view, visit https://gerrit.libreoffice.org/3224
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I94d01cd4e766f92c70f941839a67101fa2c97654
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Arnaud Versini <arnaud.versini at gmail.com>



More information about the LibreOffice mailing list