From 179fa413b047bede6e32109e2ce82437c5fb8d34 Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Mon, 16 Jan 2006 02:36:01 +0000 Subject: moving trunk for module inkscape (bzr r1) --- src/extract-uri.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/extract-uri.cpp (limited to 'src/extract-uri.cpp') diff --git a/src/extract-uri.cpp b/src/extract-uri.cpp new file mode 100644 index 000000000..dd6549c8f --- /dev/null +++ b/src/extract-uri.cpp @@ -0,0 +1,40 @@ +#include +#include + +// FIXME: kill this ugliness when we have a proper CSS parser +gchar *extract_uri(gchar const *s) +{ + gchar const *sb = s; + g_assert( strncmp(sb, "url", 3) == 0 ); + sb += 3; + + while ( ( *sb == ' ' ) || + ( *sb == '(' ) ) + { + sb++; + } + + gchar const *se = sb + strlen(sb); + while ( ( se[-1] == ' ' ) || + ( se[-1] == ')' ) ) + { + se--; + } + + if ( sb < se ) { + return g_strndup(sb, se - sb); + } else { + return NULL; + } +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- cgit v1.2.3