[librsvg] rsvg_get_url_string(): Add argument to return the rest of the string after the IRI



commit 0eb00115efa034c1dfd1f920bcfa76b985b6f9ff
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Feb 8 11:34:57 2017 -0600

    rsvg_get_url_string(): Add argument to return the rest of the string after the IRI
    
    Also, move rsvg_get_url_string() to a more reasonable place than
    rsvg-mask.c (?).

 rsvg-base.c         |   26 ++++++++++++++++++++++++++
 rsvg-mask.c         |   17 -----------------
 rsvg-paint-server.c |    2 +-
 rsvg-private.h      |    2 +-
 rsvg-styles.c       |   18 +++++++++---------
 5 files changed, 37 insertions(+), 28 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 65f59bc..aadbc77 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -2426,6 +2426,32 @@ rsvg_drawing_ctx_get_dpi (RsvgDrawingCtx *ctx, double *out_dpi_x, double *out_dp
         *out_dpi_y = ctx->dpi_y;
 }
 
+char *
+rsvg_get_url_string (const char *str, const char **out_rest)
+{
+    if (!strncmp (str, "url(", 4)) {
+        const char *p = str + 4;
+        int ix;
+
+        while (g_ascii_isspace (*p))
+            p++;
+
+        for (ix = 0; p[ix]; ix++) {
+            if (p[ix] == ')') {
+                if (out_rest)
+                    *out_rest = p + ix + 1;
+
+                return g_strndup (p, ix);
+            }
+        }
+    }
+
+    if (out_rest)
+        *out_rest = NULL;
+
+    return NULL;
+}
+
 void
 rsvg_return_if_fail_warning (const char *pretty_function, const char *expression, GError ** error)
 {
diff --git a/rsvg-mask.c b/rsvg-mask.c
index d167f94..e7792b7 100644
--- a/rsvg-mask.c
+++ b/rsvg-mask.c
@@ -81,23 +81,6 @@ rsvg_new_mask (const char *element_name)
     return &mask->super;
 }
 
-char *
-rsvg_get_url_string (const char *str)
-{
-    if (!strncmp (str, "url(", 4)) {
-        const char *p = str + 4;
-        int ix;
-
-        while (g_ascii_isspace (*p))
-            p++;
-
-        for (ix = 0; p[ix]; ix++)
-            if (p[ix] == ')')
-                return g_strndup (p, ix);
-    }
-    return NULL;
-}
-
 static void
 rsvg_clip_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
 {
diff --git a/rsvg-paint-server.c b/rsvg-paint-server.c
index 981c2de..d675624 100644
--- a/rsvg-paint-server.c
+++ b/rsvg-paint-server.c
@@ -95,7 +95,7 @@ rsvg_paint_server_parse (gboolean * inherit, const char *str)
     if (str == NULL || !strcmp (str, "none"))
         return NULL;
 
-    name = rsvg_get_url_string (str);
+    name = rsvg_get_url_string (str, NULL);
     if (name) {
         return rsvg_paint_server_iri (name);
     } else if (!strcmp (str, "inherit")) {
diff --git a/rsvg-private.h b/rsvg-private.h
index ce8d609..d4f6396 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -489,7 +489,7 @@ void rsvg_drawing_ctx_get_dpi (RsvgDrawingCtx *ctx, double *out_dpi_x, double *o
 G_GNUC_INTERNAL
 void rsvg_SAX_handler_struct_init (void);
 G_GNUC_INTERNAL
-char *rsvg_get_url_string (const char *str);
+char *rsvg_get_url_string (const char *str, const char **out_rest);
 G_GNUC_INTERNAL
 void rsvg_return_if_fail_warning (const char *pretty_function,
                                   const char *expression, GError ** error);
diff --git a/rsvg-styles.c b/rsvg-styles.c
index f2e7324..e2ad559 100644
--- a/rsvg-styles.c
+++ b/rsvg-styles.c
@@ -554,10 +554,10 @@ rsvg_parse_style_pair (RsvgHandle * ctx,
         state->has_flood_opacity = TRUE;
     } else if (g_str_equal (name, "filter")) {
         g_free (state->filter);
-        state->filter = rsvg_get_url_string (value);
+        state->filter = rsvg_get_url_string (value, NULL);
     } else if (g_str_equal (name, "mask")) {
         g_free (state->mask);
-        state->mask = rsvg_get_url_string (value);
+        state->mask = rsvg_get_url_string (value, NULL);
     } else if (g_str_equal (name, "baseline-shift")) {
         /* These values come from Inkscape's SP_CSS_BASELINE_SHIFT_(SUB/SUPER/BASELINE);
          * see sp_style_merge_baseline_shift_from_parent()
@@ -576,7 +576,7 @@ rsvg_parse_style_pair (RsvgHandle * ctx,
         }
     } else if (g_str_equal (name, "clip-path")) {
         g_free (state->clip_path);
-        state->clip_path = rsvg_get_url_string (value);
+        state->clip_path = rsvg_get_url_string (value, NULL);
     } else if (g_str_equal (name, "overflow")) {
         if (!g_str_equal (value, "inherit")) {
             state->overflow = rsvg_css_parse_overflow (value, &state->has_overflow);
@@ -831,32 +831,32 @@ rsvg_parse_style_pair (RsvgHandle * ctx,
         }
     } else if (g_str_equal (name, "marker-start")) {
         g_free (state->startMarker);
-        state->startMarker = rsvg_get_url_string (value);
+        state->startMarker = rsvg_get_url_string (value, NULL);
         state->has_startMarker = TRUE;
     } else if (g_str_equal (name, "marker-mid")) {
         g_free (state->middleMarker);
-        state->middleMarker = rsvg_get_url_string (value);
+        state->middleMarker = rsvg_get_url_string (value, NULL);
         state->has_middleMarker = TRUE;
     } else if (g_str_equal (name, "marker-end")) {
         g_free (state->endMarker);
-        state->endMarker = rsvg_get_url_string (value);
+        state->endMarker = rsvg_get_url_string (value, NULL);
         state->has_endMarker = TRUE;
     } else if (g_str_equal (name, "marker")) {
         if (!state->has_startMarker) {
             g_free (state->startMarker);
-            state->startMarker = rsvg_get_url_string (value);
+            state->startMarker = rsvg_get_url_string (value, NULL);
             state->has_startMarker = TRUE;
         }
 
         if (!state->has_middleMarker) {
             g_free (state->middleMarker);
-            state->middleMarker = rsvg_get_url_string (value);
+            state->middleMarker = rsvg_get_url_string (value, NULL);
             state->has_middleMarker = TRUE;
         }
 
         if (!state->has_endMarker) {
             g_free (state->endMarker);
-            state->endMarker = rsvg_get_url_string (value);
+            state->endMarker = rsvg_get_url_string (value, NULL);
             state->has_endMarker = TRUE;
         }
     } else if (g_str_equal (name, "stroke-miterlimit")) {


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