X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fccltoken.c;h=ed45762d5b8fbf4ab37b2e719070bc39c16e2b75;hp=79d6efc8d5f4840525ad210f1bff227de48943d3;hb=89d7ade063c6c1ecd3aba012204bb6d9ec5b8792;hpb=417c6a81ea12af107047bf5f5b28a840ae553183 diff --git a/src/ccltoken.c b/src/ccltoken.c index 79d6efc..ed45762 100644 --- a/src/ccltoken.c +++ b/src/ccltoken.c @@ -79,6 +79,7 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command) last->next->prev = last; last = last->next; } + last->left_trunc = last->right_trunc = 0; last->ws_prefix_buf = (const char *) cp0; last->ws_prefix_len = cp - cp0; last->next = NULL; @@ -121,53 +122,66 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command) else last->kind = CCL_TOK_REL; break; - case '\"': - last->kind = CCL_TOK_TERM; - last->name = (const char *) cp; - last->len = 0; - while (*cp && *cp != '\"') + default: + --cp; + --last->len; + if (*cp == '?') { + last->left_trunc = 1; cp++; - ++ last->len; } - if (*cp == '\"') - cp++; - break; - default: - if (!strchr("(),%!><= \t\n\r", cp[-1])) + if (*cp == '"') { - while (*cp && !strchr("(),%!><= \t\n\r", *cp)) + cp++; + last->kind = CCL_TOK_TERM; + last->name = (const char *) cp; + while (*cp && *cp != '"') { cp++; ++ last->len; } + if (*cp) + cp++; + } + else + { + last->kind = CCL_TOK_TERM; + last->name = (const char *) cp; + while (*cp && !strchr("(),%!><=? \t\n\r", *cp)) + { + ++ last->len; + cp++; + } + aliases = ccl_qual_search_special(cclp->bibset, "and"); + if (!aliases) + aliases = cclp->ccl_token_and; + if (token_cmp(cclp, aliases, last)) + last->kind = CCL_TOK_AND; + + aliases = ccl_qual_search_special(cclp->bibset, "or"); + if (!aliases) + aliases = cclp->ccl_token_or; + if (token_cmp(cclp, aliases, last)) + last->kind = CCL_TOK_OR; + + aliases = ccl_qual_search_special(cclp->bibset, "not"); + if (!aliases) + aliases = cclp->ccl_token_not; + if (token_cmp(cclp, aliases, last)) + last->kind = CCL_TOK_NOT; + + aliases = ccl_qual_search_special(cclp->bibset, "set"); + if (!aliases) + aliases = cclp->ccl_token_set; + + if (token_cmp(cclp, aliases, last)) + last->kind = CCL_TOK_SET; + } + if (*cp == '?') + { + last->right_trunc = 1; + cp++; } - last->kind = CCL_TOK_TERM; - - aliases = ccl_qual_search_special(cclp->bibset, "and"); - if (!aliases) - aliases = cclp->ccl_token_and; - if (token_cmp(cclp, aliases, last)) - last->kind = CCL_TOK_AND; - - aliases = ccl_qual_search_special(cclp->bibset, "or"); - if (!aliases) - aliases = cclp->ccl_token_or; - if (token_cmp(cclp, aliases, last)) - last->kind = CCL_TOK_OR; - - aliases = ccl_qual_search_special(cclp->bibset, "not"); - if (!aliases) - aliases = cclp->ccl_token_not; - if (token_cmp(cclp, aliases, last)) - last->kind = CCL_TOK_NOT; - - aliases = ccl_qual_search_special(cclp->bibset, "set"); - if (!aliases) - aliases = cclp->ccl_token_set; - - if (token_cmp(cclp, aliases, last)) - last->kind = CCL_TOK_SET; } } return first;