Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Apparently the issue was that I actually wasn't using the parameter :)
I've attached a preliminary patch (my first!) for review.

August Sodora
augsod@gmail.com
(201) 280-8138



On Sun, Oct 2, 2011 at 3:16 AM, Tor Lillqvist <tml@iki.fi> wrote:
It sounds at least reasonable to me. The normal thing is to add new
in-line functions to ustring.hxx, that saves punching a hole in the
(accursed) map file for libsal (in sal/util/sal.map) -

I am not 100% sure, but I think that in some cases (--enable-dbgutil build
with MSVC is what I am thinking of) an explicit implementation is needed
anyway. (Can't check right now.)

--tml
From 0868784236ecf6f0393da143d3783bf35e5bc123 Mon Sep 17 00:00:00 2001
From: August Sodora <aasodora@oc8513601644.ibm.com>
Date: Sun, 2 Oct 2011 17:33:10 -0400
Subject: [PATCH 1/2] String->OUString

---
 basic/source/comp/exprtree.cxx |    2 +-
 basic/source/comp/parser.cxx   |    6 +++---
 basic/source/comp/scanner.cxx  |   31 +++++++++++++++++--------------
 basic/source/comp/token.cxx    |   39 ++++++++++++++++++++++-----------------
 basic/source/inc/expr.hxx      |    2 +-
 basic/source/inc/scanner.hxx   |    4 ++--
 basic/source/inc/token.hxx     |    2 +-
 sal/inc/rtl/ustring.hxx        |    5 +++++
 8 files changed, 52 insertions(+), 39 deletions(-)

diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index 1c7ec1b..2acf90cc 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -208,7 +208,7 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
     SbiToken eTok = (pKeywordSymbolInfo == NULL) ? pParser->Next() : pKeywordSymbolInfo->m_eTok;
     // memorize the parsing's begin
     pParser->LockColumn();
-    String aSym( (pKeywordSymbolInfo == NULL) ? pParser->GetSym() : 
pKeywordSymbolInfo->m_aKeywordSymbol );
+    ::rtl::OUString aSym( (pKeywordSymbolInfo == NULL) ? pParser->GetSym() : 
pKeywordSymbolInfo->m_aKeywordSymbol );
     SbxDataType eType = (pKeywordSymbolInfo == NULL) ? pParser->GetType() : 
pKeywordSymbolInfo->m_eSbxDataType;
     SbiParameters* pPar = NULL;
     SbiExprListVector* pvMoreParLcl = NULL;
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index b8fb78f..3b09dc5 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -676,7 +676,7 @@ void SbiParser::DefXXX()
     while( !bAbort )
     {
         if( Next() != SYMBOL ) break;
-        ch1 = aSym.ToUpperAscii().GetBuffer()[0];
+        ch1 = aSym.toAsciiUpperCase().getStr()[0];
         ch2 = 0;
         if( Peek() == MINUS )
         {
@@ -684,7 +684,7 @@ void SbiParser::DefXXX()
             if( Next() != SYMBOL ) Error( SbERR_SYMBOL_EXPECTED );
             else
             {
-                ch2 = aSym.ToUpperAscii().GetBuffer()[0];
+                ch2 = aSym.toAsciiUpperCase().getStr()[0];
                 if( ch2 < ch1 ) Error( SbERR_SYNTAX ), ch2 = 0;
             }
         }
@@ -784,7 +784,7 @@ void SbiParser::Option()
             SbiToken eTok = Next();
             if( eTok == BINARY )
                 bText = sal_False;
-            else if( eTok == SYMBOL && GetSym().EqualsIgnoreCaseAscii("text") )
+            else if( eTok == SYMBOL && 
GetSym().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("text")) )
                 bText = sal_True;
             else
                 Error( SbERR_EXPECTED, "Text/Binary" );
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 1dec4db..767945f 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -173,7 +173,7 @@ sal_Bool SbiScanner::NextSym()
     bHash = sal_False;
 
     eScanType = SbxVARIANT;
-    aSym.Erase();
+    aSym = ::rtl::OUString();
     bSymbol =
     bNumber = bSpaces = sal_False;
 
@@ -241,7 +241,7 @@ sal_Bool SbiScanner::NextSym()
         aSym = aLine.copy( n, nCol - n );
 
         // Special handling for "go to"
-        if( bCompatible && *pLine && aSym.EqualsIgnoreCaseAscii( "go" ) )
+        if( bCompatible && *pLine && aSym.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( 
"go" ) ) )
         {
             const sal_Unicode* pTestLine = pLine;
             short nTestCol = nCol;
@@ -266,10 +266,8 @@ sal_Bool SbiScanner::NextSym()
         // replace closing '_' by space when end of line is following
         // (wrong line continuation otherwise)
         if( !bUsedForHilite && !*pLine && *(pLine-1) == '_' )
-        {
-            aSym.GetBufferAccess();     // #109693 force copy if necessary
             *((sal_Unicode*)(pLine-1)) = ' ';       // cast because of const
-        }
+
         // type recognition?
         // don't test the exclamation mark
         // if there's a symbol behind it
@@ -384,7 +382,9 @@ sal_Bool SbiScanner::NextSym()
                 break;
             default :
                 // treated as an operator
-                pLine--; nCol--; nCol1 = nCol-1; aSym = '&'; return SYMBOL;
+                pLine--; nCol--; nCol1 = nCol-1; 
+                aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&")); 
+                return SYMBOL;
         }
         bNumber = sal_True;
         long l = 0;
