From: Adam Dickmeiss Date: Tue, 3 May 2005 14:04:31 +0000 (+0000) Subject: Make equivalent work with trunc=104, 105. Added test for it. X-Git-Tag: snippet.version.1~44 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=5dd30bc682bf1338ed6beb1a485ccde86b06cc5a Make equivalent work with trunc=104, 105. Added test for it. --- diff --git a/.cvsignore b/.cvsignore index dc947f5..fc12008 100644 --- a/.cvsignore +++ b/.cvsignore @@ -9,3 +9,4 @@ libtool idzebra-config idzebra.spec autom4te.cache +Doxyfile diff --git a/index/zrpn.c b/index/zrpn.c index 9ac93bf..4788742 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -1,4 +1,4 @@ -/* $Id: zrpn.c,v 1.187 2005-05-03 13:57:44 adam Exp $ +/* $Id: zrpn.c,v 1.188 2005-05-03 14:04:31 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -522,7 +522,7 @@ static int term_104(ZebraMaps zebra_maps, int reg_type, const char **src, char *dst, int space_split, char *dst_term) { - const char *s0, *s1; + const char *s0; const char **map; int i = 0; int j = 0; @@ -570,17 +570,33 @@ static int term_104(ZebraMaps zebra_maps, int reg_type, } else { - s1 = s0; - map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0); + const char *s1 = s0; + int q_map_match = 0; + map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0), + &q_map_match); if (space_split && **map == *CHR_SPACE) break; - while (s1 < s0) - { - if (strchr(REGEX_CHARS, *s1)) - dst[i++] = '\\'; - dst_term[j++] = *s1; - dst[i++] = *s1++; - } + + /* add non-space char */ + memcpy(dst_term+j, s1, s0 - s1); + j += (s0 - s1); + if (!q_map_match) + { + while (s1 < s0) + { + if (strchr(REGEX_CHARS, *s1)) + dst[i++] = '\\'; + dst[i++] = *s1++; + } + } + else + { + char tmpbuf[80]; + esc_str(tmpbuf, sizeof(tmpbuf), map[0], strlen(map[0])); + + strcpy(dst + i, map[0]); + i += strlen(map[0]); + } } } dst[i] = '\0'; @@ -594,7 +610,7 @@ static int term_105(ZebraMaps zebra_maps, int reg_type, const char **src, char *dst, int space_split, char *dst_term, int right_truncate) { - const char *s0, *s1; + const char *s0; const char **map; int i = 0; int j = 0; @@ -617,17 +633,33 @@ static int term_105(ZebraMaps zebra_maps, int reg_type, } else { - s1 = s0; - map = zebra_maps_input(zebra_maps, reg_type, &s0, strlen(s0), 0); + const char *s1 = s0; + int q_map_match = 0; + map = zebra_maps_search(zebra_maps, reg_type, &s0, strlen(s0), + &q_map_match); if (space_split && **map == *CHR_SPACE) break; - while (s1 < s0) - { - if (strchr(REGEX_CHARS, *s1)) - dst[i++] = '\\'; - dst_term[j++] = *s1; - dst[i++] = *s1++; - } + + /* add non-space char */ + memcpy(dst_term+j, s1, s0 - s1); + j += (s0 - s1); + if (!q_map_match) + { + while (s1 < s0) + { + if (strchr(REGEX_CHARS, *s1)) + dst[i++] = '\\'; + dst[i++] = *s1++; + } + } + else + { + char tmpbuf[80]; + esc_str(tmpbuf, sizeof(tmpbuf), map[0], strlen(map[0])); + + strcpy(dst + i, map[0]); + i += strlen(map[0]); + } } } if (right_truncate) diff --git a/test/charmap/charmap1.c b/test/charmap/charmap1.c index 137e872..28d8090 100644 --- a/test/charmap/charmap1.c +++ b/test/charmap/charmap1.c @@ -1,4 +1,4 @@ -/* $Id: charmap1.c,v 1.4 2005-03-11 17:56:36 adam Exp $ +/* $Id: charmap1.c,v 1.5 2005-05-03 14:04:31 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -52,9 +52,18 @@ int main(int argc, char **argv) /* search for aa */ do_query(__LINE__, zh, "@term string laas", 1); - /* search for aa (regular) */ + /* search for aa regular-1 */ do_query(__LINE__, zh, "@attr 5=102 @term string lås", 1); + /* search for aa regular-2 */ + do_query(__LINE__, zh, "@attr 5=103 @term string lås", 1); + + /* search for aa trunc=104 */ + do_query(__LINE__, zh, "@attr 5=104 @term string laas", 1); + + /* search for aa trunc=105 */ + do_query(__LINE__, zh, "@attr 5=104 @term string laas", 1); + /* search for aaa */ do_query(__LINE__, zh, "@term string laaas", 0);