[Libreoffice-commits] core.git: 3 commits - configmgr/source extensions/source include/rtl unoidl/source

Stephan Bergmann sbergman at redhat.com
Tue Oct 15 13:52:43 PDT 2013


 configmgr/source/access.cxx                          |   10 +
 configmgr/source/components.cxx                      |   16 --
 configmgr/source/data.cxx                            |   11 -
 extensions/source/update/check/download.cxx          |    6 -
 extensions/source/update/check/updatecheckconfig.cxx |    7 -
 extensions/source/update/check/updatehdl.cxx         |   46 ++------
 extensions/source/update/check/updatehdl.hxx         |    1 
 include/rtl/string.hxx                               |   47 ++++++--
 include/rtl/ustring.hxx                              |  109 ++++++++++++++-----
 unoidl/source/sourceprovider-parser.y                |    7 -
 unoidl/source/unoidl-read.cxx                        |    3 
 unoidl/source/unoidl-write.cxx                       |    3 
 12 files changed, 156 insertions(+), 110 deletions(-)

New commits:
commit d9da04ddc1d72eea1a691652117d37319570fa31
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 15 22:52:13 2013 +0200

    Some string clean-up
    
    Change-Id: Ic046150605c599746ed3235c04bcbc981e18e589

diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx
index 093ef02..4809cf4 100644
--- a/extensions/source/update/check/download.cxx
+++ b/extensions/source/update/check/download.cxx
@@ -201,17 +201,17 @@ Download::getProxyForURL(const OUString& rURL, OString& rHost, sal_Int32& rPort)
     sal_Int32 nProxyType = aValue.get< sal_Int32 >();
     if( 0 != nProxyType ) // type 0 means "direct connection to the internet
     {
-        if( rURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("http:")) )
+        if( rURL.startsWith("http:") )
         {
             rHost = getStringValue(xNameAccess, "ooInetHTTPProxyName");
             rPort = getInt32Value(xNameAccess, "ooInetHTTPProxyPort");
         }
-        else if( rURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("https:")) )
+        else if( rURL.startsWith("https:") )
         {
             rHost = getStringValue(xNameAccess, "ooInetHTTPSProxyName");
             rPort = getInt32Value(xNameAccess, "ooInetHTTPSProxyPort");
         }
