diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-01-09 09:31:01 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-01-09 12:05:37 +0000 |
commit | 476f75802a538fb3576cdac996fca6c348913d6f (patch) | |
tree | 025329566fd7409fad2db3c2135f05df5b88fc43 /basic | |
parent | fff409cb0c31bbf50e508a3f2e15236533988216 (diff) |
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 869402a58720b45e7227438b2e56e5a9532c0000.
Change-Id: Ie710e4de9e7e35c84abe2770142a963532820af4
Diffstat (limited to 'basic')
-rw-r--r-- | basic/qa/vba_tests/replace.vb | 2 | ||||
-rw-r--r-- | basic/source/runtime/methods.cxx | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/basic/qa/vba_tests/replace.vb b/basic/qa/vba_tests/replace.vb index e04cde058eb2..bd4817b1e455 100644 --- a/basic/qa/vba_tests/replace.vb +++ b/basic/qa/vba_tests/replace.vb @@ -37,7 +37,7 @@ Function verify_testReplace() as String retStr = Replace(srcStr, destStr, repStr, compare:=vbTextCompare) TestLog_ASSERT retStr = "aefefdef", "text compare:" & retStr 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) TestLog_ASSERT retStr = "aefefdBc", "count = 2: " & retStr retStr = Replace(srcStr, destStr, repStr, 1, 0, vbBinaryCompare) diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 7ccbab73430d..baa9603afbae 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1405,7 +1405,7 @@ RTLFUNC(Replace) if( nPos >= 0 ) { aExpStr = aExpStr.replaceAt( nPos, nFindStrLen, aReplaceStr ); - nPos = nPos - nFindStrLen + nReplaceStrLen + 1; + nPos = nPos + nReplaceStrLen; nCounts++; } else @@ -1414,7 +1414,7 @@ RTLFUNC(Replace) } } } - rPar.Get(0)->PutString( aExpStr.copy( lStartPos - 1 ) ); + rPar.Get(0)->PutString( aExpStr ); } } |