[Libreoffice-commits] core.git: basic/source

Arnaud Versini arnaud.versini at gmail.com
Sat Jan 31 01:48:48 PST 2015


 basic/source/comp/basiccharclass.cxx |    9 ++-------
 basic/source/comp/sbcomp.cxx         |    9 ++-------
 basic/source/comp/scanner.cxx        |   12 ++++++------
 basic/source/inc/basiccharclass.hxx  |    3 +--
 4 files changed, 11 insertions(+), 22 deletions(-)

New commits:
commit 4b9a9ce8a0e5e0716dad9a9ec87d16237e534dc2
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date:   Sun Jan 25 13:58:08 2015 +0100

    Use rtl/character.hxx in basic module when possible
    
    Change-Id: I1296541ac1a6a65a613818a1264c2b7482915e64
    Reviewed-on: https://gerrit.libreoffice.org/14170
    Reviewed-by: Arnaud Versini <arnaud.versini at libreoffice.org>
    Tested-by: Arnaud Versini <arnaud.versini at libreoffice.org>

diff --git a/basic/source/comp/basiccharclass.cxx b/basic/source/comp/basiccharclass.cxx
index 59ae724..8e404cc 100644
--- a/basic/source/comp/basiccharclass.cxx
+++ b/basic/source/comp/basiccharclass.cxx
@@ -108,18 +108,13 @@ bool BasicCharClass::isLetterUnicode( sal_Unicode c )
 
 bool BasicCharClass::isAlpha( sal_Unicode c, bool bCompatible )
 {
-  return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
+  return rtl::isAsciiAlpha(c)
     || (bCompatible && isLetter( c ));
 }
 
-bool BasicCharClass::isDigit( sal_Unicode c )
-{
-  return (c >= '0' && c <= '9');
-}
-
 bool BasicCharClass::isAlphaNumeric( sal_Unicode c, bool bCompatible )
 {
-  return isDigit( c ) || isAlpha( c, bCompatible );
+  return rtl::isAsciiDigit( c ) || isAlpha( c, bCompatible );
 }
 
 bool BasicCharClass::isWhitespace( sal_Unicode c )
diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx
index 293e8cf..dfc0b4a 100644
--- a/basic/source/comp/sbcomp.cxx
+++ b/basic/source/comp/sbcomp.cxx
@@ -25,6 +25,7 @@
 #include <svtools/miscopt.hxx>
 #include <stdio.h>
 #include <boost/scoped_ptr.hpp>
+#include <rtl/character.hxx>
 
 // To activate tracing enable in sbtrace.hxx
 #ifdef DBG_TRACE_BASIC
@@ -124,12 +125,6 @@ inline void lcl_findNextLine( char*& rpc, char* pe )
         ++rpc;
 }
 
-inline bool lcl_isAlpha( char c )
-{
-    bool bRet = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
-    return bRet;
-}
-
 static void lcl_ReadIniFile( const char* pIniFileName )
 {
     const int BUF_SIZE = 1000;
@@ -153,7 +148,7 @@ static void lcl_ReadIniFile( const char* pIniFileName )
 
         // Read variable
         char* pVarStart = pc;
-        while( pc < pe && lcl_isAlpha( *pc ) )
+        while( pc < pe && rtl::isAsciiAlpha( *pc ) )
             ++pc;
         int nVarLen = pc - pVarStart;
         if( nVarLen == 0 )
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 8a893f0..41e6171 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -152,7 +152,7 @@ void SbiScanner::scanAlphanumeric()
 void SbiScanner::scanGoto()
 {
     sal_Int32 n = nCol;
-    while(n < aLine.getLength() && theBasicCharClass::get().isWhitespace(aLine[n]))
+    while(n < aLine.getLength() && BasicCharClass::isWhitespace(aLine[n]))
         ++n;
 
     if(n + 1 < aLine.getLength())
@@ -180,7 +180,7 @@ bool SbiScanner::readLine()
 
     // Trim trailing whitespace
     sal_Int32 nEnd = n;
-    while(nBufPos < nEnd && theBasicCharClass::get().isWhitespace(aBuf[nEnd - 1]))
+    while(nBufPos < nEnd && BasicCharClass::isWhitespace(aBuf[nEnd - 1]))
         --nEnd;
 
     aLine = aBuf.copy(nBufPos, nEnd - nBufPos);
@@ -223,10 +223,10 @@ bool SbiScanner::NextSym()
         nOldCol1 = nOldCol2 = 0;
     }
 
-    if(nCol < aLine.getLength() && theBasicCharClass::get().isWhitespace(aLine[nCol]))
+    if(nCol < aLine.getLength() && BasicCharClass::isWhitespace(aLine[nCol]))
     {
         bSpaces = true;
-        while(nCol < aLine.getLength() && theBasicCharClass::get().isWhitespace(aLine[nCol]))
+        while(nCol < aLine.getLength() && BasicCharClass::isWhitespace(aLine[nCol]))
             ++pLine, ++nCol;
     }
 
@@ -298,8 +298,8 @@ bool SbiScanner::NextSym()
     }
 
     // read in and convert if number
-    else if((nCol < aLine.getLength() && theBasicCharClass::get().isDigit(aLine[nCol] & 0xFF)) ||
-            (nCol + 1 < aLine.getLength() && aLine[nCol] == '.' && theBasicCharClass::get().isDigit(aLine[nCol + 1] & 0xFF)))
+    else if((nCol < aLine.getLength() && rtl::isAsciiDigit(aLine[nCol])) ||
+            (nCol + 1 < aLine.getLength() && aLine[nCol] == '.' && rtl::isAsciiDigit(aLine[nCol + 1])))
     {
         short exp = 0;
         short dec = 0;
diff --git a/basic/source/inc/basiccharclass.hxx b/basic/source/inc/basiccharclass.hxx
index 335bff6..e6fea65 100644
--- a/basic/source/inc/basiccharclass.hxx
+++ b/basic/source/inc/basiccharclass.hxx
@@ -35,9 +35,8 @@ public:
     bool isLetter( sal_Unicode c );
     bool isLetterUnicode( sal_Unicode c );
     bool isAlpha( sal_Unicode c, bool bCompatible );
-    bool isDigit( sal_Unicode c );
     bool isAlphaNumeric( sal_Unicode c, bool bCompatible );
-    bool isWhitespace( sal_Unicode c );
+    static bool isWhitespace( sal_Unicode c );
 };
 
 class theBasicCharClass: public rtl::Static<BasicCharClass, theBasicCharClass> {};


More information about the Libreoffice-commits mailing list