c7c56bc7435e7f9564fb80a4382c5714a875f3cc braney Mon Jun 9 09:56:21 2014 -0700 fix seeking problem in trix diff --git src/lib/trix.c src/lib/trix.c index 2289c58..89b7503 100644 --- src/lib/trix.c +++ src/lib/trix.c @@ -400,30 +400,32 @@ } struct trixWordResult *trixSearchWordResults(struct trix *trix, char *searchWord, boolean expand) /* Get results for single word from index. Returns NULL if no matches. */ { char *line, *word; struct trixWordResult *twr = NULL; struct trixHitPos *hitList = hashFindVal(trix->wordHitHash, searchWord); if (hitList == NULL) { struct trixHitPos *oneHitList; off_t ixPos = trixFindIndexStartLine(trix, searchWord); + // make sure we're seeking + ourSeek(trix, 0); ourSeek(trix, ixPos); while (ourReadLine(trix, trix->lf, &line)) { word = nextWord(&line); if (startsWith(searchWord, word)) { int leftoverLetters = reasonablePrefix(searchWord, word, expand); /* uglyf("reasonablePrefix(%s,%s)=%d
\n", searchWord, word, leftoverLetters); */ if (leftoverLetters >= 0) { oneHitList = trixParseHitList(searchWord, line, leftoverLetters); hitList = mergeHits(hitList, oneHitList); } }