[librsvg/librsvg-2.40] Centralize a function to create an libxml2 parser
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.40] Centralize a function to create an libxml2 parser
- Date: Wed, 4 Oct 2017 01:06:36 +0000 (UTC)
commit ef5e26c19f28b26cc71549688d7fc6b11234e541
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Oct 3 19:02:54 2017 -0500
Centralize a function to create an libxml2 parser
rsvg-base.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index b948f86..27ad688 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -589,6 +589,18 @@ rsvg_set_xml_parse_options(xmlParserCtxtPtr xml_parser,
xml_parser->replaceEntities = TRUE;
}
+static xmlParserCtxtPtr
+create_xml_parser (RsvgHandle *handle,
+ const char *base_uri)
+{
+ xmlParserCtxtPtr parser;
+
+ parser = xmlCreatePushParserCtxt (&rsvgSAXHandlerStruct, handle, NULL, 0, base_uri);
+ rsvg_set_xml_parse_options (parser, handle);
+
+ return parser;
+}
+
/* http://www.w3.org/TR/xinclude/ */
static void
rsvg_start_xinclude (RsvgHandle * ctx, RsvgPropertyBag * atts)
@@ -639,8 +651,7 @@ rsvg_start_xinclude (RsvgHandle * ctx, RsvgPropertyBag * atts)
if (stream == NULL)
goto fallback;
- xml_parser = xmlCreatePushParserCtxt (&rsvgSAXHandlerStruct, ctx, NULL, 0, NULL);
- rsvg_set_xml_parse_options(xml_parser, ctx);
+ xml_parser = create_xml_parser (ctx, NULL);
buffer = _rsvg_xml_input_buffer_new_from_stream (stream, NULL /* cancellable */, &err);
g_object_unref (stream);
@@ -1170,9 +1181,7 @@ static void
create_xml_push_parser_ctxt (RsvgHandle *handle)
{
if (handle->priv->ctxt == NULL) {
- handle->priv->ctxt = xmlCreatePushParserCtxt (&rsvgSAXHandlerStruct, handle, NULL, 0,
- rsvg_handle_get_base_uri (handle));
- rsvg_set_xml_parse_options(handle->priv->ctxt, handle);
+ handle->priv->ctxt = create_xml_parser (handle, rsvg_handle_get_base_uri (handle));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]