mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 11:57:17 +00:00
d3dxof: Fix string handling in binary mode + tests.
This commit is contained in:
parent
f92caf5ba7
commit
71986eb109
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue