diff options
author | dodji <dodji@seketeli.org> | 2003-06-21 12:04:53 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@src.gnome.org> | 2003-06-21 12:04:53 +0000 |
commit | b881f78addafcce26a7d0d29edfcc7232e24edeb (patch) | |
tree | 6bfffcdfe34a0ebd549f15c1528c2195e4fd6b80 | |
parent | 7c01b64f75deca6b18df2e3930144be4128b3e98 (diff) | |
download | libcroco-b881f78addafcce26a7d0d29edfcc7232e24edeb.tar.gz |
Changed the prototype of cr_statement_unlink() to harmonize it with
2003-06-21 dodji <dodji@seketeli.org>
* src/parser/cr-statement.[ch]:
Changed the prototype of cr_statement_unlink() to
harmonize it with cr_declaration_unlink().
Dodji.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/parser/cr-statement.c | 56 | ||||
-rw-r--r-- | src/parser/cr-statement.h | 4 |
3 files changed, 46 insertions, 20 deletions
@@ -1,3 +1,9 @@ +2003-06-21 dodji <dodji@seketeli.org> + + * src/parser/cr-statement.[ch]: + Changed the prototype of cr_statement_unlink() to + harmonize it with cr_declaration_unlink(). + 2003-06-20 Dodji Seketeli <dodji@seketeli.org> * src/parser/cr-term.[ch]: diff --git a/src/parser/cr-statement.c b/src/parser/cr-statement.c index 46dc188..1bec2fe 100644 --- a/src/parser/cr-statement.c +++ b/src/parser/cr-statement.c @@ -1720,28 +1720,50 @@ cr_statement_prepend (CRStatement *a_this, *from, or NULL in case of error. */ CRStatement * -cr_statement_unlink (CRStatement *a_this, - CRStatement *a_to_unlink) +cr_statement_unlink (CRStatement *a_stmt) { - CRStatement *cur = NULL, *next = NULL, *prev = NULL ; + CRStatement *result = a_stmt ; - g_return_val_if_fail (a_this && a_to_unlink, NULL) ; + g_return_val_if_fail (result, NULL) ; - /*make sure a_to_unlink belongs to the list headed by a_this*/ - for (cur = a_this ; cur && (cur != a_to_unlink) ; cur = cur->next) ; - - if (!cur) return NULL ; + /** + *Some sanity checks first + */ + if (a_stmt->next) + { + g_return_val_if_fail (a_stmt->next->prev == a_stmt, + NULL) ; + } + if (a_stmt->prev) + { + g_return_val_if_fail (a_stmt->prev->next == a_stmt, + NULL) ; + } + + /** + *Now, the real unlinking job. + */ + if (a_stmt->next) + { + a_stmt->next->prev = a_stmt->prev ; + } + if (a_stmt->prev) + { + a_stmt->prev->next = a_stmt->next ; + } + + if (a_stmt->parent_sheet + && a_stmt->parent_sheet->statements == a_stmt) + { + a_stmt->parent_sheet->statements = + a_stmt->parent_sheet->statements->next ; + } - next = a_to_unlink->next ; - prev = a_to_unlink->prev ; - - if (prev) - prev->next = next ; - - if (next) - next->prev = prev ; + a_stmt->next = NULL ; + a_stmt->prev = NULL ; + a_stmt->parent_sheet = NULL ; - return a_to_unlink ; + return result ; } diff --git a/src/parser/cr-statement.h b/src/parser/cr-statement.h index 3a2f31f..9f893be 100644 --- a/src/parser/cr-statement.h +++ b/src/parser/cr-statement.h @@ -306,9 +306,7 @@ cr_statement_prepend (CRStatement *a_this, CRStatement *a_new) ; CRStatement * -cr_statement_unlink (CRStatement *a_this, - CRStatement *a_to_unlink) ; - +cr_statement_unlink (CRStatement *a_stmt) ; enum CRStatus cr_statement_ruleset_set_sel_list (CRStatement *a_this, |