[librsvg/librsvg-2.40] Factor out create_xml_stream_parser()



commit 7dfc59efbb51832edef496654b0c7530d4cdd9da
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Oct 3 19:50:28 2017 -0500

    Factor out create_xml_stream_parser()

 rsvg-base.c |   40 ++++++++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index b44bc11..b421a91 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -601,6 +601,26 @@ create_xml_push_parser (RsvgHandle *handle,
     return parser;
 }
 
+static xmlParserCtxtPtr
+create_xml_stream_parser (RsvgHandle    *handle,
+                          GInputStream  *stream,
+                          GCancellable  *cancellable,
+                          GError       **error)
+{
+    xmlParserCtxtPtr parser;
+
+    parser = rsvg_create_xml_parser_from_stream (&rsvgSAXHandlerStruct,
+                                                 handle,
+                                                 stream,
+                                                 cancellable,
+                                                 error);
+    if (parser) {
+        rsvg_set_xml_parse_options (parser, handle);
+    }
+
+    return parser;
+}
+
 /* http://www.w3.org/TR/xinclude/ */
 static void
 rsvg_start_xinclude (RsvgHandle * ctx, RsvgPropertyBag * atts)
@@ -649,12 +669,10 @@ rsvg_start_xinclude (RsvgHandle * ctx, RsvgPropertyBag * atts)
         if (stream == NULL)
             goto fallback;
 
-        xml_parser = rsvg_create_xml_parser_from_stream (&rsvgSAXHandlerStruct,
-                                                         ctx,
-                                                         stream,
-                                                         NULL, /* cancellable */
-                                                         &err);
-        rsvg_set_xml_parse_options (xml_parser, ctx);
+        xml_parser = create_xml_stream_parser (ctx,
+                                               stream,
+                                               NULL, /* cancellable */
+                                               &err);
 
         g_object_unref (stream);
 
@@ -1939,12 +1957,10 @@ rsvg_handle_read_stream_sync (RsvgHandle   *handle,
     priv->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
 
     g_assert (handle->priv->ctxt == NULL);
-    handle->priv->ctxt = rsvg_create_xml_parser_from_stream (&rsvgSAXHandlerStruct,
-                                                             handle,
-                                                             stream,
-                                                             cancellable,
-                                                             &err);
-    rsvg_set_xml_parse_options (handle->priv->ctxt, handle);
+    handle->priv->ctxt = create_xml_stream_parser (handle,
+                                                   stream,
+                                                   cancellable,
+                                                   &err);
 
     if (!handle->priv->ctxt) {
         if (err) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]