@@ -85,29 +85,29 @@ static bool bigendian = false;
8585/* Higher -> better compression with exponentally dimnishing gains. */
8686#define LIMLZ_SA_NEIGHBORS 32
8787
88- struct sa_cmp_ctx { int * rank ; size_t n , k ; };
88+ struct sa_cmp_ctx { int32_t * rank ; size_t n , k ; };
8989static struct sa_cmp_ctx g_sa_ctx ;
9090
91- static int sa_cmp_idx (int i , int j ) {
92- int ri , rj ;
91+ static int32_t sa_cmp_idx (int32_t i , int32_t j ) {
92+ int32_t ri , rj ;
9393 if (g_sa_ctx .rank [i ] != g_sa_ctx .rank [j ])
9494 return g_sa_ctx .rank [i ] - g_sa_ctx .rank [j ];
95- ri = (i + (int )g_sa_ctx .k < (int )g_sa_ctx .n ) ? g_sa_ctx .rank [i + g_sa_ctx .k ] : -1 ;
96- rj = (j + (int )g_sa_ctx .k < (int )g_sa_ctx .n ) ? g_sa_ctx .rank [j + g_sa_ctx .k ] : -1 ;
95+ ri = (i + (int32_t )g_sa_ctx .k < (int32_t )g_sa_ctx .n ) ? g_sa_ctx .rank [i + g_sa_ctx .k ] : -1 ;
96+ rj = (j + (int32_t )g_sa_ctx .k < (int32_t )g_sa_ctx .n ) ? g_sa_ctx .rank [j + g_sa_ctx .k ] : -1 ;
9797 return ri - rj ;
9898}
9999
100100static int sa_qsort_cmp (const void * a , const void * b ) {
101- int i = * (const int * ) a , j = * (const int * ) b ;
102- return sa_cmp_idx ( i , j );
101+ int32_t d = sa_cmp_idx ( * (const int32_t * )a , * (const int32_t * )b ) ;
102+ return ( d > 0 ) - ( d < 0 );
103103}
104104
105- static int saca (const byte * s , size_t n , int * sa , int * rank , int * tmp ) {
105+ static int saca (const byte * s , size_t n , int32_t * sa , int32_t * rank , int32_t * tmp ) {
106106 size_t i ;
107107 if (!n )
108108 return 0 ;
109109 for (i = 0 ; i < n ; ++ i ) {
110- sa [i ] = (int )i ; rank [i ] = (int )s [i ];
110+ sa [i ] = (int32_t )i ; rank [i ] = (int32_t )s [i ];
111111 }
112112 for (g_sa_ctx .k = 1 ;; g_sa_ctx .k <<= 1 ) {
113113 g_sa_ctx .rank = rank ; g_sa_ctx .n = n ;
@@ -133,7 +133,7 @@ struct match_choice { uint32_t len; uint16_t off; };
133133struct parse_choice { uint32_t lit , mlen ; uint16_t off ; };
134134
135135static int longest_matches (const byte * src , size_t n , struct match_choice * mch ) {
136- int * sa , * rank , * tmp , * inv ;
136+ int32_t * sa , * rank , * tmp , * inv ;
137137 size_t i ;
138138 if (!n )
139139 return 0 ;
@@ -146,17 +146,18 @@ static int longest_matches(const byte * src, size_t n, struct match_choice * mch
146146 return -1 ;
147147 }
148148 for (i = 0 ; i < n ; ++ i )
149- inv [sa [i ]] = (int )i ;
149+ inv [sa [i ]] = (int32_t )i ;
150150 for (i = 0 ; i < n ; ++ i ) {
151- int r = inv [i ], d , rr ;
151+ int32_t r = inv [i ], rr ;
152+ int d ;
152153 size_t best_len = 0 ;
153154 uint16_t best_off = 0 ;
154155 for (d = - LIMLZ_SA_NEIGHBORS ; d <= LIMLZ_SA_NEIGHBORS ; ++ d ) {
155156 size_t j , l , off ;
156157 if (!d )
157158 continue ;
158159 rr = r + d ;
159- if (rr < 0 || rr >= (int )n )
160+ if (rr < 0 || rr >= (int32_t )n )
160161 continue ;
161162 j = (size_t )sa [rr ];
162163 if (j >= i )
0 commit comments