Nikolay Sivov : xmllite/reader: Implement CreateXmlReaderInputWithEncodingCodePage().

Alexandre Julliard julliard at winehq.org
Tue May 3 15:39:23 CDT 2022


Module: wine
Branch: master
Commit: f2403bf783a0cff78e1f2c935a212b98ca7b9b4b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f2403bf783a0cff78e1f2c935a212b98ca7b9b4b

Author: Nikolay Sivov <nsivov at 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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at 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 8d893b51f04..03bb6c409b7 100644
--- a/dlls/xmllite/reader.c
+++ b/dlls/xmllite/reader.c
@@ -3663,19 +3663,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 (!(readerinput = m_alloc(imalloc, sizeof(*readerinput))))
@@ -3686,7 +3679,7 @@ HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream,
     readerinput->ref = 1;
     readerinput->imalloc = imalloc;
     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);
 
@@ -3706,3 +3699,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 c4af39173a6..c1778a9764e 100644
--- a/dlls/xmllite/tests/reader.c
+++ b/dlls/xmllite/tests/reader.c
@@ -766,6 +766,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 %#lx.\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);")




More information about the wine-cvs mailing list