X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=2f35cfa93a15aadd659d4517daad971d203cc23e;hb=fbbce5a85247803288df5d97e5061889f118c826;hp=0a2c29ccd5c87717ea235a5428ff6b6a7b7cfbe9;hpb=00d69171180b9edc123986794b572be57caa5bb2;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index 0a2c29c..2f35cfa 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.126 2002-12-16 22:59:34 adam Exp $ +/* $Id: zrpn.c,v 1.127 2003-02-04 12:06:47 pop Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -31,6 +31,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include "index.h" +#include #include #include @@ -43,6 +44,14 @@ struct rpn_char_map_info { int reg_type; }; +typedef struct { + int type; + int major; + int minor; + Z_AttributesPlusTerm *zapt; +} AttrType; + + static const char **rpn_char_map_handler (void *vp, const char **from, int len) { struct rpn_char_map_info *p = (struct rpn_char_map_info *) vp; @@ -70,13 +79,6 @@ static void rpn_char_map_prepare (struct zebra_register *reg, int reg_type, dict_grep_cmap (reg->dict, map_info, rpn_char_map_handler); } -typedef struct { - int type; - int major; - int minor; - Z_AttributesPlusTerm *zapt; -} AttrType; - static int attr_find_ex (AttrType *src, oid_value *attributeSetP, const char **string_value) { @@ -2034,6 +2036,9 @@ static RSET rpn_sort_spec (ZebraHandle zh, Z_AttributesPlusTerm *zapt, return rset_create (rset_kind_null, &parms); } +/* pop - moved to xpath.c */ +#if 0 + struct xpath_predicate { int which; union { @@ -2057,6 +2062,8 @@ struct xpath_location_step { struct xpath_predicate *predicate; }; +#endif + static int parse_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt, oid_value attributeSet, struct xpath_location_step *xpath, NMEM mem) @@ -2064,7 +2071,6 @@ static int parse_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt, oid_value curAttributeSet = attributeSet; AttrType use; const char *use_string = 0; - const char *cp; int no = 0; attr_init (&use, zapt, 1); @@ -2072,87 +2078,11 @@ static int parse_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt, if (!use_string || *use_string != '/') return -1; - cp = use_string; - while (*cp) - { - int i = 0; - while (*cp && !strchr("/[",*cp)) - { - i++; - cp++; - } - xpath[no].predicate = 0; - xpath[no].part = nmem_malloc (mem, i+1); - memcpy (xpath[no].part, cp - i, i); - xpath[no].part[i] = 0; - if (*cp == '[') - { - struct xpath_predicate *p = xpath[no].predicate = - nmem_malloc (mem, sizeof(struct xpath_predicate)); - - p->which = XPATH_PREDICATE_RELATION; - cp++; - while (*cp == ' ') - cp++; - - for (i = 0; *cp && !strchr("><=] ", *cp); i++) - cp++; - p->u.relation.name = nmem_malloc (mem, i+1); - memcpy (p->u.relation.name, cp - i, i); - p->u.relation.name[i] = 0; - while (*cp == ' ') - cp++; - if (*cp != ']') - { - for (i = 0; *cp && strchr(">=u.relation.op = nmem_malloc (mem, i+1); - if (i) - memcpy (p->u.relation.op, cp - i, i); - p->u.relation.op[i] = 0; - - while (*cp == ' ') - cp++; - - if (strchr("\"'", *cp)) - { - cp++; - for (i = 0; *cp && !strchr("\"'", *cp); i++) - cp++; - - p->u.relation.value = nmem_malloc (mem, i+1); - if (i) - memcpy (p->u.relation.value, cp - i, i); - p->u.relation.value[i] = 0; - yaz_log (LOG_LOG, "value=%s", p->u.relation.value); - - cp++; - } - else - { - for (i = 0; *cp && !strchr(" ]", *cp); i++) - cp++; - p->u.relation.value = nmem_malloc (mem, i+1); - if (i) - memcpy (p->u.relation.value, cp - i, i); - p->u.relation.value[i] = 0; - } - while (*cp == ' ') - cp++; - } - if (*cp == ']') - cp++; - } /* end of ] predicate */ - no++; - if (*cp != '/') - break; - cp++; - } - return no; + return (parse_xpath_str(use_string, xpath, mem)); } - + + static RSET xpath_trunc(ZebraHandle zh, NMEM stream, int reg_type, const char *term, int use,