From: Heikki Levanto Date: Fri, 31 May 2013 13:36:35 +0000 (+0200) Subject: Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/yaz X-Git-Tag: v4.2.58~6^2 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=1d1aeb8cdd81a95305432e8fd31089787b451f3c;hp=cec9f9be3944b0d7891bf358a0679f0d32305621 Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/yaz --- diff --git a/doc/tools.xml b/doc/tools.xml index 2544316..ec3bc1b 100644 --- a/doc/tools.xml +++ b/doc/tools.xml @@ -867,6 +867,11 @@ ? + mask + Masking character + # + + field Specifies how multiple fields are to be combined. There are two modes: or: diff --git a/src/cclfind.c b/src/cclfind.c index 93ea05d..a2ea081 100644 --- a/src/cclfind.c +++ b/src/cclfind.c @@ -232,6 +232,7 @@ static size_t cmp_operator(const char **aliases, const char *input) static int append_term(CCL_parser cclp, const char *src_str, size_t src_len, char *dst_term, int *regex_trunc, int *z3958_trunc, const char **truncation_aliases, + const char **mask_aliases, int is_first, int is_last, int *left_trunc, int *right_trunc) { @@ -283,8 +284,10 @@ static int append_term(CCL_parser cclp, const char *src_str, size_t src_len, return -1; } } - else if (!quote_mode && src_str[j] == '#') + else if (!quote_mode && + (op_size = cmp_operator(mask_aliases, src_str + j))) { + j += (op_size - 1); /* j++ in for loop */ if (*regex_trunc) { strcat(dst_term, "."); @@ -339,6 +342,8 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, char *attset; const char **truncation_aliases; const char *t_default[2]; + const char **mask_aliases; + const char *m_default[2]; truncation_aliases = ccl_qual_search_special(cclp->bibset, "truncation"); @@ -349,6 +354,16 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, t_default[1] = 0; } + mask_aliases = + ccl_qual_search_special(cclp->bibset, "mask"); + if (!mask_aliases) + { + mask_aliases = m_default; + m_default[0] = "#"; + m_default[1] = 0; + } + + if (qual_val_type(qa, CCL_BIB1_STR, CCL_BIB1_STR_AND_LIST, 0)) and_list = 1; if (qual_val_type(qa, CCL_BIB1_STR, CCL_BIB1_STR_AUTO_GROUP, 0)) @@ -500,7 +515,8 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, cclp->look_token->ws_prefix_len); } if (append_term(cclp, src_str, src_len, p->u.t.term, ®ex_trunc, - &z3958_trunc, truncation_aliases, i == 0, i == no - 1, + &z3958_trunc, truncation_aliases, mask_aliases, + i == 0, i == no - 1, &left_trunc, &right_trunc)) { ccl_rpn_delete(p); diff --git a/test/test_ccl.c b/test/test_ccl.c index 9e2b927..d189f00 100644 --- a/test/test_ccl.c +++ b/test/test_ccl.c @@ -429,6 +429,9 @@ void tst2(void) ccl_qual_fitem(bibset, "u=4 s=pw t=l,r", "ti"); ccl_qual_fitem(bibset, "1=1016 s=al,pw t=z", "term"); + YAZ_CHECK(tst_ccl_query(bibset, "a?#", + "@attr 5=104 @attr 4=2 @attr 1=1016 a?# ")); + YAZ_CHECK(tst_ccl_query(bibset, "a*", "@attr 4=2 @attr 1=1016 a* ")); @@ -442,6 +445,16 @@ void tst2(void) YAZ_CHECK(tst_ccl_query(bibset, "a?", "@attr 5=104 @attr 4=2 @attr 1=1016 a\\\\? ")); + ccl_qual_fitem(bibset, "?", "@mask"); + YAZ_CHECK(tst_ccl_query(bibset, "a?", + "@attr 5=104 @attr 4=2 @attr 1=1016 a# ")); + + + ccl_qual_fitem(bibset, "", "@mask"); + ccl_qual_fitem(bibset, "", "@truncation"); + YAZ_CHECK(tst_ccl_query(bibset, "a?#", + "@attr 5=104 @attr 4=2 @attr 1=1016 a\\\\?\\\\# ")); + ccl_qual_fitem(bibset, "og", "@and"); ccl_qual_fitem(bibset, "eller", "@or"); ccl_qual_fitem(bibset, "ikke", "@not");