jscript: Ignore BOM mark in next_token.
This commit is contained in:
parent
403ff3734a
commit
66ba778cad
|
@ -241,7 +241,7 @@ static BOOL skip_comment(parser_ctx_t *ctx)
|
|||
|
||||
static BOOL skip_spaces(parser_ctx_t *ctx)
|
||||
{
|
||||
while(ctx->ptr < ctx->end && isspaceW(*ctx->ptr)) {
|
||||
while(ctx->ptr < ctx->end && (isspaceW(*ctx->ptr) || *ctx->ptr == 0xFEFF /* UTF16 BOM */)) {
|
||||
if(is_endline(*ctx->ptr++))
|
||||
ctx->nl = TRUE;
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ DEFINE_EXPECT(DeleteMemberByDispID_false);
|
|||
#define DISPID_TESTOBJ_ONLYDISPID 0x2001
|
||||
#define DISPID_TESTOBJ_WITHPROP 0x2002
|
||||
|
||||
#define JS_E_OUT_OF_MEMORY 0x800a03ec
|
||||
#define JS_E_INVALID_CHAR 0x800a03f6
|
||||
|
||||
static const WCHAR testW[] = {'t','e','s','t',0};
|
||||
|
@ -1966,6 +1967,56 @@ static void test_script_exprs(void)
|
|||
testing_expr = FALSE;
|
||||
}
|
||||
|
||||
struct bom_test
|
||||
{
|
||||
WCHAR str[1024];
|
||||
HRESULT hres;
|
||||
};
|
||||
|
||||
static void run_bom_tests(void)
|
||||
{
|
||||
BSTR src;
|
||||
int i;
|
||||
HRESULT hres;
|
||||
struct bom_test bom_tests[] = {
|
||||
{{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
|
||||
{{0xFEFF,'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
|
||||
{{'v',0xFEFF,'a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, JS_E_OUT_OF_MEMORY},
|
||||
{{'v','a','r',0xFEFF,' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
|
||||
{{'v','a','r',' ','a',' ','=',' ','1',';',' ',0xFEFF,'r','e','p','o','r','t','S','u','c','c','e','s','s','(',')',';','\0'}, S_OK},
|
||||
{{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t',0xFEFF,'S','u','c','c','e','s','s','(',')',';','\0'}, JS_E_OUT_OF_MEMORY},
|
||||
{{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s',0xFEFF,'(',')',';','\0'}, S_OK},
|
||||
{{'v','a','r',' ','a',' ','=',' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
|
||||
{{'v','a','r',' ','a',' ','=',0xFEFF,' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
|
||||
{{0xFEFF,'v','a','r',' ','a',' ','=',0xFEFF,0xFEFF,' ','1',';',' ','r','e','p','o','r','t','S','u','c','c','e','s','s','(',0xFEFF,')',';','\0'}, S_OK},
|
||||
{{0}}
|
||||
};
|
||||
|
||||
engine_clsid = &CLSID_JScript;
|
||||
|
||||
for (i = 0; bom_tests[i].str[0]; i++)
|
||||
{
|
||||
if(bom_tests[i].hres == S_OK)
|
||||
{
|
||||
SET_EXPECT(global_success_d);
|
||||
SET_EXPECT(global_success_i);
|
||||
src = SysAllocString(bom_tests[i].str);
|
||||
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
||||
ok(hres == S_OK, "test %s failed with %08x\n", wine_dbgstr_w(src), hres);
|
||||
SysFreeString(src);
|
||||
CHECK_CALLED(global_success_d);
|
||||
CHECK_CALLED(global_success_i);
|
||||
}
|
||||
else
|
||||
{
|
||||
src = SysAllocString(bom_tests[i].str);
|
||||
hres = parse_script(SCRIPTITEM_GLOBALMEMBERS, src);
|
||||
todo_wine ok(hres == bom_tests[i].hres, "test %s returned with %08x\n", wine_dbgstr_w(src), hres);
|
||||
SysFreeString(src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL run_tests(void)
|
||||
{
|
||||
HRESULT hres;
|
||||
|
@ -2259,6 +2310,8 @@ static BOOL run_tests(void)
|
|||
"Object expected",
|
||||
NULL);
|
||||
|
||||
run_bom_tests();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue