diff options
author | Dodji Seketeli <dodji@gnome.org> | 2004-02-14 13:53:49 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2004-02-14 13:53:49 +0000 |
commit | 5c693b892418b7b0603037cc508dc8e313ce0046 (patch) | |
tree | f8eb2b4558e5c3d8c23e61cfa3449060968a3070 /src | |
parent | cb6a50718eeb9ea9ad59fbbd793c44d9d4519860 (diff) | |
download | libcroco-5c693b892418b7b0603037cc508dc8e313ce0046.tar.gz |
applied a patch from Rob BUIS<rwlbuis@xs4all.nl> that does a bunch of
2004-02-14 Dodji Seketeli <dodji@gnome.org>
* src/cr-declaration.[ch]: applied a patch from
Rob BUIS<rwlbuis@xs4all.nl> that does a bunch of cleanup and
fixes. It also adds the new cr_declaration_list_to_string() api
entry point.
* AUTHORS: updated this
Diffstat (limited to 'src')
-rw-r--r-- | src/cr-declaration.c | 48 | ||||
-rw-r--r-- | src/cr-declaration.h | 3 |
2 files changed, 46 insertions, 5 deletions
diff --git a/src/cr-declaration.c b/src/cr-declaration.c index 925e758..d1b99d0 100644 --- a/src/cr-declaration.c +++ b/src/cr-declaration.c @@ -603,17 +603,55 @@ cr_declaration_to_string (CRDeclaration *a_this, } /** + *Serializes the declaration list into a string + *@param a_this the current instance of #CRDeclaration. + *@param a_indent the number of indentation white char + *to put before the actual serialisation. + */ +guchar * +cr_declaration_list_to_string (CRDeclaration *a_this, + gulong a_indent) +{ + CRDeclaration *cur = NULL ; + GString *stringue = NULL ; + guchar *str = NULL, *result = NULL ; + + g_return_val_if_fail (a_this, NULL) ; + + stringue = g_string_new (NULL) ; + + for (cur = a_this ; cur ; cur = cur->next) + { + str = cr_declaration_to_string (cur, a_indent) ; + if (str) + { + g_string_append_printf (stringue, "%s;", str) ; + g_free (str) ; + } + else + break; + } + if (stringue && stringue->str) + { + result = stringue->str ; + g_string_free (stringue, FALSE) ; + } + + return result ; +} + +/** *Return the number of properties in the declaration; *@param a_this the current instance of #CRDeclaration. *@return number of properties in the declaration list. */ -int +gint cr_declaration_nr_props (CRDeclaration *a_this) { CRDeclaration *cur = NULL ; int nr = 0; - g_return_if_fail (a_this) ; + g_return_val_if_fail (a_this, -1) ; for (cur = a_this ; cur ; cur = cur->next) nr ++; @@ -633,7 +671,7 @@ cr_declaration_get_from_list (CRDeclaration *a_this, int itemnr) CRDeclaration *cur = NULL ; int nr = 0; - g_return_if_fail (a_this) ; + g_return_val_if_fail (a_this, NULL) ; for (cur = a_this ; cur ; cur = cur->next) if (nr++ == itemnr) @@ -652,8 +690,8 @@ cr_declaration_get_by_prop_name (CRDeclaration *a_this, const guchar *a_prop) { CRDeclaration *cur = NULL ; - g_return_if_fail (a_this) ; - g_return_if_fail (a_prop) ; + g_return_val_if_fail (a_this, NULL) ; + g_return_val_if_fail (a_prop, NULL) ; for (cur = a_this ; cur ; cur = cur->next) if (!strcmp (cur->property->str, a_prop)) diff --git a/src/cr-declaration.h b/src/cr-declaration.h index a423495..c065dac 100644 --- a/src/cr-declaration.h +++ b/src/cr-declaration.h @@ -112,6 +112,9 @@ cr_declaration_get_by_prop_name (CRDeclaration *a_this, const guchar *a_str) ; guchar * cr_declaration_to_string (CRDeclaration *a_this, gulong a_indent) ; +guchar * +cr_declaration_list_to_string (CRDeclaration *a_this, + gulong a_indent) ; void cr_declaration_ref (CRDeclaration *a_this) ; |