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
9685fec1
Commit
9685fec1
authored
Mar 10, 2017
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/reader: Improve line number updating when switching to the next line.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
79a65678
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
17 deletions
+26
-17
reader.c
dlls/xmllite/reader.c
+17
-15
reader.c
dlls/xmllite/tests/reader.c
+9
-2
No files found.
dlls/xmllite/reader.c
View file @
9685fec1
...
...
@@ -1050,16 +1050,29 @@ static int reader_cmp(xmlreader *reader, const WCHAR *str)
return
0
;
}
static
void
reader_update_position
(
xmlreader
*
reader
,
WCHAR
ch
)
{
if
(
ch
==
'\r'
)
reader
->
position
.
line_position
=
1
;
else
if
(
ch
==
'\n'
)
{
reader
->
position
.
line_number
++
;
reader
->
position
.
line_position
=
1
;
}
else
reader
->
position
.
line_position
++
;
}
/* moves cursor n WCHARs forward */
static
void
reader_skipn
(
xmlreader
*
reader
,
int
n
)
{
encoded_buffer
*
buffer
=
&
reader
->
input
->
buffer
->
utf16
;
const
WCHAR
*
ptr
=
reader_get_ptr
(
reader
)
;
const
WCHAR
*
ptr
;
while
(
*
ptr
++
&&
n
--
)
while
(
*
(
ptr
=
reader_get_ptr
(
reader
))
&&
n
--
)
{
reader_update_position
(
reader
,
*
ptr
);
buffer
->
cur
++
;
reader
->
position
.
line_position
++
;
}
}
...
...
@@ -1071,23 +1084,12 @@ static inline BOOL is_wchar_space(WCHAR ch)
/* [3] S ::= (#x20 | #x9 | #xD | #xA)+ */
static
int
reader_skipspaces
(
xmlreader
*
reader
)
{
encoded_buffer
*
buffer
=
&
reader
->
input
->
buffer
->
utf16
;
const
WCHAR
*
ptr
=
reader_get_ptr
(
reader
);
UINT
start
=
reader_get_cur
(
reader
);
while
(
is_wchar_space
(
*
ptr
))
{
if
(
*
ptr
==
'\r'
)
reader
->
position
.
line_position
=
0
;
else
if
(
*
ptr
==
'\n'
)
{
reader
->
position
.
line_number
++
;
reader
->
position
.
line_position
=
0
;
}
else
reader
->
position
.
line_position
++
;
buffer
->
cur
++
;
reader_skipn
(
reader
,
1
);
ptr
=
reader_get_ptr
(
reader
);
}
...
...
dlls/xmllite/tests/reader.c
View file @
9685fec1
...
...
@@ -1590,6 +1590,7 @@ static void test_read_pending(void)
ok
(
hr
==
S_OK
||
broken
(
hr
==
E_PENDING
),
"got 0x%08x
\n
"
,
hr
);
/* newer versions are happy when it's enough data to detect node type,
older versions keep reading until it fails to read more */
todo_wine
ok
(
stream_readcall
==
1
||
broken
(
stream_readcall
>
1
),
"got %d
\n
"
,
stream_readcall
);
ok
(
type
==
XmlNodeType_Comment
||
broken
(
type
==
XmlNodeType_None
),
"got %d
\n
"
,
type
);
...
...
@@ -2474,7 +2475,7 @@ todo_wine {
static
void
test_reader_position
(
void
)
{
static
const
char
*
xml
=
"<c:a xmlns:c=
\"
nsdef c
\"
b=
\"
attr b
\"
></c:a>"
;
static
const
char
*
xml
=
"<c:a xmlns:c=
\"
nsdef c
\"
b=
\"
attr b
\"
>
\n
</c:a>"
;
IXmlReader
*
reader
;
XmlNodeType
type
;
IStream
*
stream
;
...
...
@@ -2529,8 +2530,14 @@ static void test_reader_position(void)
hr
=
IXmlReader_Read
(
reader
,
&
type
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
type
==
XmlNodeType_Whitespace
,
"got type %d
\n
"
,
type
);
todo_wine
TEST_READER_POSITION2
(
reader
,
1
,
35
,
2
,
6
);
hr
=
IXmlReader_Read
(
reader
,
&
type
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
type
==
XmlNodeType_EndElement
,
"got type %d
\n
"
,
type
);
TEST_READER_POSITION2
(
reader
,
1
,
37
,
~
0u
,
40
);
TEST_READER_POSITION2
(
reader
,
2
,
3
,
2
,
6
);
IXmlReader_SetInput
(
reader
,
NULL
);
TEST_READER_STATE2
(
reader
,
XmlReadState_Initial
,
XmlReadState_Closed
);
...
...
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