From 52bbd9cc00b5a1e15e4f96b5c5fa5e75855692c1 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 19 Nov 2013 17:06:06 +0200 Subject: remove unnecessary RTL_CONSTASCII_STRINGPARAM in appendAscii calls Convert code like: aStrBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ln(x)" )); to: aStrBuf.append( "ln(x)" ); which compiles down to the same code. Change-Id: I24c7cb45ceb32fd7cd6ec7ed203c2a5d746f1c5c --- stoc/source/implementationregistration/implreg.cxx | 47 +++++++++------------- stoc/source/security/access_controller.cxx | 14 +++---- stoc/source/security/file_policy.cxx | 16 ++++---- stoc/source/security/permissions.cxx | 35 ++++++++-------- stoc/source/servicemanager/servicemanager.cxx | 2 +- .../uriproc/ExternalUriReferenceTranslator.cxx | 2 +- stoc/source/uriproc/UriReference.cxx | 2 +- .../uriproc/VndSunStarPkgUrlReferenceFactory.cxx | 2 +- stoc/test/uriproc/test_uriproc.cxx | 8 ++-- 9 files changed, 57 insertions(+), 71 deletions(-) (limited to 'stoc') diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index b7ee54998eb1..0f9ce337503d 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -999,13 +999,11 @@ static void insert_singletons( if (! is_supported_service( service_name, xExistingService_td )) { OUStringBuffer buf( 64 ); - buf.appendAscii( - RTL_CONSTASCII_STRINGPARAM("existing singleton service (") ); + buf.append( "existing singleton service (" ); buf.append( singleton_name ); buf.append( (sal_Unicode)'=' ); buf.append( existing_name ); - buf.appendAscii( - RTL_CONSTASCII_STRINGPARAM(") does not support given one: ") ); + buf.append( ") does not support given one: " ); buf.append( service_name ); throw registry::CannotRegisterImplementationException( buf.makeStringAndClear(), Reference< XInterface >() ); @@ -1378,8 +1376,7 @@ void ImplementationRegistration::initialize( if( aArgs.getLength() != 4 ) { OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "ImplementationRegistration::initialize() expects 4 parameters, got ")); + buf.append( "ImplementationRegistration::initialize() expects 4 parameters, got " ); buf.append( (sal_Int32) aArgs.getLength() ); throw IllegalArgumentException( buf.makeStringAndClear(), Reference (), @@ -1397,11 +1394,10 @@ void ImplementationRegistration::initialize( } if( !rLoader.is()) { OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "ImplementationRegistration::initialize() invalid first parameter," - "expected " ) ); + buf.append( "ImplementationRegistration::initialize() invalid first parameter," + "expected " ); buf.append( getCppuType( &rLoader ).getTypeName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", got " ) ); + buf.append( ", got " ); buf.append( aArgs.getConstArray()[0].getValueTypeName() ); throw IllegalArgumentException( buf.makeStringAndClear(), Reference< XInterface > (), @@ -1414,9 +1410,8 @@ void ImplementationRegistration::initialize( } if( loaderServiceName.isEmpty() ) { OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "ImplementationRegistration::initialize() invalid second parameter," - "expected string, got " ) ); + buf.append( "ImplementationRegistration::initialize() invalid second parameter," + "expected string, got " ); buf.append( aArgs.getConstArray()[1].getValueTypeName() ); throw IllegalArgumentException( buf.makeStringAndClear(), Reference< XInterface > (), @@ -1429,9 +1424,8 @@ void ImplementationRegistration::initialize( } if( locationUrl.isEmpty() ) { OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "ImplementationRegistration::initialize() invalid third parameter," - "expected string, got " ) ); + buf.append( "ImplementationRegistration::initialize() invalid third parameter," + "expected string, got " ); buf.append( aArgs.getConstArray()[2].getValueTypeName() ); throw IllegalArgumentException( buf.makeStringAndClear(), Reference< XInterface > (), @@ -1447,11 +1441,10 @@ void ImplementationRegistration::initialize( rReg = getRegistryFromServiceManager(); if( !rReg.is() ) { OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "ImplementationRegistration::initialize() invalid fourth parameter," - "expected " )); + buf.append( "ImplementationRegistration::initialize() invalid fourth parameter," + "expected " ); buf.append( getCppuType( &rReg ).getTypeName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", got " ) ); + buf.append( ", got " ); buf.append( aArgs.getConstArray()[3].getValueTypeName() ); throw IllegalArgumentException( buf.makeStringAndClear(), Reference< XInterface > (), @@ -1542,22 +1535,20 @@ void ImplementationRegistration::prepareRegister( catch( const InvalidRegistryException & e ) { OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "ImplementationRegistration::registerImplementation() " - "InvalidRegistryException during registration (" )); + buf.append( "ImplementationRegistration::registerImplementation() " + "InvalidRegistryException during registration (" ); buf.append( e.Message ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) ); + buf.append( ")" ); throw CannotRegisterImplementationException( buf.makeStringAndClear(), Reference< XInterface > () ); } catch( const MergeConflictException & e ) { OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "ImplementationRegistration::registerImplementation() " - "MergeConflictException during registration (" )); + buf.append( "ImplementationRegistration::registerImplementation() " + "MergeConflictException during registration (" ); buf.append( e.Message ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) ); + buf.append( ")" ); throw CannotRegisterImplementationException( buf.makeStringAndClear(), Reference< XInterface > () ); } diff --git a/stoc/source/security/access_controller.cxx b/stoc/source/security/access_controller.cxx index 5f59ed156526..ee218a8e5eb8 100644 --- a/stoc/source/security/access_controller.cxx +++ b/stoc/source/security/access_controller.cxx @@ -562,14 +562,13 @@ static void dumpPermissions( OUStringBuffer buf( 48 ); if (!userId.isEmpty()) { - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("> dumping permissions of user \"") ); + buf.append( "> dumping permissions of user \"" ); buf.append( userId ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\":") ); + buf.append( "\":" ); } else { - buf.appendAscii( - RTL_CONSTASCII_STRINGPARAM("> dumping default permissions:") ); + buf.append( "> dumping default permissions:" ); } OString str( OUStringToOString( buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ) ); OSL_TRACE( "%s", str.getStr() ); @@ -715,9 +714,9 @@ PermissionCollection AccessController::getEffectivePermissions( } #ifdef __DIAGNOSE OUStringBuffer buf( 48 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("> info: recurring call of user \"") ); + buf.append( "> info: recurring call of user \"" ); buf.append( userId ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\"") ); + buf.append( "\"" ); OString str( OUStringToOString( buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ) ); OSL_TRACE( "%s", str.getStr() ); @@ -807,8 +806,7 @@ PermissionCollection AccessController::getEffectivePermissions( { clearPostPoned(); // safety: exception could have happened before checking postponed? OUStringBuffer buf( 64 ); - buf.appendAscii( - RTL_CONSTASCII_STRINGPARAM("deployment error (AccessControlException occurred): ") ); + buf.append( "deployment error (AccessControlException occurred): " ); buf.append( exc.Message ); throw DeploymentException( buf.makeStringAndClear(), exc.Context ); } diff --git a/stoc/source/security/file_policy.cxx b/stoc/source/security/file_policy.cxx index 46ba89f2b205..36bb86641757 100644 --- a/stoc/source/security/file_policy.cxx +++ b/stoc/source/security/file_policy.cxx @@ -207,9 +207,9 @@ void PolicyReader::assureToken( sal_Unicode token ) if (c == token) return; OUStringBuffer buf( 16 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("expected >") ); + buf.append( "expected >" ); buf.append( c ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("() ); } @@ -390,9 +390,9 @@ PolicyReader::PolicyReader( OUString const & fileName, AccessControl & ac ) if (osl_File_E_None != ::osl_openFile( m_fileName.pData, &m_file, osl_File_OpenFlag_Read )) { OUStringBuffer buf( 32 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("cannot open file \"") ); + buf.append( "cannot open file \"" ); buf.append( m_fileName ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\"!") ); + buf.append( "\"!" ); throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface >() ); } } diff --git a/stoc/source/security/permissions.cxx b/stoc/source/security/permissions.cxx index 34bb834ef339..448db7ea9f75 100644 --- a/stoc/source/security/permissions.cxx +++ b/stoc/source/security/permissions.cxx @@ -70,7 +70,7 @@ static inline sal_Int32 makeMask( if (! strings[ nPos ]) { OUStringBuffer buf( 48 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("### ignoring unknown socket action: ") ); + buf.append( "### ignoring unknown socket action: " ); buf.append( item ); OString str( OUStringToOString( buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ) ); @@ -243,8 +243,7 @@ OUString SocketPermission::toString() const SAL_THROW(()) { OUStringBuffer buf( 48 ); // host - buf.appendAscii( - RTL_CONSTASCII_STRINGPARAM("com.sun.star.connection.SocketPermission (host=\"") ); + buf.append( "com.sun.star.connection.SocketPermission (host=\"" ); buf.append( m_host ); if (m_resolvedHost) { @@ -266,9 +265,9 @@ OUString SocketPermission::toString() const SAL_THROW(()) } } // actions - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\", actions=\"") ); + buf.append( "\", actions=\"" ); buf.append( makeStrings( m_actions, s_actions ) ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\")") ); + buf.append( "\")" ); return buf.makeStringAndClear(); } @@ -327,14 +326,14 @@ FilePermission::FilePermission( { OUStringBuffer buf( 64 ); buf.append( getWorkingDir() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/*") ); + buf.append( "/*" ); m_url = buf.makeStringAndClear(); } else if ( m_url == "-" ) { OUStringBuffer buf( 64 ); buf.append( getWorkingDir() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/-") ); + buf.append( "/-" ); m_url = buf.makeStringAndClear(); } else if (!m_url.startsWith("file:///")) @@ -420,12 +419,12 @@ OUString FilePermission::toString() const SAL_THROW(()) { OUStringBuffer buf( 48 ); // url - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("com.sun.star.io.FilePermission (url=\"") ); + buf.append( "com.sun.star.io.FilePermission (url=\"" ); buf.append( m_url ); // actions - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\", actions=\"") ); + buf.append( "\", actions=\"" ); buf.append( makeStrings( m_actions, s_actions ) ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\")") ); + buf.append( "\")" ); return buf.makeStringAndClear(); } @@ -462,10 +461,9 @@ bool RuntimePermission::implies( Permission const & perm ) const SAL_THROW(()) OUString RuntimePermission::toString() const SAL_THROW(()) { OUStringBuffer buf( 48 ); - buf.appendAscii( - RTL_CONSTASCII_STRINGPARAM("com.sun.star.security.RuntimePermission (name=\"") ); + buf.append( "com.sun.star.security.RuntimePermission (name=\"" ); buf.append( m_name ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\")") ); + buf.append( "\")" ); return buf.makeStringAndClear(); } @@ -519,8 +517,7 @@ PermissionCollection::PermissionCollection( else { OUStringBuffer buf( 48 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "checking for unsupported permission type: ") ); + buf.append( "checking for unsupported permission type: " ); buf.append( perm_type.getTypeName() ); throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface >() ); @@ -560,9 +557,9 @@ static void demanded_diag( SAL_THROW(()) { OUStringBuffer buf( 48 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("demanding ") ); + buf.append( "demanding " ); buf.append( perm.toString() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" => ok.") ); + buf.append( " => ok." ); OString str( OUStringToOString( buf.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US ) ); OSL_TRACE( "%s", str.getStr() ); @@ -574,7 +571,7 @@ static void throwAccessControlException( SAL_THROW( (security::AccessControlException) ) { OUStringBuffer buf( 48 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("access denied: ") ); + buf.append( "access denied: " ); buf.append( perm.toString() ); throw security::AccessControlException( buf.makeStringAndClear(), Reference< XInterface >(), demanded_perm ); @@ -642,7 +639,7 @@ void PermissionCollection::checkPermission( Any const & perm ) const else { OUStringBuffer buf( 48 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("checking for unsupported permission type: ") ); + buf.append( "checking for unsupported permission type: " ); buf.append( demanded_type.getTypeName() ); throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface >() ); diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index 18f3b7aa86d4..13d5725ebb82 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -1538,7 +1538,7 @@ Sequence ORegistryServiceManager::getFromServiceName( const OUString& serviceName ) { OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/SERVICES/" ) ); + buf.append( "/SERVICES/" ); buf.append( serviceName ); return retrieveAsciiValueList( m_xRegistry, buf.makeStringAndClear() ); } diff --git a/stoc/source/uriproc/ExternalUriReferenceTranslator.cxx b/stoc/source/uriproc/ExternalUriReferenceTranslator.cxx index b042197bd858..91f5b8cd68d8 100644 --- a/stoc/source/uriproc/ExternalUriReferenceTranslator.cxx +++ b/stoc/source/uriproc/ExternalUriReferenceTranslator.cxx @@ -114,7 +114,7 @@ OUString Translator::translateToInternal( // authority part; treat them as having an empty authority part: if (!externalUriReference.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("//"), i)) { - buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("//")); + buf.append("//"); } rtl_TextEncoding encoding = osl_getThreadTextEncoding(); for (bool path = true;;) { diff --git a/stoc/source/uriproc/UriReference.cxx b/stoc/source/uriproc/UriReference.cxx index 312203d78587..3544b60e2c96 100644 --- a/stoc/source/uriproc/UriReference.cxx +++ b/stoc/source/uriproc/UriReference.cxx @@ -184,7 +184,7 @@ void UriReference::clearFragment() throw (css::uno::RuntimeException) { void UriReference::appendSchemeSpecificPart(OUStringBuffer & buffer) const { if (m_hasAuthority) { - buffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("//")); + buffer.append("//"); buffer.append(m_authority); } buffer.append(m_path); diff --git a/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx b/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx index 16aa0780cd56..f8234f2397c8 100644 --- a/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx +++ b/stoc/source/uriproc/VndSunStarPkgUrlReferenceFactory.cxx @@ -106,7 +106,7 @@ Factory::createVndSunStarPkgUrlReference( OSL_ASSERT(authority.is()); if (authority->isAbsolute() && !authority->hasFragment()) { OUStringBuffer buf; - buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.pkg://")); + buf.append("vnd.sun.star.pkg://"); buf.append( rtl::Uri::encode( authority->getUriReference(), rtl_UriCharClassRegName, diff --git a/stoc/test/uriproc/test_uriproc.cxx b/stoc/test/uriproc/test_uriproc.cxx index a82875a13e08..a7be7da9bc2f 100644 --- a/stoc/test/uriproc/test_uriproc.cxx +++ b/stoc/test/uriproc/test_uriproc.cxx @@ -89,13 +89,13 @@ OString createTestAssertEqualMessage( append(buf, token2); buf.append(static_cast< sal_Unicode >('|')); append(buf, token3); - buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(": TEST_ASSERT_EQUAL(")); + buf.append(": TEST_ASSERT_EQUAL("); buf.appendAscii(expectedExpr); - buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(", ")); + buf.append(", "); buf.appendAscii(actualExpr); - buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("): <")); + buf.append("): <"); append(buf, expected); - buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("> != <")); + buf.append("> != <"); append(buf, actual); buf.append(static_cast< sal_Unicode >('>')); return OUStringToOString( -- cgit