Bug 125637

Summary: names ending in underscore characters are allowed, but incorrectly handled at the end of a command line
Product: LibreOffice Reporter: Wolfgang Jäger <jag>
Component: BASICAssignee: Andreas Heinisch <andreas.heinisch>
Status: VERIFIED FIXED    
Severity: normal CC: andreas.heinisch, gerhard.weydt, jag, xiscofauli
Priority: medium    
Version: 3.3.0 release   
Hardware: All   
OS: All   
Whiteboard: target:7.3.0 target:7.2.3
Crash report or crash signature: Regression By:
Attachments: Draw file containing the code also posted in the report

Description Wolfgang Jäger 2019-06-02 12:19:36 UTC
Created attachment 151848 [details]
Draw file containing the code also posted in the report

(Heritage from StarOffice)

A variable name name like myChoice_ is generally recognized correctly. 
Occurring as the last item of a command line it is not correctly parsed. It may  wrongly be interpreted as the respective name without the underscore at the end. 

This may be related to the "feature" of using an isolated underscore at a line's end meaning "continued next line". 

This bug may also be related to bug#57307

Run the code below to reproduce the issue.

Sub showTheIssue()
Dim a_ As Long
a_ = 1234
b  = a_
Print b
a = 55
b  = a_
Print b
b  = a_ * 1
REM Also works with : b  = (a_) 
Print b
b  = a_ REM Also works with anything clearly delimiting the line.
Print b
End Sub
Comment 1 Wolfgang Jäger 2019-06-02 12:26:20 UTC
Correction:

I actually had tested with LibO V3.3, but had wrongly assumed "common heritage" then.  

Just tested with StarOffice V5.2. and it did NOT show the issue.
Comment 2 Wolfgang Jäger 2021-09-20 09:55:27 UTC
The bug is still living in V 7.2.0.4
Comment 3 Andreas Heinisch 2021-10-16 21:36:41 UTC
The problem lies in [1], because LO makes two rounds in order to parse and generate the underlying code for the macro. It could be solved in the easy way (just add a whitespace in the code after the underscore) or the hard and clean way (check where the line does not terminate if an underscore follows)

[1] https://opengrok.libreoffice.org/xref/core/basic/source/comp/scanner.cxx?r=ef38b9af#300
Comment 4 Commit Notification 2021-10-20 18:29:03 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/67c15910606575b862410179698f81e7a598aa44

tdf#125637 - Correctly hand names ending with an underscore

It will be available in 7.3.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 Commit Notification 2021-10-22 14:02:13 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/e2e2262e35278a12e716fef3cd61145047ef8680

tdf#125637 - Correctly hand names ending with an underscore

It will be available in 7.2.3.

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 6 Wolfgang Jäger 2021-11-23 13:03:52 UTC
Fix verfied with 7.2.3.2
Comment 7 Xisco Faulí 2021-11-23 14:28:07 UTC
(In reply to Wolfgang Jäger from comment #6)
> Fix verfied with 7.2.3.2

Setting to VERIFIED then
Thanks for checking