d3dxof: Empty arrays can have the semicolon at the end or not so handle both cases and add tests for them.

This fixes a regression introduced by commit 07931f73f0.
This commit is contained in:
Christian Costa 2012-02-25 12:36:51 +01:00 committed by Alexandre Julliard
parent dd65da7dce
commit 6ee15adf4d
2 changed files with 33 additions and 4 deletions

View File

@ -1315,7 +1315,11 @@ static BOOL parse_object_members_list(parse_buffer * buf)
} }
} }
if (buf->txt && (check_TOKEN(buf) != TOKEN_CBRACE) && (check_TOKEN(buf) != TOKEN_NAME)) /* Empty arrays can have the semicolon at the end or not so remove it if any and skip next check */
if (!nb_elems && (check_TOKEN(buf) == TOKEN_SEMICOLON))
get_TOKEN(buf);
if (nb_elems && buf->txt && (check_TOKEN(buf) != TOKEN_CBRACE) && (check_TOKEN(buf) != TOKEN_NAME))
{ {
token = get_TOKEN(buf); token = get_TOKEN(buf);
if ((token != TOKEN_SEMICOLON) && (token != TOKEN_COMMA)) if ((token != TOKEN_SEMICOLON) && (token != TOKEN_COMMA))

View File

@ -101,7 +101,7 @@ static char template_syntax_empty_array[] =
"DWORD dummy;\n" "DWORD dummy;\n"
"}\n"; "}\n";
static char object_syntax_empty_array[] = static char object_syntax_empty_array_semicolon[] =
"xof 0302txt 0064\n" "xof 0302txt 0064\n"
"Buffer\n" "Buffer\n"
"{\n" "{\n"
@ -110,6 +110,15 @@ static char object_syntax_empty_array[] =
"1234;\n" "1234;\n"
"}\n"; "}\n";
static char object_syntax_empty_array_nosemicolon[] =
"xof 0302txt 0064\n"
"Buffer\n"
"{\n"
"0;\n"
"1234;\n"
"}\n";
static void init_function_pointers(void) static void init_function_pointers(void)
{ {
/* We have to use LoadLibrary as no d3dxof functions are referenced directly */ /* We have to use LoadLibrary as no d3dxof functions are referenced directly */
@ -502,8 +511,8 @@ static void test_syntax(void)
hr = IDirectXFile_RegisterTemplates(lpDirectXFile, template_syntax_empty_array, sizeof(template_syntax_empty_array) - 1); hr = IDirectXFile_RegisterTemplates(lpDirectXFile, template_syntax_empty_array, sizeof(template_syntax_empty_array) - 1);
ok(hr == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates: %x\n", hr); ok(hr == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates: %x\n", hr);
dxflm.lpMemory = &object_syntax_empty_array; dxflm.lpMemory = &object_syntax_empty_array_semicolon;
dxflm.dSize = sizeof(object_syntax_empty_array) - 1; dxflm.dSize = sizeof(object_syntax_empty_array_semicolon) - 1;
hr = IDirectXFile_CreateEnumObject(lpDirectXFile, &dxflm, DXFILELOAD_FROMMEMORY, &lpdxfeo); hr = IDirectXFile_CreateEnumObject(lpDirectXFile, &dxflm, DXFILELOAD_FROMMEMORY, &lpdxfeo);
ok(hr == DXFILE_OK, "IDirectXFile_CreateEnumObject: %x\n", hr); ok(hr == DXFILE_OK, "IDirectXFile_CreateEnumObject: %x\n", hr);
hr = IDirectXFileEnumObject_GetNextDataObject(lpdxfeo, &lpdxfd); hr = IDirectXFileEnumObject_GetNextDataObject(lpdxfeo, &lpdxfd);
@ -516,6 +525,22 @@ static void test_syntax(void)
ref = IDirectXFileData_Release(lpdxfd); ref = IDirectXFileData_Release(lpdxfd);
ok(ref == 0, "Got refcount %d, expected 0\n", ref); ok(ref == 0, "Got refcount %d, expected 0\n", ref);
} }
dxflm.lpMemory = &object_syntax_empty_array_nosemicolon;
dxflm.dSize = sizeof(object_syntax_empty_array_nosemicolon) - 1;
hr = IDirectXFile_CreateEnumObject(lpDirectXFile, &dxflm, DXFILELOAD_FROMMEMORY, &lpdxfeo);
ok(hr == DXFILE_OK, "IDirectXFile_CreateEnumObject: %x\n", hr);
hr = IDirectXFileEnumObject_GetNextDataObject(lpdxfeo, &lpdxfd);
ok(hr == DXFILE_OK, "IDirectXFileEnumObject_GetNextDataObject: %x\n", hr);
ref = IDirectXFileEnumObject_Release(lpdxfeo);
ok(ref == 0, "Got refcount %d, expected 0\n", ref);
if (hr == DXFILE_OK)
{
ref = IDirectXFileData_Release(lpdxfd);
ok(ref == 0, "Got refcount %d, expected 0\n", ref);
}
ref = IDirectXFile_Release(lpDirectXFile); ref = IDirectXFile_Release(lpDirectXFile);
ok(ref == 0, "Got refcount %d, expected 0\n", ref); ok(ref == 0, "Got refcount %d, expected 0\n", ref);
} }