X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=26100a0bed216110d2f971cb95357e4e99111443;hb=238730873cdf47ff4945ce1635870b10601c9aa3;hp=c801aebb9c2d8c3bf12b62de7dae13372143acda;hpb=8f7e8952ccd2eca24d2bb91a79d2f17f346c490c;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index c801aeb..26100a0 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.119 2002-08-02 10:07:48 adam Exp $ - */ +/* $Id: zrpn.c,v 1.123 2002-09-18 21:01:15 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 @@ -30,7 +46,20 @@ struct rpn_char_map_info { 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; - return zebra_maps_input (p->zm, p->reg_type, from, len); + const char **out = zebra_maps_input (p->zm, p->reg_type, from, len); +#if 0 + if (out && *out) + { + const char *outp = *out; + yaz_log (LOG_LOG, "---"); + while (*outp) + { + yaz_log (LOG_LOG, "%02X", *outp); + outp++; + } + } +#endif + return out; } static void rpn_char_map_prepare (struct zebra_register *reg, int reg_type, @@ -250,7 +279,7 @@ static int term_pre (ZebraMaps zebra_maps, int reg_type, const char **src, return *s0; } -#define REGEX_CHARS "[]()|.*+!" +#define REGEX_CHARS " []()|.*+!" /* term_100: handle term, where trunc=none (no operators at all) */ static int term_100 (ZebraMaps zebra_maps, int reg_type, @@ -966,11 +995,11 @@ static int string_term (ZebraHandle zh, Z_AttributesPlusTerm *zapt, attributeSet, reg_type, space_split, term_dst)) return 0; - logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict+prefix_len); + logf (LOG_LOG, "dict_lookup_grep: %s", term_dict+prefix_len); r = dict_lookup_grep (zh->reg->dict, term_dict, 0, grep_info, &max_pos, 0, grep_handle); if (r) - logf (LOG_WARN, "dict_lookup_grep fail, rel=gt: %d", r); + logf (LOG_WARN, "dict_lookup_grep fail %d", r); break; case 1: /* right truncation */ term_dict[j++] = '('; @@ -1089,8 +1118,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 +1127,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; @@ -2120,12 +2147,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 @@ -2150,7 +2193,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; } @@ -2278,7 +2321,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;