X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fpquery.c;h=dceed33d561dc62ab74ae523f7dc157f37e06a49;hb=b756b711841bac38e5b69baa51939ca9e1c01adb;hp=3004c24f7412dd2447bdb3f523caeb5fae96cadf;hpb=ae61397330cc9b5ecb90c6f385dd6f22d4037021;p=yaz-moved-to-github.git diff --git a/src/pquery.c b/src/pquery.c index 3004c24..dceed33 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -1,15 +1,18 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2010 Index Data + * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. */ /** * \file pquery.c * \brief Implements PQF parsing */ +#if HAVE_CONFIG_H +#include +#endif + #include #include #include -#include #include #include @@ -73,7 +76,7 @@ static int query_token(struct yaz_pqf_parser *li) } li->lex_buf = *qptr; - if (**qptr == li->escape_char && isdigit(((const unsigned char *) *qptr)[1])) + if (**qptr == li->escape_char && yaz_isdigit((*qptr)[1])) { ++(li->lex_len); ++(*qptr); @@ -826,24 +829,20 @@ Z_AttributeList *yaz_pqf_scan_attribute_list(YAZ_PQF_Parser p, ODR o, static Z_FacetField* parse_facet(ODR odr, const char *facet, int length) { YAZ_PQF_Parser pqf_parser = yaz_pqf_create(); - char buffer[length+1]; + char *buffer = odr_strdupn(odr, facet, length); Odr_oid *attributeSetId; - Z_FacetField *facet_field; - Z_AttributeList *attribute_list; - memcpy(buffer, facet, length); - buffer[length] = '\0'; - attribute_list = yaz_pqf_scan_attribute_list(pqf_parser, odr, &attributeSetId, buffer); - - if (!attribute_list) { - printf("Invalid facet definition: %s", facet); - return 0; + Z_FacetField *facet_field = 0; + Z_AttributeList *attribute_list = + yaz_pqf_scan_attribute_list(pqf_parser, odr, &attributeSetId, buffer); + + if (attribute_list) + { + facet_field = odr_malloc(odr, sizeof(*facet_field)); + facet_field->attributes = attribute_list; + facet_field->num_terms = 0; + facet_field->terms = 0; } - facet_field = odr_malloc(odr, sizeof(*facet_field)); - facet_field->attributes = attribute_list; - facet_field->num_terms = 0; - facet_field->terms = 0; - //debug_add_facet_term(odr, facet_field); - + yaz_pqf_destroy(pqf_parser); return facet_field; }