X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=bd0ceab8f68489439e84a0c49f9a4b4c87b97ec5;hb=ffedd6a68cc4abe71450a0d504c7f0db8393a9d4;hp=9d6b8c682a8389fea3db8b1ffd64a20d20e55273;hpb=dbf7ead21f60be189f0d532175c92924a8eb73fd;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index 9d6b8c6..bd0ceab 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,10 +1,26 @@ -/* - * Copyright (C) 1995-2002, Index Data - * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss - * - * $Id: zrpn.c,v 1.118 2002-08-01 08:53:35 adam Exp $ - */ +/* $Id: zrpn.c,v 1.122 2002-08-28 19:52:29 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 + Index Data Aps + +This file is part of the Zebra server. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Zebra; see the file LICENSE.zebra. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +*/ + + #include #include #ifdef WIN32 @@ -1089,8 +1105,7 @@ static int trans_term (ZebraHandle zh, Z_AttributesPlusTerm *zapt, switch (term->which) { case Z_Term_general: -#if HAVE_ICONV_H - if (zh->iconv_to_utf8 != (iconv_t)(-1)) + if (zh->iconv_to_utf8 != 0) { char *inbuf = term->u.general->buf; size_t inleft = term->u.general->len; @@ -1099,18 +1114,17 @@ static int trans_term (ZebraHandle zh, Z_AttributesPlusTerm *zapt, size_t ret; yaz_log (LOG_DEBUG, "converting general from ISO-8859-1"); - ret = iconv(zh->iconv_to_utf8, &inbuf, &inleft, + ret = yaz_iconv(zh->iconv_to_utf8, &inbuf, &inleft, &outbuf, &outleft); if (ret == (size_t)(-1)) { - ret = iconv(zh->iconv_to_utf8, 0, 0, 0, 0); + ret = yaz_iconv(zh->iconv_to_utf8, 0, 0, 0, 0); zh->errCode = 125; return -1; } *outbuf = 0; return 0; } -#endif sizez = term->u.general->len; if (sizez > IT_MAX_WORD-1) sizez = IT_MAX_WORD-1; @@ -2081,6 +2095,7 @@ static int parse_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt, 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++; } @@ -2119,12 +2134,28 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream, int prefix_len = 0; int ord = zebraExplain_lookupSU (zh->reg->zei, curAttributeSet, use); int ord_len, i, r, max_pos; + int term_type = Z_Term_characterString; + const char *flags = "void"; if (grep_info_prepare (zh, 0 /* zapt */, &grep_info, '0', stream)) - return 0; + { + rset_null_parms parms; + + parms.rset_term = rset_term_create (term, strlen(term), + flags, term_type); + parms.rset_term->nn = 0; + return rset_create (rset_kind_null, &parms); + } if (ord < 0) - return 0; + { + rset_null_parms parms; + + parms.rset_term = rset_term_create (term, strlen(term), + flags, term_type); + parms.rset_term->nn = 0; + return rset_create (rset_kind_null, &parms); + } if (prefix_len) term_dict[prefix_len++] = '|'; else @@ -2149,7 +2180,7 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream, grep_info.isam_p_indx); rset = rset_trunc (zh, grep_info.isam_p_buf, grep_info.isam_p_indx, term, strlen(term), - "void", 1, Z_Term_characterString); + flags, 1, term_type); grep_info_delete (&grep_info); return rset; } @@ -2208,28 +2239,6 @@ static RSET rpn_search_xpath (ZebraHandle zh, zh->errString = basenames[base_no]; return rset; } - if (level > 0 && xpath[level-1].part[0] == '@') - { - rset_between_parms parms; - RSET rset_start_attr, rset_end_attr; - --level; - rset_start_attr = xpath_trunc(zh, stream, - '0', xpath[level].part+1, - 3, curAttributeSet); - - rset_end_attr = xpath_trunc(zh, stream, - '0', xpath[level].part+1, - 4, curAttributeSet); - - parms.key_size = sizeof(struct it_key); - parms.cmp = key_compare_it; - parms.rset_l = rset_start_attr; - parms.rset_m = rset; - parms.rset_r = rset_end_attr; - parms.rset_attr = 0; - parms.printer = key_print_it; - rset = rset_create (rset_kind_between, &parms); - } while (--level >= 0) { char xpath_rev[128]; @@ -2250,6 +2259,13 @@ static RSET rpn_search_xpath (ZebraHandle zh, memcpy (xpath_rev + len, "[^/]*", 5); len += 5; } + else if (*cp == ' ') + { + + xpath_rev[len++] = 1; + xpath_rev[len++] = ' '; + } + else xpath_rev[len++] = *cp; xpath_rev[len++] = '/'; @@ -2292,7 +2308,7 @@ static RSET rpn_search_xpath (ZebraHandle zh, rset_end_tag = xpath_trunc(zh, stream, '0', xpath_rev, 2, curAttributeSet); - + parms.key_size = sizeof(struct it_key); parms.cmp = key_compare_it; parms.rset_l = rset_start_tag;