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

Noel Grandin noel at peralex.com
Mon Feb 22 14:55:44 UTC 2016


 basic/source/classes/sbxmod.cxx  |   19 ++++++++++++++----
 basic/source/comp/dim.cxx        |    8 +++++--
 basic/source/comp/exprnode.cxx   |   36 ++++++++++++++++++++++++++++------
 basic/source/comp/exprtree.cxx   |    6 +++--
 basic/source/comp/io.cxx         |    6 ++++-
 basic/source/comp/loops.cxx      |   11 ++++++++--
 basic/source/comp/parser.cxx     |   11 ++++++++--
 basic/source/comp/scanner.cxx    |   41 ++++++++++++++++++++++++++++++---------
 basic/source/runtime/iosys.cxx   |    6 +++--
 basic/source/runtime/runtime.cxx |    9 +++++---
 basic/source/sbx/sbxexec.cxx     |    6 +++--
 basic/source/sbx/sbxscan.cxx     |   24 +++++++++++++++++++---
 basic/source/sbx/sbxstr.cxx      |    5 +++-
 basic/source/sbx/sbxvalue.cxx    |   10 +++++++--
 14 files changed, 156 insertions(+), 42 deletions(-)

New commits:
commit 2d0dab5b150440e1b548ccb64d87883d7c045031
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Feb 22 16:53:50 2016 +0200

    loplugin:commaoperator in basic/
    
    Change-Id: I320a06e50d032a55d8d5e6354959c12327e319ee

diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 4d9a9f0..033dd04 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1202,7 +1202,9 @@ void SbModule::Run( SbMethod* pMeth )
                 clearNativeObjectWrapperVector();
 
                 SAL_WARN_IF(GetSbData()->pInst->nCallLvl != 0,"basic","BASIC-Call-Level > 0");
-                delete GetSbData()->pInst, GetSbData()->pInst = nullptr, bDelInst = false;
+                delete GetSbData()->pInst;
+                GetSbData()->pInst = nullptr;
+                bDelInst = false;
 
                 // #i30690
                 SolarMutexGuard aSolarGuard;
@@ -1486,7 +1488,10 @@ const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine,
             p = reinterpret_cast<const sal_uInt8*>(pImg->GetCode()) + nOp1;
         }
         else if( eOp >= SbOP1_START && eOp <= SbOP1_END )
-            p += 4, nPC += 4;
+        {
+            p += 4;
+            nPC += 4;
+        }
         else if( eOp == _STMNT )
         {
             sal_uInt32 nl, nc;
@@ -1498,7 +1503,10 @@ const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine,
             return p;
         }
         else if( eOp >= SbOP2_START && eOp <= SbOP2_END )
-            p += 8, nPC += 8;
+        {
+            p += 8;
+            nPC += 8;
+        }
         else if( !( eOp >= SbOP0_START && eOp <= SbOP0_END ) )
         {
             StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
@@ -1580,7 +1588,10 @@ bool SbModule::ClearBP( sal_uInt16 nLine )
                 break;
         }
         if( pBreaks->empty() )
-            delete pBreaks, pBreaks = nullptr;
+        {
+            delete pBreaks;
+            pBreaks = nullptr;
+        }
     }
     return bRes;
 }
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index ffd7174f..e13bd62 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -225,7 +225,10 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
     if( eCurTok == _CONST_ )
         bConst = true;
     else if( Peek() == _CONST_ )
-        Next(), bConst = true;
+    {
+        Next();
+        bConst = true;
+    }
 
     // #110004 It can also be a sub/function
     if( !bConst && (eCurTok == SUB || eCurTok == FUNCTION || eCurTok == PROPERTY ||
@@ -1225,7 +1228,8 @@ void SbiParser::DefProc( bool bStatic, bool bPrivate )
     }
     else
     {
-        aPublics.Add( pDef ), pProc = pDef;
+        aPublics.Add( pDef );
+        pProc = pDef;
     }
     if( !pProc )
     {
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index d5d9cb6..70de509 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -315,10 +315,26 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* pParser)
             {
                 // Integer operations
                 bool bErr = false;
-                if( nl > SbxMAXLNG ) bErr = true, nl = SbxMAXLNG;
-                else if( nl < SbxMINLNG ) bErr = true, nl = SbxMINLNG;
-                if( nr > SbxMAXLNG ) bErr = true, nr = SbxMAXLNG;
-                else if( nr < SbxMINLNG ) bErr = true, nr = SbxMINLNG;
+                if( nl > SbxMAXLNG )
+                {
+                    bErr = true;
+                    nl = SbxMAXLNG;
+                }
+                else if( nl < SbxMINLNG )
+                {
+                    bErr = true;
+                    nl = SbxMINLNG;
+                }
+                if( nr > SbxMAXLNG )
+                {
+                    bErr = true;
+                    nr = SbxMAXLNG;
+                }
+                else if( nr < SbxMINLNG )
+                {
+                    bErr = true;
+                    nr = SbxMINLNG;
+                }
                 ll = static_cast<long>(nl); lr = static_cast<long>(nr);
                 llMod = static_cast<long>(nl);
                 lrMod = static_cast<long>(nr);
@@ -434,8 +450,16 @@ void SbiExprNode::FoldConstantsUnaryNode(SbiParser* pParser)
             case NOT: {
                 // Integer operation!
                 bool bErr = false;
-                if( nVal > SbxMAXLNG ) bErr = true, nVal = SbxMAXLNG;
-                else if( nVal < SbxMINLNG ) bErr = true, nVal = SbxMINLNG;
+                if( nVal > SbxMAXLNG )
+                {
+                    bErr = true;
+                    nVal = SbxMAXLNG;
+                }
+                else if( nVal < SbxMINLNG )
+                {
+                    bErr = true;
+                    nVal = SbxMINLNG;
+                }
                 if( bErr )
                 {
                     pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW );
diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index 99f1f57..8e3c441 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -781,7 +781,8 @@ SbiExprNode* SbiExpression::Like()
         while( pParser->Peek() == LIKE )
         {
             SbiToken eTok = pParser->Next();
-            pNd = new SbiExprNode( pNd, eTok, Comp() ), nCount++;
+            pNd = new SbiExprNode( pNd, eTok, Comp() );
+            nCount++;
         }
         // multiple operands in a row does not work
         if( nCount > 1 && !pParser->IsVBASupportOn() )
@@ -1107,7 +1108,8 @@ SbiExprListPtr SbiExprList::ParseDimList( SbiParser* pParser )
             if( eTok == TO )
             {
                 auto pExpr2 = o3tl::make_unique<SbiExpression>( pParser );
-                pExpr1->ConvertToIntConstIfPossible(), pExpr2->ConvertToIntConstIfPossible();
+                pExpr1->ConvertToIntConstIfPossible();
+                pExpr2->ConvertToIntConstIfPossible();
                 eTok = pParser->Next();
                 pExprList->bError = pExprList->bError || !pExpr1->IsValid() || !pExpr2->IsValid();
                 pExprList->aData.push_back(std::move(pExpr1));
diff --git a/basic/source/comp/io.cxx b/basic/source/comp/io.cxx
index f991f4ea..4624f6a 100644
--- a/basic/source/comp/io.cxx
+++ b/basic/source/comp/io.cxx
@@ -228,7 +228,11 @@ void SbiParser::Open()
             eTok = Next();
             if( eTok == READ )
             {
-                if( Peek() == WRITE ) Next(), nMode |= StreamMode::SHARE_DENYALL;
+                if( Peek() == WRITE )
+                {
+                    Next();
+                    nMode |= StreamMode::SHARE_DENYALL;
+                }
                 else nMode |= StreamMode::SHARE_DENYREAD;
             }
             else if( eTok == WRITE )
diff --git a/basic/source/comp/loops.cxx b/basic/source/comp/loops.cxx
index 92a4fcb..1c744e8 100644
--- a/basic/source/comp/loops.cxx
+++ b/basic/source/comp/loops.cxx
@@ -367,7 +367,10 @@ void SbiParser::Select()
         if( eTok == CASE )
         {
             if( nNextTarget )
-                aGen.BackChain( nNextTarget ), nNextTarget = 0;
+            {
+                aGen.BackChain( nNextTarget );
+                nNextTarget = 0;
+            }
             aGen.Statement();
 
             bool bDone = false;
@@ -416,7 +419,11 @@ void SbiParser::Select()
 
                 }
                 if( Peek() == COMMA ) Next();
-                else TestEoln(), bDone = true;
+                else
+                {
+                    TestEoln();
+                    bDone = true;
+                }
             }
 
             if( !bElse )
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index 2048163..35481d6 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -437,7 +437,10 @@ bool SbiParser::Parse()
                 (this->*( p->Func ) )();
                 SbxError nSbxErr = SbxBase::GetError();
                 if( nSbxErr )
-                    SbxBase::ResetError(), Error( (SbError)nSbxErr );
+                {
+                    SbxBase::ResetError();
+                    Error( (SbError)nSbxErr );
+                }
             }
         }
         else
@@ -681,7 +684,11 @@ void SbiParser::DefXXX()
             else
             {
                 ch2 = rtl::toAsciiUpperCase(aSym[0]);
-                if( ch2 < ch1 ) Error( ERRCODE_BASIC_SYNTAX ), ch2 = 0;
+                if( ch2 < ch1 )
+                {
+                    Error( ERRCODE_BASIC_SYNTAX );
+                    ch2 = 0;
+                }
             }
         }
         if (!ch2) ch2 = ch1;
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 21188e1..6dfe2c5 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -228,7 +228,10 @@ bool SbiScanner::NextSym()
     {
         bSpaces = true;
         while(nCol < aLine.getLength() && BasicCharClass::isWhitespace(aLine[nCol]))
-            ++pLine, ++nCol;
+        {
+            ++pLine;
+            ++nCol;
+        }
     }
 
     nCol1 = nCol;
