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
85ced167
Commit
85ced167
authored
Nov 03, 2010
by
Adam Martinson
Committed by
Alexandre Julliard
Nov 04, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msxml3: Fix node_get_text() whitespace handling.
parent
e9512216
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
168 additions
and
51 deletions
+168
-51
msxml_private.h
dlls/msxml3/msxml_private.h
+2
-0
node.c
dlls/msxml3/node.c
+85
-1
domdoc.c
dlls/msxml3/tests/domdoc.c
+81
-50
No files found.
dlls/msxml3/msxml_private.h
View file @
85ced167
...
@@ -159,6 +159,8 @@ extern void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const
...
@@ -159,6 +159,8 @@ extern void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const
#define LIBXML2_CALLBACK_SERROR(caller, err) \
#define LIBXML2_CALLBACK_SERROR(caller, err) \
wineXmlCallbackLog(#caller, err->level, err->message, NULL)
wineXmlCallbackLog(#caller, err->level, err->message, NULL)
extern
BOOL
is_preserving_whitespace
(
xmlNodePtr
node
);
/* IXMLDOMNode Internal Structure */
/* IXMLDOMNode Internal Structure */
typedef
struct
_xmlnode
typedef
struct
_xmlnode
{
{
...
...
dlls/msxml3/node.c
View file @
85ced167
...
@@ -543,6 +543,90 @@ static HRESULT WINAPI xmlnode_get_nodeTypeString(
...
@@ -543,6 +543,90 @@ static HRESULT WINAPI xmlnode_get_nodeTypeString(
return
S_OK
;
return
S_OK
;
}
}
static
inline
xmlChar
*
trim_whitespace
(
xmlChar
*
str
)
{
xmlChar
*
ret
=
str
;
int
len
;
if
(
!
str
)
return
NULL
;
while
(
*
ret
&&
isspace
(
*
ret
))
++
ret
;
len
=
xmlStrlen
(
ret
);
while
(
isspace
(
ret
[
len
-
1
]))
--
len
;
ret
=
xmlStrndup
(
ret
,
len
);
xmlFree
(
str
);
return
ret
;
}
static
xmlChar
*
do_get_text
(
xmlNodePtr
node
)
{
xmlNodePtr
child
;
xmlChar
*
str
;
BOOL
preserving
=
is_preserving_whitespace
(
node
);
if
(
!
node
->
children
)
{
str
=
xmlNodeGetContent
(
node
);
}
else
{
xmlElementType
prev_type
=
XML_TEXT_NODE
;
xmlChar
*
tmp
;
str
=
xmlStrdup
(
BAD_CAST
""
);
for
(
child
=
node
->
children
;
child
!=
NULL
;
child
=
child
->
next
)
{
switch
(
child
->
type
)
{
case
XML_ELEMENT_NODE
:
tmp
=
do_get_text
(
child
);
break
;
case
XML_TEXT_NODE
:
case
XML_CDATA_SECTION_NODE
:
case
XML_ENTITY_REF_NODE
:
case
XML_ENTITY_NODE
:
tmp
=
xmlNodeGetContent
(
child
);
break
;
default:
tmp
=
NULL
;
break
;
}
if
(
tmp
)
{
if
(
*
tmp
)
{
if
(
prev_type
==
XML_ELEMENT_NODE
&&
child
->
type
==
XML_ELEMENT_NODE
)
str
=
xmlStrcat
(
str
,
BAD_CAST
" "
);
str
=
xmlStrcat
(
str
,
tmp
);
prev_type
=
child
->
type
;
}
xmlFree
(
tmp
);
}
}
}
switch
(
node
->
type
)
{
case
XML_ELEMENT_NODE
:
case
XML_TEXT_NODE
:
case
XML_ENTITY_REF_NODE
:
case
XML_ENTITY_NODE
:
case
XML_DOCUMENT_NODE
:
case
XML_DOCUMENT_FRAG_NODE
:
if
(
!
preserving
)
str
=
trim_whitespace
(
str
);
break
;
default:
break
;
}
return
str
;
}
static
HRESULT
WINAPI
xmlnode_get_text
(
static
HRESULT
WINAPI
xmlnode_get_text
(
IXMLDOMNode
*
iface
,
IXMLDOMNode
*
iface
,
BSTR
*
text
)
BSTR
*
text
)
...
@@ -556,7 +640,7 @@ static HRESULT WINAPI xmlnode_get_text(
...
@@ -556,7 +640,7 @@ static HRESULT WINAPI xmlnode_get_text(
if
(
!
text
)
if
(
!
text
)
return
E_INVALIDARG
;
return
E_INVALIDARG
;
pContent
=
xmlNodeGetConten
t
((
xmlNodePtr
)
This
->
node
);
pContent
=
do_get_tex
t
((
xmlNodePtr
)
This
->
node
);
if
(
pContent
)
if
(
pContent
)
{
{
str
=
bstr_from_xmlChar
(
pContent
);
str
=
bstr_from_xmlChar
(
pContent
);
...
...
dlls/msxml3/tests/domdoc.c
View file @
85ced167
This diff is collapsed.
Click to expand it.
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