-        else if( rURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("ftp:")) )
+        else if( rURL.startsWith("ftp:") )
         {
             rHost = getStringValue(xNameAccess, "ooInetFTPProxyName");
             rPort = getInt32Value(xNameAccess, "ooInetFTPProxyPort");
diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx
index d739bdc..198414a 100644
--- a/extensions/source/update/check/updatecheckconfig.cxx
+++ b/extensions/source/update/check/updatecheckconfig.cxx
@@ -592,16 +592,13 @@ UpdateCheckConfig::commitChanges()
             for( sal_Int32 i=0; i<nChanges; ++i )
             {
                 aChangesSet[i].Accessor >>= aString;
-
-                // FIXME: use non IgnoreAsciiCase version as soon as it becomes available
-                if( aString.endsWithIgnoreAsciiCaseAsciiL(AUTOCHECK_ENABLED "']", sizeof(AUTOCHECK_ENABLED)+1) )
+                if( aString.endsWith(AUTOCHECK_ENABLED "']") )
                 {
                     sal_Bool bEnabled = sal_False;
                     aChangesSet[i].Element >>= bEnabled;
                     m_rListener->autoCheckStatusChanged(sal_True == bEnabled);
                 }
-                // FIXME: use non IgnoreAsciiCase version as soon as it becomes available
-                else if( aString.endsWithIgnoreAsciiCaseAsciiL(CHECK_INTERVAL "']", sizeof(CHECK_INTERVAL)+1) )
+                else if( aString.endsWith(CHECK_INTERVAL "']") )
                 {
                     m_rListener->autoCheckIntervalChanged();
                 }
diff --git a/extensions/source/update/check/updatehdl.cxx b/extensions/source/update/check/updatehdl.cxx
index 86fc8ff..57ff85f 100644
--- a/extensions/source/update/check/updatehdl.cxx
+++ b/extensions/source/update/check/updatehdl.cxx
@@ -611,20 +611,6 @@ void UpdateHandler::updateState( UpdateState eState )
 }
 
 //--------------------------------------------------------------------
-void UpdateHandler::searchAndReplaceAll( OUString &rText,
-                                         const OUString &rWhat,
-                                         const OUString &rWith ) const
-{
-    sal_Int32 nIndex = rText.indexOf( rWhat );
-
-    while ( nIndex != -1 )
-    {
-        rText = rText.replaceAt( nIndex, rWhat.getLength(), rWith );
-        nIndex = rText.indexOf( rWhat, nIndex );
-    }
-}
-
-//--------------------------------------------------------------------
 OUString UpdateHandler::loadString( const uno::Reference< resource::XResourceBundle > xBundle,
                                          sal_Int32 nResourceId ) const
 {
@@ -646,14 +632,11 @@ OUString UpdateHandler::loadString( const uno::Reference< resource::XResourceBun
 
 OUString UpdateHandler::substVariables( const OUString &rSource ) const
 {
-    OUString sString( rSource );
-
-    searchAndReplaceAll( sString, "%NEXTVERSION", msNextVersion );
-    searchAndReplaceAll( sString, "%DOWNLOAD_PATH", msDownloadPath );
-    searchAndReplaceAll( sString, "%FILE_NAME", msDownloadFile );
-    searchAndReplaceAll( sString, "%PERCENT", OUString::number( mnPercent ) );
-
-    return sString;
+    return rSource
+        .replaceAll( "%NEXTVERSION", msNextVersion )
+        .replaceAll( "%DOWNLOAD_PATH", msDownloadPath )
+        .replaceAll( "%FILE_NAME", msDownloadFile )
+        .replaceAll( "%PERCENT", OUString::number( mnPercent ) );
 }
 
 //--------------------------------------------------------------------
@@ -866,13 +849,9 @@ void UpdateHandler::setFullVersion( OUString& rString )
 
     OUString aProductVersion;
     xNameAccess->getByName("ooSetupVersion") >>= aProductVersion;
-    sal_Int32 nVerIndex = rString.indexOf( aProductVersion );
-    if ( nVerIndex != -1 )
-    {
-        OUString aProductFullVersion;
-        xNameAccess->getByName("ooSetupVersionAboutBox") >>= aProductFullVersion;
-        rString = rString.replaceAt( nVerIndex, aProductVersion.getLength(), aProductFullVersion );
-    }
+    OUString aProductFullVersion;
+    xNameAccess->getByName("ooSetupVersionAboutBox") >>= aProductFullVersion;
+    rString = rString.replaceFirst( aProductVersion, aProductFullVersion );
 }
 
 //--------------------------------------------------------------------
@@ -996,10 +975,11 @@ bool UpdateHandler::showWarning( const OUString &rWarningText,
 //--------------------------------------------------------------------
 bool UpdateHandler::showOverwriteWarning( const OUString& rFileName ) const
 {
-    OUString aMsg( msReloadWarning );
-    searchAndReplaceAll( aMsg, "%FILENAME", rFileName );
-    searchAndReplaceAll( aMsg, "%DOWNLOAD_PATH", msDownloadPath );
-    return showWarning( aMsg, msReloadContinue, msReloadReload );
+    return showWarning(
+        (msReloadWarning
+         .replaceAll( "%FILENAME", rFileName )
+         .replaceAll( "%DOWNLOAD_PATH", msDownloadPath )),
+        msReloadContinue, msReloadReload );
 }
 
 //--------------------------------------------------------------------
diff --git a/extensions/source/update/check/updatehdl.hxx b/extensions/source/update/check/updatehdl.hxx
index 661b6a8..ee65381 100644
--- a/extensions/source/update/check/updatehdl.hxx
+++ b/extensions/source/update/check/updatehdl.hxx
@@ -156,7 +156,6 @@ private:
                                                 com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > const & rProps );
 
     void                    setFullVersion( OUString& rString );
-    void                    searchAndReplaceAll( OUString &rText, const OUString &rWhat, const OUString &rWith ) const;
 
 public:
                             UpdateHandler( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rxContext,
commit 57af2ee947feb06caaa8ffca1320a950bb049605
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 15 22:46:05 2013 +0200

    Allow starts-/endsWith* to also return the rest of the matched string
    
    ...as there are many cases where the code later wants to obtain this part, and
    esp. for the string literal variants it is awkward to calculate the length of
    the literal again if this is coded with a following copy() call.  Adapt some
    code to use this new feature.
    
    (Strictly speaking, the @since tags for the---backwards-compatibly---modified
    functions are no longer accurate of course.  Also, clean up some sal_Bool and
    SAL_THROWS(()) that are unnecesssary cargo-cult here, and where the clean-up
    should have no practical compatibility consequences.)
    
    Change-Id: I43e5c578c8c4b44cb47fd08f170b5c69322ad641

diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 31c632c..a181d62 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -1398,9 +1398,11 @@ rtl::Reference< Node > Access::getParentNode() {
 }
 
 rtl::Reference< ChildAccess > Access::getChild(OUString const & name) {
-    if (getNode()->kind() == Node::KIND_LOCALIZED_PROPERTY && name.match("*")) {
-        OUString locale(name.copy(1));
-        if (locale.match("*")) {
+    OUString locale;
+    if (getNode()->kind() == Node::KIND_LOCALIZED_PROPERTY
+        && name.startsWith("*", &locale))
+    {
+        if (locale.startsWith("*")) {
             SAL_WARN(
                 "configmgr",
                 ("access best-matching localized property value via"
@@ -1443,7 +1445,7 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) {
                  i != children.end(); ++i)
             {
                 OUString name2((*i)->getNameInternal());
-                if (name2.match(locale) &&
+                if (name2.startsWith(locale) &&
                     (name2.getLength() == locale.getLength() ||
                      name2[locale.getLength()] == '-' ||
                      name2[locale.getLength()] == '_'))
diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index b5b38b5..85865fd 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -43,9 +43,7 @@
 #include "osl/mutex.hxx"
 #include "rtl/bootstrap.hxx"
 #include "rtl/ref.hxx"
-#include "rtl/string.h"
 #include "rtl/ustrbuf.hxx"
-#include "rtl/ustring.h"
 #include "rtl/ustring.hxx"
 #include "rtl/instance.hxx"
 #include "sal/log.hxx"
@@ -639,9 +637,7 @@ void Components::parseFiles(
             parseFiles(layer, extension, parseFile, stat.getFileURL(), true);
         } else {
             OUString file(stat.getFileName());
-            if (file.getLength() >= extension.getLength() &&
-                file.match(extension, file.getLength() - extension.getLength()))
-            {
+            if (file.endsWith(extension)) {
                 try {
                     parseFileLeniently(
                         parseFile, stat.getFileURL(), layer, data_, 0, 0, 0);
@@ -718,14 +714,8 @@ void Components::parseXcdFiles(int layer, OUString const & url) {
         }
         if (stat.getFileType() != osl::FileStatus::Directory) { //TODO: symlinks
             OUString file(stat.getFileName());
-            if (file.getLength() >= RTL_CONSTASCII_LENGTH(".xcd") &&
-                file.matchAsciiL(
-                    RTL_CONSTASCII_STRINGPARAM(".xcd"),
-                    file.getLength() - RTL_CONSTASCII_LENGTH(".xcd")))
-            {
-                OUString name(
-                    file.copy(
-                        0, file.getLength() - RTL_CONSTASCII_LENGTH(".xcd")));
+            OUString name;
+            if (file.endsWith(".xcd", &name)) {
                 existingDeps.insert(name);
                 rtl::Reference< ParseManager > manager;
                 try {
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index e54ce8e..e9c6350 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -682,15 +682,22 @@ public:
     /**
       Check whether this string starts with a given substring.
 
-      @param str  the substring to be compared
+      @param str the substring to be compared
+
+      @param rest if non-null, and this function returns true, then assign a
+      copy of the remainder of this string to *rest
 
       @return true if and only if the given str appears as a substring at the
       start of this string
 
       @since LibreOffice 4.0
     */
-    bool startsWith(OString const & str) const {
-        return match(str, 0);
+    bool startsWith(OString const & str, OString * rest = 0) const {
+        bool b = match(str, 0);
+        if (b && rest != 0) {
+            *rest = copy(str.getLength());
+        }
+        return b;
     }
 
     /**
@@ -699,25 +706,37 @@ public:
      @since LibreOffice 4.0
     */
     template< typename T >
-    typename internal::ConstCharArrayDetector< T, bool >::Type startsWith( T& literal ) const
+    typename internal::ConstCharArrayDetector< T, bool >::Type startsWith(
+        T & literal, OString * rest = 0) const
     {
         RTL_STRING_CONST_FUNCTION
-        return match(literal, 0);
+        bool b = match(literal, 0);
+        if (b && rest != 0) {
+            *rest = copy(internal::ConstCharArrayDetector< T, void >::size - 1);
+        }
+        return b;
     }
 
     /**
       Check whether this string ends with a given substring.
 
-      @param str  the substring to be compared
+      @param str the substring to be compared
+
+      @param rest if non-null, and this function returns true, then assign a
+      copy of the remainder of this string to *rest
 
       @return true if and only if the given str appears as a substring at the
       end of this string
 
       @since LibreOffice 3.6
     */
-    bool endsWith(OString const & str) const {
-        return str.getLength() <= getLength()
+    bool endsWith(OString const & str, OString * rest = 0) const {
+        bool b = str.getLength() <= getLength()
             && match(str, getLength() - str.getLength());
+        if (b && rest != 0) {
+            *rest = copy(0, getLength() - str.getLength());
+        }
+        return b;
     }
 
     /**
@@ -726,12 +745,20 @@ public:
      @since LibreOffice 3.6
     */
     template< typename T >
-    typename internal::ConstCharArrayDetector< T, bool >::Type endsWith( T& literal ) const
+    typename internal::ConstCharArrayDetector< T, bool >::Type endsWith(
+        T & literal, OString * rest = 0) const
     {
         RTL_STRING_CONST_FUNCTION
         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
-        return internal::ConstCharArrayDetector< T, void >::size - 1 <= getLength()
+        bool b = internal::ConstCharArrayDetector< T, void >::size - 1 <= getLength()
             && match(literal, getLength() - ( internal::ConstCharArrayDetector< T, void >::size - 1 ));
+        if (b && rest != 0) {
+            *rest = copy(
+                0,
+                (getLength()
+                 - (internal::ConstCharArrayDetector< T, void >::size - 1)));
+        }
+        return b;
     }
 
     /**
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index daa0ff5..ba8c358 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -923,15 +923,22 @@ public:
     /**
       Check whether this string starts with a given substring.
 
-      @param str  the substring to be compared
+      @param str the substring to be compared
+
+      @param rest if non-null, and this function returns true, then assign a
+      copy of the remainder of this string to *rest
 
       @return true if and only if the given str appears as a substring at the
       start of this string
 
       @since LibreOffice 4.0
     */
-    bool startsWith(OUString const & str) const {
-        return match(str, 0);
+    bool startsWith(OUString const & str, OUString * rest = 0) const {
+        bool b = match(str, 0);
+        if (b && rest != 0) {
+            *rest = copy(str.getLength());
+        }
+        return b;
     }
 
     /**
@@ -940,12 +947,17 @@ public:
      @since LibreOffice 4.0
     */
     template< typename T >
-    typename internal::ConstCharArrayDetector< T, bool >::Type startsWith( T& literal ) const
+    typename internal::ConstCharArrayDetector< T, bool >::Type startsWith(
+        T & literal, OUString * rest = 0) const
     {
         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
-        return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
+        bool b = internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
             && rtl_ustr_asciil_reverseEquals_WithLength( pData->buffer, literal,
                 internal::ConstCharArrayDetector< T, void >::size - 1);
+        if (b && rest != 0) {
+            *rest = copy(internal::ConstCharArrayDetector< T, void >::size - 1);
+        }
+        return b;
     }
 
     /**
@@ -956,14 +968,25 @@ public:
       values between 97 and 122 (ASCII a-z).
       This function can't be used for language specific comparison.
 
-      @param    str         the object (substring) to be compared.
-      @return true if this string starts with str, ignoring the case of ASCII
-      letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
+      @param str the substring to be compared
+
+      @param rest if non-null, and this function returns true, then assign a
+      copy of the remainder of this string to *rest
+
+      @return true if and only if the given str appears as a substring at the
+      start of this string, ignoring the case of ASCII letters ("A"--"Z" and
+      "a"--"z")
+
       @since LibreOffice 4.0
     */
-    sal_Bool startsWithIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
+    bool startsWithIgnoreAsciiCase(OUString const & str, OUString * rest = 0)
+        const
     {
-        return matchIgnoreAsciiCase(str, 0);
+        bool b = matchIgnoreAsciiCase(str, 0);
+        if (b && rest != 0) {
+            *rest = copy(str.getLength());
+        }
+        return b;
     }
 
     /**
@@ -972,29 +995,41 @@ public:
      @since LibreOffice 4.0
     */
     template< typename T >
-    typename internal::ConstCharArrayDetector< T, bool >::Type startsWithIgnoreAsciiCase( T& literal ) const SAL_THROW(())
+    typename internal::ConstCharArrayDetector< T, bool >::Type
+    startsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
     {
         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
-        return (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+        bool b = (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
                     pData->buffer,
                     internal::ConstCharArrayDetector< T, void >::size - 1, literal,
                     internal::ConstCharArrayDetector< T, void >::size - 1)
                 == 0);
+        if (b && rest != 0) {
+            *rest = copy(internal::ConstCharArrayDetector< T, void >::size - 1);
+        }
+        return b;
     }
 
     /**
       Check whether this string ends with a given substring.
 
-      @param str  the substring to be compared
+      @param str the substring to be compared
+
+      @param rest if non-null, and this function returns true, then assign a
+      copy of the remainder of this string to *rest
 
       @return true if and only if the given str appears as a substring at the
       end of this string
 
       @since LibreOffice 3.6
     */
-    bool endsWith(OUString const & str) const {
-        return str.getLength() <= getLength()
+    bool endsWith(OUString const & str, OUString * rest = 0) const {
+        bool b = str.getLength() <= getLength()
             && match(str, getLength() - str.getLength());
+        if (b && rest != 0) {
+            *rest = copy(0, getLength() - str.getLength());
+        }
+        return b;
     }
 
     /**
@@ -1003,13 +1038,21 @@ public:
      @since LibreOffice 3.6
     */
     template< typename T >
-    typename internal::ConstCharArrayDetector< T, bool >::Type endsWith( T& literal ) const
+    typename internal::ConstCharArrayDetector< T, bool >::Type
+    endsWith(T & literal, OUString * rest = 0) const
     {
         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
-        return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
+        bool b = internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
             && rtl_ustr_asciil_reverseEquals_WithLength(
                 pData->buffer + pData->length - ( internal::ConstCharArrayDetector< T, void >::size - 1 ), literal,
                 internal::ConstCharArrayDetector< T, void >::size - 1);
+        if (b && rest != 0) {
+            *rest = copy(
+                0,
+                (getLength()
+                 - (internal::ConstCharArrayDetector< T, void >::size - 1)));
+        }
+        return b;
     }
 
     /**
@@ -1040,15 +1083,25 @@ public:
       values between 97 and 122 (ASCII a-z).
       This function can't be used for language specific comparison.
 
-      @param    str         the object (substring) to be compared.
-      @return true if this string ends with str, ignoring the case of ASCII
-      letters ("A"--"Z" and "a"--"z"); otherwise, false is returned
+      @param str the substring to be compared
+
+      @param rest if non-null, and this function returns true, then assign a
+      copy of the remainder of this string to *rest
+
+      @return true if and only if the given str appears as a substring at the
+      end of this string, ignoring the case of ASCII letters ("A"--"Z" and
+      "a"--"z")
+
       @since LibreOffice 3.6
     */
-    sal_Bool endsWithIgnoreAsciiCase( const OUString & str ) const SAL_THROW(())
+    bool endsWithIgnoreAsciiCase(OUString const & str, OUString * rest) const
     {
-        return str.getLength() <= getLength()
+        bool b =  str.getLength() <= getLength()
             && matchIgnoreAsciiCase(str, getLength() - str.getLength());
+        if (b && rest != 0) {
+            *rest = copy(0, getLength() - str.getLength());
+        }
+        return b;
     }
 
     /**
@@ -1057,15 +1110,23 @@ public:
      @since LibreOffice 3.6
     */
     template< typename T >
-    typename internal::ConstCharArrayDetector< T, bool >::Type endsWithIgnoreAsciiCase( T& literal ) const SAL_THROW(())
+    typename internal::ConstCharArrayDetector< T, bool >::Type
+    endsWithIgnoreAsciiCase(T & literal, OUString * rest = 0) const
     {
         assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 );
-        return internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
+        bool b = internal::ConstCharArrayDetector< T, void >::size - 1 <= pData->length
             && (rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
                     pData->buffer + pData->length - ( internal::ConstCharArrayDetector< T, void >::size - 1 ),
                     internal::ConstCharArrayDetector< T, void >::size - 1, literal,
                     internal::ConstCharArrayDetector< T, void >::size - 1)
                 == 0);
+        if (b && rest != 0) {
+            *rest = copy(
+                0,
+                (getLength()
+                 - (internal::ConstCharArrayDetector< T, void >::size - 1)));
+        }
+        return b;
     }
 
     /**
diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y
index 6512e4a..8f813c3 100644
--- a/unoidl/source/sourceprovider-parser.y
+++ b/unoidl/source/sourceprovider-parser.y
@@ -261,9 +261,7 @@ unoidl::detail::SourceProviderEntity * findEntity_(
     assert(data != 0);
     assert(name != 0);
     OUString n;
-    if (name->startsWith(".")) {
-        n = name->copy(1);
-    } else {
+    if (!name->startsWith(".", &n)) {
         for (std::vector<OUString>::const_reverse_iterator i(data->modules.rbegin());
              i != data->modules.rend(); ++i)
         {
@@ -345,7 +343,7 @@ Found findEntity(
                         static_cast<unoidl::TypedefEntity *>(e->entity.get())
                         ->getType());
                     typeNucleus = t;
-                    while (typeNucleus.startsWith("[]")) {
+                    while (typeNucleus.startsWith("[]", &typeNucleus)) {
                         if (!args.empty()) {
                             error(
                                 location, yyscanner,
@@ -363,7 +361,6 @@ Found findEntity(
                             return FOUND_ERROR;
                         }
                         ++rank;
-                        typeNucleus = typeNucleus.copy(2);
                     }
                     sal_Int32 i = typeNucleus.indexOf('<');
                     if (i != -1) {
diff --git a/unoidl/source/unoidl-read.cxx b/unoidl/source/unoidl-read.cxx
index 2bbe8b6..1a76335 100644
--- a/unoidl/source/unoidl-read.cxx
+++ b/unoidl/source/unoidl-read.cxx
@@ -91,9 +91,8 @@ OUString decomposeType(
     OUString nucl(type);
     *rank = 0;
     typeArguments->clear();
-    while (nucl.startsWith("[]")) {
+    while (nucl.startsWith("[]", &nucl)) {
         ++*rank;
-        nucl = nucl.copy(2);
     }
     sal_Int32 i = nucl.indexOf('<');
     if (i != -1) {
diff --git a/unoidl/source/unoidl-write.cxx b/unoidl/source/unoidl-write.cxx
index ad9268e..8b3b3bf 100644
--- a/unoidl/source/unoidl-write.cxx
+++ b/unoidl/source/unoidl-write.cxx
@@ -57,12 +57,11 @@ void badUsage() {
 OUString getArgumentUri(sal_uInt32 argument, bool * entities) {
     OUString arg;
     rtl_getAppCommandArg(argument, &arg.pData);
-    if (arg.startsWith("@")) {
+    if (arg.startsWith("@", &arg)) {
         if (entities == 0) {
             badUsage();
         }
         *entities = true;
-        arg = arg.copy(1);
     } else if (entities != 0) {
         *entities = false;
     }
commit bb20def9f65689633928fe2f6f5e34584122b17e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 15 22:44:39 2013 +0200

    Simplify some matchAsciiL -> match
    
    Change-Id: Ib0cac79b86ed60b4df1fc90db15842cc99abc1e9

diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx
index 146da67..dfca764 100644
--- a/configmgr/source/data.cxx
+++ b/configmgr/source/data.cxx
@@ -56,18 +56,13 @@ bool decode(
     while (begin != end) {
         sal_Unicode c = encoded[begin++];
         if (c == '&') {
-            if (encoded.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("amp;"), begin))
-            {
+            if (encoded.match("amp;", begin)) {
                 buf.append(sal_Unicode('&'));
                 begin += RTL_CONSTASCII_LENGTH("amp;");
-            } else if (encoded.matchAsciiL(
-                           RTL_CONSTASCII_STRINGPARAM("quot;"), begin))
-            {
+            } else if (encoded.match("quot;", begin)) {
                 buf.append(sal_Unicode('"'));
                 begin += RTL_CONSTASCII_LENGTH("quot;");
-            } else if (encoded.matchAsciiL(
-                           RTL_CONSTASCII_STRINGPARAM("apos;"), begin))
-            {
+            } else if (encoded.match("apos;", begin)) {
                 buf.append(sal_Unicode('\''));
                 begin += RTL_CONSTASCII_LENGTH("apos;");
             } else {


More information about the Libreoffice-commits mailing list