CheckAffix(const char *word, size_t len, AFFIX * Affix, char flagflags, char *newword) {
regmatch_t subs[2]; /* workaround for apache&linux */
int err;
+ pg_wchar *data;
+ size_t data_len;
+ int dat_len;
if ( flagflags & FF_COMPOUNDONLYAFX ) {
if ( (Affix->flagflags & FF_COMPOUNDONLYAFX) == 0 )
if (Affix->compile)
{
- err = regcomp(&(Affix->reg), Affix->mask, REG_EXTENDED | REG_ICASE | REG_NOSUB);
+ int wmasklen,masklen = strlen(Affix->mask);
+ pg_wchar *mask;
+ mask = (pg_wchar *) palloc((masklen + 1) * sizeof(pg_wchar));
+ wmasklen = pg_mb2wchar_with_len( Affix->mask, mask, masklen);
+
+ err = pg_regcomp(&(Affix->reg), mask, wmasklen, REG_EXTENDED | REG_ICASE | REG_NOSUB);
if (err)
{
/* regerror(err, &(Affix->reg), regerrstr, ERRSTRSIZE); */
- regfree(&(Affix->reg));
+ pg_regfree(&(Affix->reg));
return (NULL);
}
Affix->compile = 0;
}
- if (!(err = regexec(&(Affix->reg), newword, 1, subs, 0)))
+
+ /* Convert data string to wide characters */
+ dat_len = strlen(newword);
+ data = (pg_wchar *) palloc((dat_len + 1) * sizeof(pg_wchar));
+ data_len = pg_mb2wchar_with_len(newword, data, dat_len);
+
+ if (!(err = pg_regexec(&(Affix->reg), data,dat_len,NULL, 1, subs, 0)))
return newword;
+
return NULL;
}
for (i = 0; i < Conf->naffixes; i++)
{
if (Affix[i].compile == 0)
- regfree(&(Affix[i].reg));
+ pg_regfree(&(Affix[i].reg));
}
if (Conf->Spell) {
for (i = 0; i < Conf->nspell; i++)
static int
compareWORD(const void *a, const void *b)
{
- if (((WORD *) a)->len == ((WORD *) b)->len)
+ if (((TSWORD *) a)->len == ((TSWORD *) b)->len)
{
int res = strncmp(
- ((WORD *) a)->word,
- ((WORD *) b)->word,
- ((WORD *) b)->len);
+ ((TSWORD *) a)->word,
+ ((TSWORD *) b)->word,
+ ((TSWORD *) b)->len);
if (res == 0)
- return (((WORD *) a)->pos.pos > ((WORD *) b)->pos.pos) ? 1 : -1;
+ return (((TSWORD *) a)->pos.pos > ((TSWORD *) b)->pos.pos) ? 1 : -1;
return res;
}
- return (((WORD *) a)->len > ((WORD *) b)->len) ? 1 : -1;
+ return (((TSWORD *) a)->len > ((TSWORD *) b)->len) ? 1 : -1;
}
static int
-uniqueWORD(WORD * a, int4 l)
+uniqueWORD(TSWORD * a, int4 l)
{
- WORD *ptr,
+ TSWORD *ptr,
*res;
int tmppos;
res = a;
ptr = a + 1;
- qsort((void *) a, l, sizeof(WORD), compareWORD);
+ qsort((void *) a, l, sizeof(TSWORD), compareWORD);
tmppos = LIMITPOS(a->pos.pos);
a->alen = 2;
a->pos.apos = (uint16 *) palloc(sizeof(uint16) * a->alen);
prs.lenwords = 32;
prs.curwords = 0;
prs.pos = 0;
- prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
+ prs.words = (TSWORD *) palloc(sizeof(TSWORD) * prs.lenwords);
parsetext_v2(cfg, &prs, VARDATA(in), VARSIZE(in) - VARHDRSZ);
PG_FREE_IF_COPY(in, 1);
prs.lenwords = 32;
prs.curwords = 0;
prs.pos = 0;
- prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords);
+ prs.words = (TSWORD *) palloc(sizeof(TSWORD) * prs.lenwords);
/* find all words in indexable column */
for (i = 1; i < trigger->tgnargs; i++)