Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/reader.c | 138 ++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 85 deletions(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c index eddc4d8eec0..a463934202a 100644 --- a/dlls/xmllite/reader.c +++ b/dlls/xmllite/reader.c @@ -83,17 +83,6 @@ typedef enum StringValue_Last } XmlReaderStringValue;
-static const WCHAR usasciiW[] = {'U','S','-','A','S','C','I','I',0}; -static const WCHAR utf16W[] = {'U','T','F','-','1','6',0}; -static const WCHAR utf8W[] = {'U','T','F','-','8',0}; - -static const WCHAR dblquoteW[] = {'"',0}; -static const WCHAR quoteW[] = {''',0}; -static const WCHAR ltW[] = {'<',0}; -static const WCHAR gtW[] = {'>',0}; -static const WCHAR commentW[] = {'<','!','-','-',0}; -static const WCHAR piW[] = {'<','?',0}; - BOOL is_namestartchar(WCHAR ch);
static const char *debugstr_nodetype(XmlNodeType nodetype) @@ -153,10 +142,11 @@ struct xml_encoding_data UINT cp; };
-static const struct xml_encoding_data xml_encoding_map[] = { - { usasciiW, XmlEncoding_USASCII, 20127 }, - { utf16W, XmlEncoding_UTF16, 1200 }, - { utf8W, XmlEncoding_UTF8, CP_UTF8 }, +static const struct xml_encoding_data xml_encoding_map[] = +{ + { L"US-ASCII", XmlEncoding_USASCII, 20127 }, + { L"UTF-16", XmlEncoding_UTF16, 1200 }, + { L"UTF-8", XmlEncoding_UTF8, CP_UTF8 }, };
const WCHAR *get_encoding_name(xml_encoding encoding) @@ -221,11 +211,11 @@ typedef struct } strval;
static WCHAR emptyW[] = {0}; -static WCHAR xmlW[] = {'x','m','l',0}; -static WCHAR xmlnsW[] = {'x','m','l','n','s',0}; -static const strval strval_empty = { emptyW }; -static const strval strval_xml = { xmlW, 3 }; -static const strval strval_xmlns = { xmlnsW, 5 }; +static WCHAR xmlW[] = L"xml"; +static WCHAR xmlnsW[] = L"xmlns"; +static const strval strval_empty = { (WCHAR *)emptyW, 0 }; +static const strval strval_xml = { (WCHAR *)xmlW, 3 }; +static const strval strval_xmlns = { (WCHAR *)xmlnsW, 5 };
struct reader_position { @@ -1185,11 +1175,10 @@ static int reader_skipspaces(xmlreader *reader) /* [26] VersionNum ::= '1.' [0-9]+ */ static HRESULT reader_parse_versionnum(xmlreader *reader, strval *val) { - static const WCHAR onedotW[] = {'1','.',0}; WCHAR *ptr, *ptr2; UINT start;
- if (reader_cmp(reader, onedotW)) return WC_E_XMLDECL; + if (reader_cmp(reader, L"1.")) return WC_E_XMLDECL;
start = reader_get_cur(reader); /* skip "1." */ @@ -1211,19 +1200,22 @@ static HRESULT reader_parse_versionnum(xmlreader *reader, strval *val) /* [25] Eq ::= S? '=' S? */ static HRESULT reader_parse_eq(xmlreader *reader) { - static const WCHAR eqW[] = {'=',0}; reader_skipspaces(reader); - if (reader_cmp(reader, eqW)) return WC_E_EQUAL; + if (reader_cmp(reader, L"=")) return WC_E_EQUAL; /* skip '=' */ reader_skipn(reader, 1); reader_skipspaces(reader); return S_OK; }
+static BOOL reader_is_quote(xmlreader *reader) +{ + return !reader_cmp(reader, L"'") || !reader_cmp(reader, L"""); +} + /* [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"') */ static HRESULT reader_parse_versioninfo(xmlreader *reader) { - static const WCHAR versionW[] = {'v','e','r','s','i','o','n',0}; struct reader_position position; strval val, name; HRESULT hr; @@ -1231,7 +1223,7 @@ static HRESULT reader_parse_versioninfo(xmlreader *reader) if (!reader_skipspaces(reader)) return WC_E_WHITESPACE;
position = reader->position; - if (reader_cmp(reader, versionW)) return WC_E_XMLDECL; + if (reader_cmp(reader, L"version")) return WC_E_XMLDECL; reader_init_strvalue(reader_get_cur(reader), 7, &name); /* skip 'version' */ reader_skipn(reader, 7); @@ -1239,7 +1231,7 @@ static HRESULT reader_parse_versioninfo(xmlreader *reader) hr = reader_parse_eq(reader); if (FAILED(hr)) return hr;
- if (reader_cmp(reader, quoteW) && reader_cmp(reader, dblquoteW)) + if (!reader_is_quote(reader)) return WC_E_QUOTE; /* skip "'"|'"' */ reader_skipn(reader, 1); @@ -1247,7 +1239,7 @@ static HRESULT reader_parse_versioninfo(xmlreader *reader) hr = reader_parse_versionnum(reader, &val); if (FAILED(hr)) return hr;
- if (reader_cmp(reader, quoteW) && reader_cmp(reader, dblquoteW)) + if (!reader_is_quote(reader)) return WC_E_QUOTE;
/* skip "'"|'"' */ @@ -1299,7 +1291,6 @@ static HRESULT reader_parse_encname(xmlreader *reader, strval *val) /* [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" ) */ static HRESULT reader_parse_encdecl(xmlreader *reader) { - static const WCHAR encodingW[] = {'e','n','c','o','d','i','n','g',0}; struct reader_position position; strval name, val; HRESULT hr; @@ -1307,7 +1298,7 @@ static HRESULT reader_parse_encdecl(xmlreader *reader) if (!reader_skipspaces(reader)) return S_FALSE;
position = reader->position; - if (reader_cmp(reader, encodingW)) return S_FALSE; + if (reader_cmp(reader, L"encoding")) return S_FALSE; name.str = reader_get_ptr(reader); name.start = reader_get_cur(reader); name.len = 8; @@ -1317,7 +1308,7 @@ static HRESULT reader_parse_encdecl(xmlreader *reader) hr = reader_parse_eq(reader); if (FAILED(hr)) return hr;
- if (reader_cmp(reader, quoteW) && reader_cmp(reader, dblquoteW)) + if (!reader_is_quote(reader)) return WC_E_QUOTE; /* skip "'"|'"' */ reader_skipn(reader, 1); @@ -1325,7 +1316,7 @@ static HRESULT reader_parse_encdecl(xmlreader *reader) hr = reader_parse_encname(reader, &val); if (FAILED(hr)) return hr;
- if (reader_cmp(reader, quoteW) && reader_cmp(reader, dblquoteW)) + if (!reader_is_quote(reader)) return WC_E_QUOTE;
/* skip "'"|'"' */ @@ -1337,9 +1328,6 @@ static HRESULT reader_parse_encdecl(xmlreader *reader) /* [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) */ static HRESULT reader_parse_sddecl(xmlreader *reader) { - static const WCHAR standaloneW[] = {'s','t','a','n','d','a','l','o','n','e',0}; - static const WCHAR yesW[] = {'y','e','s',0}; - static const WCHAR noW[] = {'n','o',0}; struct reader_position position; strval name, val; UINT start; @@ -1348,7 +1336,7 @@ static HRESULT reader_parse_sddecl(xmlreader *reader) if (!reader_skipspaces(reader)) return S_FALSE;
position = reader->position; - if (reader_cmp(reader, standaloneW)) return S_FALSE; + if (reader_cmp(reader, L"standalone")) return S_FALSE; reader_init_strvalue(reader_get_cur(reader), 10, &name); /* skip 'standalone' */ reader_skipn(reader, 10); @@ -1356,21 +1344,21 @@ static HRESULT reader_parse_sddecl(xmlreader *reader) hr = reader_parse_eq(reader); if (FAILED(hr)) return hr;
- if (reader_cmp(reader, quoteW) && reader_cmp(reader, dblquoteW)) + if (!reader_is_quote(reader)) return WC_E_QUOTE; /* skip "'"|'"' */ reader_skipn(reader, 1);
- if (reader_cmp(reader, yesW) && reader_cmp(reader, noW)) + if (reader_cmp(reader, L"yes") && reader_cmp(reader, L"no")) return WC_E_XMLDECL;
start = reader_get_cur(reader); /* skip 'yes'|'no' */ - reader_skipn(reader, reader_cmp(reader, yesW) ? 2 : 3); + reader_skipn(reader, reader_cmp(reader, L"yes") ? 2 : 3); reader_init_strvalue(start, reader_get_cur(reader)-start, &val); TRACE("standalone=%s\n", debug_strval(reader, &val));
- if (reader_cmp(reader, quoteW) && reader_cmp(reader, dblquoteW)) + if (!reader_is_quote(reader)) return WC_E_QUOTE; /* skip "'"|'"' */ reader_skipn(reader, 1); @@ -1381,13 +1369,10 @@ static HRESULT reader_parse_sddecl(xmlreader *reader) /* [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>' */ static HRESULT reader_parse_xmldecl(xmlreader *reader) { - static const WCHAR xmldeclW[] = {'<','?','x','m','l',' ',0}; - static const WCHAR declcloseW[] = {'?','>',0}; struct reader_position position; HRESULT hr;
- /* check if we have "<?xml " */ - if (reader_cmp(reader, xmldeclW)) + if (reader_cmp(reader, L"<?xml ")) return S_FALSE;
reader_skipn(reader, 2); @@ -1406,7 +1391,7 @@ static HRESULT reader_parse_xmldecl(xmlreader *reader) return hr;
reader_skipspaces(reader); - if (reader_cmp(reader, declcloseW)) + if (reader_cmp(reader, L"?>")) return WC_E_XMLDECL;
/* skip '?>' */ @@ -1605,8 +1590,7 @@ static HRESULT reader_parse_name(xmlreader *reader, strval *name) /* [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l')) */ static HRESULT reader_parse_pitarget(xmlreader *reader, strval *target) { - static const WCHAR xmlW[] = {'x','m','l'}; - static const strval xmlval = { (WCHAR*)xmlW, 3 }; + static const strval xmlval = { (WCHAR *)L"xml", 3 }; strval name; WCHAR *ptr; HRESULT hr; @@ -1762,9 +1746,9 @@ static HRESULT reader_parse_misc(xmlreader *reader)
if (is_wchar_space(*cur)) hr = reader_parse_whitespace(reader); - else if (!reader_cmp(reader, commentW)) + else if (!reader_cmp(reader, L"<!--")) hr = reader_parse_comment(reader); - else if (!reader_cmp(reader, piW)) + else if (!reader_cmp(reader, L"<?")) hr = reader_parse_pi(reader); else break; @@ -1829,8 +1813,8 @@ static HRESULT reader_parse_pub_literal(xmlreader *reader, strval *literal) /* [75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral */ static HRESULT reader_parse_externalid(xmlreader *reader) { - static WCHAR systemW[] = {'S','Y','S','T','E','M',0}; - static WCHAR publicW[] = {'P','U','B','L','I','C',0}; + static WCHAR systemW[] = L"SYSTEM"; + static WCHAR publicW[] = L"PUBLIC"; struct reader_position position = reader->position; strval name, sys; HRESULT hr; @@ -1882,13 +1866,11 @@ static HRESULT reader_parse_externalid(xmlreader *reader) /* [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' intSubset ']' S?)? '>' */ static HRESULT reader_parse_dtd(xmlreader *reader) { - static const WCHAR doctypeW[] = {'<','!','D','O','C','T','Y','P','E',0}; strval name; WCHAR *cur; HRESULT hr;
- /* check if we have "<!DOCTYPE" */ - if (reader_cmp(reader, doctypeW)) return S_FALSE; + if (reader_cmp(reader, L"<!DOCTYPE")) return S_FALSE; reader_shrink(reader);
/* DTD processing is not allowed by default */ @@ -2042,16 +2024,11 @@ static HRESULT reader_parse_qname(xmlreader *reader, strval *prefix, strval *loc
static WCHAR get_predefined_entity(const xmlreader *reader, const strval *name) { - static const WCHAR entltW[] = {'l','t'}; - static const WCHAR entgtW[] = {'g','t'}; - static const WCHAR entampW[] = {'a','m','p'}; - static const WCHAR entaposW[] = {'a','p','o','s'}; - static const WCHAR entquotW[] = {'q','u','o','t'}; - static const strval lt = { (WCHAR*)entltW, 2 }; - static const strval gt = { (WCHAR*)entgtW, 2 }; - static const strval amp = { (WCHAR*)entampW, 3 }; - static const strval apos = { (WCHAR*)entaposW, 4 }; - static const strval quot = { (WCHAR*)entquotW, 4 }; + static const strval lt = { (WCHAR *)L"lt", 2 }; + static const strval gt = { (WCHAR *)L"gt", 2 }; + static const strval amp = { (WCHAR *)L"amp", 3 }; + static const strval apos = { (WCHAR *)L"apos", 4 }; + static const strval quot = { (WCHAR *)L"quot", 4 }; WCHAR *str = reader_get_strptr(reader, name);
switch (*str) @@ -2270,12 +2247,10 @@ static HRESULT reader_parse_stag(xmlreader *reader, strval *prefix, strval *loca
for (;;) { - static const WCHAR endW[] = {'/','>',0}; - reader_skipspaces(reader);
/* empty element */ - if ((reader->is_empty_element = !reader_cmp(reader, endW))) + if ((reader->is_empty_element = !reader_cmp(reader, L"/>"))) { struct element *element = &reader->empty_element;
@@ -2294,7 +2269,7 @@ static HRESULT reader_parse_stag(xmlreader *reader, strval *prefix, strval *loca }
/* got a start tag */ - if (!reader_cmp(reader, gtW)) + if (!reader_cmp(reader, L">")) { /* skip '>' */ reader_skipn(reader, 1); @@ -2317,7 +2292,7 @@ static HRESULT reader_parse_element(xmlreader *reader) { case XmlReadResumeState_Initial: /* check if we are really on element */ - if (reader_cmp(reader, ltW)) return S_FALSE; + if (reader_cmp(reader, L"<")) return S_FALSE;
/* skip '<' */ reader_skipn(reader, 1); @@ -2371,7 +2346,7 @@ static HRESULT reader_parse_endtag(xmlreader *reader)
reader_skipspaces(reader);
- if (reader_cmp(reader, gtW)) return WC_E_GREATERTHAN; + if (reader_cmp(reader, L">")) return WC_E_GREATERTHAN;
/* skip '>' */ reader_skipn(reader, 1); @@ -2473,8 +2448,6 @@ static HRESULT reader_parse_chardata(xmlreader *reader) position = reader->position; while (*ptr) { - static const WCHAR ampW[] = {'&',0}; - /* CDATA closing sequence ']]>' is not allowed */ if (ptr[0] == ']' && ptr[1] == ']' && ptr[2] == '>') return WC_E_CDSECTEND; @@ -2495,7 +2468,7 @@ static HRESULT reader_parse_chardata(xmlreader *reader) /* this covers a case when text has leading whitespace chars */ if (!is_wchar_space(*ptr)) reader->nodetype = XmlNodeType_Text;
- if (!reader_cmp(reader, ampW)) + if (!reader_cmp(reader, L"&")) reader_parse_reference(reader); else reader_skipn(reader, 1); @@ -2509,9 +2482,6 @@ static HRESULT reader_parse_chardata(xmlreader *reader) /* [43] content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)* */ static HRESULT reader_parse_content(xmlreader *reader) { - static const WCHAR cdstartW[] = {'<','!','[','C','D','A','T','A','[',0}; - static const WCHAR etagW[] = {'<','/',0}; - if (reader->resumestate != XmlReadResumeState_Initial) { switch (reader->resumestate) @@ -2533,19 +2503,19 @@ static HRESULT reader_parse_content(xmlreader *reader) reader_shrink(reader);
/* handle end tag here, it indicates end of content as well */ - if (!reader_cmp(reader, etagW)) + if (!reader_cmp(reader, L"</")) return reader_parse_endtag(reader);
- if (!reader_cmp(reader, commentW)) + if (!reader_cmp(reader, L"<!--")) return reader_parse_comment(reader);
- if (!reader_cmp(reader, piW)) + if (!reader_cmp(reader, L"<?")) return reader_parse_pi(reader);
- if (!reader_cmp(reader, cdstartW)) + if (!reader_cmp(reader, L"<![CDATA[")) return reader_parse_cdata(reader);
- if (!reader_cmp(reader, ltW)) + if (!reader_cmp(reader, L"<")) return reader_parse_element(reader);
/* what's left must be CharData */ @@ -3002,10 +2972,8 @@ static HRESULT WINAPI xmlreader_MoveToNextAttribute(IXmlReader* iface)
static void reader_get_attribute_ns_uri(xmlreader *reader, struct attribute *attr, const WCHAR **uri, UINT *len) { - static const WCHAR xmlns_uriW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/', - '2','0','0','0','/','x','m','l','n','s','/',0}; - static const WCHAR xml_uriW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/', - 'X','M','L','/','1','9','9','8','/','n','a','m','e','s','p','a','c','e',0}; + static const WCHAR xmlns_uriW[] = L"http://www.w3.org/2000/xmlns/"; + static const WCHAR xml_uriW[] = L"http://www.w3.org/XML/1998/namespace";
/* Check for reserved prefixes first */ if ((strval_eq(reader, &attr->prefix, &strval_empty) && strval_eq(reader, &attr->localname, &strval_xmlns)) ||
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/writer.c | 130 ++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 82 deletions(-)
diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 35d4c0e6217..e4553ccf01d 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -38,11 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(xmllite); /* not defined in public headers */ DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33, 0x24, 0x51, 0xbc, 0x1a);
-static const WCHAR closeelementW[] = {'<','/'}; -static const WCHAR closetagW[] = {' ','/','>'}; -static const WCHAR closepiW[] = {'?','>'}; -static const WCHAR xmlnsW[] = {' ','x','m','l','n','s'}; -static const WCHAR xmlnsuriW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/','2','0','0','0','/','x','m','l','n','s','/',0}; +static const WCHAR xmlnsuriW[] = L"http://www.w3.org/2000/xmlns/";
struct output_buffer { @@ -185,10 +181,10 @@ static struct element *alloc_element(xmlwriter *writer, const WCHAR *prefix, con
ret->qname = writer_alloc(writer, (len + 1)*sizeof(WCHAR)); ret->len = len; - if (prefix) { - static const WCHAR colonW[] = {':',0}; + if (prefix) + { lstrcpyW(ret->qname, prefix); - lstrcatW(ret->qname, colonW); + lstrcatW(ret->qname, L":"); } else ret->qname[0] = 0; @@ -595,33 +591,27 @@ static const WCHAR *get_output_encoding_name(xmlwriteroutput *output)
static HRESULT write_xmldecl(xmlwriter *writer, XmlStandalone standalone) { - static const WCHAR versionW[] = {'<','?','x','m','l',' ','v','e','r','s','i','o','n','=','"','1','.','0','"'}; - static const WCHAR encodingW[] = {' ','e','n','c','o','d','i','n','g','='}; - write_encoding_bom(writer); writer->state = XmlWriterState_DocStarted; if (writer->omitxmldecl) return S_OK;
/* version */ - write_output_buffer(writer->output, versionW, ARRAY_SIZE(versionW)); + write_output_buffer(writer->output, L"<?xml version="1.0"", 19);
/* encoding */ - write_output_buffer(writer->output, encodingW, ARRAY_SIZE(encodingW)); + write_output_buffer(writer->output, L" encoding=", 10); write_output_buffer_quoted(writer->output, get_output_encoding_name(writer->output), -1);
/* standalone */ if (standalone == XmlStandalone_Omit) - write_output_buffer(writer->output, closepiW, ARRAY_SIZE(closepiW)); - else { - static const WCHAR standaloneW[] = {' ','s','t','a','n','d','a','l','o','n','e','=','"'}; - static const WCHAR yesW[] = {'y','e','s','"','?','>'}; - static const WCHAR noW[] = {'n','o','"','?','>'}; - - write_output_buffer(writer->output, standaloneW, ARRAY_SIZE(standaloneW)); + write_output_buffer(writer->output, L"?>", 2); + else + { + write_output_buffer(writer->output, L" standalone="", 13); if (standalone == XmlStandalone_Yes) - write_output_buffer(writer->output, yesW, ARRAY_SIZE(yesW)); + write_output_buffer(writer->output, L"yes"?>", 6); else - write_output_buffer(writer->output, noW, ARRAY_SIZE(noW)); + write_output_buffer(writer->output, L"no"?>", 5); }
return S_OK; @@ -636,7 +626,7 @@ static void writer_output_ns(xmlwriter *writer, struct element *element) if (ns->emitted) continue;
- write_output_qname(writer->output, xmlnsW, ARRAY_SIZE(xmlnsW), ns->prefix, ns->prefix_len); + write_output_qname(writer->output, L" xmlns", 6, ns->prefix, ns->prefix_len); write_output_buffer_char(writer->output, '='); write_output_buffer_quoted(writer->output, ns->uri, -1); } @@ -667,8 +657,6 @@ static void writer_dec_indent(xmlwriter *writer)
static void write_node_indent(xmlwriter *writer) { - static const WCHAR dblspaceW[] = {' ',' '}; - static const WCHAR crlfW[] = {'\r','\n'}; unsigned int indent_level = writer->indent_level;
if (!writer->indent || writer->textnode) @@ -680,9 +668,9 @@ static void write_node_indent(xmlwriter *writer) /* Do state check to prevent newline inserted after BOM. It is assumed that state does not change between writing BOM and inserting indentation. */ if (writer->output->written && writer->state != XmlWriterState_Ready) - write_output_buffer(writer->output, crlfW, ARRAY_SIZE(crlfW)); + write_output_buffer(writer->output, L"\r\n", 2); while (indent_level--) - write_output_buffer(writer->output, dblspaceW, ARRAY_SIZE(dblspaceW)); + write_output_buffer(writer->output, L" ", 2);
writer->textnode = 0; } @@ -868,21 +856,12 @@ static void write_output_attribute(xmlwriter *writer, const WCHAR *prefix, int p
static BOOL is_valid_xml_space_value(const WCHAR *value) { - static const WCHAR preserveW[] = {'p','r','e','s','e','r','v','e',0}; - static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0}; - - if (!value) - return FALSE; - - return !wcscmp(value, preserveW) || !wcscmp(value, defaultW); + return value && (!wcscmp(value, L"preserve") || !wcscmp(value, L"default")); }
static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR prefix, LPCWSTR local, LPCWSTR uri, LPCWSTR value) { - static const WCHAR spaceattrW[] = {'s','p','a','c','e',0}; - static const WCHAR xmlnsW[] = {'x','m','l','n','s',0}; - static const WCHAR xmlW[] = {'x','m','l',0}; xmlwriter *This = impl_from_IXmlWriter(iface); BOOL is_xmlns_prefix, is_xmlns_local; int prefix_len, local_len; @@ -906,7 +885,7 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR }
/* Prefix "xmlns" */ - is_xmlns_prefix = prefix && !wcscmp(prefix, xmlnsW); + is_xmlns_prefix = prefix && !wcscmp(prefix, L"xmlns"); if (is_xmlns_prefix && is_empty_string(uri) && is_empty_string(local)) return WR_E_NSPREFIXDECLARED;
@@ -920,7 +899,7 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR if (FAILED(hr = is_valid_ncname(local, &local_len))) return hr;
- is_xmlns_local = !wcscmp(local, xmlnsW); + is_xmlns_local = !wcscmp(local, L"xmlns");
/* Trivial case, no prefix. */ if (prefix_len == 0 && is_empty_string(uri)) @@ -930,10 +909,10 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR }
/* Predefined "xml" prefix. */ - if (prefix_len && !wcscmp(prefix, xmlW)) + if (prefix_len && !wcscmp(prefix, L"xml")) { /* Valid "space" value is enforced. */ - if (!wcscmp(local, spaceattrW) && !is_valid_xml_space_value(value)) + if (!wcscmp(local, L"space") && !is_valid_xml_space_value(value)) return WR_E_INVALIDXMLSPACE;
/* Redefinition is not allowed. */ @@ -955,7 +934,7 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR ns = writer_push_ns(This, local, local_len, value); ns->emitted = TRUE;
- write_output_attribute(This, xmlnsW, ARRAY_SIZE(xmlnsW) - 1, local, local_len, value); + write_output_attribute(This, L"xmlns", 5, local, local_len, value);
return S_OK; } @@ -963,7 +942,7 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR /* Ignore prefix is URI wasn't specified. */ if (is_xmlns_local && is_empty_string(uri)) { - write_output_attribute(This, NULL, 0, xmlnsW, ARRAY_SIZE(xmlnsW) - 1, value); + write_output_attribute(This, NULL, 0, L"xmlns", 5, value); return S_OK; }
@@ -988,12 +967,10 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR
static void write_cdata_section(xmlwriteroutput *output, const WCHAR *data, int len) { - static const WCHAR cdataopenW[] = {'<','!','[','C','D','A','T','A','['}; - static const WCHAR cdatacloseW[] = {']',']','>'}; - write_output_buffer(output, cdataopenW, ARRAY_SIZE(cdataopenW)); + write_output_buffer(output, L"<![CDATA[", 9); if (data) write_output_buffer(output, data, len); - write_output_buffer(output, cdatacloseW, ARRAY_SIZE(cdatacloseW)); + write_output_buffer(output, L"]]>", 3); }
static HRESULT WINAPI xmlwriter_WriteCData(IXmlWriter *iface, LPCWSTR data) @@ -1025,10 +1002,11 @@ static HRESULT WINAPI xmlwriter_WriteCData(IXmlWriter *iface, LPCWSTR data) write_node_indent(This); if (!len) write_cdata_section(This->output, NULL, 0); - else { - static const WCHAR cdatacloseW[] = {']',']','>',0}; - while (len) { - const WCHAR *str = wcsstr(data, cdatacloseW); + else + { + while (len) + { + const WCHAR *str = wcsstr(data, L"]]>"); if (str) { str += 2; write_cdata_section(This->output, data, str - data); @@ -1047,7 +1025,6 @@ static HRESULT WINAPI xmlwriter_WriteCData(IXmlWriter *iface, LPCWSTR data)
static HRESULT WINAPI xmlwriter_WriteCharEntity(IXmlWriter *iface, WCHAR ch) { - static const WCHAR fmtW[] = {'&','#','x','%','x',';',0}; xmlwriter *This = impl_from_IXmlWriter(iface); WCHAR bufW[16];
@@ -1068,7 +1045,7 @@ static HRESULT WINAPI xmlwriter_WriteCharEntity(IXmlWriter *iface, WCHAR ch) ; }
- swprintf(bufW, ARRAY_SIZE(bufW), fmtW, ch); + swprintf(bufW, ARRAY_SIZE(bufW), L"&#x%x;", ch); write_output_buffer(This->output, bufW, -1);
return S_OK; @@ -1098,8 +1075,6 @@ static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *pwch,
static HRESULT WINAPI xmlwriter_WriteComment(IXmlWriter *iface, LPCWSTR comment) { - static const WCHAR copenW[] = {'<','!','-','-'}; - static const WCHAR ccloseW[] = {'-','-','>'}; xmlwriter *This = impl_from_IXmlWriter(iface);
TRACE("%p %s\n", This, debugstr_w(comment)); @@ -1120,7 +1095,7 @@ static HRESULT WINAPI xmlwriter_WriteComment(IXmlWriter *iface, LPCWSTR comment) }
write_node_indent(This); - write_output_buffer(This->output, copenW, ARRAY_SIZE(copenW)); + write_output_buffer(This->output, L"<!--", 4); if (comment) { int len = lstrlenW(comment), i;
@@ -1139,7 +1114,7 @@ static HRESULT WINAPI xmlwriter_WriteComment(IXmlWriter *iface, LPCWSTR comment) if (len && comment[len-1] == '-') write_output_buffer_char(This->output, ' '); } - write_output_buffer(This->output, ccloseW, ARRAY_SIZE(ccloseW)); + write_output_buffer(This->output, L"-->", 3);
return S_OK; } @@ -1147,9 +1122,6 @@ static HRESULT WINAPI xmlwriter_WriteComment(IXmlWriter *iface, LPCWSTR comment) static HRESULT WINAPI xmlwriter_WriteDocType(IXmlWriter *iface, LPCWSTR name, LPCWSTR pubid, LPCWSTR sysid, LPCWSTR subset) { - static const WCHAR doctypeW[] = {'<','!','D','O','C','T','Y','P','E',' '}; - static const WCHAR publicW[] = {' ','P','U','B','L','I','C',' '}; - static const WCHAR systemW[] = {' ','S','Y','S','T','E','M',' '}; xmlwriter *This = impl_from_IXmlWriter(iface); unsigned int name_len, pubid_len; HRESULT hr; @@ -1179,19 +1151,19 @@ static HRESULT WINAPI xmlwriter_WriteDocType(IXmlWriter *iface, LPCWSTR name, LP if (FAILED(hr = is_valid_pubid(pubid, &pubid_len))) return hr;
- write_output_buffer(This->output, doctypeW, ARRAY_SIZE(doctypeW)); + write_output_buffer(This->output, L"<!DOCTYPE ", 10); write_output_buffer(This->output, name, name_len);
if (pubid) { - write_output_buffer(This->output, publicW, ARRAY_SIZE(publicW)); + write_output_buffer(This->output, L" PUBLIC ", 8); write_output_buffer_quoted(This->output, pubid, pubid_len); write_output_buffer_char(This->output, ' '); write_output_buffer_quoted(This->output, sysid, -1); } else if (sysid) { - write_output_buffer(This->output, systemW, ARRAY_SIZE(systemW)); + write_output_buffer(This->output, L" SYSTEM ", 8); write_output_buffer_quoted(This->output, sysid, -1); }
@@ -1269,7 +1241,7 @@ static HRESULT WINAPI xmlwriter_WriteElementString(IXmlWriter *iface, LPCWSTR pr
if (!ns && (prefix_len || !is_empty_string(uri))) { - write_output_qname(This->output, xmlnsW, ARRAY_SIZE(xmlnsW), prefix, prefix_len); + write_output_qname(This->output, L" xmlns", 6, prefix, prefix_len); write_output_buffer_char(This->output, '='); write_output_buffer_quoted(This->output, uri, -1); } @@ -1278,12 +1250,12 @@ static HRESULT WINAPI xmlwriter_WriteElementString(IXmlWriter *iface, LPCWSTR pr { write_output_buffer_char(This->output, '>'); write_output_buffer(This->output, value, -1); - write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); + write_output_buffer(This->output, L"</", 2); write_output_qname(This->output, prefix, prefix_len, local_name, local_len); write_output_buffer_char(This->output, '>'); } else - write_output_buffer(This->output, closetagW, ARRAY_SIZE(closetagW)); + write_output_buffer(This->output, L" />", 3);
This->state = XmlWriterState_Content;
@@ -1348,14 +1320,14 @@ static HRESULT WINAPI xmlwriter_WriteEndElement(IXmlWriter *iface) if (This->starttagopen) { writer_output_ns(This, element); - write_output_buffer(This->output, closetagW, ARRAY_SIZE(closetagW)); + write_output_buffer(This->output, L" />", 3); This->starttagopen = 0; } else { /* Write full end tag. */ write_node_indent(This); - write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); + write_output_buffer(This->output, L"</", 2); write_output_buffer(This->output, element->qname, element->len); write_output_buffer_char(This->output, '>'); } @@ -1425,7 +1397,7 @@ static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface) write_node_indent(This);
/* write full end tag */ - write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); + write_output_buffer(This->output, L"</", 2); write_output_buffer(This->output, element->qname, element->len); write_output_buffer_char(This->output, '>');
@@ -1504,8 +1476,6 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP LPCWSTR text) { xmlwriter *This = impl_from_IXmlWriter(iface); - static const WCHAR xmlW[] = {'x','m','l',0}; - static const WCHAR openpiW[] = {'<','?'};
TRACE("(%p)->(%s %s)\n", This, wine_dbgstr_w(name), wine_dbgstr_w(text));
@@ -1516,7 +1486,7 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP case XmlWriterState_InvalidEncoding: return MX_E_ENCODING; case XmlWriterState_DocStarted: - if (!wcscmp(name, xmlW)) + if (!wcscmp(name, L"xml")) return WR_E_INVALIDACTION; break; case XmlWriterState_ElemStarted: @@ -1528,13 +1498,13 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP
write_encoding_bom(This); write_node_indent(This); - write_output_buffer(This->output, openpiW, ARRAY_SIZE(openpiW)); + write_output_buffer(This->output, L"<?", 2); write_output_buffer(This->output, name, -1); write_output_buffer_char(This->output, ' '); write_output_buffer(This->output, text, -1); - write_output_buffer(This->output, closepiW, ARRAY_SIZE(closepiW)); + write_output_buffer(This->output, L"?>", 2);
- if (!wcscmp(name, xmlW)) + if (!wcscmp(name, L"xml")) This->state = XmlWriterState_PIDocStarted;
return S_OK; @@ -1711,22 +1681,18 @@ static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR pre
static void write_escaped_string(xmlwriter *writer, const WCHAR *string) { - static const WCHAR ampW[] = {'&','a','m','p',';'}; - static const WCHAR ltW[] = {'&','l','t',';'}; - static const WCHAR gtW[] = {'&','g','t',';'}; - while (*string) { switch (*string) { case '<': - write_output_buffer(writer->output, ltW, ARRAY_SIZE(ltW)); + write_output_buffer(writer->output, L"<", 4); break; case '&': - write_output_buffer(writer->output, ampW, ARRAY_SIZE(ampW)); + write_output_buffer(writer->output, L"&", 5); break; case '>': - write_output_buffer(writer->output, gtW, ARRAY_SIZE(gtW)); + write_output_buffer(writer->output, L">", 4); break; default: write_output_buffer(writer->output, string, 1);