@@ -450,13 +450,15 @@ sal_Bool SbiScanner::NextSym()
         // get out duplicate string delimiters
         String s( cSep );
         s += cSep;
-        sal_uInt16 nIdx = 0;
+        sal_Int32 nIdx = 0;
         do
         {
-            nIdx = aSym.Search( s, nIdx );
-            if( nIdx == STRING_NOTFOUND )
+            ::rtl::OUStringBuffer aSymBuf(aSym);
+            nIdx = aSym.indexOf( s, nIdx );
+            if( nIdx >= 0 )
                 break;
-            aSym.Erase( nIdx, 1 );
+            aSymBuf.remove( nIdx, 1 );
+            aSym = aSymBuf.makeStringAndClear();
             nIdx++;
         }
         while( true );
@@ -487,10 +489,11 @@ sal_Bool SbiScanner::NextSym()
 PrevLineCommentLbl:
 
     if( bPrevLineExtentsComment || (eScanType != SbxSTRING &&
-        ( aSym.GetBuffer()[0] == '\'' || aSym.EqualsIgnoreCaseAscii( "REM" ) ) ) )
+                                    ( aSym.getStr()[0] == '\'' || 
+                                      aSym.equalsIgnoreAsciiCaseAsciiL( 
RTL_CONSTASCII_STRINGPARAM( "REM" ) ) ) ) )
     {
         bPrevLineExtentsComment = sal_False;
-        aSym = String::CreateFromAscii( "REM" );
+        aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "REM" ));
         sal_uInt16 nLen = String( pLine ).Len();
         if( bCompatible && pLine[ nLen - 1 ] == '_' && pLine[ nLen - 2 ] == ' ' )
             bPrevLineExtentsComment = sal_True;
@@ -505,7 +508,7 @@ eoln:
     {
         pLine = NULL;
         bool bRes = NextSym();
-        if( bVBASupportOn && aSym.GetBuffer()[0] == '.' )
+        if( bVBASupportOn && aSym.getStr()[0] == '.' )
         {
             // object _
             //    .Method
@@ -521,7 +524,7 @@ eoln:
         nLine = nOldLine;
         nCol1 = nOldCol1;
         nCol2 = nOldCol2;
-        aSym = '\n';
+        aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
         nColLock = 0;
         return sal_True;
     }
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index 1027d5b..3bf1037 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -281,19 +281,25 @@ SbiToken SbiTokenizer::Peek()
 
 // For decompilation. Numbers and symbols return an empty string.
 
-const String& SbiTokenizer::Symbol( SbiToken t )
+const ::rtl::OUString& SbiTokenizer::Symbol( SbiToken t )
 {
     // character token?
     if( t < FIRSTKWD )
     {
-        aSym = (char) t;
+        aSym = ::rtl::OUString::valueOf(sal::static_int_cast<sal_Unicode>(t));
         return aSym;
     }
     switch( t )
     {
-        case NEG   : aSym = '-'; return aSym;
-        case EOS   : aSym = String::CreateFromAscii( ":/CRLF" ); return aSym;
-        case EOLN  : aSym = String::CreateFromAscii( "CRLF" ); return aSym;
+        case NEG   : 
+            aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
+            return aSym;
+        case EOS   : 
+            aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":/CRLF"));
+            return aSym;
+        case EOLN  : 
+            aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CRLF"));
+            return aSym;
         default: break;
     }
     TokenTable* tp = pTokTable;
@@ -301,12 +307,12 @@ const String& SbiTokenizer::Symbol( SbiToken t )
     {
         if( tp->t == t )
         {
-            aSym = String::CreateFromAscii( tp->s );
+            aSym = ::rtl::OUString::createFromAscii( tp->s );
             return aSym;
         }
     }
-    const sal_Unicode *p = aSym.GetBuffer();
-    if (*p <= ' ') aSym = String::CreateFromAscii( "???" );
+    const sal_Unicode *p = aSym.getStr();
+    if (*p <= ' ') aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("???"));
     return aSym;
 }
 
@@ -337,7 +343,7 @@ SbiToken SbiTokenizer::Next()
         return eCurTok = EOLN;
     }
 
-    if( aSym.GetBuffer()[0] == '\n' )
+    if( aSym.getStr()[0] == '\n' )
     {
         bEos = sal_True; return eCurTok = EOLN;
     }
@@ -350,9 +356,9 @@ SbiToken SbiTokenizer::Next()
         return eCurTok = FIXSTRING;
     // Special cases of characters that are between "Z" and "a". ICompare()
     // evaluates the position of these characters in different ways.
-    else if( aSym.GetBuffer()[0] == '^' )
+    else if( aSym.getStr()[0] == '^' )
         return eCurTok = EXPON;
-    else if( aSym.GetBuffer()[0] == '\\' )
+    else if( aSym.getStr()[0] == '\\' )
         return eCurTok = IDIV;
     else
     {
@@ -367,17 +373,16 @@ SbiToken SbiTokenizer::Next()
         {
             delta = (ub - lb) >> 1;
             tp = &pTokTable[ lb + delta ];
-            StringCompare res = aSym.CompareIgnoreCaseToAscii( tp->s );
+            sal_Int32 res = aSym.compareToIgnoreAsciiCaseAscii( tp->s );
 
-            if( res == COMPARE_EQUAL )
+            if( res == 0 )
                 goto special;
 
-            if( res == COMPARE_LESS )
+            if( res < 0 )
             {
                 if ((ub - lb) == 2) ub = lb;
                 else ub = ub - delta;
             }
-
             else
             {
                 if ((ub -lb) == 2) lb = ub;
@@ -385,7 +390,7 @@ SbiToken SbiTokenizer::Next()
             }
         } while( delta );
         // Symbol? if not >= token
-        sal_Unicode ch = aSym.GetBuffer()[0];
+        sal_Unicode ch = aSym.getStr()[0];
         if( !BasicSimpleCharClass::isAlpha( ch, bCompatible ) && !bSymbol )
             return eCurTok = (SbiToken) (ch & 0x00FF);
         return eCurTok = SYMBOL;
@@ -457,7 +462,7 @@ special:
     if( bCompatible )
     {
         // #129904 Suppress system
-        if( eTok == STOP && aSym.CompareIgnoreCaseToAscii( "system" ) == COMPARE_EQUAL )
+        if( eTok == STOP && aSym.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "system" 
) ) )
             eCurTok = SYMBOL;
 
         if( eTok == GET && bStartOfLine )
diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx
index 3cc12b0..0a7d4aa 100644
--- a/basic/source/inc/expr.hxx
+++ b/basic/source/inc/expr.hxx
@@ -55,7 +55,7 @@ struct SbVar {
 
 struct KeywordSymbolInfo
 {
-    String          m_aKeywordSymbol;
+    ::rtl::OUString m_aKeywordSymbol;
     SbxDataType     m_eSbxDataType;
     SbiToken        m_eTok;
 };
diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx
index 06447fa..baba425 100644
--- a/basic/source/inc/scanner.hxx
+++ b/basic/source/inc/scanner.hxx
@@ -46,7 +46,7 @@ class SbiScanner
     const sal_Unicode* pLine;
     const sal_Unicode* pSaveLine;
 protected:
-    String aSym;
+    ::rtl::OUString aSym;
     String aError;
     SbxDataType eScanType;
     StarBASIC* pBasic;                  // instance for error callbacks
@@ -96,7 +96,7 @@ public:
     sal_Bool  DoesColonFollow();
 
     sal_Bool NextSym();
-    const String& GetSym()          { return aSym;  }
+    const ::rtl::OUString& GetSym() { return aSym;  }
     SbxDataType GetType()           { return eScanType; }
     double    GetDbl()              { return nVal;  }
 };
diff --git a/basic/source/inc/token.hxx b/basic/source/inc/token.hxx
index 666c8e4..1048176 100644
--- a/basic/source/inc/token.hxx
+++ b/basic/source/inc/token.hxx
@@ -155,7 +155,7 @@ public:
     inline sal_Bool IsEos()             { return bEos; }
 
     void  Push( SbiToken );
-    const String& Symbol( SbiToken );   // reconversion
+    const ::rtl::OUString& Symbol( SbiToken );   // reconversion
 
     SbiToken Peek();                    // read the next token
     SbiToken Next();                    // read a token
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index ed268d9..1587077 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -596,6 +596,11 @@ public:
         return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, 
asciiStr ) == 0;
     }
 
+    sal_Int32 compareToIgnoreAsciiCaseAscii( const sal_Char * asciiStr ) const SAL_THROW(())
+    {
+        return rtl_ustr_ascii_compareIgnoreAsciiCase_WithLength( pData->buffer, pData->length, 
asciiStr );
+    }
+
     /**
       Perform a ASCII lowercase comparison of two strings.
 
-- 
1.7.4.4


From 5c5779575db7bf30d3a267395aa6391b33485b70 Mon Sep 17 00:00:00 2001
From: August Sodora <aasodora@oc8513601644.ibm.com>
Date: Sun, 2 Oct 2011 19:39:05 -0400
Subject: [PATCH 2/2] String->OUString

---
 basic/source/comp/scanner.cxx |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 767945f..9e67144 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -448,14 +448,14 @@ sal_Bool SbiScanner::NextSym()
         else
             aSym = aLine.copy( n, nCol - n - 1 );
         // get out duplicate string delimiters
-        String s( cSep );
-        s += cSep;
+        ::rtl::OUString s = ::rtl::OUString::valueOf( static_cast<sal_Unicode>( cSep ) );
+        s += s;
         sal_Int32 nIdx = 0;
         do
         {
             ::rtl::OUStringBuffer aSymBuf(aSym);
             nIdx = aSym.indexOf( s, nIdx );
-            if( nIdx >= 0 )
+            if( nIdx < 0 )
                 break;
             aSymBuf.remove( nIdx, 1 );
             aSym = aSymBuf.makeStringAndClear();
-- 
1.7.4.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.