From: Robert Wilhelm robert.wilhelm@gmx.net
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55052 --- dlls/vbscript/interp.c | 13 +++++++++++-- dlls/vbscript/tests/lang.vbs | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 2d979f07605..9ff6f86d28a 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1393,7 +1393,7 @@ static HRESULT interp_step(exec_ctx_t *ctx) { const BSTR ident = ctx->instr->arg2.bstr; BOOL gteq_zero; - VARIANT zero; + VARIANT zero, end, *r; ref_t ref; HRESULT hres;
@@ -1416,7 +1416,16 @@ static HRESULT interp_step(exec_ctx_t *ctx) return E_FAIL; }
- hres = VarCmp(ref.u.v, stack_top(ctx, 1), ctx->script->lcid, 0); + r = stack_top(ctx, 1); + if (V_VT(r) == VT_BSTR) { + V_VT(&end) = VT_EMPTY; + hres = VariantChangeType(&end, stack_top(ctx, 1), 0, VT_R8); + if(FAILED(hres)) + return hres; + hres = VarCmp(ref.u.v, &end, ctx->script->lcid, 0); + } else { + hres = VarCmp(ref.u.v, stack_top(ctx, 1), ctx->script->lcid, 0); + } if(FAILED(hres)) return hres;
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 42af6df0e76..0b9ebacec50 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -679,6 +679,29 @@ for x = 5 to 8 next Call ok(y = "for8: 5 7", "y = " & y)
+function testfor( startvalue, endvalue, stepvalue, steps) + Dim s + for x=startvalue to endvalue step stepvalue + s = s + 1 + Next + Call ok( s = steps, "counted " & s & " steps in for loop, expected " & steps) +end function + +Call testfor (1, 2, 1, 2) +Call testfor (1, "2", 1, 2) +Call testfor (1, 2, "1", 2) +Call testfor (1, "2", "1", 2) +if (isEnglishLang) then + Call testfor (1, 2, 0.5, 3) + Call testfor (1, 2.5, 0.5, 4) + Call testfor (1, "2", 0.5, 3) + Call testfor (1, "2.5", 0.5, 4) + Call testfor (1, 2, "0.5", 3) + Call testfor (1, 2.5, "0.5", 4) + Call testfor (1, "2", "0.5", 3) + Call testfor (1, "2.5", "0.5", 4) +end if + for x = 1.5 to 1 Call ok(false, "for..to called when unexpected") next
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=140816
Your paranoid android.
=== debian11b (64 bit WoW report) ===
dinput: device8.c:2238: Test failed: 0x700: got key_state[0] 0
It seems to me that we should convert step to a number earlier. I tried a simple test:
``` dim x for x = 1 to 2 step "a" call ok(false, "in for..to, expected an earlier error") next ```
On Windows it throws type error earlier, before the first step. To implement that, I guess we could have a new opcode converting value to a number and use that instead of OP_val in `compile_forto_statement`.