@@ -104,7 +104,7 @@ static int isInRange(int x, int minx, int maxx) // returns nonzero if x in the r
104104{
105105 if (minx <= x && x < maxx ) { return 1 ; }
106106 if (x < minx ) { x += 360000000 ; } else { x -= 360000000 ; } // 1.32 fix FIJI edge case
107- if (minx <= x && x < maxx ) return 1 ;
107+ if (minx <= x && x < maxx ) { return 1 ; }
108108 return 0 ;
109109}
110110
@@ -148,17 +148,19 @@ static int disambiguate_str(const char *s, int len) // returns disambiguation >=
148148 const char * f ;
149149 char country [4 ];
150150 if (s [0 ] == 0 || s [1 ] == 0 ) { return -27 ; } // solve bad args
151- if (len != 2 && len != 3 ) return -923 ; // solve bad args
151+ if (len != 2 && len != 3 ) { return -923 ; } // solve bad args
152152 memcpy (country , s , len );
153153 country [len ] = 0 ;
154154 {
155155 char * t ;
156- for (t = country ; * t != 0 ; t ++ )
156+ for (t = country ; * t != 0 ; t ++ ) {
157157 * t = (char ) toupper (* t );
158+ }
158159 }
159160 f = strstr (p , country );
160- if (f == NULL )
161- return -23 ; // unknown country
161+ if (f == NULL ) {
162+ return -23 ;
163+ } // unknown country
162164 return 1 + (int ) ((f - p ) / (len + 1 ));
163165}
164166
@@ -187,15 +189,16 @@ static int ccode_of_iso3(const char *in_iso, int parentcode) {
187189
188190 // make (uppercased) copy of at most three characters
189191 iso [0 ] = (char ) toupper (in_iso [0 ]);
190- if (iso [0 ]) iso [1 ] = (char ) toupper (in_iso [1 ]);
191- if (iso [1 ]) iso [2 ] = (char ) toupper (in_iso [2 ]);
192+ if (iso [0 ]) { iso [1 ] = (char ) toupper (in_iso [1 ]); }
193+ if (iso [1 ]) { iso [2 ] = (char ) toupper (in_iso [2 ]); }
192194 iso [3 ] = 0 ;
193195
194196 if (iso [2 ] == 0 || iso [2 ] == ' ' ) // 2-letter iso code?
195197 {
196198 static char disambiguate_iso3 [4 ] = {'1' , '?' , '?' , 0 }; // cache for disambiguation
197- if (parentcode > 0 )
199+ if (parentcode > 0 ) {
198200 disambiguate_iso3 [0 ] = (char ) ('0' + parentcode );
201+ }
199202 disambiguate_iso3 [1 ] = iso [0 ];
200203 disambiguate_iso3 [2 ] = iso [1 ];
201204
@@ -218,8 +221,9 @@ static int ccode_of_iso3(const char *in_iso, int parentcode) {
218221 // find the FIRST disambiguation option, if any
219222 for (s = entity_iso - 1 ; ;) {
220223 s = strstr (s + 1 , disambiguate_iso3 + 1 );
221- if (s == NULL )
224+ if (s == NULL ) {
222225 break ;
226+ }
223227 if (s && s [-1 ] >= '1' && s [-1 ] <= '9' ) {
224228 s -- ;
225229 break ;
@@ -229,8 +233,9 @@ static int ccode_of_iso3(const char *in_iso, int parentcode) {
229233 // find first disambiguation option in aliases, if any
230234 for (s = aliases - 1 ; ;) {
231235 s = strstr (s + 1 , disambiguate_iso3 + 1 );
232- if (s == NULL )
236+ if (s == NULL ) {
233237 break ;
238+ }
234239 if (s && s [-1 ] >= '1' && s [-1 ] <= '9' ) {
235240 memcpy (iso , s + 3 , 3 );
236241 s = strstr (entity_iso , iso ); // search disambiguated 2-letter iso
@@ -239,8 +244,9 @@ static int ccode_of_iso3(const char *in_iso, int parentcode) {
239244 }
240245 }
241246
242- if (s == NULL )
247+ if (s == NULL ) {
243248 return -26 ;
249+ }
244250 }
245251 }
246252 else {
@@ -260,8 +266,9 @@ static int ccode_of_iso3(const char *in_iso, int parentcode) {
260266 }
261267 }
262268 }
263- if (s == NULL )
269+ if (s == NULL ) {
264270 return -23 ;
271+ }
265272 }
266273 // return result
267274 return (int ) ((s - entity_iso ) / 4 );
@@ -384,7 +391,7 @@ static int decodeExtension(decodeRec *dec, int dividerx4, int dividery, int ydir
384391 column1 = (c1 % 5 );
385392 if (* extrapostfix ) {
386393 int c2 = decodeChar (* extrapostfix ++ );
387- if (c2 < 0 || c2 == 30 ) return -1 ; // illegal extension character
394+ if (c2 < 0 || c2 == 30 ) { return -1 ; } // illegal extension character
388395 row2 = (c2 / 6 );
389396 column2 = (c2 % 6 );
390397 }
@@ -833,7 +840,7 @@ static int decodeNameless(decodeRec *dec, int m) {
833840 int BASEPOWER = (codexm == 21 ) ? 961 * 961 : 961 * 961 * 31 ;
834841 int BASEPOWERA = (BASEPOWER / A );
835842
836- if (A == 62 ) BASEPOWERA ++ ; else BASEPOWERA = 961 * (BASEPOWERA / 961 );
843+ if (A == 62 ) { BASEPOWERA ++ ; } else { BASEPOWERA = 961 * (BASEPOWERA / 961 ); }
837844
838845 v = decodeBase31 (result );
839846 X = (v / BASEPOWERA );
@@ -960,12 +967,13 @@ static int unpack_if_alldigits(
960967 int aonly = (* s == 'A' || * s == 'a' );
961968 if (aonly ) { s ++ ; } //*** v1.50
962969 for (; * s != 0 && s [2 ] != 0 && s [2 ] != '-' ; s ++ ) {
963- if (* s == '-' )
970+ if (* s == '-' ) {
964971 break ;
965- else if (* s == '.' && !dotpos )
972+ } else if (* s == '.' && !dotpos ) {
966973 dotpos = s ;
967- else if (decodeChar (* s ) < 0 || decodeChar (* s ) > 9 )
968- return 0 ; // nondigit, so stop
974+ } else if (decodeChar (* s ) < 0 || decodeChar (* s ) > 9 ) {
975+ return 0 ;
976+ } // nondigit, so stop
969977 }
970978
971979 if (dotpos ) {
@@ -985,14 +993,19 @@ static int unpack_if_alldigits(
985993 char * e = s + 1 ; // s is vowel, e is lastchar
986994
987995 int v = 0 ;
988- if (* s == 'e' || * s == 'E' ) v = 34 ;
989- else if (* s == 'u' || * s == 'U' ) v = 68 ;
990-
991- if (* e == 'a' || * e == 'A' ) v += 31 ;
992- else if (* e == 'e' || * e == 'E' ) v += 32 ;
993- else if (* e == 'u' || * e == 'U' ) v += 33 ;
994- else if (decodeChar (* e ) < 0 ) return -9 ; // invalid last character!
995- else v += decodeChar (* e );
996+ if (* s == 'e' || * s == 'E' ) {
997+ v = 34 ;
998+ } else if (* s == 'u' || * s == 'U' ) { v = 68 ; }
999+
1000+ if (* e == 'a' || * e == 'A' ) {
1001+ v += 31 ;
1002+ } else if (* e == 'e' || * e == 'E' ) {
1003+ v += 32 ;
1004+ } else if (* e == 'u' || * e == 'U' ) {
1005+ v += 33 ;
1006+ } else if (decodeChar (* e ) < 0 ) {
1007+ return -9 ; // invalid last character!
1008+ } else { v += decodeChar (* e ); }
9961009
9971010 if (v < 100 ) {
9981011 * s = encode_chars [(unsigned int ) v / 10 ];
@@ -1282,8 +1295,11 @@ static void encoderEngine(int ccode, const encodeRec *enc, int stop_with_one_res
12821295 from = firstrec (ccode );
12831296 upto = lastrec (ccode );
12841297
1285- if (ccode != ccode_earth ) if (!fitsInside (x , y , upto ))
1286- return ;
1298+ if (ccode != ccode_earth ) {
1299+ if (!fitsInside (x , y , upto )) {
1300+ return ;
1301+ }
1302+ }
12871303
12881304 ///////////////////////////////////////////////////////////
12891305 // look for encoding options
@@ -1342,9 +1358,9 @@ static void encoderEngine(int ccode, const encodeRec *enc, int stop_with_one_res
13421358 strcat (s , result );
13431359 }
13441360 }
1345- if (debugStopAt == i ) return ;
1361+ if (debugStopAt == i ) { return ; }
13461362 }
1347- if (stop_with_one_result ) return ;
1363+ if (stop_with_one_result ) { return ; }
13481364 * result = 0 ; // clear for next iteration
13491365 }
13501366 }
@@ -1368,8 +1384,8 @@ static int decoderEngine(decodeRec *dec) {
13681384 const char * r = dec -> orginput ;
13691385 while (* r > 0 && * r <= 32 ) { r ++ ; } // skip lead
13701386 len = (int ) strlen (r );
1371- if (len > MAX_MAPCODE_RESULT_LEN - 1 ) len = MAX_MAPCODE_RESULT_LEN - 1 ;
1372- while (len > 0 && r [len - 1 ] >= 0 && r [len - 1 ] <= 32 ) len -- ; // remove trail
1387+ if (len > MAX_MAPCODE_RESULT_LEN - 1 ) { len = MAX_MAPCODE_RESULT_LEN - 1 ; }
1388+ while (len > 0 && r [len - 1 ] >= 0 && r [len - 1 ] <= 32 ) { len -- ; } // remove trail
13731389 memcpy (s , r , len );
13741390 s [len ] = 0 ;
13751391 }
@@ -1466,8 +1482,9 @@ static int decoderEngine(decodeRec *dec) {
14661482
14671483 // unpack digits (a-lead or aeu-encoded
14681484 int voweled = unpack_if_alldigits (s );
1469- if (voweled < 0 )
1485+ if (voweled < 0 ) {
14701486 return -7 ;
1487+ }
14711488
14721489 // debug support: U-lead pre-processing
14731490 if (* s == 'u' || * s == 'U' ) {
@@ -1476,27 +1493,30 @@ static int decoderEngine(decodeRec *dec) {
14761493 voweled = 1 ;
14771494 }
14781495
1479- if (len > 10 ) return -8 ;
1496+ if (len > 10 ) { return -8 ; }
14801497
14811498 // find dot and check that all characters are valid
14821499 {
14831500 int nrd = 0 ; // nr of true digits
14841501 const char * r = s ;
14851502 for (; * r != 0 ; r ++ ) {
14861503 if (* r == '.' ) {
1487- if (dot )
1488- return -5 ; // more than one dot
1504+ if (dot ) {
1505+ return -5 ;
1506+ } // more than one dot
14891507 dot = r ;
14901508 }
1491- else if (decodeChar (* r ) < 0 ) // invalid char?
1509+ else if (decodeChar (* r ) < 0 ) { // invalid char?
14921510 return -4 ;
1493- else if (decodeChar (* r ) < 10 ) // digit?
1511+ } else if (decodeChar (* r ) < 10 ) { // digit?
14941512 nrd ++ ;
1513+ }
14951514 }
1496- if (dot == NULL )
1515+ if (dot == NULL ) {
14971516 return -2 ;
1498- else if (!voweled && nrd + 1 == len ) // everything but the dot is digit, so MUST be voweled!
1517+ } else if (!voweled && nrd + 1 == len ) { // everything but the dot is digit, so MUST be voweled!
14991518 return -998 ;
1519+ }
15001520 }
15011521
15021522//////////// AT THIS POINT, dot=FIRST DOT, input=CLEAN INPUT (no vowels) ilen=INPUT LENGTH
@@ -1505,8 +1525,9 @@ static int decoderEngine(decodeRec *dec) {
15051525 prelen = (int ) (dot - s );
15061526 postlen = len - 1 - prelen ;
15071527 codex = prelen * 10 + postlen ;
1508- if (prelen < 2 || prelen > 5 || postlen < 2 || postlen > 4 )
1528+ if (prelen < 2 || prelen > 5 || postlen < 2 || postlen > 4 ) {
15091529 return -3 ;
1530+ }
15101531
15111532 if (len == 10 ) {
15121533 // international mapcodes must be in international context
@@ -1516,8 +1537,9 @@ static int decoderEngine(decodeRec *dec) {
15161537 // int mapcodes must be interpreted in the parent of a subdivision
15171538
15181539 int parent = ParentTerritoryOf (ccode );
1519- if (len == 9 || (len == 8 && (parent == ccode_ind || parent == ccode_mex )))
1540+ if (len == 9 || (len == 8 && (parent == ccode_ind || parent == ccode_mex ))) {
15201541 ccode = parent ;
1542+ }
15211543 }
15221544
15231545 // remember final territory context
@@ -1589,18 +1611,22 @@ static int decoderEngine(decodeRec *dec) {
15891611#endif
15901612
15911613 // normalise between =180 and 180
1592- if (dec -> lat < -90.0 ) dec -> lat = -90.0 ;
1593- if (dec -> lat > 90.0 ) dec -> lat = 90.0 ;
1594- if (dec -> lon < -180.0 ) dec -> lon += 360.0 ;
1595- if (dec -> lon >= 180.0 ) dec -> lon -= 360.0 ;
1614+ if (dec -> lat < -90.0 ) { dec -> lat = -90.0 ; }
1615+ if (dec -> lat > 90.0 ) { dec -> lat = 90.0 ; }
1616+ if (dec -> lon < -180.0 ) { dec -> lon += 360.0 ; }
1617+ if (dec -> lon >= 180.0 ) { dec -> lon -= 360.0 ; }
15961618
15971619 // store as integers for legacy's sake
15981620 dec -> lat32 = (int ) (dec -> lat * 1000000 );
15991621 dec -> lon32 = (int ) (dec -> lon * 1000000 );
16001622
16011623 // make sure decode result fits the country
1602- if (err == 0 ) if (ccode != ccode_earth ) if (!fitsInsideWithRoom (dec -> lon32 , dec -> lat32 , lastrec (ccode ))) {
1603- err = -2222 ;
1624+ if (err == 0 ) {
1625+ if (ccode != ccode_earth ) {
1626+ if (!fitsInsideWithRoom (dec -> lon32 , dec -> lat32 , lastrec (ccode ))) {
1627+ err = -2222 ;
1628+ }
1629+ }
16041630 }
16051631
16061632 return err ;
@@ -2007,7 +2033,7 @@ int convertTerritoryIsoNameToCode(const char *string, int optional_tc) // option
20072033 strcat (tmp , string );
20082034 ccode = ccode_of_iso3 (tmp , -1 );
20092035 }
2010- if (ccode < 0 ) return -1 ; else return ccode + 1 ;
2036+ if (ccode < 0 ) { return -1 ; } else { return ccode + 1 ; }
20112037}
20122038
20132039
@@ -2037,7 +2063,7 @@ UWORD *convertToAlphabet(UWORD *unibuf, int maxlength, const char *mapcode, int
20372063{
20382064 if (asc2lan [alphabet ][4 ] == 0x003f ) { // alphabet has no letter E
20392065 if (strchr (mapcode , 'E' ) || strchr (mapcode , 'U' ) || strchr (mapcode , 'e' ) ||
2040- strchr (mapcode , 'u' )) // v1.50 get rid of E and U
2066+ strchr (mapcode , 'u' )) // v1.50 get rid of E and U
20412067 {
20422068 // safely copy mapcode into temporary buffer u
20432069 char u [MAX_MAPCODE_RESULT_LEN ];
0 commit comments