@@ -314,7 +317,8 @@ bool SbiScanner::NextSym()
             if( (p-buf) == (BUF_SIZE-1) )
             {
                 bBufOverflow = true;
-                ++pLine, ++nCol;
+                ++pLine;
+                ++nCol;
                 continue;
             }
             // point or exponent?
@@ -334,7 +338,8 @@ bool SbiScanner::NextSym()
                     *p++ = 'E';
                     if (nCol + 1 < aLine.getLength() && (aLine[nCol+1] == '+' || aLine[nCol+1] == '-'))
                     {
-                        ++pLine, ++nCol;
+                        ++pLine;
+                        ++nCol;
                         if( (p-buf) == (BUF_SIZE-1) )
                         {
                             bBufOverflow = true;
@@ -348,7 +353,8 @@ bool SbiScanner::NextSym()
             {
                 *p++ = aLine[nCol];
             }
-            ++pLine, ++nCol;
+            ++pLine;
+            ++nCol;
         }
         *p = 0;
         aSym = p; bNumber = true;
@@ -357,7 +363,8 @@ bool SbiScanner::NextSym()
         SbError nError = 0;
         if (bScanError)
         {
-            --pLine, --nCol;
+            --pLine;
+            --nCol;
             aError = OUString( aLine[nCol]);
             nError = ERRCODE_BASIC_BAD_CHAR_IN_NUMBER;
         }
@@ -460,7 +467,11 @@ bool SbiScanner::NextSym()
                 GenError( ERRCODE_BASIC_BAD_CHAR_IN_NUMBER );
             }
         }
