[librsvg] Centralize a function to create an libxml2 parser
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Centralize a function to create an libxml2 parser
- Date: Wed, 4 Oct 2017 00:53:29 +0000 (UTC)
commit 8f4b2e5ee003d0369f64a6759ff90a13073285b8
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 f00f833..f092d99 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -695,6 +695,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)
@@ -745,8 +757,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);
@@ -1319,9 +1330,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]