[Libreoffice-commits] .: 2 commits - binfilter/bf_sw

Caolán McNamara caolan at kemper.freedesktop.org
Sat Sep 17 15:22:53 PDT 2011


 binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx |   11 ++++-------
 binfilter/bf_sw/source/core/swg/sw_rdnds.cxx     |    8 +++++++-
 2 files changed, 11 insertions(+), 8 deletions(-)

New commits:
commit 9a1321f25cb60f1d2605136124acd912a2ebe4e8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Sep 17 00:27:13 2011 +0100

    ByteString::Expand->comphelper::string::padToLength

diff --git a/binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx b/binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx
index 895beae..965bb03 100644
--- a/binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx
+++ b/binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx
@@ -31,6 +31,7 @@
 
 #include <string.h>
 #include <tools/string.hxx>
+#include <comphelper/string.hxx>
 
 #include <crypter.hxx>
 
@@ -49,8 +50,9 @@ Crypter::Crypter( const ByteString& r )
     { 0xAB, 0x9E, 0x43, 0x05, 0x38, 0x12, 0x4d, 0x44,
       0xD5, 0x7e, 0xe3, 0x84, 0x98, 0x23, 0x3f, 0xba };
 
-    ByteString aPasswd( r );
-    aPasswd.Expand( PASSWDLEN, ' ' );
+    rtl::OStringBuffer aBuf(r);
+    comphelper::string::padToLength(aBuf, PASSWDLEN, ' ');
+    ByteString aPasswd(aBuf.makeStringAndClear());
     memcpy( cPasswd, cEncode, PASSWDLEN );
     Encrypt( aPasswd );
     memcpy( cPasswd, aPasswd.GetBuffer(), PASSWDLEN );
diff --git a/binfilter/bf_sw/source/core/swg/sw_rdnds.cxx b/binfilter/bf_sw/source/core/swg/sw_rdnds.cxx
index c029bc9..f5ceb96 100644
--- a/binfilter/bf_sw/source/core/swg/sw_rdnds.cxx
+++ b/binfilter/bf_sw/source/core/swg/sw_rdnds.cxx
@@ -33,6 +33,8 @@
 
 #include <hintids.hxx>
 
+#include <comphelper/string.hxx>
+
 #include <bf_so3/persist.hxx>
 #include <bf_so3/embobj.hxx>
 #include <bf_svtools/urihelper.hxx>
@@ -352,7 +354,11 @@ namespace binfilter {
         : rRdr( rR )
     {
         if( nOffset )
-            sReadTxt.Expand( nOffset );
+        {
+            rtl::OStringBuffer aBuf;
+            sReadTxt = comphelper::string::padToLength(aBuf, nOffset, ' ')
+                .makeStringAndClear();
+        }
         pOldTxt = rRdr.GetReadTxt();
         rRdr.SetReadTxt( &sReadTxt );
     }
commit b6d69159654e4a52502ccc899196ddd081344692
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Sep 17 00:22:00 2011 +0100

    first branch of second if cannot be taken as first if rules it out
    
    correspondingly reduce to logically equivalent code

diff --git a/binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx b/binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx
index 7f86e64..895beae 100644
--- a/binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx
+++ b/binfilter/bf_sw/source/core/sw3io/sw_crypter.cxx
@@ -49,13 +49,8 @@ Crypter::Crypter( const ByteString& r )
     { 0xAB, 0x9E, 0x43, 0x05, 0x38, 0x12, 0x4d, 0x44,
       0xD5, 0x7e, 0xe3, 0x84, 0x98, 0x23, 0x3f, 0xba };
 
-    xub_StrLen nLen = r.Len();
-    if( nLen > PASSWDLEN ) nLen = PASSWDLEN;
     ByteString aPasswd( r );
-    if( nLen > PASSWDLEN )
-        aPasswd.Erase( nLen );
-    else
-        aPasswd.Expand( PASSWDLEN, ' ' );
+    aPasswd.Expand( PASSWDLEN, ' ' );
     memcpy( cPasswd, cEncode, PASSWDLEN );
     Encrypt( aPasswd );
     memcpy( cPasswd, aPasswd.GetBuffer(), PASSWDLEN );


More information about the Libreoffice-commits mailing list