Kaydet (Commit) 476f7580 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: #i94895# fix illegal result of Replace runtime function"

and adjust the basic test-case, which is surely wrong

The syntax for REPLACE is:

// Replace(expression, find, replace[, start[, count[, compare]]])

surely in the case of a start of 3 the preceeding chars should
be returned unchanged in the result, not stripped off as before
this change.

This reverts commit 869402a5.

Change-Id: Ie710e4de9e7e35c84abe2770142a963532820af4
üst fff409cb
...@@ -37,7 +37,7 @@ Function verify_testReplace() as String ...@@ -37,7 +37,7 @@ Function verify_testReplace() as String
retStr = Replace(srcStr, destStr, repStr, compare:=vbTextCompare) retStr = Replace(srcStr, destStr, repStr, compare:=vbTextCompare)
TestLog_ASSERT retStr = "aefefdef", "text compare:" & retStr TestLog_ASSERT retStr = "aefefdef", "text compare:" & retStr
retStr = Replace(srcStr, destStr, repStr, 3, -1, vbBinaryCompare) retStr = Replace(srcStr, destStr, repStr, 3, -1, vbBinaryCompare)
TestLog_ASSERT retStr = "cefdBc", "start = 3:" & retStr TestLog_ASSERT retStr = "abcefdBc", "start = 3:" & retStr
retStr = Replace(srcStr, destStr, repStr, 1, 2, vbBinaryCompare) retStr = Replace(srcStr, destStr, repStr, 1, 2, vbBinaryCompare)
TestLog_ASSERT retStr = "aefefdBc", "count = 2: " & retStr TestLog_ASSERT retStr = "aefefdBc", "count = 2: " & retStr
retStr = Replace(srcStr, destStr, repStr, 1, 0, vbBinaryCompare) retStr = Replace(srcStr, destStr, repStr, 1, 0, vbBinaryCompare)
......
...@@ -1405,7 +1405,7 @@ RTLFUNC(Replace) ...@@ -1405,7 +1405,7 @@ RTLFUNC(Replace)
if( nPos >= 0 ) if( nPos >= 0 )
{ {
aExpStr = aExpStr.replaceAt( nPos, nFindStrLen, aReplaceStr ); aExpStr = aExpStr.replaceAt( nPos, nFindStrLen, aReplaceStr );
nPos = nPos - nFindStrLen + nReplaceStrLen + 1; nPos = nPos + nReplaceStrLen;
nCounts++; nCounts++;
} }
else else
...@@ -1414,7 +1414,7 @@ RTLFUNC(Replace) ...@@ -1414,7 +1414,7 @@ RTLFUNC(Replace)
} }
} }
} }
rPar.Get(0)->PutString( aExpStr.copy( lStartPos - 1 ) ); rPar.Get(0)->PutString( aExpStr );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment