From 4e0757c4ea6d3081ccdd5420d8a80926c858c960 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 17 Jun 2011 12:15:55 +0200 Subject: [PATCH] ccl_qual_dup fixes; previous version totally broken --- src/cclqual.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cclqual.c b/src/cclqual.c index e55a654..e0761b8 100644 --- a/src/cclqual.c +++ b/src/cclqual.c @@ -277,7 +277,6 @@ CCL_bibset ccl_qual_dup(CCL_bibset b) attrp = &(*qp)->attr_list; for (attr = q->attr_list; attr; attr = attr->next) { - int i; *attrp = xmalloc(sizeof(**attrp)); (*attrp)->next = 0; (*attrp)->set = attr->set ? xstrdup(attr->set) : 0; @@ -287,14 +286,20 @@ CCL_bibset ccl_qual_dup(CCL_bibset b) else if (attr->kind == CCL_RPN_ATTR_STRING) (*attrp)->value.str = xstrdup(attr->value.str); + attrp = &(*attrp)->next; + } + (*qp)->no_sub = q->no_sub; + if (!q->sub) + (*qp)->sub = 0; + else + { /* fix up the sub qualifiers.. */ - for (i = 0; q->sub[i]; i++) - ; - (*qp)->sub = xmalloc(sizeof(*(*qp)->sub) * (i+1)); - for (i = 0; q->sub[i]; i++) + int i; + (*qp)->sub = xmalloc(sizeof(*q->sub) * (q->no_sub + 1)); + for (i = 0; i < q->no_sub; i++) { struct ccl_qualifier *q1, *q2; - + /* sweep though original and match up the corresponding ent */ q2 = n->list; for (q1 = b->list; q1 && q2; q1 = q1->next, q2 = q2->next) @@ -302,9 +307,6 @@ CCL_bibset ccl_qual_dup(CCL_bibset b) break; (*qp)->sub[i] = q2; } - (*qp)->sub[i] = 0; - - attrp = &(*attrp)->next; } qp = &(*qp)->next; } -- 1.7.10.4