-        if(nCol < aLine.getLength() && aLine[nCol] == '&') ++pLine, ++nCol;
+        if(nCol < aLine.getLength() && aLine[nCol] == '&')
+        {
+            ++pLine;
+            ++nCol;
+        }
         sal_Int32 ls = static_cast<sal_Int32>(lu);
         nVal = (double) ls;
         eScanType = ( ls >= SbxMININT && ls <= SbxMAXINT ) ? SbxINTEGER : SbxLONG;
@@ -473,11 +484,18 @@ bool SbiScanner::NextSym()
     {
         sal_Unicode cSep = *pLine;
         if( cSep == '[' )
-            bSymbol = true, cSep = ']';
+        {
+            bSymbol = true;
+            cSep = ']';
+        }
         sal_Int32 n = nCol + 1;
         while( *pLine )
         {
-            do pLine++, nCol++;
+            do
+            {
+                pLine++;
+                nCol++;
+            }
             while( *pLine && ( *pLine != cSep ) );
             if( *pLine == cSep )
             {
@@ -502,7 +520,12 @@ bool SbiScanner::NextSym()
                         eScanType = ( cSep == '#' ) ? SbxDATE : SbxSTRING;
                     break;
                 }
-            } else aError = OUString(cSep), GenError( ERRCODE_BASIC_EXPECTED );
+            }
+            else
+            {
+                aError = OUString(cSep);
+                GenError( ERRCODE_BASIC_EXPECTED );
+            }
         }
     }
     // invalid characters:
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index f6e9487..a6cdf58 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -620,7 +620,8 @@ SbError SbiStream::Open
     MapError();
     if( nError )
     {
-        delete pStrm, pStrm = nullptr;
+        delete pStrm;
+        pStrm = nullptr;
     }
     return nError;
 }
@@ -793,7 +794,8 @@ void SbiIoSystem::Open(short nCh, const OString& rName, StreamMode nMode, SbiStr
         nError = pChan[ nCh ]->Open( nCh, rName, nMode, nFlags, nLen );
        if( nError )
        {
-            delete pChan[ nCh ], pChan[ nCh ] = nullptr;
+            delete pChan[ nCh ];
+            pChan[ nCh ] = nullptr;
        }
     }
     nChan = 0;
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index a92b12b..b3c092b 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1092,7 +1092,8 @@ void SbiRuntime::ClearGosubStack()
     SbiGosubStack* p;
     while(( p = pGosubStk ) != nullptr )
     {
-        pGosubStk = p->pNext, delete p;
+        pGosubStk = p->pNext;
+        delete p;
     }
     nGosubLvl = 0;
 }
@@ -2168,7 +2169,8 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar )
                 sal_Int32 ub = pDims->Get( i++ )->GetLong();
                 if( ub < lb )
                 {
-                    Error( ERRCODE_BASIC_OUT_OF_RANGE ), ub = lb;
+                    Error( ERRCODE_BASIC_OUT_OF_RANGE );
+                    ub = lb;
                 }
                 pArray->AddDim32( lb, ub );
                 if ( lb != ub )
@@ -3542,7 +3544,8 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt
                 if( t != SbxVARIANT && t != t2 &&
                     t >= SbxINTEGER && t <= SbxSTRING )
                 {
-                    pElem->SetType( t ), bSet = true;
+                    pElem->SetType( t );
+                    bSet = true;
                 }
             }
             // assign pElem to a Ref, to delete a temp-var if applicable
diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx
index 0465bbe..49f56c3 100644
--- a/basic/source/sbx/sbxexec.cxx
+++ b/basic/source/sbx/sbxexec.cxx
@@ -46,7 +46,8 @@ static const sal_Unicode* Symbol( const sal_Unicode* p, OUString& rSym )
         rSym = ++p;
         while( *p && *p != ']' )
         {
-            p++, nLen++;
+            p++;
+            nLen++;
         }
         p++;
     }
