d3dxof: Only parse templates for object files, but with RegisterTemplates parse the whole file.

This commit is contained in:
Christian Costa 2013-04-29 21:42:55 +02:00 committed by Alexandre Julliard
parent 37d037749d
commit 1bd5bfebae
5 changed files with 11 additions and 8 deletions

View File

@ -77,7 +77,7 @@ static void test_templates(void)
ok(ret == D3DXFERR_BADFILEFLOATSIZE, "RegisterTemplates returned %#x, expected %#x\n", ret, D3DXFERR_BADFILEFLOATSIZE);
ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates_parse_error, sizeof(templates_parse_error) - 1);
todo_wine ok(ret == D3DXFERR_PARSEERROR, "RegisterTemplates returned %#x, expected %#x\n", ret, D3DXFERR_PARSEERROR);
ok(ret == D3DXFERR_PARSEERROR, "RegisterTemplates returned %#x, expected %#x\n", ret, D3DXFERR_PARSEERROR);
ret = d3dxfile->lpVtbl->RegisterTemplates(d3dxfile, templates, sizeof(templates) - 1);
ok(ret == S_OK, "RegisterTemplates failed with %#x\n", ret);

View File

@ -241,7 +241,8 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
if (FAILED(hr))
goto error;
if (!parse_templates(&object->buf))
/* Check if there are templates defined before the object */
if (!parse_templates(&object->buf, TRUE))
{
hr = DXFILEERR_PARSEERROR;
goto error;
@ -320,7 +321,7 @@ static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LP
if (FAILED(hr))
goto cleanup;
if (!parse_templates(&buf))
if (!parse_templates(&buf, FALSE))
{
hr = DXFILEERR_PARSEERROR;
goto cleanup;
@ -1003,7 +1004,7 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE
}
/* Check if there are templates defined before the object */
if (!parse_templates(&This->buf))
if (!parse_templates(&This->buf, TRUE))
return DXFILEERR_PARSEERROR;
if (!This->buf.rem_bytes)

View File

@ -161,7 +161,7 @@ HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HID
HRESULT parse_header(parse_buffer *buf, BYTE **decomp_buffer_ptr) DECLSPEC_HIDDEN;
BOOL parse_object(parse_buffer * buf) DECLSPEC_HIDDEN;
BOOL parse_templates(parse_buffer * buf) DECLSPEC_HIDDEN;
BOOL parse_templates(parse_buffer * buf, BOOL templates_only) DECLSPEC_HIDDEN;
int mszip_decompress(int inlen, int outlen, char* inbuffer, char* outbuffer) DECLSPEC_HIDDEN;

View File

@ -1121,10 +1121,12 @@ static BOOL parse_template(parse_buffer * buf)
return TRUE;
}
BOOL parse_templates(parse_buffer * buf)
BOOL parse_templates(parse_buffer * buf, BOOL templates_only)
{
while (check_TOKEN(buf) == TOKEN_TEMPLATE)
while (check_TOKEN(buf) != TOKEN_NONE)
{
if (templates_only && (check_TOKEN(buf) != TOKEN_TEMPLATE))
return TRUE;
if (!parse_template(buf))
{
WARN("Template is not correct\n");

View File

@ -427,7 +427,7 @@ static void test_templates(void)
ok(ret == DXFILEERR_BADFILEFLOATSIZE, "RegisterTemplates returned %#x, expected %#x\n", ret, DXFILEERR_BADFILEFLOATSIZE);
ret = IDirectXFile_RegisterTemplates(dxfile, templates_parse_error, sizeof(templates_parse_error) - 1);
todo_wine ok(ret == DXFILEERR_PARSEERROR, "RegisterTemplates returned %#x, expected %#x\n", ret, DXFILEERR_PARSEERROR);
ok(ret == DXFILEERR_PARSEERROR, "RegisterTemplates returned %#x, expected %#x\n", ret, DXFILEERR_PARSEERROR);
IDirectXFile_Release(dxfile);
}