[Libreoffice-bugs] [Bug 126913] Wrong behavior of Basic "mid" statement

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Wed Aug 14 17:23:35 UTC 2019


https://bugs.documentfoundation.org/show_bug.cgi?id=126913

--- Comment #5 from Julien Nabet <serval2412 at yahoo.fr> ---
With this patch:
diff --git a/basic/source/runtime/methods.cxx
b/basic/source/runtime/methods.cxx
index fe266fdc009c..777b21040230 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1159,7 +1159,7 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite)

                 OUStringBuffer aResultStr = aArgStr;
                 sal_Int32 nErase = nReplaceLen;
-                aResultStr.remove( nStartPos, nErase );
+                aResultStr.remove( nStartPos, nErase - nStartPos);
                 aResultStr.insert(
                     nStartPos, aReplaceStr.getStr(), std::min(nReplaceLen,
nReplaceStrLen));

it works.
But this unit test fails:
    s = "The lightbrown fox"
    Mid(s, 5, 10, "lazy")
it expects:
"The lazy fox"
but with the patch I get:
"The lazyrown fox"

Perhaps, I could use "nErase - nStartPos" only when using VBASupport 1
but:
1) Still I don't know if the patch is right
2) Changing behaviour of mid function may bring some regressions for some other
users

=> There's no more Basic expert in
https://wiki.documentfoundation.org/FindTheExpert, so I'm a bit stuck.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20190814/504ac9fb/attachment-0001.html>


More information about the Libreoffice-bugs mailing list