From: Adam Dickmeiss Date: Mon, 21 Jan 2013 11:23:54 +0000 (+0100) Subject: Fix code to search for \x01 characters (ICU mode) X-Git-Tag: v2.0.54~5 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=2b86700a060db9a529b7227a1d3a9175564cd931 Fix code to search for \x01 characters (ICU mode) Avoid constructs using while (--i >= 0 ..) - when i is an unsigned integer (always true). --- diff --git a/index/rpnsearch.c b/index/rpnsearch.c index b214aef..f5aa669 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -265,13 +265,10 @@ static int term_102_icu(zebra_map_t zm, &display_buf, &display_len)) { size_t i = res_len; - while (--i >= 0 && res_buf[i] != '\x01') + while (i > 0 && res_buf[--i] != '\x01') + ; + while (i > 0 && res_buf[--i] != '\x01') ; - if (i > 0) - { - while (--i >= 0 && res_buf[i] != '\x01') - ; - } res_len = i; /* reduce res_len */ for (i = 0; i < res_len; i++) { @@ -348,13 +345,10 @@ static int term_100_icu(zebra_map_t zm, may give false hits due to accents not being used. */ i = res_len; - while (--i >= 0 && res_buf[i] != '\x01') + while (i > 0 && res_buf[--i] != '\x01') + ; + 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;