X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=ccl%2Fccltoken.c;h=31a18d83e4fb3cd3fa0cc9936ffd96a85abf5239;hp=12111b1726b2ecc9e214ec60b7fca951e1c0e9a9;hb=d0e56fdb958b43316f5ebffddd7f9dd8480978f8;hpb=cb9bad819f13e44d7af6753bfa1bc8274ca37b9b diff --git a/ccl/ccltoken.c b/ccl/ccltoken.c index 12111b1..31a18d8 100644 --- a/ccl/ccltoken.c +++ b/ccl/ccltoken.c @@ -44,7 +44,7 @@ /* CCL - lexical analysis * Europagate, 1995 * - * $Id: ccltoken.c,v 1.18 2001-11-27 22:38:50 adam Exp $ + * $Id: ccltoken.c,v 1.22 2003-02-14 18:49:23 adam Exp $ * * Old Europagate Log: * @@ -85,6 +85,7 @@ #include #include +#include #include @@ -149,13 +150,13 @@ struct ccl_token *ccl_token_simple (const char *command) } if (!first) { - first = last = (struct ccl_token *)malloc (sizeof (*first)); + first = last = (struct ccl_token *)xmalloc (sizeof (*first)); ccl_assert (first); last->prev = NULL; } else { - last->next = (struct ccl_token *)malloc (sizeof(*first)); + last->next = (struct ccl_token *)xmalloc (sizeof(*first)); ccl_assert (last->next); last->next->prev = last; last = last->next; @@ -213,13 +214,13 @@ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command) } if (!first) { - first = last = (struct ccl_token *)malloc (sizeof (*first)); + first = last = (struct ccl_token *)xmalloc (sizeof (*first)); ccl_assert (first); last->prev = NULL; } else { - last->next = (struct ccl_token *)malloc (sizeof(*first)); + last->next = (struct ccl_token *)xmalloc (sizeof(*first)); ccl_assert (last->next); last->next->prev = last; last = last->next; @@ -244,7 +245,7 @@ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command) case '%': case '!': last->kind = CCL_TOK_PROX; - while (*cp == '%' || *cp == '!') + while (isdigit(*cp)) { ++ last->len; cp++; @@ -277,9 +278,9 @@ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command) cp++; break; default: - if (!strchr ("(),%!><=- \t\n\r", cp[-1])) + if (!strchr ("(),%!><= \t\n\r", cp[-1])) { - while (*cp && !strchr ("(),%!><=- \t\n\r", *cp)) + while (*cp && !strchr ("(),%!><= \t\n\r", *cp)) { cp++; ++ last->len; @@ -337,7 +338,7 @@ void ccl_token_del (struct ccl_token *list) while (list) { list1 = list->next; - free (list); + xfree (list); list = list1; } } @@ -345,14 +346,14 @@ void ccl_token_del (struct ccl_token *list) char *ccl_strdup (const char *str) { int len = strlen(str); - char *p = (char*) malloc (len+1); + char *p = (char*) xmalloc (len+1); strcpy (p, str); return p; } CCL_parser ccl_parser_create (void) { - CCL_parser p = (CCL_parser)malloc (sizeof(*p)); + CCL_parser p = (CCL_parser)xmalloc (sizeof(*p)); if (!p) return p; p->look_token = NULL; @@ -373,11 +374,11 @@ void ccl_parser_destroy (CCL_parser p) { if (!p) return; - free (p->ccl_token_and); - free (p->ccl_token_or); - free (p->ccl_token_not); - free (p->ccl_token_set); - free (p); + xfree (p->ccl_token_and); + xfree (p->ccl_token_or); + xfree (p->ccl_token_not); + xfree (p->ccl_token_set); + xfree (p); } void ccl_parser_set_op_and (CCL_parser p, const char *op) @@ -385,7 +386,7 @@ void ccl_parser_set_op_and (CCL_parser p, const char *op) if (p && op) { if (p->ccl_token_and) - free (p->ccl_token_and); + xfree (p->ccl_token_and); p->ccl_token_and = ccl_strdup (op); } } @@ -395,7 +396,7 @@ void ccl_parser_set_op_or (CCL_parser p, const char *op) if (p && op) { if (p->ccl_token_or) - free (p->ccl_token_or); + xfree (p->ccl_token_or); p->ccl_token_or = ccl_strdup (op); } } @@ -404,7 +405,7 @@ void ccl_parser_set_op_not (CCL_parser p, const char *op) if (p && op) { if (p->ccl_token_not) - free (p->ccl_token_not); + xfree (p->ccl_token_not); p->ccl_token_not = ccl_strdup (op); } } @@ -413,7 +414,7 @@ void ccl_parser_set_op_set (CCL_parser p, const char *op) if (p && op) { if (p->ccl_token_set) - free (p->ccl_token_set); + xfree (p->ccl_token_set); p->ccl_token_set = ccl_strdup (op); } }