@@ -966,17 +966,43 @@ silly_cmp_tsvector(const tsvector * a, const tsvector * b)
966966return 1 ;
967967else
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+ 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+ }
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+
9801006return 0 ;
9811007}
9821008