StopLow = node->data;
StopHigh = node->data+node->length;
while (StopLow < StopHigh) {
- StopMiddle = StopLow + (StopHigh - StopLow) / 2;
+ StopMiddle = StopLow + ((StopHigh - StopLow) >> 1);
symbol = GETWCHAR(word,wrdlen,*level,type);
if ( StopMiddle->val == symbol ) {
+ (*level)++;
if ( StopMiddle->naff )
return StopMiddle;
node=StopMiddle->node;
- (*level)++;
break;
} else if ( StopMiddle->val < symbol ) {
StopLow = StopMiddle + 1;
static char *
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 )
return NULL;
}
- if ( Affix->type=='s' ) {
+ if ( Affix->type==FF_SUFFIX ) {
strcpy(newword, word);
strcpy(newword + len - Affix->replen, Affix->find);
} else {
strcat(newword, word + Affix->replen);
}
- if (Affix->compile)
- {
- 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);
- pfree(mask);
- if (err)
+ if ( Affix->issimple ) {
+ return newword;
+ } else if ( Affix->isregis ) {
+ if (Affix->compile) {
+ RS_compile(&(Affix->reg.regis), (Affix->type==FF_SUFFIX) ? 1 : 0, Affix->mask);
+ Affix->compile = 0;
+ }
+ if ( RS_execute(&(Affix->reg.regis), newword, -1) )
+ return newword;
+ } else {
+ regmatch_t subs[2]; /* workaround for apache&linux */
+ int err;
+ pg_wchar *data;
+ size_t data_len;
+ int dat_len;
+ if (Affix->compile)
{
- /* regerror(err, &(Affix->reg), regerrstr, ERRSTRSIZE); */
- pg_regfree(&(Affix->reg));
- return (NULL);
+ 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.regex), mask, wmasklen, REG_EXTENDED | REG_ICASE | REG_NOSUB);
+ pfree(mask);
+ if (err)
+ {
+ /* regerror(err, &(Affix->reg.regex), regerrstr, ERRSTRSIZE); */
+ pg_regfree(&(Affix->reg.regex));
+ return (NULL);
+ }
+ Affix->compile = 0;
}
- Affix->compile = 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);
+ /* 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))) {
- pfree(data);
- return newword;
+ if (!(err = pg_regexec(&(Affix->reg.regex), data,dat_len,NULL, 1, subs, 0))) {
+ pfree(data);
+ return newword;
+ }
+ pfree(data);
}
- pfree(data);
return NULL;
}
}
}
pnode = prefix->node;
- plevel++;
}
/* Find all other NORMAL forms of the 'word' (check suffix and then prefix)*/
}
}
pnode = prefix->node;
- plevel++;
}
}
}
snode=suffix->node;
- slevel++;
}
if (cur == forms) {
for (i = 0; i < Conf->naffixes; i++)
{
- if (Affix[i].compile == 0)
- pg_regfree(&(Affix[i].reg));
+ if (Affix[i].compile == 0) {
+ if ( Affix[i].isregis )
+ RS_free(&(Affix[i].reg.regis));
+ else
+ pg_regfree(&(Affix[i].reg.regex));
+ }
}
if (Conf->Spell) {
for (i = 0; i < Conf->nspell; i++)