Bug 121325 - 4-argument form of Mid() BASIC function broken in 6.x (worked in 5.x and OO)
Summary: 4-argument form of Mid() BASIC function broken in 6.x (worked in 5.x and OO)
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.1.3.2 release
Hardware: All All
: medium normal
Assignee: Stephan Bergmann
URL:
Whiteboard: target:6.2.0 target:6.1.4
Keywords: bibisected, bisected, regression
: 121920 122352 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-11-10 02:26 UTC by Jim Avera
Modified: 2018-12-28 11:03 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
MidBugDemo.ods (see Steps To Reproduce) (15.14 KB, application/vnd.oasis.opendocument.spreadsheet)
2018-11-10 02:26 UTC, Jim Avera
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Avera 2018-11-10 02:26:00 UTC
Description:
The 4-argument form of the BASIC instruction Mid(str,start,len,repl) is supposed to replace the selected sub-string with the specified replacement text.  However starting with 6.1 it produces the wrong result if the replacement text is shorter than the selected text: the extra characters are not deleted.

Note: The documentation says that the replacement text will be truncated if it is *longer* than the specified substring.  However it is allowed to be shorter, in which case the extra character(s) should be deleted.

Documentation is at
  https://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Strings_(Runtime_Library)
  [search for "replaces three"]

I will attach a spreadsheet with a small macro which demonstrates the bug.

Steps to Reproduce:
1. Open attached "MidBugDemo.ods" spreadsheet
2. Enable macros & run the macro at <filename>->Standard->Module1->BugDemo
(detailed instructions are in the spreadsheet)

Actual Results:
MyString = "This was my text"
Mid(MyString, 6, 3, "is")
RESULT IS "This iss my text" (wrong)


Expected Results:
Should get "This is my text"


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Jim Avera 2018-11-10 02:26:48 UTC
Created attachment 146517 [details]
MidBugDemo.ods (see Steps To Reproduce)
Comment 2 Jim Avera 2018-11-10 02:34:02 UTC
The link to the documentation does not work because the final ")" is omitted from the URL inside the hyperlink.  There must be a bug in the LO Bug system.

Here is the url again in quotes.  I'm hoping this works:

  'https://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Strings_(Runtime_Library)'
Comment 3 raal 2018-11-10 09:24:41 UTC
This seems to have begun at the below commit.
Adding Cc: to Stephan Bergmann ; Could you possibly take a look at this one?
Thanks
 0de91826e0d5bceba5aa669cb0d8b266de5b325b is the first bad commit
commit 0de91826e0d5bceba5aa669cb0d8b266de5b325b
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Fri Apr 6 15:12:53 2018 +0200

    source cc20344010e94eda22fee662aab966d395a0796a

author	Stephan Bergmann <sbergman@redhat.com>	2018-04-06 13:48:11 +0200
committer	Stephan Bergmann <sbergman@redhat.com>	2018-04-06 14:56:20 +0200
commit cc20344010e94eda22fee662aab966d395a0796a (patch)
tree 2653839238f1bdfac6c7f146a00b71f9210ce702
parent e66d7dbbfe83b5ca3e009540bdfbe42eb438e1b2 (diff)
tdf#111313: Honor bWriteNoLenParam in !bCompatibility, too
Comment 4 Commit Notification 2018-11-13 14:26:44 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/a6a48eeef16e473be14642469cd922f177f54998%5E%21

tdf#121325: Replace all of given length, even if replacement is shorter

It will be available in 6.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Xisco Faulí 2018-11-14 10:55:17 UTC
Verified in

Version: 6.2.0.0.alpha1+
Build ID: db01b26d2e7d6626b7504fc7ee6ba6aac50e6098
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded

@Stephan Bergmann, thanks for fixing this!!
Comment 6 Stephan Bergmann 2018-11-14 12:23:46 UTC
(In reply to Commit Notification from comment #4)
> Stephan Bergmann committed a patch related to this issue.
> It has been pushed to "master":
> 
> https://git.libreoffice.org/core/+/
> a6a48eeef16e473be14642469cd922f177f54998%5E%21
> 
> tdf#121325: Replace all of given length, even if replacement is shorter
> 
> It will be available in 6.2.0.

libreoffice-6-1 backport request is at <https://gerrit.libreoffice.org/#/c/63332/>
Comment 7 Jim Avera 2018-11-14 18:16:13 UTC
Verified.  Thank you for the rapid fix!

Version: 6.2.0.0.alpha1+
Build ID: 85dba18a3d3644a4ac49bd32ea106a4d69159fb4
CPU threads: 12; OS: Linux 4.15; UI render: default; VCL: gtk3; 
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2018-11-13_23:14:30
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Calc: threaded
Comment 8 Commit Notification 2018-11-17 16:52:25 UTC
Stephan Bergmann committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

https://git.libreoffice.org/core/+/cb2cd5b76b0981bf07b8d1264f4b3074543a19eb%5E%21

tdf#121325: Replace all of given length, even if replacement is shorter

It will be available in 6.1.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Stephan Bergmann 2018-12-21 14:19:32 UTC
*** Bug 121920 has been marked as a duplicate of this bug. ***
Comment 10 Oliver Brinzing 2018-12-28 11:03:05 UTC
*** Bug 122352 has been marked as a duplicate of this bug. ***