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

Alexandre Julliard julliard at winehq.org
Mon Feb 27 11:27:02 CST 2012


Module: wine
Branch: master
Commit: 6ee15adf4d607558827e467e4da37fb111fe783c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6ee15adf4d607558827e467e4da37fb111fe783c

Author: Christian Costa <titan.costa at gmail.com>
Date:   Sat Feb 25 12:36:51 2012 +0100

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 07931f73f0544e067c5a86b4ac92723c11600dd3.

---

 dlls/d3dxof/parsing.c      |    6 +++++-
 dlls/d3dxof/tests/d3dxof.c |   31 ++++++++++++++++++++++++++++---
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dxof/parsing.c b/dlls/d3dxof/parsing.c
index b2f51bb..f40c202 100644
--- a/dlls/d3dxof/parsing.c
+++ b/dlls/d3dxof/parsing.c
@@ -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);
       if ((token != TOKEN_SEMICOLON) && (token != TOKEN_COMMA))
diff --git a/dlls/d3dxof/tests/d3dxof.c b/dlls/d3dxof/tests/d3dxof.c
index c166054..0c3a295 100644
--- a/dlls/d3dxof/tests/d3dxof.c
+++ b/dlls/d3dxof/tests/d3dxof.c
@@ -101,7 +101,7 @@ static char template_syntax_empty_array[] =
 "DWORD dummy;\n"
 "}\n";
 
-static char object_syntax_empty_array[] =
+static char object_syntax_empty_array_semicolon[] =
 "xof 0302txt 0064\n"
 "Buffer\n"
 "{\n"
@@ -110,6 +110,15 @@ static char object_syntax_empty_array[] =
 "1234;\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)
 {
     /* We have to use LoadLibrary as no d3dxof functions are referenced directly */
@@ -502,8 +511,23 @@ static void test_syntax(void)
     hr = IDirectXFile_RegisterTemplates(lpDirectXFile, template_syntax_empty_array, sizeof(template_syntax_empty_array) - 1);
     ok(hr == DXFILE_OK, "IDirectXFileImpl_RegisterTemplates: %x\n", hr);
 
-    dxflm.lpMemory = &object_syntax_empty_array;
-    dxflm.dSize = sizeof(object_syntax_empty_array) - 1;
+    dxflm.lpMemory = &object_syntax_empty_array_semicolon;
+    dxflm.dSize = sizeof(object_syntax_empty_array_semicolon) - 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);
+    }
+
+    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);
@@ -516,6 +540,7 @@ static void test_syntax(void)
         ref = IDirectXFileData_Release(lpdxfd);
         ok(ref == 0, "Got refcount %d, expected 0\n", ref);
     }
+
     ref = IDirectXFile_Release(lpDirectXFile);
     ok(ref == 0, "Got refcount %d, expected 0\n", ref);
 }




More information about the wine-cvs mailing list