You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ha...@apache.org on 2015/10/10 10:42:22 UTC

svn commit: r1707844 - /openoffice/trunk/main/i18npool/source/search/textsearch.cxx

Author: hanya
Date: Sat Oct 10 08:42:22 2015
New Revision: 1707844

URL: http://svn.apache.org/viewvc?rev=1707844&view=rev
Log:
#i107619# use next index to the last position from the offset when the match result is started at the end of thes string

Modified:
    openoffice/trunk/main/i18npool/source/search/textsearch.cxx

Modified: openoffice/trunk/main/i18npool/source/search/textsearch.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/i18npool/source/search/textsearch.cxx?rev=1707844&r1=1707843&r2=1707844&view=diff
==============================================================================
--- openoffice/trunk/main/i18npool/source/search/textsearch.cxx (original)
+++ openoffice/trunk/main/i18npool/source/search/textsearch.cxx Sat Oct 10 08:42:22 2015
@@ -241,10 +241,18 @@ SearchResult TextSearch::searchForward(
 
         sres = (this->*fnForward)( in_str, newStartPos, newEndPos );
 
+        sal_Int32 nOffsetLength = offset.getLength();
+        sal_Int32 nStartOffset = 0;
         for ( int k = 0; k < sres.startOffset.getLength(); k++ )
         {
-            if (sres.startOffset[k])
-	      sres.startOffset[k] = offset[sres.startOffset[k]];
+            nStartOffset = sres.startOffset[k];
+            if ( nStartOffset )
+            {
+                if ( nStartOffset < nOffsetLength )
+                    sres.startOffset[k] = offset[nStartOffset];
+                else
+                    sres.startOffset[k] = offset[offset.getLength()-1] +1;
+            }
             // JP 20.6.2001: end is ever exclusive and then don't return
             //               the position of the next character - return the
             //               next position behind the last found character!
@@ -330,6 +338,8 @@ SearchResult TextSearch::searchBackward(
 
         sres = (this->*fnBackward)( in_str, newStartPos, newEndPos );
 
+        sal_Int32 nOffsetLength = offset.getLength();
+        sal_Int32 nEndOffset = 0;
         for ( int k = 0; k < sres.startOffset.getLength(); k++ )
         {
             if (sres.startOffset[k])
@@ -338,8 +348,14 @@ SearchResult TextSearch::searchBackward(
             //               the position of the next character - return the
             //               next position behind the last found character!
             //               "a b c" find "b" must return 2,3 and not 2,4!!!
-            if (sres.endOffset[k])
-	      sres.endOffset[k] = offset[sres.endOffset[k]];
+            nEndOffset = sres.endOffset[k];
+            if ( nEndOffset )
+            {
+                if ( nEndOffset < nOffsetLength )
+                    sres.endOffset[k] = offset[nEndOffset];
+                else
+                    sres.endOffset[k] = offset[offset.getLength()-1] +1;
+            }
         }
     }
     else