Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 55 additions & 125 deletions README.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/wine.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,9 @@ BOOL WINAPI GetCursorPos(POINT *pt)

UINT WINAPI GetCurrentDirectoryA(UINT buflen, LPSTR buf)
{
getcwd(buf, buflen);
return 0;
if (!getcwd(buf, buflen))
return 0;
return strlen(buf);
}

BOOL WINAPI SetCurrentDirectoryA(LPCSTR buf)
Expand Down
1 change: 0 additions & 1 deletion wine/dlls/kernelbase/locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <stdlib.h>

#include "ntstatus.h"
#define WIN32_NO_STATUS
#define WINNORMALIZEAPI
#include "windef.h"
#include "winbase.h"
Expand Down
2 changes: 1 addition & 1 deletion wine/dlls/oleaut32/oleaut32_oaidl.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*** Autogenerated by WIDL 11.1 from dlls/oleaut32/oleaut32_oaidl.idl - Do not edit ***/
/*** Autogenerated by WIDL 11.5 from dlls/oleaut32/oleaut32_oaidl.idl - Do not edit ***/

#ifdef _WIN32
#ifndef __REQUIRED_RPCNDR_H_VERSION__
Expand Down
2 changes: 1 addition & 1 deletion wine/dlls/scrrun/scrrun.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*** Autogenerated by WIDL 11.1 from dlls/scrrun/scrrun.idl - Do not edit ***/
/*** Autogenerated by WIDL 11.5 from dlls/scrrun/scrrun.idl - Do not edit ***/

