Module: wine Branch: master Commit: 1bd5bfebaeb3cf7dd901203c6b554a20723fff0b URL: http://source.winehq.org/git/wine.git/?a=commit;h=1bd5bfebaeb3cf7dd901203c6b... Author: Christian Costa <titan.costa(a)gmail.com> Date: Mon Apr 29 21:42:55 2013 +0200 d3dxof: Only parse templates for object files, but with RegisterTemplates parse the whole file. --- dlls/d3dx9_36/tests/xfile.c | 2 +- dlls/d3dxof/d3dxof.c | 7 ++++--- dlls/d3dxof/d3dxof_private.h | 2 +- dlls/d3dxof/parsing.c | 6 ++++-- dlls/d3dxof/tests/d3dxof.c | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dlls/d3dx9_36/tests/xfile.c b/dlls/d3dx9_36/tests/xfile.c index 1238bcd..e514a5f 100644 --- a/dlls/d3dx9_36/tests/xfile.c +++ b/dlls/d3dx9_36/tests/xfile.c @@ -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); diff --git a/dlls/d3dxof/d3dxof.c b/dlls/d3dxof/d3dxof.c index 5a08b21..498b192 100644 --- a/dlls/d3dxof/d3dxof.c +++ b/dlls/d3dxof/d3dxof.c @@ -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) diff --git a/dlls/d3dxof/d3dxof_private.h b/dlls/d3dxof/d3dxof_private.h index 8872c14..5bd3c71 100644 --- a/dlls/d3dxof/d3dxof_private.h +++ b/dlls/d3dxof/d3dxof_private.h @@ -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; diff --git a/dlls/d3dxof/parsing.c b/dlls/d3dxof/parsing.c index 1c624d3..b1dde86 100644 --- a/dlls/d3dxof/parsing.c +++ b/dlls/d3dxof/parsing.c @@ -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"); diff --git a/dlls/d3dxof/tests/d3dxof.c b/dlls/d3dxof/tests/d3dxof.c index 43a7fde..f6874a4 100644 --- a/dlls/d3dxof/tests/d3dxof.c +++ b/dlls/d3dxof/tests/d3dxof.c @@ -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); }