X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Frpnsearch.c;h=872cf8bbbf59f1c9ecb65bc8a12ec6be4b6a65ab;hp=543f61c4a45679eae293ab977398a2e374a654b2;hb=3bb2fd863b1664f1ff71dadb540313f301ca234f;hpb=c00021ca63c39b965a6c02c51f56d359b9cba4b3 diff --git a/index/rpnsearch.c b/index/rpnsearch.c index 543f61c..872cf8b 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1994-2010 Index Data + Copyright (C) 1994-2011 Index Data 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 @@ -17,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #ifdef WIN32 @@ -154,7 +157,7 @@ static int grep_handle(char *name, const char *info, void *p) } static int term_pre(zebra_map_t zm, const char **src, - const char *ct1, const char *ct2, int first) + const char *ct1, int first) { const char *s1, *s0 = *src; const char **map; @@ -164,8 +167,6 @@ static int term_pre(zebra_map_t zm, const char **src, { if (ct1 && strchr(ct1, *s0)) break; - if (ct2 && strchr(ct2, *s0)) - break; s1 = s0; map = zebra_maps_input(zm, &s1, strlen(s1), first); if (**map != *CHR_SPACE) @@ -297,7 +298,7 @@ static int term_100(zebra_map_t zm, const char *space_start = 0; const char *space_end = 0; - if (!term_pre(zm, src, NULL, NULL, !space_split)) + if (!term_pre(zm, src, 0, !space_split)) return 0; s0 = *src; while (*s0) @@ -350,7 +351,7 @@ static int term_101(zebra_map_t zm, const char **map; int i = 0; - if (!term_pre(zm, src, "#", "#", !space_split)) + if (!term_pre(zm, src, "#", !space_split)) return 0; s0 = *src; while (*s0) @@ -387,7 +388,7 @@ static int term_103(zebra_map_t zm, const char **src, const char *s0; const char **map; - if (!term_pre(zm, src, "^\\()[].*+?|", "(", !space_split)) + if (!term_pre(zm, src, "^\\()[].*+?|", !space_split)) return 0; s0 = *src; if (errors && *s0 == '+' && s0[1] && s0[2] == '+' && s0[3] && @@ -432,7 +433,7 @@ static int term_102(zebra_map_t zm, const char **src, } -/* term_104: handle term, process # and ! */ +/* term_104: handle term, process ?n * # */ static int term_104(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term) { @@ -440,7 +441,7 @@ static int term_104(zebra_map_t zm, const char **src, const char **map; int i = 0; - if (!term_pre(zm, src, "?*#", "?*#", !space_split)) + if (!term_pre(zm, src, "?*#", !space_split)) return 0; s0 = *src; while (*s0) @@ -501,7 +502,7 @@ static int term_104(zebra_map_t zm, const char **src, return i; } -/* term_105/106: handle term, where trunc = Process * and ! and right trunc */ +/* term_105/106: handle term, process * ! and possibly right_truncate */ static int term_105(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term, int right_truncate) @@ -510,7 +511,7 @@ static int term_105(zebra_map_t zm, const char **src, const char **map; int i = 0; - if (!term_pre(zm, src, "*!", "*!", !space_split)) + if (!term_pre(zm, src, "\\*!", !space_split)) return 0; s0 = *src; while (*s0) @@ -529,6 +530,13 @@ static int term_105(zebra_map_t zm, const char **src, wrbuf_putc(display_term, *s0); s0++; } + else if (*s0 == '\\') + { + i++; + wrbuf_puts(term_dict, "\\\\"); + wrbuf_putc(display_term, *s0); + s0++; + } else { const char *s1 = s0; @@ -1139,7 +1147,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } wrbuf_putc(term_dict, ')'); break; - case 104: /* process # and ! in term */ + case 104: /* process ?n * # term */ wrbuf_putc(term_dict, '('); if (!term_104(zm, &termp, term_dict, space_split, display_term)) { @@ -1148,7 +1156,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } wrbuf_putc(term_dict, ')'); break; - case 105: /* process * and ! in term */ + case 105: /* process * ! in term and right truncate */ wrbuf_putc(term_dict, '('); if (!term_105(zm, &termp, term_dict, space_split, display_term, 1)) { @@ -1157,7 +1165,7 @@ static ZEBRA_RES string_term(ZebraHandle zh, Z_AttributesPlusTerm *zapt, } wrbuf_putc(term_dict, ')'); break; - case 106: /* process * and ! in term */ + case 106: /* process * ! in term */ wrbuf_putc(term_dict, '('); if (!term_105(zm, &termp, term_dict, space_split, display_term, 0)) { @@ -1803,6 +1811,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, Z_AttributesPlusTerm *zapt, const char *termz, const Odr_oid *attributeSet, + zint hits_limit, NMEM stream, const char *index_type, int complete_flag, @@ -1818,7 +1827,7 @@ static ZEBRA_RES rpn_search_APT_numeric(ZebraHandle zh, ZEBRA_RES res; struct grep_info grep_info; int alloc_sets = 0; - zint hits_limit_value; + zint hits_limit_value = hits_limit; const char *term_ref_id_str = 0; zebra_term_limits_APT(zh, zapt, &hits_limit_value, &term_ref_id_str, @@ -2375,7 +2384,8 @@ static ZEBRA_RES rpn_search_database(ZebraHandle zh, } else if (!strcmp(search_type, "numeric")) { - res = rpn_search_APT_numeric(zh, zapt, termz, attributeSet, stream, + res = rpn_search_APT_numeric(zh, zapt, termz, attributeSet, hits_limit, + stream, index_type, complete_flag, rank_type, xpath_use, rset_nmem,