Обсуждение: Bug: Contrib\fulltextindex\fti.c?

Поиск
Список
Период
Сортировка

Bug: Contrib\fulltextindex\fti.c?

От
Paul McGarry
Дата:
Hello,

Is it me, or does the declaration of difference as an unsigned int
prevent the if statements just below from working correctly?
Should it not be a normal int?

From postgresql-7.0.2/contrib/fulltextindex/fti.c
======
bool
is_stopword(char *text)
{
    char      **StopLow;        /* for list of stop-words */
    char      **StopHigh;
    char      **StopMiddle;
    unsigned int difference;

    StopLow = &StopWords[0];    /* initialize stuff for binary search */
    StopHigh = endof(StopWords);

    if (lengthof(StopWords) == 0)
        return false;

    while (StopLow <= StopHigh)
    {
        StopMiddle = StopLow + (StopHigh - StopLow) / 2;
        difference = strcmp(*StopMiddle, text);
        if (difference == 0)
            return (true);
        else if (difference < 0)
            StopLow = StopMiddle + 1;
        else
            StopHigh = StopMiddle - 1;
    }

    return (false);
}
======


--
Paul McGarry            mailto:paulm@opentec.com.au
Systems Integrator      http://www.opentec.com.au
Opentec Pty Ltd         http://www.iebusiness.com.au
6 Lyon Park Road        Phone: (02) 9878 1744
North Ryde NSW 2113     Fax:   (02) 9878 1755

Re: Bug: Contrib\fulltextindex\fti.c?

От
Tom Lane
Дата:
Paul McGarry <paulm@opentec.com.au> writes:
> Is it me, or does the declaration of difference as an unsigned int
> prevent the if statements just below from working correctly?

*Clearly* broken :-(

I suppose this could only have escaped notice because hardly anyone
uses fti with a stopword list ...

            regards, tom lane