From bc9967a6c28413922ad7055fa8257dbbfb6ba8f3 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Thu, 26 Feb 2004 22:52:38 +0000 Subject: Second (or maybe third) attempt to fix the cascading cascading thing. I 2004-02-26 Dodji Seketeli * src/cr-sel-eng.c: (cr_sel_eng_get_matched_properties_from_cascade): Second (or maybe third) attempt to fix the cascading cascading thing. I got *really* confused here. I hope it works this time. Thanks to to Rob BUIS who reported the bug. Off to bed now. --- ChangeLog | 10 ++++++++++ src/cr-sel-eng.c | 56 +++++++++++++++++++++++++++++++------------------------- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88cb404..a201928 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-02-26 Dodji Seketeli + + * src/cr-sel-eng.c: + (cr_sel_eng_get_matched_properties_from_cascade): + Second (or maybe third) attempt to fix the cascading + cascading thing. I got *really* confused here. + I hope it works this time. + Thanks to to Rob BUIS who reported the bug. + Off to bed now. + 2004-02-24 Dodji Seketeli * src/cr-parser.c: diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c index f2a730d..9896781 100644 --- a/src/cr-sel-eng.c +++ b/src/cr-sel-eng.c @@ -1388,8 +1388,7 @@ cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, { CRStatement ** stmts_tab = NULL ; enum CRStatus status = CR_OK ; - gulong tab_size = 0, tab_len = 0, i = 0, total_tab_len = 0, - index = 0; + gulong tab_size = 0, tab_len = 0, i = 0, index = 0; enum CRStyleOrigin origin = 0 ; gushort stmts_chunck_size = 8 ; CRStyleSheet *sheet = NULL ; @@ -1400,30 +1399,35 @@ cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, && a_props_hashtable, CR_BAD_PARAM_ERROR) ; - stmts_tab = g_try_malloc (stmts_chunck_size * - sizeof (CRStatement *)) ; - - if (!stmts_tab) - { - cr_utils_trace_info ("Out of memory") ; - status = CR_ERROR ; - goto error ; - } - memset (stmts_tab, 0, stmts_chunck_size * sizeof (CRStatement*)) ; - tab_size = stmts_chunck_size ; - tab_len = tab_size ; - for (origin = ORIGIN_UA ; origin < NB_ORIGINS ; origin++) { sheet = cr_cascade_get_sheet (a_cascade, origin) ; if (!sheet) - continue ; - - while ((status = cr_sel_eng_get_matched_rulesets_real + continue ; + if (tab_size - index < 1) + { + stmts_tab = g_try_realloc + (stmts_tab, + (tab_size + stmts_chunck_size) + * sizeof (CRStatement*)) ; + if (!stmts_tab) + { + cr_utils_trace_info ("Out of memory") ; + status = CR_ERROR ; + goto error ; + } + tab_size += stmts_chunck_size ; + /* + *compute the max size left for + *cr_sel_eng_get_matched_rulesets_real()'s output tab + */ + tab_len = tab_size - index ; + } + while ((status = cr_sel_eng_get_matched_rulesets_real (a_this, sheet, a_node, stmts_tab + index, &tab_len)) == CR_OUTPUT_TOO_SHORT_ERROR) { - stmts_tab = g_try_realloc + stmts_tab = g_try_realloc (stmts_tab, (tab_size + stmts_chunck_size) * sizeof (CRStatement*)) ; @@ -1433,8 +1437,12 @@ cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, status = CR_ERROR ; goto error ; } - tab_size += stmts_chunck_size ; + tab_size += stmts_chunck_size ; index += tab_len ; + /* + *compute the max size left for + *cr_sel_eng_get_matched_rulesets_real()'s output tab + */ tab_len = tab_size - index ; } if (status != CR_OK) @@ -1443,7 +1451,7 @@ cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, "selector engine") ; goto error ; } - total_tab_len += tab_len ; + index += tab_len ; } /* @@ -1452,13 +1460,12 @@ cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, *Make sure one can walk from the declaration to *the stylesheet. */ - for (i = 0 ; i < total_tab_len ; i ++) + for (i = 0 ; i < index ; i ++) { CRStatement *stmt = stmts_tab[i] ; if (!stmt) - continue ; - + continue ; switch (stmt->type) { case RULESET_STMT: @@ -1468,7 +1475,6 @@ cr_sel_eng_get_matched_properties_from_cascade (CRSelEng *a_this, (a_props_hashtable, stmt) ; break ; - default: break ; } -- cgit v1.2.1