From eb467c75687daef0419eb95f652693ca00c60195 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 15 Jul 2014 14:11:30 +0200 Subject: [PATCH] CCL combo qualifier should allow forward references YAZ-779 --- src/cclqual.c | 31 ++++++++++++++++++------------- test/test_ccl.c | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/cclqual.c b/src/cclqual.c index 963bbd1..8f9a4e8 100644 --- a/src/cclqual.c +++ b/src/cclqual.c @@ -104,6 +104,19 @@ void ccl_qual_add_special(CCL_bibset bibset, const char *n, const char *cp) yaz_tok_parse_destroy(tp); } +static struct ccl_qualifier *ccl_qual_new(CCL_bibset b, const char *name) +{ + struct ccl_qualifier *q; + q = (struct ccl_qualifier *)xmalloc(sizeof(*q)); + ccl_assert(q); + q->next = b->list; + b->list = q; + q->name = xstrdup(name); + q->attr_list = 0; + q->no_sub = 0; + q->sub = 0; + return q; +} /** \brief adds specifies qualifier aliases @@ -131,7 +144,11 @@ void ccl_qual_add_combi(CCL_bibset b, const char *n, const char **names) q->sub = (struct ccl_qualifier **) xmalloc(sizeof(*q->sub) * (1+q->no_sub)); for (i = 0; names[i]; i++) + { q->sub[i] = ccl_qual_lookup(b, names[i], strlen(names[i])); + if (!q->sub[i]) + q->sub[i] = ccl_qual_new(b, names[i]); + } } /** \brief adds specifies attributes for qualifier @@ -157,19 +174,7 @@ void ccl_qual_add_set(CCL_bibset b, const char *name, int no, if (!strcmp(name, q->name)) break; if (!q) - { - q = (struct ccl_qualifier *)xmalloc(sizeof(*q)); - ccl_assert(q); - - q->next = b->list; - b->list = q; - - q->name = xstrdup(name); - q->attr_list = 0; - - q->no_sub = 0; - q->sub = 0; - } + q = ccl_qual_new(b, name); attrp = &q->attr_list; while (*attrp) attrp = &(*attrp)->next; diff --git a/test/test_ccl.c b/test/test_ccl.c index a78dfdf..1f1050d 100644 --- a/test/test_ccl.c +++ b/test/test_ccl.c @@ -77,6 +77,7 @@ void tst1(int pass) switch(pass) { case 0: + ccl_qual_fitem(bibset, "term dc.title", "comb"); ccl_qual_fitem(bibset, "u=4 s=pw t=l,r", "ti"); ccl_qual_fitem(bibset, "1=1016 s=al,pw t=r", "term"); ccl_qual_fitem(bibset, "t=x", "reg"); @@ -85,7 +86,6 @@ void tst1(int pass) ccl_qual_fitem(bibset, "r=r,omiteq", "date"); ccl_qual_fitem(bibset, "r=o", "x"); ccl_qual_fitem(bibset, "dc.title", "title"); - ccl_qual_fitem(bibset, "term dc.title", "comb"); ccl_qual_fitem(bibset, "s=ag", "ag"); break; case 1: -- 1.7.10.4