aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-07-04 06:29:27 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-07-04 06:29:27 +0000
commit4e71240dbb64b08d16e41ebf60898602124b303d (patch)
tree78ad468b1a6c3aa32f1b3381c2764c223ceaa415
parent6d87107b0e87aa5b39772c8bbdab4c79c0ed9c97 (diff)
downloadpostgresql-4e71240dbb64b08d16e41ebf60898602124b303d.tar.gz
postgresql-4e71240dbb64b08d16e41ebf60898602124b303d.zip
Now that I look at it, is_stopword() is broken and always has been.
Doesn't anyone remember how to program a binary search??
-rw-r--r--contrib/fulltextindex/fti.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/contrib/fulltextindex/fti.c b/contrib/fulltextindex/fti.c
index be4522321d7..a98fcd47dc7 100644
--- a/contrib/fulltextindex/fti.c
+++ b/contrib/fulltextindex/fti.c
@@ -351,10 +351,9 @@ is_stopword(char *text)
StopLow = &StopWords[0]; /* initialize stuff for binary search */
StopHigh = endof(StopWords);
- if (lengthof(StopWords) == 0)
- return false;
+ /* Loop invariant: *StopLow <= text < *StopHigh */
- while (StopLow <= StopHigh)
+ while (StopLow < StopHigh)
{
StopMiddle = StopLow + (StopHigh - StopLow) / 2;
difference = strcmp(*StopMiddle, text);
@@ -363,7 +362,7 @@ is_stopword(char *text)
else if (difference < 0)
StopLow = StopMiddle + 1;
else
- StopHigh = StopMiddle - 1;
+ StopHigh = StopMiddle;
}
return (false);