[PATCH 2/4] d3dxof: Only parse templates for object files but with RegisterTemplates we must parse the whole file.
Christian Costa
titan.costa at gmail.com
Mon Apr 29 14:42:55 CDT 2013
---
dlls/d3dxof/d3dxof.c | 7 ++++---
dlls/d3dxof/d3dxof_private.h | 2 +-
dlls/d3dxof/parsing.c | 6 ++++--
dlls/d3dxof/tests/d3dxof.c | 2 +-
4 files changed, 10 insertions(+), 7 deletions(-)
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);
}
More information about the wine-patches
mailing list