| Summary: | BASIC VBASupport=1 erroneously inherited by StrComp() in module without VBASupport | ||
|---|---|---|---|
| Product: | LibreOffice | Reporter: | Jean-Pierre Ledure <jp> |
| Component: | BASIC | Assignee: | Not Assigned <libreoffice-bugs> |
| Status: | NEW --- | ||
| Severity: | normal | CC: | elmau, himajin100000, jp, mentoring, xiscofauli |
| Priority: | medium | Keywords: | difficultyMedium, easyHack, skillCpp |
| Version: | 6.4.3.2 release | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Crash report or crash signature: | Regression By: | ||
| Bug Depends on: | |||
| Bug Blocks: | 107659 | ||
| Attachments: |
Small test case
Small test case (TestStrComp.odt) |
||
|
Description
Jean-Pierre Ledure
2020-04-23 10:28:46 UTC
Created attachment 159842 [details]
Small test case
Created attachment 159843 [details]
Small test case (TestStrComp.odt)
I confirm this :
> When I store above script in a module WITHOUT VBASupport set, and I call it
> from another module like this:
>
> Option VBASUpport 1
> Sub Comp_Str_Call
> CompStr
> End Sub
>
> the CompStr routine bahaves as if the VBASupport in its module was set to 1,
> which is not the case.
But did you try to explicitly add `Option VBASupport 0` in the beginning of the module WITHOUT VBASupport.
> But did you try to explicitly add `Option VBASupport 0` in the beginning of the module WITHOUT VBASupport.
The presence or absence of the statement `Option VBASupport 0` in the NOVBA module does not make any difference.
JPL
All over the place, the current compatibility mode is tested in the code like this:
SbiInstance* pInst = GetSbData()->pInst;
bool bCompatibility = pInst && pInst->IsCompatibility();
But SbiInstance::IsCompatibility is ~useless, as it's set to some "random" value (unrelated to the currently executed function, current module opened in IDE, and even last built module).
Instead, the code should ask for *current module* to detect its compatibility mode - and the proper method to find the current module seems to be StarBASIC::GetActiveModule.
So the places like SbRtl_StrComp should use something like this:
SbiInstance* pInst = GetSbData()->pInst;
SbModule* pMod = StarBASIC::GetActiveModule();
bool bCompatibility = pMod ? pMod->IsVBACompat() : pInst && pInst->IsCompatibility();
Whoever decides to fix the bug, should make sure to do that function-by-function; and should provide unit tests for each such function. This would require to create a mixed unit test, similar to what currently basic/qa/cppunit/test_vba.cxx does, but its list of tests should possibly contain pairs of source files (one with compat mode, one without) to load them both, and test the resulting interaction.
|