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

Commit8f91e2b

Browse files
committed
Fix compare bug for tsvector: problem was in aligment. Per Stefan Kaltenbrunner <stefan@kaltenbrunner.cc> and Phil Frost <indigo@bitglue.com>
1 parent726ede7 commit8f91e2b

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

‎contrib/tsearch2/tsvector.c

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -966,17 +966,43 @@ silly_cmp_tsvector(const tsvector * a, const tsvector * b)
966966
return1;
967967
else
968968
{
969-
unsignedchar*aptr= (unsignedchar*) (a->data)+DATAHDRSIZE;
970-
unsignedchar*bptr= (unsignedchar*) (b->data)+DATAHDRSIZE;
969+
WordEntry*aptr=ARRPTR(a);
970+
WordEntry*bptr=ARRPTR(b);
971+
inti=0;
972+
intres;
973+
974+
975+
for(i=0;i<a->size;i++) {
976+
if (aptr->haspos!=bptr->haspos ) {
977+
return (aptr->haspos>bptr->haspos ) ?-1 :1;
978+
}elseif (aptr->pos!=bptr->pos ) {
979+
return (aptr->pos>bptr->pos ) ?-1 :1;
980+
}elseif (aptr->len!=bptr->len ) {
981+
return (aptr->len>bptr->len ) ?-1 :1;
982+
}elseif ( (res=strncmp(STRPTR(a)+aptr->pos,STRPTR(b)+bptr->pos,b->len))!=0 ) {
983+
returnres;
984+
}elseif (aptr->haspos ) {
985+
WordEntryPos*ap=POSDATAPTR(a,aptr);
986+
WordEntryPos*bp=POSDATAPTR(b,bptr);
987+
intj;
988+
989+
if (POSDATALEN(a,aptr)!=POSDATALEN(b,bptr) )
990+
return (POSDATALEN(a,aptr)>POSDATALEN(b,bptr) ) ?-1 :1;
991+
992+
for(j=0;j<POSDATALEN(a,aptr);j++) {
993+
if (WEP_GETPOS(*ap)!=WEP_GETPOS(*bp) ) {
994+
return (WEP_GETPOS(*ap)>WEP_GETPOS(*bp) ) ?-1 :1;
995+
}elseif (WEP_GETWEIGHT(*ap)!=WEP_GETWEIGHT(*bp) ) {
996+
return (WEP_GETWEIGHT(*ap)>WEP_GETWEIGHT(*bp) ) ?-1 :1;
997+
}
998+
ap++,bp++;
999+
}
1000+
}
9711001

972-
while (aptr- ((unsignedchar*) (a->data))<a->len)
973-
{
974-
if (*aptr!=*bptr)
975-
return (*aptr<*bptr) ?-1 :1;
976-
aptr++;
977-
bptr++;
1002+
aptr++;bptr++;
9781003
}
9791004
}
1005+
9801006
return0;
9811007
}
9821008

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp