/* 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:
*
#include <string.h>
#include <stdlib.h>
+#include <ctype.h>
#include <yaz/ccl.h>
}
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;
}
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;
case '%':
case '!':
last->kind = CCL_TOK_PROX;
- while (*cp == '%' || *cp == '!')
+ while (isdigit(*cp))
{
++ last->len;
cp++;
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;
while (list)
{
list1 = list->next;
- free (list);
+ xfree (list);
list = list1;
}
}
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;
{
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)
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);
}
}
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);
}
}
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);
}
}
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);
}
}