#ifdef _WIN32
#ifndef __REQUIRED_RPCNDR_H_VERSION__
Expand Down
121 changes: 115 additions & 6 deletions wine/dlls/vbscript/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1201,10 +1201,11 @@ static HRESULT compile_const_statement(compile_ctx_t *ctx, const_statement_t *st
do {
decl = next_decl;

if(lookup_const_decls(ctx, decl->name, FALSE) || lookup_args_name(ctx, decl->name)
|| lookup_dim_decls(ctx, decl->name)) {
FIXME("%s redefined\n", debugstr_w(decl->name));
return E_FAIL;
if(!lookup_const_decls(ctx, decl->name, FALSE)) {
if(lookup_args_name(ctx, decl->name) || lookup_dim_decls(ctx, decl->name)) {
FIXME("%s redefined\n", debugstr_w(decl->name));
return E_FAIL;
}
}

if(ctx->func->type == FUNC_GLOBAL) {
Expand All @@ -1223,8 +1224,10 @@ static HRESULT compile_const_statement(compile_ctx_t *ctx, const_statement_t *st
}

next_decl = decl->next;
decl->next = ctx->const_decls;
ctx->const_decls = decl;
if(!lookup_const_decls(ctx, decl->name, FALSE)) {
decl->next = ctx->const_decls;
ctx->const_decls = decl;
}
} while(next_decl);

return S_OK;
Expand Down Expand Up @@ -1359,6 +1362,107 @@ static HRESULT compile_retval_statement(compile_ctx_t *ctx, retval_statement_t *
return S_OK;
}

static HRESULT collect_const_decls(compile_ctx_t *ctx, statement_t *stat)
{
HRESULT hres;

while(stat) {
switch(stat->type) {
case STAT_CONST: {
const_statement_t *const_stat = (const_statement_t*)stat;
const_decl_t *decl;

for(decl = const_stat->decls; decl; decl = decl->next) {
const_decl_t *new_decl;

if(lookup_const_decls(ctx, decl->name, FALSE))
break; /* already collected */

if(lookup_args_name(ctx, decl->name) || lookup_dim_decls(ctx, decl->name)) {
FIXME("%s redefined\n", debugstr_w(decl->name));
return E_FAIL;
}

new_decl = compiler_alloc(ctx->code, sizeof(*new_decl));
if(!new_decl)
return E_OUTOFMEMORY;
new_decl->name = decl->name;
new_decl->value_expr = decl->value_expr;
new_decl->next = ctx->const_decls;
ctx->const_decls = new_decl;
}
break;
}
case STAT_IF: {
if_statement_t *if_stat = (if_statement_t*)stat;
elseif_decl_t *elseif;

hres = collect_const_decls(ctx, if_stat->if_stat);
if(FAILED(hres))
return hres;
for(elseif = if_stat->elseifs; elseif; elseif = elseif->next) {
hres = collect_const_decls(ctx, elseif->stat);
if(FAILED(hres))
return hres;
}
hres = collect_const_decls(ctx, if_stat->else_stat);
if(FAILED(hres))
return hres;
break;
}
case STAT_WHILE:
case STAT_WHILELOOP:
case STAT_DOWHILE:
case STAT_DOUNTIL:
case STAT_UNTIL: {
while_statement_t *while_stat = (while_statement_t*)stat;
hres = collect_const_decls(ctx, while_stat->body);
if(FAILED(hres))
return hres;
break;
}
case STAT_FORTO: {
forto_statement_t *forto_stat = (forto_statement_t*)stat;
hres = collect_const_decls(ctx, forto_stat->body);
if(FAILED(hres))
return hres;
break;
}
case STAT_FOREACH: {
foreach_statement_t *foreach_stat = (foreach_statement_t*)stat;
hres = collect_const_decls(ctx, foreach_stat->body);
if(FAILED(hres))
return hres;
break;
}
case STAT_SELECT: {
select_statement_t *select_stat = (select_statement_t*)stat;
case_clausule_t *clause;
for(clause = select_stat->case_clausules; clause; clause = clause->next) {
hres = collect_const_decls(ctx, clause->stat);
if(FAILED(hres))
return hres;
}
break;
}
case STAT_WITH: {
with_statement_t *with_stat = (with_statement_t*)stat;
hres = collect_const_decls(ctx, with_stat->body);
if(FAILED(hres))
return hres;
break;
}
case STAT_FUNC:
/* Don't recurse into sub/function bodies; they are compiled separately */
break;
default:
break;
}
stat = stat->next;
}
return S_OK;
}

static HRESULT compile_statement(compile_ctx_t *ctx, statement_ctx_t *stat_ctx, statement_t *stat)
{
HRESULT hres;
Expand Down Expand Up @@ -1531,6 +1635,11 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f
ctx->func = func;
ctx->dim_decls = ctx->dim_decls_tail = NULL;
ctx->const_decls = NULL;

hres = collect_const_decls(ctx, stat);
if(FAILED(hres))
return hres;

hres = compile_statement(ctx, NULL, stat);
ctx->func = NULL;
if(FAILED(hres))
Expand Down
30 changes: 20 additions & 10 deletions wine/dlls/vbscript/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -3025,7 +3025,7 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
if(V_VT(args+1) != VT_BSTR) {
hres = to_string(args+1, &delimiter);
if(FAILED(hres))
goto error;
goto done;
}else {
delimiter = V_BSTR(args+1);
}
Expand All @@ -3035,10 +3035,10 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
if(args_cnt > 2) {
hres = to_int(args+2, &max);
if(FAILED(hres))
goto error;
goto done;
if (max < -1) {
hres = MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
goto error;
goto done;
}
}else {
max = -1;
Expand All @@ -3047,10 +3047,10 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
if(args_cnt == 4) {
hres = to_int(args+3, &mode);
if(FAILED(hres))
goto error;
goto done;
if (mode != 0 && mode != 1) {
hres = MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
goto error;
goto done;
}
}else {
mode = 0;
Expand All @@ -3059,12 +3059,22 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
start = 0;

len = SysStringLen(string);

if(!len) {
bounds.lLbound = 0;
bounds.cElements = 0;
sa = SafeArrayCreate(VT_VARIANT, 1, &bounds);
if(!sa)
hres = E_OUTOFMEMORY;
goto done;
}

count = 0;

indices = malloc( indices_max * sizeof(int));
if(!indices) {
hres = E_OUTOFMEMORY;
goto error;
goto done;
}

while(1) {
Expand All @@ -3084,7 +3094,7 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
new_indices = realloc(indices, indices_max * 2 * sizeof(int));
if(!new_indices) {
hres = E_OUTOFMEMORY;
goto error;
goto done;
}
indices = new_indices;
indices_max *= 2;
Expand All @@ -3101,11 +3111,11 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
sa = SafeArrayCreate( VT_VARIANT, 1, &bounds);
if (!sa) {
hres = E_OUTOFMEMORY;
goto error;
goto done;
}
hres = SafeArrayAccessData(sa, (void**)&data);
if(FAILED(hres)) {
goto error;
goto done;
}

start = 0;
Expand All @@ -3121,7 +3131,7 @@ static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt,
}
SafeArrayUnaccessData(sa);

error:
done:
if(SUCCEEDED(hres) && res) {
V_VT(res) = VT_ARRAY|VT_VARIANT;
V_ARRAY(res) = sa;
Expand Down
51 changes: 14 additions & 37 deletions wine/dlls/vbscript/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,12 @@ static HRESULT stack_assume_disp(exec_ctx_t *ctx, unsigned n, IDispatch **disp)

if(V_VT(v) != VT_DISPATCH && (disp || V_VT(v) != VT_UNKNOWN)) {
if(V_VT(v) != (VT_VARIANT|VT_BYREF)) {
FIXME("not supported type: %s\n", debugstr_variant(v));
return E_FAIL;
return MAKE_VBSERROR(VBSE_OBJECT_REQUIRED);
}

ref = V_VARIANTREF(v);
if(V_VT(ref) != VT_DISPATCH && (disp || V_VT(ref) != VT_UNKNOWN)) {
FIXME("not disp %s\n", debugstr_variant(ref));
return E_FAIL;
return MAKE_VBSERROR(VBSE_OBJECT_REQUIRED);
}

V_VT(v) = V_VT(ref);
Expand Down Expand Up @@ -655,30 +653,15 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res, BSTR identifier, unsigned
return hres;
break;
case REF_OBJ:
#ifndef __LIBWINEVBS__
if(arg_cnt) {
FIXME("arguments on object\n");
return E_NOTIMPL;
vbstack_to_dp(ctx, arg_cnt, FALSE, &dp);
hres = disp_call(ctx->script, ref.u.obj, DISPID_VALUE, &dp, res);
if(FAILED(hres))
return hres;
break;
}
#endif

if(res) {
#ifdef __LIBWINEVBS__
if (arg_cnt) {
vbstack_to_dp(ctx, arg_cnt, FALSE, &dp);

hres = IDispatch_Invoke(ref.u.obj, DISPID_VALUE, &IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dp, res,
NULL, NULL);

if(FAILED(hres))
return hres;

IDispatch_AddRef(V_DISPATCH(res));

break;
}
#endif
IDispatch_AddRef(ref.u.obj);
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = ref.u.obj;
Expand Down Expand Up @@ -911,10 +894,8 @@ static HRESULT assign_ident(exec_ctx_t *ctx, BSTR name, WORD flags, DISPPARAMS *
break;
}

if(!(V_VT(v) & VT_ARRAY)) {
FIXME("array assign on type %d\n", V_VT(v));
return E_FAIL;
}
if(!(V_VT(v) & VT_ARRAY))
return DISP_E_TYPEMISMATCH;

switch(V_VT(v)) {
case VT_ARRAY|VT_BYREF|VT_VARIANT:
Expand Down Expand Up @@ -963,10 +944,8 @@ static HRESULT assign_ident(exec_ctx_t *ctx, BSTR name, WORD flags, DISPPARAMS *
}else {
VARIANT *new_var;

if(arg_cnt(dp)) {
FIXME("arg_cnt %d not supported\n", arg_cnt(dp));
return E_NOTIMPL;
}
if(arg_cnt(dp))
return DISP_E_TYPEMISMATCH;

TRACE("creating variable %s\n", debugstr_w(name));
hres = add_dynamic_var(ctx, name, FALSE, &new_var);
Expand Down Expand Up @@ -1572,9 +1551,8 @@ static HRESULT interp_newenum(exec_ctx_t *ctx)
break;
}
default:
FIXME("Unsupported for %s\n", debugstr_variant(v.v));
release_val(&v);
return E_NOTIMPL;
return MAKE_VBSERROR(VBSE_NOT_ENUM);
}

return S_OK;
Expand All @@ -1593,8 +1571,7 @@ static HRESULT interp_enumnext(exec_ctx_t *ctx)
TRACE("\n");

if(V_VT(stack_top(ctx, 0)) == VT_EMPTY) {
FIXME("uninitialized\n");
return E_FAIL;
return MAKE_VBSERROR(VBSE_NOT_ENUM);
}

assert(V_VT(stack_top(ctx, 0)) == VT_UNKNOWN);
Expand Down Expand Up @@ -2491,7 +2468,7 @@ static HRESULT interp_incc(exec_ctx_t *ctx)

#ifdef __LIBWINEVBS__
if(V_VT(stack_top(ctx, 0)) == VT_EMPTY)
return MAKE_VBSERROR(92);
return MAKE_VBSERROR(VBSE_FOR_LOOP_NOT_INITIALIZED);
#endif

hres = lookup_identifier(ctx, ident, VBDISP_LET, &ref);
Expand Down
4 changes: 2 additions & 2 deletions wine/dlls/vbscript/lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx)
* Parser can't predict if bracket is part of argument expression or an argument
* in call expression. We predict it here instead.
*/
if(ctx->last_token == tIdentifier || ctx->last_token == ')')
if(ctx->last_token == tIdentifier || ctx->last_token == ')' || ctx->last_token == tME)
return '(';
return tEXPRLBRACKET;
#else
Expand All @@ -531,7 +531,7 @@ static int parse_next_token(void *lval, unsigned *loc, parser_ctx_t *ctx)
* not call parens. Detect this when: identifier/')' precedes '(' with a space,
* and a binary-only operator (*, /, \, ^, &) follows the matching ')'.
*/
if(ctx->last_token == tIdentifier || ctx->last_token == ')') {
if(ctx->last_token == tIdentifier || ctx->last_token == ')' || ctx->last_token == tME) {
if(paren_pos > ctx->code && (paren_pos[-1] == ' ' || paren_pos[-1] == '\t')
&& ctx->is_statement_ctx) {
const WCHAR *p = ctx->ptr;
Expand Down
Loading