X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcclfind.c;h=3cbeacf04054c7db31b2c5691c92ad14c2714f1e;hb=ce0b30b9bf7f8f30798724aa29a4d4dc83eaccfa;hp=7932ecbd099a257d1c02cd69d9dc9b0f74550b7d;hpb=c508282c3e52e145f998d0bb85c0ea6b36fe956c;p=yaz-moved-to-github.git diff --git a/src/cclfind.c b/src/cclfind.c index 7932ecb..3cbeacf 100644 --- a/src/cclfind.c +++ b/src/cclfind.c @@ -212,6 +212,19 @@ void ccl_add_attr_string(struct ccl_rpn_node *p, const char *set, n->value.str = xstrdup(value); } +static size_t cmp_operator(const char **aliases, const char *input) +{ + for (; *aliases; aliases++) + { + const char *cp = *aliases; + size_t i; + for (i = 0; *cp && *cp == input[i]; i++, cp++) + ; + if (*cp == '\0') + return i; + } + return 0; +} #define REGEX_CHARS "^[]{}()|.*+?!$" #define CCL_CHARS "#?\\" @@ -385,13 +398,12 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, if (p->u.t.term[0] && cclp->look_token->ws_prefix_len) { - size_t len = strlen(p->u.t.term); - memcpy(p->u.t.term + len, cclp->look_token->ws_prefix_buf, - cclp->look_token->ws_prefix_len); - p->u.t.term[len + cclp->look_token->ws_prefix_len] = '\0'; + strxcat(p->u.t.term, cclp->look_token->ws_prefix_buf, + cclp->look_token->ws_prefix_len); } for (j = 0; j < src_len; j++) { + size_t op_size; if (j > 0 && src_str[j-1] == '\\') { if (regex_trunc && strchr(REGEX_CHARS "\\", src_str[j])) @@ -408,8 +420,12 @@ static struct ccl_rpn_node *search_term_x(CCL_parser cclp, } else if (src_str[j] == '"') quote_mode = !quote_mode; - else if (!quote_mode && src_str[j] == '?') + else if (!quote_mode && + (op_size = cmp_operator(truncation_aliases, + src_str + j)) + ) { + j += (op_size - 1); /* j++ in for loop */ if (regex_trunc) { strcat(p->u.t.term, ".*");