X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fpquery.c;h=289e368219635470ff19a909e693b917e716b517;hb=6fad29ebb31777f3e01ad80f0c59a7a4dede9989;hp=bcaa487bcb80a704f642ce4c2e4c078ff28a28b2;hpb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9;p=yaz-moved-to-github.git diff --git a/src/pquery.c b/src/pquery.c index bcaa487..289e368 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -1,10 +1,13 @@ /* - * Copyright (c) 1995-2003, Index Data. + * Copyright (c) 1995-2004, Index Data. * See the file LICENSE for details. * - * $Id: pquery.c,v 1.1 2003-10-27 12:21:35 adam Exp $ + * $Id: pquery.c,v 1.4 2004-12-30 00:21:12 adam Exp $ + */ +/** + * \file pquery.c + * \brief Implements PQF parsing */ - #include #include #include @@ -77,7 +80,7 @@ static int query_token (struct yaz_pqf_parser *li) } li->lex_buf = *qptr; - if (**qptr == li->escape_char && isdigit ((*qptr)[1])) + if (**qptr == li->escape_char && isdigit (((const unsigned char *) *qptr)[1])) { ++(li->lex_len); ++(*qptr); @@ -397,15 +400,9 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o) return NULL; } if (*li->lex_buf == '1') - { - p->exclusion = (int *)odr_malloc (o, sizeof(*p->exclusion)); - *p->exclusion = 1; - } + p->exclusion = odr_intdup (o, 1); else if (*li->lex_buf == '0') - { - p->exclusion = (int *)odr_malloc (o, sizeof(*p->exclusion)); - *p->exclusion = 0; - } + p->exclusion = odr_intdup (o, 0); else p->exclusion = NULL; @@ -414,24 +411,21 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o) li->error = YAZ_PQF_ERROR_MISSING; return NULL; } - p->distance = (int *)odr_malloc (o, sizeof(*p->distance)); - *p->distance = atoi (li->lex_buf); + p->distance = odr_intdup (o, atoi(li->lex_buf)); if (!lex (li)) { li->error = YAZ_PQF_ERROR_MISSING; return NULL; } - p->ordered = (int *)odr_malloc (o, sizeof(*p->ordered)); - *p->ordered = atoi (li->lex_buf); + p->ordered = odr_intdup (o, atoi (li->lex_buf)); if (!lex (li)) { li->error = YAZ_PQF_ERROR_MISSING; return NULL; } - p->relationType = (int *)odr_malloc (o, sizeof(*p->relationType)); - *p->relationType = atoi (li->lex_buf); + p->relationType = odr_intdup (o, atoi (li->lex_buf)); if (!lex (li)) { @@ -439,9 +433,9 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o) return NULL; } if (*li->lex_buf == 'k') - p->which = 0; + p->which = Z_ProximityOperator_known; else if (*li->lex_buf == 'p') - p->which = 1; + p->which = Z_ProximityOperator_private; else p->which = atoi (li->lex_buf); @@ -450,9 +444,7 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o) li->error = YAZ_PQF_ERROR_MISSING; return NULL; } - p->which = Z_ProximityOperator_known; - p->u.known = (int *)odr_malloc (o, sizeof(*p->u.known)); - *p->u.known = atoi (li->lex_buf); + p->u.known = odr_intdup (o, atoi(li->lex_buf)); return p; } @@ -640,8 +632,7 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct yaz_pqf_parser *li, oid_proto proto, return zq; } -Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto, - const char *qbuf) +Z_RPNQuery *p_query_rpn (ODR o, oid_proto proto, const char *qbuf) { struct yaz_pqf_parser li;