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 ::= '' */ 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 "")) 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"