@@ -966,17 +966,43 @@ silly_cmp_tsvector(const tsvector * a, const tsvector * b)
966
966
return 1 ;
967
967
else
968
968
{
969
- unsigned char * aptr = (unsigned char * ) (a -> data ) + DATAHDRSIZE ;
970
- unsigned char * bptr = (unsigned char * ) (b -> data ) + DATAHDRSIZE ;
969
+ WordEntry * aptr = ARRPTR (a );
970
+ WordEntry * bptr = ARRPTR (b );
971
+ int i = 0 ;
972
+ int res ;
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
+ } else if ( aptr -> pos != bptr -> pos ) {
979
+ return ( aptr -> pos > bptr -> pos ) ? -1 : 1 ;
980
+ } else if ( aptr -> len != bptr -> len ) {
981
+ return ( aptr -> len > bptr -> len ) ? -1 : 1 ;
982
+ } else if ( (res = strncmp (STRPTR (a ) + aptr -> pos , STRPTR (b ) + bptr -> pos , b -> len ))!= 0 ) {
983
+ return res ;
984
+ } else if ( aptr -> haspos ) {
985
+ WordEntryPos * ap = POSDATAPTR (a , aptr );
986
+ WordEntryPos * bp = POSDATAPTR (b , bptr );
987
+ int j ;
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
+ } else if ( WEP_GETWEIGHT (* ap ) != WEP_GETWEIGHT (* bp ) ) {
996
+ return ( WEP_GETWEIGHT (* ap ) > WEP_GETWEIGHT (* bp ) ) ? -1 : 1 ;
997
+ }
998
+ ap ++ , bp ++ ;
999
+ }
1000
+ }
971
1001
972
- while (aptr - ((unsigned char * ) (a -> data )) < a -> len )
973
- {
974
- if (* aptr != * bptr )
975
- return (* aptr < * bptr ) ? -1 : 1 ;
976
- aptr ++ ;
977
- bptr ++ ;
1002
+ aptr ++ ; bptr ++ ;
978
1003
}
979
1004
}
1005
+
980
1006
return 0 ;
981
1007
}
982
1008
0 commit comments