>
> Actually, this code seems probably flat-out wrong: won't every
> successful call of hlCover() on a given document return exactly the same
> q value (end position), namely the last token occurrence in the
> document? How is that helpful?
>
> regards, tom lane
>
There is a line that saves the computation state from the previous call and
search only starts from there:
int pos = *p;