From: Francis De Brabandere <francisdb@gmail.com> Native VBScript treats a whitespace-only BSTR (e.g. Space(N)) as larger than any numeric in BSTR-vs-numeric comparison, regardless of binary lex order. Wine's CStr-coerce path goes through VarCmp's binary order and gets the opposite result for single-digit numerics, breaking the practical Left(str, n) guard pattern Len(str) > Space(n). --- dlls/vbscript/tests/lang.vbs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index cc33d6951af..e5c06431df8 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -317,6 +317,31 @@ Call ok(not ("10" > CDbl(5)), """10"" > CDbl(5) should be false (lex)") Call ok(not ("10" > CSng(5)), """10"" > CSng(5) should be false (lex)") Call ok(not ("9" < CDbl(10)), """9"" < CDbl(10) should be false (lex)") +' --- Non-literal numeric vs whitespace-only BSTR: native treats a +' whitespace-only BSTR as larger than any numeric, regardless of binary +' lex order. Wine's CStr-coerce + binary VarCmp gives the opposite for +' single-digit numerics (0x20 < 0x32, so "2" > " " in ASCII), so the +' relational cases stay todo_wine until VarCmp is taught the native rule. +Dim space3 : space3 = Space(3) +Call todo_wine_ok(not (Len("ab") > space3), "Len(""ab"") > Space(3) should be false") +Call todo_wine_ok((Len("ab") < space3), "Len(""ab"") < Space(3) should be true") +Call ok(not (Len("ab") = space3), "Len(""ab"") = Space(3) should be false") + +' --- The practical fallout: VPW DMD's ExpandLine guards Left(str, n) with +' Len(str) > Space(n). On native the guard is False so Left() never runs; +' on wine post-MR-10775 the guard is True and Left() raises error 13. --- +Dim guard_str : guard_str = "ab" +Dim guard_err, guard_r +On Error Resume Next +Err.Clear +If Len(guard_str) > Space(3) Then + guard_r = Left(guard_str, Space(3)) +End If +guard_err = Err.number +Err.Clear +On Error Goto 0 +Call todo_wine_ok(guard_err = 0, "Len(""ab"") > Space(3) guard should not raise (got " & guard_err & ")") + ' --- VT_DATE from CDate is non-literal: string compare, no error. --- Dim cdt : cdt = CDate("2024-01-15") Call ok(not ("abc" = cdt), "CDate: ""abc"" = CDate(...) should be false") -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10818