@@ -63,7 +64,8 @@ static const sal_Unicode* Symbol( const sal_Unicode* p, OUString& rSym )
             // The it can contain alphabetic characters, numbers or underlines
             while( *p && (rtl::isAsciiAlphanumeric( *p ) || *p == '_') )
             {
-                p++, nLen++;
+                p++;
+                nLen++;
             }
             // BASIC-Standard-Suffixes were ignored
             if( *p && (*p == '%' || *p == '&' || *p == '!' || *p == '#' || *p == '$' ) )
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index bc3d2ca..f108946 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -326,8 +326,16 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth,
     nExp = 0;
     if( nNum > 0.0 )
     {
-        while( nNum <   1.0 ) nNum *= 10.0, nExp--;
-        while( nNum >= 10.0 ) nNum /= 10.0, nExp++;
+        while( nNum <   1.0 )
+        {
+            nNum *= 10.0;
+            nExp--;
+        }
+        while( nNum >= 10.0 )
+        {
+            nNum /= 10.0;
+            nExp++;
+        }
     }
     if( !bFix && !nExpWidth )
         nDig = nDig + nExp;
@@ -393,7 +401,11 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth,
         nExpWidth -= 2;
         *pBuf++ = 'E';
         *pBuf++ =( nExp < 0 ) ?( (nExp = -nExp ), '-' ) : '+';
-        while( nExpWidth > 3 ) *pBuf++ = '0', nExpWidth--;
+        while( nExpWidth > 3 )
+        {
+            *pBuf++ = '0';
+            nExpWidth--;
+        }
         if( nExp >= 100 || nExpWidth == 3 )
         {
             *pBuf++ = sal::static_int_cast< char >(nExp/100 + '0');
@@ -431,7 +443,11 @@ void ImpCvtNum( double nNum, short nPrec, OUString& rRes, bool bCoreString )
     // remove trailing zeros
     for( p = cBuf; *p &&( *p != 'E' ); p++ ) {}
     q = p; p--;
-    while( nPrec && *p == '0' ) nPrec--, p--;
+    while( nPrec && *p == '0' )
+    {
+        nPrec--;
+        p--;
+    }
     if( *p == cDecimalSep ) p--;
     while( *q ) *++p = *q++;
     *++p = 0;
diff --git a/basic/source/sbx/sbxstr.cxx b/basic/source/sbx/sbxstr.cxx
index 71dffbf..f095e04 100644
--- a/basic/source/sbx/sbxstr.cxx
+++ b/basic/source/sbx/sbxstr.cxx
@@ -214,7 +214,10 @@ void ImpPutString( SbxValues* p, const OUString* n )
                     *p->pOUString = *n;
             }
             else
-                delete p->pOUString, p->pOUString = nullptr;
+            {
+                delete p->pOUString;
+                p->pOUString = nullptr;
+            }
             break;
         case SbxOBJECT:
         {
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 692109e..aaf3030 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -1508,7 +1508,10 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
                 r.ReadUChar( n );
                 // Match the Int on this system?
                 if( n > SAL_TYPES_SIZEOFINT )
-                    r.ReadInt32( aData.nLong ), aData.eType = SbxLONG;
+                {
+                    r.ReadInt32( aData.nLong );
+                    aData.eType = SbxLONG;
+                }
                 else {
                     sal_Int32 nInt;
                     r.ReadInt32( nInt );
@@ -1522,7 +1525,10 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
                 r.ReadUChar( n );
                 // Match the UInt on this system?
                 if( n > SAL_TYPES_SIZEOFINT )
-                    r.ReadUInt32( aData.nULong ), aData.eType = SbxULONG;
+                {
+                    r.ReadUInt32( aData.nULong );
+                    aData.eType = SbxULONG;
+                }
                 else {
                     sal_uInt32 nUInt;
                     r.ReadUInt32( nUInt );


More information about the Libreoffice-commits mailing list