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

Matteo Casalin matteo.casalin at yahoo.com
Wed Aug 21 04:37:02 PDT 2013


 sw/source/core/doc/number.cxx |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit cf3318f6edc93bfb0d8951a3c1d74ecfbc393a8d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Wed Aug 21 01:47:45 2013 +0200

    Fix off-by-one access and clarify loop
    
    Change-Id: Iaf6fa4de07c04319e6a1846ae77c3ad02dc262a7
    Reviewed-on: https://gerrit.libreoffice.org/5562
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 346f6f8..9f1fc86 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -771,19 +771,20 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
                      !aExtremities.nPrefixChars
                    )
                 {
-                    nStrip = aPrevStr.getLength();
-                    while (aPrevStr.getLength() - nStrip < aExtremities.nSuffixChars)
+                    nStrip = 0;
+                    const sal_Int32 nLastPos = aPrevStr.getLength() - 1;
+                    while (nStrip < aExtremities.nSuffixChars)
                     {
-                        const sal_Unicode cur = aPrevStr[nStrip];
+                        const sal_Unicode cur = aPrevStr[nLastPos-nStrip];
                         if  (!bFirstIteration && '\t' != cur && ' ' != cur)
                         {
                             break;
                         }
-                        --nStrip;
+                        ++nStrip;
                     }
-                    if (nStrip < aPrevStr.getLength())
+                    if (nStrip)
                     {
-                        aPrevStr = aPrevStr.copy(0, nStrip);
+                        aPrevStr = aPrevStr.copy(0, aPrevStr.getLength()-nStrip);
                     }
                 }
                 else if (!sOldPrefix.isEmpty())


More information about the Libreoffice-commits mailing list