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 (?).
parent b4dfdddd
......@@ -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)
{
......
......@@ -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)
{
......
......@@ -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")) {
......
......@@ -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);
......
......@@ -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")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment