]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix various comparing functions
authorTeodor Sigaev <teodor@sigaev.ru>
Thu, 31 Mar 2005 15:10:48 +0000 (15:10 +0000)
committerTeodor Sigaev <teodor@sigaev.ru>
Thu, 31 Mar 2005 15:10:48 +0000 (15:10 +0000)
contrib/tsearch2/dict.c
contrib/tsearch2/rank.c
contrib/tsearch2/ts_cfg.c
contrib/tsearch2/tsvector.c
contrib/tsearch2/wparser.c

index 357097681e55d0a839c95aeb1e50eab2fb22b6f8..7bbc996d51f273a229340a973f08445bd6443e29 100644 (file)
@@ -92,7 +92,9 @@ reset_dict(void)
 static int
 comparedict(const void *a, const void *b)
 {
-       return ((DictInfo *) a)->dict_id - ((DictInfo *) b)->dict_id;
+       if ( ((DictInfo *) a)->dict_id == ((DictInfo *) b)->dict_id )
+               return 0;
+       return ( ((DictInfo *) a)->dict_id < ((DictInfo *) b)->dict_id ) ? -1 : 1;
 }
 
 DictInfo *
index 3c4a3cef0895d0d5267fea2f574573f3c57570eb..8dc10e2a4261fa6f7692aceb8e3860df4b89d92f 100644 (file)
@@ -386,7 +386,7 @@ static int
 compareDocR(const void *a, const void *b)
 {
        if (((DocRepresentation *) a)->pos == ((DocRepresentation *) b)->pos)
-               return 1;
+               return 0;
        return (((DocRepresentation *) a)->pos > ((DocRepresentation *) b)->pos) ? 1 : -1;
 }
 
@@ -654,7 +654,7 @@ static int
 compareDocWord(const void *a, const void *b)
 {
        if (((DocWord *) a)->pos == ((DocWord *) b)->pos)
-               return 1;
+               return 0;
        return (((DocWord *) a)->pos > ((DocWord *) b)->pos) ? 1 : -1;
 }
 
index afebb11319963885595e3b7a364a9720169ee787..3c64cb0a932e466e72e9ec51d35f733d37b7f683 100644 (file)
@@ -186,7 +186,9 @@ reset_cfg(void)
 static int
 comparecfg(const void *a, const void *b)
 {
-       return ((TSCfgInfo *) a)->id - ((TSCfgInfo *) b)->id;
+       if ( ((TSCfgInfo *) a)->id == ((TSCfgInfo *) b)->id )
+               return 0;
+       return ( ((TSCfgInfo *) a)->id < ((TSCfgInfo *) b)->id ) ? -1 : 1;
 }
 
 TSCfgInfo *
index a8e1dbfe738bff86092855f40da6d2409c45c2a2..888367c8293fcfd6885fbec2c92518ba27f6d6df 100644 (file)
@@ -51,7 +51,7 @@ static int
 comparePos(const void *a, const void *b)
 {
        if (((WordEntryPos *) a)->pos == ((WordEntryPos *) b)->pos)
-               return 1;
+               return 0;
        return (((WordEntryPos *) a)->pos > ((WordEntryPos *) b)->pos) ? 1 : -1;
 }
 
index 554c2684b9bfc2a445b14967e0df049ac7e90a11..33bfd4d87e817523b8917bfa79cf30eae243bf1d 100644 (file)
@@ -93,7 +93,9 @@ reset_prs(void)
 static int
 compareprs(const void *a, const void *b)
 {
-       return ((WParserInfo *) a)->prs_id - ((WParserInfo *) b)->prs_id;
+       if ( ((WParserInfo *) a)->prs_id == ((WParserInfo *) b)->prs_id )
+               return 0;
+       return ( ((WParserInfo *) a)->prs_id < ((WParserInfo *) b)->prs_id ) ? -1 : 1;
 }
 
 WParserInfo *