~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/backend/tsearch/spell.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *
8
8
 *
9
9
 * IDENTIFICATION
10
 
 *        $PostgreSQL: pgsql/src/backend/tsearch/spell.c,v 1.15 2009/01/29 16:22:10 teodor Exp $
 
10
 *        $PostgreSQL: pgsql/src/backend/tsearch/spell.c,v 1.16 2009/06/11 14:49:03 momjian Exp $
11
11
 *
12
12
 *-------------------------------------------------------------------------
13
13
 */
521
521
                                (errcode(ERRCODE_CONFIG_FILE_ERROR),
522
522
                                 errmsg("multibyte flag character is not allowed")));
523
523
 
524
 
        Conf->flagval[*(unsigned char*) s] = (unsigned char) val;
 
524
        Conf->flagval[*(unsigned char *) s] = (unsigned char) val;
525
525
        Conf->usecompound = true;
526
526
}
527
527
 
654
654
                                ptr = repl + (ptr - prepl) + 1;
655
655
                                while (*ptr)
656
656
                                {
657
 
                                        aflg |= Conf->flagval[*(unsigned char*) ptr];
 
657
                                        aflg |= Conf->flagval[*(unsigned char *) ptr];
658
658
                                        ptr++;
659
659
                                }
660
660
                        }
735
735
 
736
736
                                if (*s && pg_mblen(s) == 1)
737
737
                                {
738
 
                                        Conf->flagval[*(unsigned char*) s] = FF_COMPOUNDFLAG;
 
738
                                        Conf->flagval[*(unsigned char *) s] = FF_COMPOUNDFLAG;
739
739
                                        Conf->usecompound = true;
740
740
                                }
741
741
                                oldformat = true;
791
791
                                                (errcode(ERRCODE_CONFIG_FILE_ERROR),
792
792
                                                 errmsg("multibyte flag character is not allowed")));
793
793
 
794
 
                        flag = *(unsigned char*) s;
 
794
                        flag = *(unsigned char *) s;
795
795
                        goto nextline;
796
796
                }
797
797
                if (STRNCMP(recoded, "COMPOUNDFLAG") == 0 || STRNCMP(recoded, "COMPOUNDMIN") == 0 ||
851
851
 
852
852
        while (str && *str)
853
853
        {
854
 
                flag |= Conf->flagval[*(unsigned char*) str];
 
854
                flag |= Conf->flagval[*(unsigned char *) str];
855
855
                str++;
856
856
        }
857
857
 
1306
1306
        if (forms == cur || strcmp(word, *(cur - 1)) != 0)
1307
1307
        {
1308
1308
                *cur = pstrdup(word);
1309
 
                *(cur+1) = NULL;
 
1309
                *(cur + 1) = NULL;
1310
1310
                return 1;
1311
1311
        }
1312
1312
 
1497
1497
static void
1498
1498
AddStem(SplitVar *v, char *word)
1499
1499
{
1500
 
        if ( v->nstem >= v->lenstem )
 
1500
        if (v->nstem >= v->lenstem)
1501
1501
        {
1502
1502
                v->lenstem *= 2;
1503
1503
                v->stem = (char **) repalloc(v->stem, sizeof(char *) * v->lenstem);
1546
1546
                        if (level + lenaff - 1 <= minpos)
1547
1547
                                continue;
1548
1548
 
1549
 
                        if ( lenaff >= MAXNORMLEN )
1550
 
                                continue; /* skip too big value */
 
1549
                        if (lenaff >= MAXNORMLEN)
 
1550
                                continue;               /* skip too big value */
1551
1551
                        if (lenaff > 0)
1552
1552
                                memcpy(buf, word + startpos, lenaff);
1553
1553
                        buf[lenaff] = '\0';
1570
1570
 
1571
1571
                                while (*sptr)
1572
1572
                                {
1573
 
                                        AddStem( new, *sptr ); 
 
1573
                                        AddStem(new, *sptr);
1574
1574
                                        sptr++;
1575
1575
                                }
1576
1576
                                pfree(subres);
1621
1621
                                        if (wordlen == level + 1)
1622
1622
                                        {
1623
1623
                                                /* well, it was last word */
1624
 
                                                AddStem( var, pnstrdup(word + startpos, wordlen - startpos) );
 
1624
                                                AddStem(var, pnstrdup(word + startpos, wordlen - startpos));
1625
1625
                                                pfree(notprobed);
1626
1626
                                                return var;
1627
1627
                                        }
1635
1635
                                                ptr->next = SplitToVariants(Conf, node, var, word, wordlen, startpos, level);
1636
1636
                                                /* we can find next word */
1637
1637
                                                level++;
1638
 
                                                AddStem( var, pnstrdup(word + startpos, level - startpos) );
 
1638
                                                AddStem(var, pnstrdup(word + startpos, level - startpos));
1639
1639
                                                node = Conf->Dictionary;
1640
1640
                                                startpos = level;
1641
1641
                                                continue;
1649
1649
                level++;
1650
1650
        }
1651
1651
 
1652
 
        AddStem( var, pnstrdup(word + startpos, wordlen - startpos) );
 
1652
        AddStem(var, pnstrdup(word + startpos, wordlen - startpos));
1653
1653
        pfree(notprobed);
1654
1654
        return var;
1655
1655
}
1656
1656
 
1657
1657
static void
1658
 
addNorm( TSLexeme **lres, TSLexeme **lcur, char *word, int flags, uint16 NVariant)
 
1658
addNorm(TSLexeme **lres, TSLexeme **lcur, char *word, int flags, uint16 NVariant)
1659
1659
{
1660
 
        if ( *lres == NULL ) 
 
1660
        if (*lres == NULL)
1661
1661
                *lcur = *lres = (TSLexeme *) palloc(MAX_NORM * sizeof(TSLexeme));
1662
1662
 
1663
 
        if ( *lcur - *lres < MAX_NORM-1 ) { 
 
1663
        if (*lcur - *lres < MAX_NORM - 1)
 
1664
        {
1664
1665
                (*lcur)->lexeme = word;
1665
1666
                (*lcur)->flags = flags;
1666
1667
                (*lcur)->nvariant = NVariant;
1683
1684
        {
1684
1685
                char      **ptr = res;
1685
1686
 
1686
 
                while (*ptr && (lcur-lres) < MAX_NORM)
 
1687
                while (*ptr && (lcur - lres) < MAX_NORM)
1687
1688
                {
1688
 
                        addNorm( &lres, &lcur, *ptr, 0, NVariant++);
 
1689
                        addNorm(&lres, &lcur, *ptr, 0, NVariant++);
1689
1690
                        ptr++;
1690
1691
                }
1691
1692
                pfree(res);
1712
1713
                                        {
1713
1714
                                                for (i = 0; i < var->nstem - 1; i++)
1714
1715
                                                {
1715
 
                                                        addNorm( &lres, &lcur, (subptr == subres) ? var->stem[i] : pstrdup(var->stem[i]), 0, NVariant); 
 
1716
                                                        addNorm(&lres, &lcur, (subptr == subres) ? var->stem[i] : pstrdup(var->stem[i]), 0, NVariant);
1716
1717
                                                }
1717
1718
 
1718
 
                                                addNorm( &lres, &lcur, *subptr, 0, NVariant); 
 
1719
                                                addNorm(&lres, &lcur, *subptr, 0, NVariant);
1719
1720
                                                subptr++;
1720
1721
                                                NVariant++;
1721
1722
                                        }