Module: wine Branch: stable Commit: 7357361fef0c7551321e1b1afa1bd497ca2b9dc0 URL: https://gitlab.winehq.org/wine/wine/-/commit/7357361fef0c7551321e1b1afa1bd49...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue May 3 14:40:31 2022 +0300
xmllite/reader: Implement CreateXmlReaderInputWithEncodingCodePage().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52953 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit f2403bf783a0cff78e1f2c935a212b98ca7b9b4b) Conflicts: dlls/xmllite/tests/reader.c Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/xmllite/reader.c | 36 ++++++++++++++++++++++++++---------- dlls/xmllite/tests/reader.c | 6 ++++++ dlls/xmllite/xmllite.spec | 2 +- include/xmllite.idl | 2 ++ 4 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c index 834c36ae18c..e506c29d67d 100644 --- a/dlls/xmllite/reader.c +++ b/dlls/xmllite/reader.c @@ -3667,19 +3667,12 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc) return hr; }
-HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, - IMalloc *imalloc, - LPCWSTR encoding, - BOOL hint, - LPCWSTR base_uri, - IXmlReaderInput **ppInput) +static HRESULT create_reader_input(IUnknown *stream, IMalloc *imalloc, xml_encoding encoding, + BOOL hint, const WCHAR *base_uri, IXmlReaderInput **ppInput) { xmlreaderinput *readerinput; HRESULT hr;
- TRACE("%p %p %s %d %s %p\n", stream, imalloc, wine_dbgstr_w(encoding), - hint, wine_dbgstr_w(base_uri), ppInput); - if (!stream || !ppInput) return E_INVALIDARG;
if (imalloc) @@ -3693,7 +3686,7 @@ HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, readerinput->imalloc = imalloc; readerinput->stream = NULL; if (imalloc) IMalloc_AddRef(imalloc); - readerinput->encoding = parse_encoding_name(encoding, -1); + readerinput->encoding = encoding; readerinput->hint = hint; readerinput->baseuri = readerinput_strdupW(readerinput, base_uri); readerinput->pending = 0; @@ -3714,3 +3707,26 @@ HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream,
return S_OK; } + +/*********************************************************************** + * CreateXmlReaderInputWithEncodingName (xmllite.@) + */ +HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, IMalloc *imalloc, + const WCHAR *encoding, BOOL hint, const WCHAR *base_uri, IXmlReaderInput **input) +{ + TRACE("%p, %p, %s, %d, %s, %p.\n", stream, imalloc, wine_dbgstr_w(encoding), + hint, wine_dbgstr_w(base_uri), input); + + return create_reader_input(stream, imalloc, parse_encoding_name(encoding, -1), hint, base_uri, input); +} + +/*********************************************************************** + * CreateXmlReaderInputWithEncodingCodePage (xmllite.@) + */ +HRESULT WINAPI CreateXmlReaderInputWithEncodingCodePage(IUnknown *stream, IMalloc *imalloc, + UINT codepage, BOOL hint, const WCHAR *base_uri, IXmlReaderInput **input) +{ + TRACE("%p, %p, %u, %d, %s, %p.\n", stream, imalloc, codepage, hint, wine_dbgstr_w(base_uri), input); + + return create_reader_input(stream, imalloc, get_encoding_from_codepage(codepage), hint, base_uri, input); +} diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c index cb3a3f4e571..33d01d74c2b 100644 --- a/dlls/xmllite/tests/reader.c +++ b/dlls/xmllite/tests/reader.c @@ -767,6 +767,12 @@ static void test_readerinput(void) IXmlReader_Release(reader);
IUnknown_Release(reader_input); + + /* Using codepage */ + hr = CreateXmlReaderInputWithEncodingCodePage(input, NULL, 1200, FALSE, NULL, &reader_input); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IUnknown_Release(reader_input); + IUnknown_Release(input); }
diff --git a/dlls/xmllite/xmllite.spec b/dlls/xmllite/xmllite.spec index 574ed9865c3..3097e8d4e88 100644 --- a/dlls/xmllite/xmllite.spec +++ b/dlls/xmllite/xmllite.spec @@ -1,5 +1,5 @@ @ stdcall CreateXmlReader(ptr ptr ptr) -@ stub CreateXmlReaderInputWithEncodingCodePage +@ stdcall CreateXmlReaderInputWithEncodingCodePage(ptr ptr long long wstr ptr) @ stdcall CreateXmlReaderInputWithEncodingName(ptr ptr wstr long wstr ptr) @ stdcall CreateXmlWriter(ptr ptr ptr) @ stdcall CreateXmlWriterOutputWithEncodingCodePage(ptr ptr long ptr) diff --git a/include/xmllite.idl b/include/xmllite.idl index 0fd68f7b781..b2de76e5630 100644 --- a/include/xmllite.idl +++ b/include/xmllite.idl @@ -228,6 +228,8 @@ typedef enum XmlError cpp_quote("STDAPI CreateXmlReader(REFIID riid, void **ppvObject, IMalloc *pMalloc);")
cpp_quote("typedef IUnknown IXmlReaderInput;") +cpp_quote("STDAPI CreateXmlReaderInputWithEncodingCodePage(IUnknown *stream, IMalloc *pMalloc,") +cpp_quote(" UINT encoding_codepage, BOOL hint, const WCHAR *base_uri, IXmlReaderInput **pInput);") cpp_quote("STDAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, IMalloc *pMalloc,") cpp_quote(" LPCWSTR encoding, BOOL hint,") cpp_quote(" LPCWSTR base_uri, IXmlReaderInput **ppInput);")