Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
4c0f142e
Commit
4c0f142e
authored
Jan 06, 2013
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jan 07, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite: Support streams starting with comments, simplify tests.
parent
65bcdb2c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
42 deletions
+38
-42
reader.c
dlls/xmllite/reader.c
+6
-2
reader.c
dlls/xmllite/tests/reader.c
+32
-40
No files found.
dlls/xmllite/reader.c
View file @
4c0f142e
...
...
@@ -403,7 +403,9 @@ static HRESULT readerinput_detectencoding(xmlreaderinput *readerinput, xml_encod
{
encoded_buffer
*
buffer
=
&
readerinput
->
buffer
->
encoded
;
static
char
startA
[]
=
{
'<'
,
'?'
};
static
char
commentA
[]
=
{
'<'
,
'!'
};
static
WCHAR
startW
[]
=
{
'<'
,
'?'
};
static
WCHAR
commentW
[]
=
{
'<'
,
'!'
};
static
char
utf8bom
[]
=
{
0xef
,
0xbb
,
0xbf
};
static
char
utf16lebom
[]
=
{
0xff
,
0xfe
};
...
...
@@ -413,9 +415,11 @@ static HRESULT readerinput_detectencoding(xmlreaderinput *readerinput, xml_encod
/* try start symbols if we have enough data to do that, input buffer should contain
first chunk already */
if
(
!
memcmp
(
buffer
->
data
,
startA
,
sizeof
(
startA
)))
if
(
!
memcmp
(
buffer
->
data
,
startA
,
sizeof
(
startA
))
||
!
memcmp
(
buffer
->
data
,
commentA
,
sizeof
(
commentA
)))
*
enc
=
XmlEncoding_UTF8
;
else
if
(
!
memcmp
(
buffer
->
data
,
startW
,
sizeof
(
startW
)))
else
if
(
!
memcmp
(
buffer
->
data
,
startW
,
sizeof
(
startW
))
||
!
memcmp
(
buffer
->
data
,
commentW
,
sizeof
(
commentW
)))
*
enc
=
XmlEncoding_UTF16
;
/* try with BOM now */
else
if
(
!
memcmp
(
buffer
->
data
,
utf8bom
,
sizeof
(
utf8bom
)))
...
...
dlls/xmllite/tests/reader.c
View file @
4c0f142e
...
...
@@ -701,61 +701,53 @@ todo_wine {
IXmlReader_Release
(
reader
);
}
static
const
char
xml_comment
[]
=
"
\xef\xbb\xbf
<!-- comment -->"
;
static
const
char
xml_comment1
[]
=
"
\xef\xbb\xbf
<!-- - comment-->"
;
static
const
char
xml_comment2
[]
=
"
\xef\xbb\xbf
<!-- -- comment-->"
;
struct
test_entry
{
const
char
*
xml
;
HRESULT
hr
;
HRESULT
hr_broken
;
/* this is set to older version results */
};
static
struct
test_entry
comment_tests
[]
=
{
{
"<!-- comment -->"
,
S_OK
},
{
"<!-- - comment-->"
,
S_OK
},
{
"<!-- -- comment-->"
,
WC_E_COMMENT
,
WC_E_GREATERTHAN
},
{
NULL
}
};
static
void
test_read_comment
(
void
)
{
HRESULT
hr
;
IStream
*
stream
;
struct
test_entry
*
test
=
comment_tests
;
IXmlReader
*
reader
;
XmlNodeType
type
;
HRESULT
hr
;
hr
=
pCreateXmlReader
(
&
IID_IXmlReader
,
(
void
**
)
&
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"S_OK, got %08x
\n
"
,
hr
);
stream
=
create_stream_on_data
(
xml_comment
,
sizeof
(
xml_comment
));
hr
=
IXmlReader_SetInput
(
reader
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
type
=
XmlNodeType_None
;
hr
=
IXmlReader_Read
(
reader
,
&
type
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
type
==
XmlNodeType_Comment
,
"got %d
\n
"
,
type
);
IStream_Release
(
stream
);
stream
=
create_stream_on_data
(
xml_comment1
,
sizeof
(
xml_comment1
));
hr
=
IXmlReader_SetInput
(
reader
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
type
=
XmlNodeType_None
;
hr
=
IXmlReader_Read
(
reader
,
&
type
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
type
==
XmlNodeType_Comment
,
"got %d
\n
"
,
type
);
while
(
test
->
xml
)
{
XmlNodeType
type
;
IStream
*
stream
;
IStream_Release
(
stream
);
stream
=
create_stream_on_data
(
test
->
xml
,
strlen
(
test
->
xml
)
+
1
);
hr
=
IXmlReader_SetInput
(
reader
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
stream
=
create_stream_on_data
(
xml_comment2
,
sizeof
(
xml_comment2
));
hr
=
IXmlReader_SetInput
(
reader
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
type
=
XmlNodeType_None
;
hr
=
IXmlReader_Read
(
reader
,
&
type
);
if
(
test
->
hr_broken
)
ok
(
hr
==
test
->
hr
||
broken
(
hr
==
test
->
hr_broken
),
"got %08x for %s
\n
"
,
hr
,
test
->
xml
);
else
ok
(
hr
==
test
->
hr
,
"got %08x for %s
\n
"
,
hr
,
test
->
xml
);
if
(
hr
==
S_OK
)
ok
(
type
==
XmlNodeType_Comment
,
"got %d for %s
\n
"
,
type
,
test
->
xml
);
type
=
XmlNodeType_None
;
hr
=
IXmlReader_Read
(
reader
,
&
type
);
ok
(
hr
==
WC_E_COMMENT
||
broken
(
hr
==
WC_E_GREATERTHAN
),
"got %08x
\n
"
,
hr
);
ok
(
type
==
XmlNodeType_None
,
"got %d
\n
"
,
type
);
IStream_Release
(
stream
);
IStream_Release
(
stream
);
test
++
;
}
IXmlReader_Release
(
reader
);
}
struct
test_entry
{
const
char
*
xml
;
HRESULT
hr
;
HRESULT
hr_broken
;
/* this is set to older version results */
};
static
struct
test_entry
pi_tests
[]
=
{
{
"<?pi?>"
,
S_OK
},
{
"<?pi ?>"
,
S_OK
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment