Module: wine Branch: master Commit: 71986eb109bb3ff45d374d15174afbe442830873 URL: http://source.winehq.org/git/wine.git/?a=commit;h=71986eb109bb3ff45d374d1517...
Author: Christian Costa titan.costa@gmail.com Date: Tue Jun 11 22:08:59 2013 +0200
d3dxof: Fix string handling in binary mode + tests.
---
dlls/d3dxof/parsing.c | 5 ----- dlls/d3dxof/tests/d3dxof.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dxof/parsing.c b/dlls/d3dxof/parsing.c index 69fb992..fc7250c 100644 --- a/dlls/d3dxof/parsing.c +++ b/dlls/d3dxof/parsing.c @@ -811,7 +811,6 @@ static WORD parse_TOKEN(parse_buffer * buf) case TOKEN_STRING: { DWORD count; - WORD tmp_token; char *string = (char*)buf->value;
if (!read_bytes(buf, &count, 4)) @@ -819,10 +818,6 @@ static WORD parse_TOKEN(parse_buffer * buf) if (!read_bytes(buf, string, count)) return TOKEN_ERROR; string[count] = 0; - if (!read_bytes(buf, &tmp_token, 2)) - return TOKEN_ERROR; - if ((tmp_token != TOKEN_COMMA) && (tmp_token != TOKEN_SEMICOLON)) - ERR("No comma or semicolon (got %d)\n", tmp_token); TRACE("string = %s\n", string);
token = TOKEN_LPSTR; diff --git a/dlls/d3dxof/tests/d3dxof.c b/dlls/d3dxof/tests/d3dxof.c index 3a92ce9..ede23f8 100644 --- a/dlls/d3dxof/tests/d3dxof.c +++ b/dlls/d3dxof/tests/d3dxof.c @@ -30,6 +30,7 @@ #define I4(x) x,0,0,0
#define TOKEN_NAME I2(1) +#define TOKEN_STRING I2(2) #define TOKEN_INTEGER I2(3) #define TOKEN_INTEGER_LIST I2(6) #define TOKEN_OBRACE I2(10) @@ -328,6 +329,13 @@ static char object_syntax_string_with_separator[] = ""foo;bar";\n" "}\n";
+static char object_syntax_string_bin[] = { +'x','o','f',' ','0','3','0','2','b','i','n',' ','0','0','6','4', +TOKEN_NAME, /* size */ I4(8), /* name */ 'F','i','l','e','n','a','m','e', TOKEN_OBRACE, +TOKEN_STRING, /* size */ I4(6), /* string */ 'f','o','o','b','a','r', TOKEN_SEMICOLON, +TOKEN_CBRACE +}; + static char templates_complex_object[] = "xof 0302txt 0064\n" "template Vector\n" @@ -850,6 +858,21 @@ static void test_syntax(void) IDirectXFileData_Release(lpdxfd); IDirectXFileEnumObject_Release(lpdxfeo);
+ /* Test string in binary mode */ + dxflm.lpMemory = &object_syntax_string_bin; + dxflm.dSize = sizeof(object_syntax_string_bin); + 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); + hr = IDirectXFileData_GetData(lpdxfd, NULL, &size, (void**)&string); + ok(hr == DXFILE_OK, "IDirectXFileData_GetData: %x\n", hr); + ok(size == sizeof(char*), "Got wrong data size %d\n", size); + ok(!strcmp(*string, "foobar"), "Got string %s, expected foobar\n", *string); + if (hr == DXFILE_OK) + IDirectXFileData_Release(lpdxfd); + IDirectXFileEnumObject_Release(lpdxfeo); + IDirectXFile_Release(lpDirectXFile); }