X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fccltoken.c;h=5211fe888267bbaa317186932d7db4b40dac2dbb;hb=3c287bc1d48ee6a1f300054c2cebd0ba312bd5b9;hp=150006f6082739bbe24783e351af6994bfce0201;hpb=65371f5d5f265a4c5ee43f784b2d8a6db1e0774a;p=yaz-moved-to-github.git diff --git a/src/ccltoken.c b/src/ccltoken.c index 150006f..5211fe8 100644 --- a/src/ccltoken.c +++ b/src/ccltoken.c @@ -1,18 +1,18 @@ -/* - * Copyright (C) 1995-2008, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. - * - * $Id: ccltoken.c,v 1.15 2008-01-09 21:32:28 adam Exp $ */ /** * \file ccltoken.c * \brief Implements CCL lexical analyzer (scanner) */ +#if HAVE_CONFIG_H +#include +#endif #include #include -#include - +#include #include "cclp.h" /* @@ -103,7 +103,7 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command) case '%': case '!': last->kind = CCL_TOK_PROX; - while (isdigit(*cp)) + while (yaz_isdigit(*cp)) { ++ last->len; cp++; @@ -123,51 +123,61 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command) else last->kind = CCL_TOK_REL; break; - case '\"': + default: + --cp; + --last->len; + last->kind = CCL_TOK_TERM; last->name = (const char *) cp; - last->len = 0; - while (*cp && *cp != '\"') - { - cp++; - ++ last->len; - } - if (*cp == '\"') - cp++; - break; - default: - if (!strchr("(),%!><= \t\n\r", cp[-1])) + while (*cp && !strchr("(),%!><= \t\n\r", *cp)) { - while (*cp && !strchr("(),%!><= \t\n\r", *cp)) + if (*cp == '\\' && cp[1]) { cp++; ++ last->len; } + else if (*cp == '"') + { + while (*cp) + { + cp++; + ++ last->len; + if (*cp == '\\' && cp[1]) + { + cp++; + ++ last->len; + } + else if (*cp == '"') + break; + } + } + if (!*cp) + break; + cp++; + ++ last->len; } - 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; } @@ -279,6 +289,7 @@ int ccl_parser_get_error(CCL_parser cclp, int *pos) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab