Logo Search packages:      
Sourcecode: inkscape version File versions

gchar * Inkscape::parse_css_url ( const gchar *  string  ) 

Parses a CSS url() specification; temporary hack until style stuff is redone.

Parameters:
string the CSS string to parse
Returns:
a newly-allocated URL string (or NULL); free with g_free()

Definition at line 50 of file style.cpp.

                                          {
    const gchar *iter;
    gchar *result;
    gchar end_char;
    GString *temp;

    if (!string)
        return NULL;

    iter = string;

    for ( ; g_ascii_isspace(*iter) ; iter = g_utf8_next_char(iter) );
    if (strncmp(iter, "url(", 4))
        return NULL;
    iter += 4;

    if ( *iter == '"' || *iter == '\'' ) {
        end_char = *iter;
        iter += 1;
    } else {
        end_char = *iter;
    }

    temp = g_string_new(NULL);

    for ( ; *iter ; iter = g_utf8_next_char(iter) ) {
        if ( *iter == '(' || *iter == ')'  ||
             *iter == '"' || *iter == '\'' ||
             g_ascii_isspace(*iter)        ||
             g_ascii_iscntrl(*iter)           )
        {
            break;
        }
        if ( *iter == '\\' ) {
            iter = g_utf8_next_char(iter);
        }
        if ( *iter & (gchar)0x80 ) {
            break;
        } else {
            g_string_append_c(temp, *iter);
        }
    }

    if ( *iter == end_char && end_char != ')' ) {
        iter = g_utf8_next_char(iter);
    }
    if ( *iter == ')' ) {
        result = temp->str;
        g_string_free(temp, FALSE);
    } else {
        result = NULL;
        g_string_free(temp, TRUE);
    }

    return result;
}


Generated by  Doxygen 1.6.0   Back to index