compilerplugins/clang/conststringvar.cxx | 17 + compilerplugins/clang/stringconstant.cxx | 65 +++++- connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx | 8 dbaccess/source/ui/dlg/dbadmin.cxx | 2 forms/source/xforms/propertysetbase.hxx | 2 linguistic/source/dicimp.cxx | 2 sal/qa/OStringBuffer/rtl_String_Const.h | 98 +++++----- sal/qa/rtl/process/rtl_Process_Const.h | 8 sc/qa/unit/helper/shared_test_impl.hxx | 4 sc/source/filter/xml/xmldrani.cxx | 4 sd/source/ui/remotecontrol/BluetoothServer.cxx | 2 sdext/source/pdfimport/test/tests.cxx | 2 sw/source/filter/html/css1atr.cxx | 4 vcl/source/app/svdata.cxx | 4 xmloff/source/chart/ColorPropertySet.cxx | 6 xmloff/source/draw/animationimport.cxx | 2 xmloff/source/meta/xmlmetae.cxx | 22 +- 17 files changed, 154 insertions(+), 98 deletions(-)
New commits: commit 618785dfd28a6cf8f075371afd451b6440718e07 Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:27:40 2017 +0100 Some loplugin:conststringvar/stringconstant improvements Change-Id: I73f694e6dedb84b3fb3b63ffb9dcda2481bc403c diff --git a/compilerplugins/clang/conststringvar.cxx b/compilerplugins/clang/conststringvar.cxx index a6d348a..f113416 100644 --- a/compilerplugins/clang/conststringvar.cxx +++ b/compilerplugins/clang/conststringvar.cxx @@ -65,8 +65,23 @@ public: } bool TraverseImplicitCastExpr(ImplicitCastExpr * expr) { + bool match; + switch (expr->getCastKind()) { + case CK_NoOp: + // OString CharPtrDetector ctor: + match = bool( + loplugin::TypeCheck(expr->getType()).Const().Pointer().Const() + .Char()); + break; + case CK_LValueToRValue: + match = true; + break; + default: + match = false; + break; + } bool pushed = false; - if (expr->getCastKind() == CK_LValueToRValue) { + if (match) { if (auto dr = dyn_cast<DeclRefExpr>( expr->getSubExpr()->IgnoreParenImpCasts())) { diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx index d8f04a6..259cee7 100644 --- a/compilerplugins/clang/stringconstant.cxx +++ b/compilerplugins/clang/stringconstant.cxx @@ -671,6 +671,7 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { { ChangeKind kind; PassThrough pass; + bool simplify; switch (expr->getConstructor()->getNumParams()) { case 1: if (!loplugin::TypeCheck( @@ -681,6 +682,7 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { } kind = ChangeKind::SingleChar; pass = PassThrough::NonEmptyConstantString; + simplify = false; break; case 2: { @@ -691,6 +693,7 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { { kind = ChangeKind::OUStringLiteral1; pass = PassThrough::NonEmptyConstantString; + simplify = false; } else { unsigned n; bool non; @@ -732,9 +735,52 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { pass = n == 0 ? PassThrough::EmptyConstantString : PassThrough::NonEmptyConstantString; + simplify = false; } break; } + case 4: + { + unsigned n; + bool non; + bool emb; + bool trm; + if (!isStringConstant( + expr->getArg(0)->IgnoreParenImpCasts(), &n, &non, &emb, + &trm)) + { + return true; + } + APSInt res; + if (!expr->getArg(1)->EvaluateAsInt( + res, compiler.getASTContext()) + || res != n) + { + return true; + } + if (!expr->getArg(2)->EvaluateAsInt( + res, compiler.getASTContext()) + || res != 11) // RTL_TEXTENCODING_ASCII_US + { + return true; + } + if (!expr->getArg(3)->EvaluateAsInt( + res, compiler.getASTContext()) + || res != 0x333) // OSTRING_TO_OUSTRING_CVTFLAGS + { + return true; + } + if (non || emb) { + // cf. remaining uses of RTL_CONSTASCII_USTRINGPARAM + return true; + } + kind = ChangeKind::Char; + pass = n == 0 + ? PassThrough::EmptyConstantString + : PassThrough::NonEmptyConstantString; + simplify = true; + break; + } default: return true; } @@ -913,7 +959,6 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { return true; } } - return true; } else if (isa<CXXConstructExpr>(call)) { } else { assert(false); @@ -921,6 +966,14 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) { } } } + if (simplify) { + report( + DiagnosticsEngine::Warning, + "simplify construction of %0 with %1", + expr->getExprLoc()) + << classdecl << describeChangeKind(kind) + << expr->getSourceRange(); + } return true; } return true; @@ -1078,8 +1131,7 @@ bool StringConstant::isStringConstant( bool StringConstant::isZero(Expr const * expr) { APSInt res; - return expr->isIntegerConstantExpr(res, compiler.getASTContext()) - && res == 0; + return expr->EvaluateAsInt(res, compiler.getASTContext()) && res == 0; } void StringConstant::reportChange( @@ -1369,9 +1421,7 @@ void StringConstant::handleCharLen( return; } APSInt res; - if (expr->getArg(arg2)->isIntegerConstantExpr( - res, compiler.getASTContext())) - { + if (expr->getArg(arg2)->EvaluateAsInt(res, compiler.getASTContext())) { if (res != n) { return; } @@ -1395,8 +1445,7 @@ void StringConstant::handleCharLen( &trm2) && n2 == n && non2 == non && emb2 == emb && trm2 == trm //TODO: same strings - && subs->getIdx()->isIntegerConstantExpr( - res, compiler.getASTContext()) + && subs->getIdx()->EvaluateAsInt(res, compiler.getASTContext()) && res == 0)) { return; commit f28939b9f9869b8ac578232dac2bb5d3be9eabf4 Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:27:22 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: connectivity Change-Id: I8b026b61b8744e21584bc64d80a957aca08aae2b diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx index 1b85498..91f4afd 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx @@ -857,7 +857,7 @@ void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const OUString& const char *pCOL = nullptr; - const char* pComma = ","; + const char* const pComma = ","; const OUString* pBegin = types.getConstArray(); const OUString* pEnd = pBegin + types.getLength(); for(;pBegin != pEnd;++pBegin) @@ -1110,11 +1110,7 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(bool _bRowVer,const Any& cat { const char errMsg[] = "ODBC: Trying to get special columns of empty table name"; const char SQLState[] = "HY009"; - throw SQLException( OUString(errMsg, sizeof(errMsg) - sizeof(errMsg[0]), RTL_TEXTENCODING_ASCII_US), - *this, - OUString(SQLState, sizeof(SQLState) - sizeof(SQLState[0]), RTL_TEXTENCODING_ASCII_US), - -1, - Any() ); + throw SQLException( errMsg, *this, SQLState, -1, Any() ); } const OUString *pSchemaPat = nullptr; commit 8f37bcb51cc9b15d89a8959e07ada91e44aec0b8 Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:27:08 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: dbaccess Change-Id: I30fee1c51ff3e0b8e3e74b4293227a5bfbfe0837 diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index b63b4d8..f840c18 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -302,7 +302,7 @@ SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rp _rpPool = nullptr; _rpDefaults = nullptr; - const OUString sFilterAll( "%", 1, RTL_TEXTENCODING_ASCII_US ); + const OUString sFilterAll( "%" ); // create and initialize the defaults _rpDefaults = new std::vector<SfxPoolItem*>(DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1); SfxPoolItem** pCounter = _rpDefaults->data(); // want to modify this without affecting the out param _rppDefaults commit 3dbea89a72f8cbce190310c3187ce870c783c03b Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:27:02 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: forms Change-Id: Iec2be8c9ddbdf8d5d8bc1054c20a0bd40707262a diff --git a/forms/source/xforms/propertysetbase.hxx b/forms/source/xforms/propertysetbase.hxx index 4408f8a..7d9f6b6 100644 --- a/forms/source/xforms/propertysetbase.hxx +++ b/forms/source/xforms/propertysetbase.hxx @@ -346,7 +346,7 @@ public: #define PROPERTY_FLAGS( NAME, TYPE, FLAG ) css::beans::Property( \ - OUString( #NAME, sizeof( #NAME ) - 1, RTL_TEXTENCODING_ASCII_US ), \ + #NAME, \ HANDLE_##NAME, cppu::UnoType<TYPE>::get(), FLAG ) #define PROPERTY( NAME, TYPE ) PROPERTY_FLAGS( NAME, TYPE, css::beans::PropertyAttribute::BOUND ) #define PROPERTY_RO( NAME, TYPE ) PROPERTY_FLAGS( NAME, TYPE, css::beans::PropertyAttribute::BOUND | css::beans::PropertyAttribute::READONLY ) commit 44960f43f50bfa9ed76e9153d23d98f6f0d5665a Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:26:56 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: linguistic Change-Id: Ic41c77c24f43503a7984bae3520948917ec6bb23 diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx index 401398e..96d3cb0 100644 --- a/linguistic/source/dicimp.cxx +++ b/linguistic/source/dicimp.cxx @@ -62,7 +62,7 @@ using namespace linguistic; static const sal_Char* const pVerStr2 = "WBSWG2"; static const sal_Char* const pVerStr5 = "WBSWG5"; static const sal_Char* const pVerStr6 = "WBSWG6"; -static const sal_Char* pVerOOo7 = "OOoUserDict1"; +static const sal_Char* const pVerOOo7 = "OOoUserDict1"; static const sal_Int16 DIC_VERSION_DONTKNOW = -1; static const sal_Int16 DIC_VERSION_2 = 2; commit 5e355dabccdbaa94de8897edc1fd88b16993b493 Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:26:49 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: sal Change-Id: I8b5d81c2b51f846a24fd1f7f9cdd831f1ea54ea5 diff --git a/sal/qa/OStringBuffer/rtl_String_Const.h b/sal/qa/OStringBuffer/rtl_String_Const.h index b6b2511..dca9603 100644 --- a/sal/qa/OStringBuffer/rtl_String_Const.h +++ b/sal/qa/OStringBuffer/rtl_String_Const.h @@ -35,61 +35,61 @@ static const rtl_TextEncoding kEncodingRTLTextUSASCII = RTL_TEXTENCODING_ASCII_U static const sal_uInt32 kConvertFlagsOUStringToOString = OUSTRING_TO_OSTRING_CVTFLAGS; static const sal_uInt32 kConvertFlagsOStringToOUString = OSTRING_TO_OUSTRING_CVTFLAGS; -static const sal_Char *kTestStr1 = "Sun Microsystems"; -static const sal_Char *kTestStr2 = "Sun Microsystems Java Technology"; -static const sal_Char *kTestStr7 = "Sun "; -static const sal_Char *kTestStr8 = "Microsystems"; -static const sal_Char *kTestStr14 = " Sun Microsystems"; -static const sal_Char *kTestStr17 = " Sun Microsystems "; -static const sal_Char *kTestStr23 = " Java Technology"; -static const sal_Char *kTestStr25 = ""; -static const sal_Char *kTestStr27 = "s"; -static const sal_Char *kTestStr28 = "\50\3\5\7\11\13\15\17sun"; -static const sal_Char *kTestStr29 = "\50\3\5\7\11\13\15\17sun\21\23\25\27\31\33\50"; -static const sal_Char *kTestStr31 = "sun Microsystems"; -static const sal_Char *kTestStr36 = "Microsystems Java Technology"; -static const sal_Char *kTestStr37 = "Sun Java Technology"; -static const sal_Char *kTestStr38 = "\21\23\25\27\31\33\50"; -static const sal_Char *kTestStr39 = "\50\3\5\7\11\13\15\17sun Sun Microsystems "; -static const sal_Char *kTestStr40 = "\50\3\5\7\11\13\15\17sunsun Microsystems"; -static const sal_Char *kTestStr45 = "Sun true"; -static const sal_Char *kTestStr46 = "Sun false"; -static const sal_Char *kTestStr47 = "true"; -static const sal_Char *kTestStr48 = "false"; -static const sal_Char *kTestStr49 = "\50\3\5\7\11\13\15\17suntrue"; -static const sal_Char *kTestStr50 = "\50\3\5\7\11\13\15\17sunfalse"; -static const sal_Char *kTestStr51 = "Sun M"; +static const sal_Char * const kTestStr1 = "Sun Microsystems"; +static const sal_Char * const kTestStr2 = "Sun Microsystems Java Technology"; +static const sal_Char * const kTestStr7 = "Sun "; +static const sal_Char * const kTestStr8 = "Microsystems"; +static const sal_Char * const kTestStr14 = " Sun Microsystems"; +static const sal_Char * const kTestStr17 = " Sun Microsystems "; +static const sal_Char * const kTestStr23 = " Java Technology"; +static const sal_Char * const kTestStr25 = ""; +static const sal_Char * const kTestStr27 = "s"; +static const sal_Char * const kTestStr28 = "\50\3\5\7\11\13\15\17sun"; +static const sal_Char * const kTestStr29 = "\50\3\5\7\11\13\15\17sun\21\23\25\27\31\33\50"; +static const sal_Char * const kTestStr31 = "sun Microsystems"; +static const sal_Char * const kTestStr36 = "Microsystems Java Technology"; +static const sal_Char * const kTestStr37 = "Sun Java Technology"; +static const sal_Char * const kTestStr38 = "\21\23\25\27\31\33\50"; +static const sal_Char * const kTestStr39 = "\50\3\5\7\11\13\15\17sun Sun Microsystems "; +static const sal_Char * const kTestStr40 = "\50\3\5\7\11\13\15\17sunsun Microsystems"; +static const sal_Char * const kTestStr45 = "Sun true"; +static const sal_Char * const kTestStr46 = "Sun false"; +static const sal_Char * const kTestStr47 = "true"; +static const sal_Char * const kTestStr48 = "false"; +static const sal_Char * const kTestStr49 = "\50\3\5\7\11\13\15\17suntrue"; +static const sal_Char * const kTestStr50 = "\50\3\5\7\11\13\15\17sunfalse"; +static const sal_Char * const kTestStr51 = "Sun M"; //static const sal_Char *kTestStr52 = "Sun \077777"; //static const sal_Char *kTestStr53 = "Sun \100000"; //static const sal_Char *kTestStr54 = "\77777"; //static const sal_Char *kTestStr55 = "\100000"; -static const sal_Char *kTestStr56 = "\50\3\5\7\11\13\15\17suns"; +static const sal_Char * const kTestStr56 = "\50\3\5\7\11\13\15\17suns"; //static const sal_Char *kTestStr57 = "\50\3\5\7\11\13\15\17sun\77777"; //static const sal_Char *kTestStr58 = "\50\3\5\7\11\13\15\17sun\10000"; -static const sal_Char *kTestStr59 = "Sun 11"; -static const sal_Char *kTestStr60 = "11"; -static const sal_Char *kTestStr61 = "\50\3\5\7\11\13\15\17sun11"; -static const sal_Char *kTestStr62 = "Sun 0"; -static const sal_Char *kTestStr63 = "Sun -11"; -static const sal_Char *kTestStr64 = "Sun 2147483647"; -static const sal_Char *kTestStr65 = "Sun -2147483648"; -static const sal_Char *kTestStr66 = "0"; -static const sal_Char *kTestStr67 = "-11"; -static const sal_Char *kTestStr68 = "2147483647"; -static const sal_Char *kTestStr69 = "-2147483648"; -static const sal_Char *kTestStr70 = "\50\3\5\7\11\13\15\17sun0"; -static const sal_Char *kTestStr71 = "\50\3\5\7\11\13\15\17sun-11"; -static const sal_Char *kTestStr72 = "\50\3\5\7\11\13\15\17sun2147483647"; -static const sal_Char *kTestStr73 = "\50\3\5\7\11\13\15\17sun-2147483648"; -static const sal_Char *kTestStr116 = "Sun 9223372036854775807"; -static const sal_Char *kTestStr117 = "Sun -9223372036854775808"; -static const sal_Char *kTestStr118 = "9223372036854775807"; -static const sal_Char *kTestStr119 = "-9223372036854775808"; -static const sal_Char *kTestStr120 = "\50\3\5\7\11\13\15\17sun9223372036854775807"; -static const sal_Char *kTestStr121 = "\50\3\5\7\11\13\15\17sun-9223372036854775808"; -static const sal_Char *kTestStr143 = "Sun \377"; -static const sal_Char *kTestStr144 = "\377"; -static const sal_Char *kTestStr145 = "\50\3\5\7\11\13\15\17sun\377"; +static const sal_Char * const kTestStr59 = "Sun 11"; +static const sal_Char * const kTestStr60 = "11"; +static const sal_Char * const kTestStr61 = "\50\3\5\7\11\13\15\17sun11"; +static const sal_Char * const kTestStr62 = "Sun 0"; +static const sal_Char * const kTestStr63 = "Sun -11"; +static const sal_Char * const kTestStr64 = "Sun 2147483647"; +static const sal_Char * const kTestStr65 = "Sun -2147483648"; +static const sal_Char * const kTestStr66 = "0"; +static const sal_Char * const kTestStr67 = "-11"; +static const sal_Char * const kTestStr68 = "2147483647"; +static const sal_Char * const kTestStr69 = "-2147483648"; +static const sal_Char * const kTestStr70 = "\50\3\5\7\11\13\15\17sun0"; +static const sal_Char * const kTestStr71 = "\50\3\5\7\11\13\15\17sun-11"; +static const sal_Char * const kTestStr72 = "\50\3\5\7\11\13\15\17sun2147483647"; +static const sal_Char * const kTestStr73 = "\50\3\5\7\11\13\15\17sun-2147483648"; +static const sal_Char * const kTestStr116 = "Sun 9223372036854775807"; +static const sal_Char * const kTestStr117 = "Sun -9223372036854775808"; +static const sal_Char * const kTestStr118 = "9223372036854775807"; +static const sal_Char * const kTestStr119 = "-9223372036854775808"; +static const sal_Char * const kTestStr120 = "\50\3\5\7\11\13\15\17sun9223372036854775807"; +static const sal_Char * const kTestStr121 = "\50\3\5\7\11\13\15\17sun-9223372036854775808"; +static const sal_Char * const kTestStr143 = "Sun \377"; +static const sal_Char * const kTestStr144 = "\377"; +static const sal_Char * const kTestStr145 = "\50\3\5\7\11\13\15\17sun\377"; static const sal_Int32 kTestStr1Len = 16; static const sal_Int32 kTestStr2Len = 32; diff --git a/sal/qa/rtl/process/rtl_Process_Const.h b/sal/qa/rtl/process/rtl_Process_Const.h index 2c0b496..8f5c746 100644 --- a/sal/qa/rtl/process/rtl_Process_Const.h +++ b/sal/qa/rtl/process/rtl_Process_Const.h @@ -27,10 +27,10 @@ extern "C" { #endif -::rtl::OUString suParam0(RTL_CONSTASCII_USTRINGPARAM("-join")); -::rtl::OUString suParam1(RTL_CONSTASCII_USTRINGPARAM("-with")); -::rtl::OUString suParam2(RTL_CONSTASCII_USTRINGPARAM("-child")); -::rtl::OUString suParam3(RTL_CONSTASCII_USTRINGPARAM("-process")); +::rtl::OUString suParam0("-join"); +::rtl::OUString suParam1("-with"); +::rtl::OUString suParam2("-child"); +::rtl::OUString suParam3("-process"); #ifdef __cplusplus } commit 3c29d5a502f5140b65b739543194108d45217250 Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:26:45 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: sc Change-Id: Ie01088776c4339ec7d1fb5941c4e65d95aff8b1f diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx index 7a27d31..b1a850c 100644 --- a/sc/qa/unit/helper/shared_test_impl.hxx +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -276,8 +276,8 @@ void testCeilingFloor_Impl( ScDocument& rDoc ) { // Original test case document is ceiling-floor.xlsx // Sheet1.K1 has =AND(K3:K81) to evaluate all results. - const char* pORef = "Sheet1.K1"; - OUString aRef( OUString::createFromAscii( pORef)); + const char pORef[] = "Sheet1.K1"; + OUString aRef(pORef); ScAddress aPos; aPos.Parse(aRef); if (!checkFormula( rDoc, aPos, "AND(K3:K81)")) diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx index 7f81c22..45b9b29 100644 --- a/sc/source/filter/xml/xmldrani.cxx +++ b/sc/source/filter/xml/xmldrani.cxx @@ -204,9 +204,9 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport, mpQueryParam->nCol2 = maRange.aEnd.Col(); mpQueryParam->nRow2 = maRange.aEnd.Row(); - if (sDatabaseRangeName.matchAsciiL(STR_DB_LOCAL_NONAME, strlen(STR_DB_LOCAL_NONAME))) + if (sDatabaseRangeName.startsWith(STR_DB_LOCAL_NONAME)) meRangeType = ScDBCollection::SheetAnonymous; - else if (sDatabaseRangeName.matchAsciiL(STR_DB_GLOBAL_NONAME, strlen(STR_DB_GLOBAL_NONAME))) + else if (sDatabaseRangeName.startsWith(STR_DB_GLOBAL_NONAME)) meRangeType = ScDBCollection::GlobalAnonymous; } commit 7533e58f7c53644ffaaffc420809230a884a690f Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:26:42 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: sd Change-Id: If44cce6e4c241f6a2203d73f6d191f270fb5ca5a diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx index d515911..28e5c37 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.cxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx @@ -295,7 +295,7 @@ bluez4GetDefaultService( DBusConnection *pConnection ) { DBusMessage *pMsg; DBusMessageIter it; - const gchar* pInterfaceType = "org.bluez.Service"; + const gchar* const pInterfaceType = "org.bluez.Service"; // org.bluez.manager only exists for bluez 4. // getMethodCall should return NULL if there is any issue e.g. the commit e838e360ff3cac7e22b8e010c03b4f9124764843 Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:26:38 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: sdext Change-Id: I47884eeb14a67b7e260835b8603d7b76c7ec018b diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index f651ff8..9e4437e 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -95,7 +95,7 @@ namespace rtl::math::approxEqual(m_aHyperlinkBounds.Y2,406.2) ); CPPUNIT_ASSERT_EQUAL_MESSAGE( "Correct hyperlink URI", OUString("http://download.openoffice.org/"), m_aURI ); - const char* sText = " \n \nThis is a testtext\nNew paragraph,\nnew line\n" + const char* const sText = " \n \nThis is a testtext\nNew paragraph,\nnew line\n" "Hyperlink, this is\n?\nThis is more text\noutline mode\n?\nNew paragraph\n"; OString aTmp; m_aTextOut.makeStringAndClear().convertToString( &aTmp, commit 15e1a0bb4a8813aea57495dc25bc716c17c571a5 Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:26:34 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: sw Change-Id: I5b9c3d2dac275659569141d4eae7b97e3aa397b8 diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 40eb5b5..08acd42 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -163,8 +163,8 @@ static Writer& OutCSS1_SwFormatLayoutSplit( Writer& rWrt, const SfxPoolItem& rHt namespace { -const sal_Char* sCSS1_rule_end = " }"; -const sal_Char* sCSS1_span_tag_end = "\">"; +const sal_Char* const sCSS1_rule_end = " }"; +const sal_Char* const sCSS1_span_tag_end = "\">"; const sal_Char cCSS1_style_opt_end = '\"'; const sal_Char* const sHTML_FTN_fontheight = "57%"; commit 7ca7e52bcaf8383b4643092c8ef4a2d699721ce9 Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:25:47 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: vcl Change-Id: I999549a840864060be4e80fe973ebb530202b807 diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index d7a0715..f29b879 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -171,11 +171,11 @@ ResMgr* ImplGetResMgr() if( !pSVData->mpResMgr && ! bMessageOnce ) { bMessageOnce = true; - const char* pMsg = + const char pMsg[] = "Missing vcl resource. This indicates that files vital to localization are missing. " "You might have a corrupt installation."; SAL_WARN("vcl", "" << pMsg << "\n"); - ScopedVclPtrInstance< MessageDialog > aBox( nullptr, OUString(pMsg, strlen(pMsg), RTL_TEXTENCODING_ASCII_US) ); + ScopedVclPtrInstance< MessageDialog > aBox( nullptr, pMsg ); aBox->Execute(); } } commit 15f84c9cd4bf0a58ce85868c980eeaf1dc330f5c Author: Stephan Bergmann <[email protected]> Date: Wed Jan 11 11:25:42 2017 +0100 Some loplugin:conststringvar/stringconstant improvements: xmloff Change-Id: I05e03936d9e5518fa7ba4d9c72d5b8e241e32526 diff --git a/xmloff/source/chart/ColorPropertySet.cxx b/xmloff/source/chart/ColorPropertySet.cxx index 0494864..7061bac 100644 --- a/xmloff/source/chart/ColorPropertySet.cxx +++ b/xmloff/source/chart/ColorPropertySet.cxx @@ -50,8 +50,7 @@ private: }; lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo() : - // note: length of FillColor and LineColor is 9 - m_aColorPropName( "FillColor", 9, RTL_TEXTENCODING_ASCII_US ), + m_aColorPropName( "FillColor" ), m_aColorProp( m_aColorPropName, -1, cppu::UnoType<sal_Int32>::get(), 0) {} @@ -85,8 +84,7 @@ namespace chart { ColorPropertySet::ColorPropertySet( sal_Int32 nColor ) : - // note: length of FillColor and LineColor is 9 - m_aColorPropName( "FillColor", 9, RTL_TEXTENCODING_ASCII_US ), + m_aColorPropName( "FillColor" ), m_nColor( nColor ), m_nDefaultColor( 0x0099ccff ) // blue 8 {} diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx index c4c113b..ac7033f 100644 --- a/xmloff/source/draw/animationimport.cxx +++ b/xmloff/source/draw/animationimport.cxx @@ -105,7 +105,7 @@ static ::rtl::OUString lcl_GetMediaReference(SvXMLImport const& rImport, ::rtl::OUString const& rURL) { if (rImport.IsPackageURL(rURL)) - return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.Package:")) + rURL; + return "vnd.sun.star.Package:" + rURL; return rImport.GetAbsoluteReference(rURL); } diff --git a/xmloff/source/meta/xmlmetae.cxx b/xmloff/source/meta/xmlmetae.cxx index 6532545..9d94e79 100644 --- a/xmloff/source/meta/xmlmetae.cxx +++ b/xmloff/source/meta/xmlmetae.cxx @@ -295,10 +295,10 @@ void SvXMLMetaExport::MExport_() } } -static const char * const s_xmlns = "xmlns"; -static const char * const s_xmlns2 = "xmlns:"; -static const char * const s_meta = "meta:"; -static const char * const s_href = "xlink:href"; +static const char s_xmlns[] = "xmlns"; +static const char s_xmlns2[] = "xmlns:"; +static const char s_meta[] = "meta:"; +static const char s_href[] = "xlink:href"; SvXMLMetaExport::SvXMLMetaExport( SvXMLExport& i_rExp, @@ -326,11 +326,9 @@ void SvXMLMetaExport::Export() key != USHRT_MAX; key = rNsMap.GetNextKey(key)) { beans::StringPair ns; const OUString attrname = rNsMap.GetAttrNameByKey(key); - if (attrname.matchAsciiL(s_xmlns2, strlen(s_xmlns2))) { - ns.First = attrname.copy(strlen(s_xmlns2)); - } else if (attrname.equalsAsciiL(s_xmlns, strlen(s_xmlns))) { - // default initialized empty string - } else { + if (!attrname.startsWith(s_xmlns2, &ns.First) + || attrname == s_xmlns) // default initialized empty string + { assert(!"namespace attribute not starting with xmlns unexpected"); } ns.Second = rNsMap.GetNameByKey(key); @@ -376,7 +374,7 @@ SvXMLMetaExport::startElement(const OUString & i_rName, const sal_Int16 nCount = i_xAttribs->getLength(); for (sal_Int16 i = 0; i < nCount; ++i) { const OUString name(i_xAttribs->getNameByIndex(i)); - if (name.matchAsciiL(s_xmlns, strlen(s_xmlns))) { + if (name.startsWith(s_xmlns)) { bool found(false); const SvXMLNamespaceMap & rNsMap(mrExport.GetNamespaceMap()); for (sal_uInt16 key = rNsMap.GetFirstKey(); @@ -419,14 +417,14 @@ SvXMLMetaExport::startElement(const OUString & i_rName, } // attach the attributes - if (i_rName.matchAsciiL(s_meta, strlen(s_meta))) { + if (i_rName.startsWith(s_meta)) { // special handling for all elements that may have // xlink:href attributes; these must be made relative const sal_Int16 nLength = i_xAttribs->getLength(); for (sal_Int16 i = 0; i < nLength; ++i) { const OUString name (i_xAttribs->getNameByIndex (i)); OUString value(i_xAttribs->getValueByIndex(i)); - if (name.matchAsciiL(s_href, strlen(s_href))) { + if (name.startsWith(s_href)) { value = mrExport.GetRelativeReference(value); } mrExport.AddAttribute(name, value); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
