@@ -169,7 +169,7 @@ static const char *get_entity_iso3(char *entity_iso3_result, int ccode) {
169
169
170
170
static void makeupper (char * s )
171
171
{
172
- for (; * s ; * s ++ ) { * s = toupper (* s ); }
172
+ while ( * s ) { * s = ( char ) toupper (* s ); s ++ ; }
173
173
}
174
174
175
175
static int disambiguate_str (const char * s , const int len ) // returns disambiguation 1-8, or negative if error
@@ -829,7 +829,7 @@ static int decodeNameless(decodeRec *dec, int m) {
829
829
{
830
830
const int p = 31 / A ;
831
831
const int r = 31 % A ;
832
- int v ;
832
+ int v = 0 ;
833
833
int SIDE ;
834
834
int swapletters = 0 ;
835
835
int xSIDE ;
@@ -1250,7 +1250,8 @@ static void encodeAutoHeader(char *result, const encodeRec *enc, const int m, co
1250
1250
firstindex -- ;
1251
1251
}
1252
1252
1253
- for (i = firstindex ; i <= m ; i ++ ) {
1253
+ i = firstindex ;
1254
+ for (;;) {
1254
1255
b = boundaries (i );
1255
1256
// determine how many cells
1256
1257
H = (b -> maxy - b -> miny + 89 ) / 90 ; // multiple of 10m
@@ -1265,37 +1266,36 @@ static void encodeAutoHeader(char *result, const encodeRec *enc, const int m, co
1265
1266
const int GOODROUNDER = codexm >= 23 ? (961 * 961 * 31 ) : (961 * 961 );
1266
1267
product = ((STORAGE_START + product + GOODROUNDER - 1 ) / GOODROUNDER ) * GOODROUNDER - STORAGE_START ;
1267
1268
}
1268
- if (i < m ) {
1269
- STORAGE_START += product ;
1270
- }
1271
- }
1272
-
1273
- {
1274
- // encode
1275
- const int dividerx = (b -> maxx - b -> minx + W - 1 ) / W ;
1276
- const int vx = (enc -> coord32 .lon - b -> minx ) / dividerx ;
1277
- const int extrax = (enc -> coord32 .lon - b -> minx ) % dividerx ;
1269
+ if (i == m ) {
1270
+ // encode
1271
+ const int dividerx = (b -> maxx - b -> minx + W - 1 ) / W ;
1272
+ const int vx = (enc -> coord32 .lon - b -> minx ) / dividerx ;
1273
+ const int extrax = (enc -> coord32 .lon - b -> minx ) % dividerx ;
1278
1274
1279
- const int dividery = (b -> maxy - b -> miny + H - 1 ) / H ;
1280
- int vy = (b -> maxy - enc -> coord32 .lat ) / dividery ;
1281
- int extray = (b -> maxy - enc -> coord32 .lat ) % dividery ;
1275
+ const int dividery = (b -> maxy - b -> miny + H - 1 ) / H ;
1276
+ int vy = (b -> maxy - enc -> coord32 .lat ) / dividery ;
1277
+ int extray = (b -> maxy - enc -> coord32 .lat ) % dividery ;
1282
1278
1283
- const int codexlen = (codexm / 10 ) + (codexm % 10 );
1284
- int value = (vx / 168 ) * (H / 176 );
1279
+ const int codexlen = (codexm / 10 ) + (codexm % 10 );
1280
+ int value = (vx / 168 ) * (H / 176 );
1285
1281
1286
- if (extray == 0 && enc -> fraclat > 0 ) {
1287
- vy -- ;
1288
- extray += dividery ;
1289
- }
1282
+ if (extray == 0 && enc -> fraclat > 0 ) {
1283
+ vy -- ;
1284
+ extray += dividery ;
1285
+ }
1290
1286
1291
- value += (vy / 176 );
1287
+ value += (vy / 176 );
1292
1288
1293
- // PIPELETTER ENCODE
1294
- encodeBase31 (result , (STORAGE_START / (961 * 31 )) + value , codexlen - 2 );
1295
- result [codexlen - 2 ] = '.' ;
1296
- encode_triple (result + codexlen - 1 , vx % 168 , vy % 176 );
1289
+ // PIPELETTER ENCODE
1290
+ encodeBase31 (result , (STORAGE_START / (961 * 31 )) + value , codexlen - 2 );
1291
+ result [codexlen - 2 ] = '.' ;
1292
+ encode_triple (result + codexlen - 1 , vx % 168 , vy % 176 );
1297
1293
1298
- encodeExtension (result , extrax << 2 , extray , dividerx << 2 , dividery , extraDigits , -1 , enc ); // autoheader
1294
+ encodeExtension (result , extrax << 2 , extray , dividerx << 2 , dividery , extraDigits , -1 , enc ); // autoheader
1295
+ return ;
1296
+ }
1297
+ STORAGE_START += product ;
1298
+ i ++ ;
1299
1299
}
1300
1300
}
1301
1301
@@ -1391,7 +1391,7 @@ static int decoderEngine(decodeRec *dec) {
1391
1391
int hasvowels = 0 ;
1392
1392
int hasletters = 0 ;
1393
1393
const char * dot = NULL ;
1394
- int prelen ;
1394
+ int prelen = 0 ;
1395
1395
int len ;
1396
1396
char * w ;
1397
1397
// skip whitesace
@@ -2062,7 +2062,7 @@ int binfindmatch(int parentcode, const char *str) {
2062
2062
char tmp [5 ];
2063
2063
if (parentcode < 0 ) { return -1 ; }
2064
2064
if (parentcode > 0 ) {
2065
- tmp [0 ] = '0' + parentcode ;
2065
+ tmp [0 ] = ( char ) ( '0' + parentcode ) ;
2066
2066
memcpy (tmp + 1 , str , 3 );
2067
2067
} else {
2068
2068
memcpy (tmp , str , 4 );
0 commit comments