Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11864ab

Browse files
committed
Win32 related patch by Darko Prenosil. Small correct by teodor
1 parent9b17855 commit11864ab

File tree

6 files changed

+38
-20
lines changed

6 files changed

+38
-20
lines changed

‎contrib/tsearch2/ispell/spell.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,9 @@ static char *
619619
CheckAffix(constchar*word,size_tlen,AFFIX*Affix,charflagflags,char*newword) {
620620
regmatch_tsubs[2];/* workaround for apache&linux */
621621
interr;
622+
pg_wchar*data;
623+
size_tdata_len;
624+
intdat_len;
622625

623626
if (flagflags&FF_COMPOUNDONLYAFX ) {
624627
if ( (Affix->flagflags&FF_COMPOUNDONLYAFX)==0 )
@@ -638,17 +641,29 @@ CheckAffix(const char *word, size_t len, AFFIX * Affix, char flagflags, char *ne
638641

639642
if (Affix->compile)
640643
{
641-
err=regcomp(&(Affix->reg),Affix->mask,REG_EXTENDED |REG_ICASE |REG_NOSUB);
644+
intwmasklen,masklen=strlen(Affix->mask);
645+
pg_wchar*mask;
646+
mask= (pg_wchar*)palloc((masklen+1)*sizeof(pg_wchar));
647+
wmasklen=pg_mb2wchar_with_len(Affix->mask,mask,masklen);
648+
649+
err=pg_regcomp(&(Affix->reg),mask,wmasklen,REG_EXTENDED |REG_ICASE |REG_NOSUB);
642650
if (err)
643651
{
644652
/* regerror(err, &(Affix->reg), regerrstr, ERRSTRSIZE); */
645-
regfree(&(Affix->reg));
653+
pg_regfree(&(Affix->reg));
646654
return (NULL);
647655
}
648656
Affix->compile=0;
649657
}
650-
if (!(err=regexec(&(Affix->reg),newword,1,subs,0)))
658+
659+
/* Convert data string to wide characters */
660+
dat_len=strlen(newword);
661+
data= (pg_wchar*)palloc((dat_len+1)*sizeof(pg_wchar));
662+
data_len=pg_mb2wchar_with_len(newword,data,dat_len);
663+
664+
if (!(err=pg_regexec(&(Affix->reg),data,dat_len,NULL,1,subs,0)))
651665
returnnewword;
666+
652667
returnNULL;
653668
}
654669

@@ -995,7 +1010,7 @@ NIFree(IspellDict * Conf)
9951010
for (i=0;i<Conf->naffixes;i++)
9961011
{
9971012
if (Affix[i].compile==0)
998-
regfree(&(Affix[i].reg));
1013+
pg_regfree(&(Affix[i].reg));
9991014
}
10001015
if (Conf->Spell) {
10011016
for (i=0;i<Conf->nspell;i++)

‎contrib/tsearch2/ispell/spell.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
#define__SPELL_H__
33

44
#include<sys/types.h>
5-
#include<regex.h>
5+
#include"regex/regex.h"
66
#include"c.h"
77

8+
89
structSPNode;
910

1011

‎contrib/tsearch2/query.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we
269269
prs.lenwords=32;
270270
prs.curwords=0;
271271
prs.pos=0;
272-
prs.words= (WORD*)palloc(sizeof(WORD)*prs.lenwords);
272+
prs.words= (TSWORD*)palloc(sizeof(TSWORD)*prs.lenwords);
273273

274274
parsetext_v2(findcfg(state->cfg_id),&prs,strval,lenval);
275275

‎contrib/tsearch2/ts_cfg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen)
338338
if (prs->curwords==prs->lenwords)
339339
{
340340
prs->lenwords *=2;
341-
prs->words= (WORD*)repalloc((void*)prs->words,prs->lenwords*sizeof(WORD));
341+
prs->words= (TSWORD*)repalloc((void*)prs->words,prs->lenwords*sizeof(TSWORD));
342342
}
343343

344344
prs->words[prs->curwords].len=strlen(*ptr);

‎contrib/tsearch2/ts_cfg.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#ifndef__TS_CFG_H__
22
#define__TS_CFG_H__
3+
34
#include"postgres.h"
45
#include"query.h"
56

7+
68
typedefstruct
79
{
810
intlen;
@@ -32,11 +34,11 @@ typedef struct
3234
}pos;
3335
char*word;
3436
uint32alen;
35-
}WORD;
37+
}TSWORD;
3638

3739
typedefstruct
3840
{
39-
WORD*words;
41+
TSWORD*words;
4042
int4lenwords;
4143
int4curwords;
4244
int4pos;

‎contrib/tsearch2/tsvector.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,24 +573,24 @@ tsvector_out(PG_FUNCTION_ARGS)
573573
staticint
574574
compareWORD(constvoid*a,constvoid*b)
575575
{
576-
if (((WORD*)a)->len== ((WORD*)b)->len)
576+
if (((TSWORD*)a)->len== ((TSWORD*)b)->len)
577577
{
578578
intres=strncmp(
579-
((WORD*)a)->word,
580-
((WORD*)b)->word,
581-
((WORD*)b)->len);
579+
((TSWORD*)a)->word,
580+
((TSWORD*)b)->word,
581+
((TSWORD*)b)->len);
582582

583583
if (res==0)
584-
return (((WORD*)a)->pos.pos> ((WORD*)b)->pos.pos) ?1 :-1;
584+
return (((TSWORD*)a)->pos.pos> ((TSWORD*)b)->pos.pos) ?1 :-1;
585585
returnres;
586586
}
587-
return (((WORD*)a)->len> ((WORD*)b)->len) ?1 :-1;
587+
return (((TSWORD*)a)->len> ((TSWORD*)b)->len) ?1 :-1;
588588
}
589589

590590
staticint
591-
uniqueWORD(WORD*a,int4l)
591+
uniqueWORD(TSWORD*a,int4l)
592592
{
593-
WORD*ptr,
593+
TSWORD*ptr,
594594
*res;
595595
inttmppos;
596596

@@ -607,7 +607,7 @@ uniqueWORD(WORD * a, int4 l)
607607
res=a;
608608
ptr=a+1;
609609

610-
qsort((void*)a,l,sizeof(WORD),compareWORD);
610+
qsort((void*)a,l,sizeof(TSWORD),compareWORD);
611611
tmppos=LIMITPOS(a->pos.pos);
612612
a->alen=2;
613613
a->pos.apos= (uint16*)palloc(sizeof(uint16)*a->alen);
@@ -728,7 +728,7 @@ to_tsvector(PG_FUNCTION_ARGS)
728728
prs.lenwords=32;
729729
prs.curwords=0;
730730
prs.pos=0;
731-
prs.words= (WORD*)palloc(sizeof(WORD)*prs.lenwords);
731+
prs.words= (TSWORD*)palloc(sizeof(TSWORD)*prs.lenwords);
732732

733733
parsetext_v2(cfg,&prs,VARDATA(in),VARSIZE(in)-VARHDRSZ);
734734
PG_FREE_IF_COPY(in,1);
@@ -853,7 +853,7 @@ tsearch2(PG_FUNCTION_ARGS)
853853
prs.lenwords=32;
854854
prs.curwords=0;
855855
prs.pos=0;
856-
prs.words= (WORD*)palloc(sizeof(WORD)*prs.lenwords);
856+
prs.words= (TSWORD*)palloc(sizeof(TSWORD)*prs.lenwords);
857857

858858
/* find all words in indexable column */
859859
for (i=1;i<trigger->tgnargs;i++)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp