Jacek Caban (@jacek) commented about dlls/vbscript/interp.c:
- /* FIXME: Fix comparing string to number */ + /* VBScript compares string to number by converting the string to double, + * while VarCmp would use string comparison. */ + if(V_VT(l) == VT_BSTR && is_numeric_vt(V_VT(r))) { + V_VT(&v) = VT_EMPTY; + hres = VariantChangeType(&v, l, 0, VT_R8); + if(SUCCEEDED(hres)) + return VarCmp(&v, r, ctx->script->lcid, 0); + return hres; + }else if(V_VT(r) == VT_BSTR && is_numeric_vt(V_VT(l))) { + V_VT(&v) = VT_EMPTY; + hres = VariantChangeType(&v, r, 0, VT_R8); + if(SUCCEEDED(hres)) + return VarCmp(l, &v, ctx->script->lcid, 0); + return hres; + } We don't really need `VarCmp` for comparing numbers, I would suggest something like (with proper error handling):
if(is_numeric_vt(V_VT(l)) || is_numeric_vt(V_VT(r)) {
to_double(l, &dl);
to_double(r, &dr);
if(dl < dr)
return VARCMP_LT;
if(dl > dr)
return VARCMP_GT;
return VARCMP_EQ;
}
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10314#note_137607