X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Frpnsearch.c;h=9aee46e9453e0b6d60c6933b6ebeaacc3d3ddfe1;hp=7733a5d9e651b306ded58c3ca15adf9539b2503a;hb=e2e073b5c947e996304ed7d577497af5e9a879ee;hpb=f5eb6612606c3365834ea5aad430b364902d42a3 diff --git a/index/rpnsearch.c b/index/rpnsearch.c index 7733a5d..9aee46e 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1994-2011 Index Data + Copyright (C) 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 @@ -187,7 +187,7 @@ static void esc_str(char *out_buf, size_t out_size, assert(in_buf); assert(out_size > 20); *out_buf = '\0'; - for (k = 0; k 0 && buf[--i] != '\x01') /* skip length */ + ; + while (i > 0 && buf[--i] != '\x01') /* skip accents */ + ; + return i; /* only basechars left */ +} + static int term_102_icu(zebra_map_t zm, const char **src, WRBUF term_dict, int space_split, WRBUF display_term) @@ -264,15 +278,8 @@ static int term_102_icu(zebra_map_t zm, if (zebra_map_tokenize_next(zm, &res_buf, &res_len, &display_buf, &display_len)) { - size_t i = res_len; - while (--i >= 0 && res_buf[i] != '\x01') - ; - if (i > 0) - { - while (--i >= 0 && res_buf[i] != '\x01') - ; - } - res_len = i; /* reduce res_len */ + size_t i; + res_len = icu_basechars(res_buf, res_len); for (i = 0; i < res_len; i++) { if (strchr(REGEX_CHARS "\\", res_buf[i])) @@ -342,24 +349,7 @@ static int term_100_icu(zebra_map_t zm, wrbuf_write(display_term, display_buf, display_len); if (mode) { - /* ICU sort keys seem to be of the form - basechars \x01 accents \x01 length - For now we'll just right truncate from basechars . This - may give false hits due to accents not being used. - */ - i = res_len; - while (--i >= 0 && res_buf[i] != '\x01') - ; - if (i > 0) - { - while (--i >= 0 && res_buf[i] != '\x01') - ; - } - if (i == 0) - { /* did not find base chars at all. Throw error */ - return -1; - } - res_len = i; /* reduce res_len */ + res_len = icu_basechars(res_buf, res_len); } if (mode & 2) wrbuf_puts(term_dict, ".*"); @@ -734,7 +724,7 @@ static void gen_regular_rel(WRBUF term_dict, int val, int islt) else dst[dst_p++] = d; } - for (i = 0; ispecs = (Z_SortKeySpec **) nmem_malloc(stream, sort_sequence->num_specs * sizeof(*sort_sequence->specs)); - for (i = 0; inum_specs; i++) + for (i = 0; i < sort_sequence->num_specs; i++) sort_sequence->specs[i] = 0; } if (zapt->term->which != Z_Term_general) @@ -2165,7 +2155,7 @@ static RSET xpath_trunc(ZebraHandle zh, NMEM stream, const char *flags = "void"; wrbuf_putc(term_dict, '('); - for (i = 0; i