Skip to content

Commit e3eda03

Browse files
committed
Renames
1 parent cdf0b82 commit e3eda03

10 files changed

+48
-45
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
gmon.out
2+
report_*.txt
3+
14
# -----------------------------------------------------------------------------
25
# Compiled sources
36
# -----------------------------------------------------------------------------
@@ -35,7 +38,6 @@ utility/mapcode
3538
*.swp
3639
*.hprof
3740
*.hprof.index
38-
gmon.out
3941
*~
4042

4143
# -----------------------------------------------------------------------------

mapcodelib/internal_alphabet_recognizer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ extern "C" {
2424
// *** GENERATED FILE (dividemaps.cpp), DO NOT CHANGE OR PRETTIFY ***
2525

2626
// Returns alphabet of character, or negative (_ALPHABET_MIN) in not recognized
27-
#define ALPHABET_OF_CHAR(w) ((enum Alphabet) alphabetOf[(w) >> 6])
27+
#define ALPHABET_OF_CHAR(w) ((enum Alphabet) ALPHABET_OF[(w) >> 6])
2828

29-
static signed char alphabetOf[] = {
29+
static const signed char ALPHABET_OF[] = {
3030
/* 0000 */ ALPHABET_ROMAN , ALPHABET_ROMAN , ALPHABET_ROMAN , ALPHABET_ROMAN,
3131
/* 0100 */ ALPHABET_ROMAN , ALPHABET_ROMAN , ALPHABET_ROMAN , ALPHABET_ROMAN,
3232
/* 0200 */ ALPHABET_ROMAN , ALPHABET_ROMAN , ALPHABET_ROMAN , ALPHABET_ROMAN,
@@ -285,8 +285,8 @@ static signed char alphabetOf[] = {
285285
/* ff00 */ ALPHABET_ARABIC , ALPHABET_ARABIC , ALPHABET_ARABIC , ALPHABET_ARABIC
286286
}; // 1024 records
287287

288-
#define ROMANVERSION_MAXCHAR 0x3129
289-
static const char *romanVersionOf[] = {
288+
#define ROMAN_VERSION_MAX_CHAR 0x3129
289+
static const char *ROMAN_VERSION_OF[] = {
290290
/* 0000 */ "\0 !?#$%&'()*+,-./0123456789:;<=>?",
291291
/* 0040 */ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[?]^_`abcdefghijklmnopqrstuvwxyz{|}~?",
292292
/* 0080 */ NULL,

mapcodelib/internal_data.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ extern "C" {
2222

2323
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
2424

25-
#define mapcode_dataversion "2.3.0" // coords 2.0.2
25+
#define MAPCODE_DATA_VERSION "2.3.0" // coords 2.0.2
2626

27-
static const char *iso3166alpha[_TERRITORY_MAX - _TERRITORY_MIN - 1] = {
27+
static const char *ISO3166_ALPHA[_TERRITORY_MAX - _TERRITORY_MIN - 1] = {
2828
"VAT", "MCO", "GIB", "TKL", "CCK", "BLM", "NRU", "TUV", "MAC", "SXM",
2929
"MAF", "NFK", "PCN", "BVT", "BMU", "IOT", "SMR", "GGY", "AIA", "MSR",
3030
"JEY", "CXR", "WLF", "VGB", "LIE", "ABW", "MHL", "ASM", "COK", "SPM",
@@ -113,7 +113,7 @@ static const char *iso3166alpha[_TERRITORY_MAX - _TERRITORY_MIN - 1] = {
113113

114114

115115
// index of first rectangle record for x-th territory
116-
static const int data_start[_TERRITORY_MAX - _TERRITORY_MIN] = {
116+
static const int DATA_START[_TERRITORY_MAX - _TERRITORY_MIN] = {
117117
0, 3, 6, 10, 14, 17, 19, 20, 31, 32,
118118
34, 36, 38, 43, 45, 48, 52, 59, 63, 65,
119119
67, 71, 73, 81, 87, 95, 97, 132, 139, 149,
@@ -181,7 +181,7 @@ typedef struct {
181181
} TerritoryBoundary;
182182

183183
#ifndef MAKE_SOURCE_DIGITAL
184-
static const TerritoryBoundary territoryBoundaries[MAPCODE_BOUNDARY_MAX + 1] = {
184+
static const TerritoryBoundary TERRITORY_BOUNDARIES[MAPCODE_BOUNDARY_MAX + 1] = {
185185
{12433114, 41851944, 12548434, 41938434, 0x001000b}, // VAT
186186
{5850000, 35450000, 18560000, 55080000, 0x50a0216},
187187
{12444000, 41899000, 12460000, 41908000, 0x003021c},
@@ -16540,7 +16540,7 @@ static const TerritoryBoundary territoryBoundaries[MAPCODE_BOUNDARY_MAX + 1] = {
1654016540
{-180000000, -90000000, 180000000, 90000001, 0x000001d},
1654116541
};
1654216542

16543-
#define territoryBoundary(m) (&territoryBoundaries[m])
16543+
#define TERRITORY_BOUNDARY(m) (&TERRITORY_BOUNDARIES[m])
1654416544

1654516545
#endif // MAKE_SOURCE_DIGITAL
1654616546

mapcodelib/internal_iso3166_data.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ static const char PARENT_NUMBER[_TERRITORY_MAX - _TERRITORY_MIN] = {
7070
typedef struct {
7171
const char *alphaCode;
7272
enum Territory territory;
73-
} alphaRec;
74-
static const alphaRec ALPHA_SEARCH[NR_TERRITORY_RECS] = {
73+
} AlphaRec;
74+
75+
static const AlphaRec ALPHA_SEARCH[NR_TERRITORY_RECS] = {
7576
{"AAA", TERRITORY_AAA},
7677
{"AB", TERRITORY_CA_AB},
7778
{"ABW", TERRITORY_ABW},

mapcodelib/internal_territory_alphabets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern "C" {
2424

2525
#include "mapcoder.h"
2626

27-
static const TerritoryAlphabets alphabetsForTerritory[_TERRITORY_MAX - _TERRITORY_MIN - 1] = {
27+
static const TerritoryAlphabets ALPHABETS_FOR_TERRITORY[_TERRITORY_MAX - _TERRITORY_MIN - 1] = {
2828
{1, {ALPHABET_ROMAN}}, // VAT Vatican
2929
{1, {ALPHABET_ROMAN}}, // MCO Monaco
3030
{1, {ALPHABET_ROMAN}}, // GIB Gibraltar

mapcodelib/internal_territory_names_english.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern "C" {
2121
#endif
2222

2323
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
24-
static const char *isofullname[] = {
24+
static const char *TERRITORY_FULL_NAME[] = {
2525
"Vatican|Holy See",
2626
"Monaco",
2727
"Gibraltar",

mapcodelib/internal_territory_names_local.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern "C" {
2121
#endif
2222

2323
// *** GENERATED FILE (coords.cpp), DO NOT CHANGE OR PRETTIFY ***
24-
static const char *localname_utf8[] = {
24+
static const char *TERRITORY_LOCAL_NAME_UTF8[] = {
2525
"Sancta Sedes|Holy See",
2626
"Monaco",
2727
"Gibraltar",

mapcodelib/internal_territory_search.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern "C" {
2828
#error "NO_FAST_ENCODE cannot be specified in this file"
2929
#endif
3030

31-
static int redivar[] = {
31+
static const int REDIVAR[] = {
3232
27984500, 1383,
3333
2537718, 676,
3434
12842450, 332,

mapcodelib/mapcoder.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ void _TestAssert(int iCondition, const char *cstrFile, int iLine) {
6262

6363
#endif
6464

65-
#define IS_NAMELESS(m) (territoryBoundaries[m].flags & 64)
66-
#define IS_RESTRICTED(m) (territoryBoundaries[m].flags & 512)
67-
#define IS_SPECIAL_SHAPE(m) (territoryBoundaries[m].flags & 1024)
68-
#define REC_TYPE(m) ((territoryBoundaries[m].flags >> 7) & 3)
69-
#define SMART_DIV(m) (territoryBoundaries[m].flags >> 16)
70-
#define HEADER_LETTER(m) (ENCODE_CHARS[(territoryBoundaries[m].flags >> 11) & 31])
71-
#define BOUNDARY_PTR(m) (&territoryBoundaries[m])
65+
#define IS_NAMELESS(m) (TERRITORY_BOUNDARIES[m].flags & 64)
66+
#define IS_RESTRICTED(m) (TERRITORY_BOUNDARIES[m].flags & 512)
67+
#define IS_SPECIAL_SHAPE(m) (TERRITORY_BOUNDARIES[m].flags & 1024)
68+
#define REC_TYPE(m) ((TERRITORY_BOUNDARIES[m].flags >> 7) & 3)
69+
#define SMART_DIV(m) (TERRITORY_BOUNDARIES[m].flags >> 16)
70+
#define HEADER_LETTER(m) (ENCODE_CHARS[(TERRITORY_BOUNDARIES[m].flags >> 11) & 31])
71+
#define BOUNDARY_PTR(m) (&TERRITORY_BOUNDARIES[m])
7272

7373
#define TOKENSEP 0
7474
#define TOKENDOT 1
@@ -454,13 +454,13 @@ static char *safeCopy(char *targetString, const char *sourceString, const int ta
454454

455455
static int firstRec(const enum Territory ccode) {
456456
ASSERT((_TERRITORY_MIN < ccode) && (ccode < _TERRITORY_MAX));
457-
return data_start[INDEX_OF_TERRITORY(ccode)];
457+
return DATA_START[INDEX_OF_TERRITORY(ccode)];
458458
}
459459

460460

461461
static int lastRec(const enum Territory ccode) {
462462
ASSERT((_TERRITORY_MIN < ccode) && (ccode < _TERRITORY_MAX));
463-
return data_start[INDEX_OF_TERRITORY(ccode) + 1] - 1;
463+
return DATA_START[INDEX_OF_TERRITORY(ccode) + 1] - 1;
464464
}
465465

466466

@@ -475,7 +475,7 @@ static enum Territory parentTerritoryOf(const enum Territory ccode) {
475475

476476

477477
static int coDex(const int m) {
478-
int c = territoryBoundaries[m].flags & 31;
478+
int c = TERRITORY_BOUNDARIES[m].flags & 31;
479479
ASSERT((0 <= m) && (m <= MAPCODE_BOUNDARY_MAX));
480480
return 10 * (c / 5) + ((c % 5) + 1);
481481
}
@@ -1228,13 +1228,13 @@ static int encodeLatLonToMapcodes_internal(Mapcodes *mapcodes,
12281228
{
12291229
const int sum = enc.coord32.lonMicroDeg + enc.coord32.latMicroDeg;
12301230
int coord = enc.coord32.lonMicroDeg;
1231-
int i = 0; // pointer into redivar
1231+
int i = 0; // pointer into REDIVAR
12321232
for (;;) {
1233-
const int r = redivar[i++];
1233+
const int r = REDIVAR[i++];
12341234
if (r >= 0 && r < 1024) { // leaf?
12351235
int j;
12361236
for (j = 0; j <= r; j++) {
1237-
const enum Territory ccode = (j == r ? TERRITORY_AAA : (enum Territory) redivar[i + j]);
1237+
const enum Territory ccode = (j == r ? TERRITORY_AAA : (enum Territory) REDIVAR[i + j]);
12381238
encoderEngine(ccode, &enc, stop_with_one_result, extraDigits, requiredEncoder, TERRITORY_NONE);
12391239
if ((stop_with_one_result || (requiredEncoder >= 0)) && (enc.mapcodes->count > 0)) {
12401240
break;
@@ -1244,7 +1244,7 @@ static int encodeLatLonToMapcodes_internal(Mapcodes *mapcodes,
12441244
} else {
12451245
coord = sum - coord;
12461246
if (coord > r) {
1247-
i = redivar[i];
1247+
i = REDIVAR[i];
12481248
} else {
12491249
i++;
12501250
}
@@ -1750,10 +1750,10 @@ static enum MapcodeError decodeAutoHeader(DecodeRec *dec, int m) {
17501750

17511751
// Returns romanised version of character, or question mark in not recognized
17521752
static unsigned char getRomanVersionOf(UWORD w) {
1753-
if (w > ROMANVERSION_MAXCHAR || romanVersionOf[w >> 6] == NULL) {
1753+
if (w > ROMAN_VERSION_MAX_CHAR || ROMAN_VERSION_OF[w >> 6] == NULL) {
17541754
return '?';
17551755
}
1756-
return (unsigned char) romanVersionOf[w >> 6][w & 63];
1756+
return (unsigned char) ROMAN_VERSION_OF[w >> 6][w & 63];
17571757
}
17581758

17591759

@@ -2745,7 +2745,7 @@ char *getTerritoryIsoName(char *territoryISO, enum Territory territory, int useS
27452745
if (territory == TERRITORY_NONE) {
27462746
*territoryISO = 0;
27472747
} else {
2748-
const char *alphaCode = iso3166alpha[INDEX_OF_TERRITORY(territory)];
2748+
const char *alphaCode = ISO3166_ALPHA[INDEX_OF_TERRITORY(territory)];
27492749
const char *hyphen = strchr(alphaCode, '-');
27502750
if (useShortName && hyphen != NULL) {
27512751
strcpy(territoryISO, hyphen + 1);
@@ -2809,8 +2809,8 @@ int multipleBordersNearby(double latDeg, double lonDeg, enum Territory territory
28092809

28102810

28112811
static int compareAlphaCode(const void *e1, const void *e2) {
2812-
const alphaRec *a1 = (const alphaRec *) e1;
2813-
const alphaRec *a2 = (const alphaRec *) e2;
2812+
const AlphaRec *a1 = (const AlphaRec *) e1;
2813+
const AlphaRec *a2 = (const AlphaRec *) e2;
28142814
ASSERT(e1);
28152815
ASSERT(e2);
28162816
return strcmp(a1->alphaCode, a2->alphaCode);
@@ -2841,11 +2841,11 @@ static enum Territory findMatch(const int parentNumber, const char *territoryISO
28412841
codeISO[len] = 0;
28422842
makeUppercase(codeISO);
28432843
{ // binary-search the result
2844-
const alphaRec *p;
2845-
alphaRec t;
2844+
const AlphaRec *p;
2845+
AlphaRec t;
28462846
t.alphaCode = codeISO;
28472847

2848-
p = (const alphaRec *) bsearch(&t, ALPHA_SEARCH, NR_TERRITORY_RECS, sizeof(alphaRec), compareAlphaCode);
2848+
p = (const AlphaRec *) bsearch(&t, ALPHA_SEARCH, NR_TERRITORY_RECS, sizeof(AlphaRec), compareAlphaCode);
28492849
if (p) {
28502850
if (strcmp(t.alphaCode, p->alphaCode) == 0) { // only interested in PERFECT match
28512851
return p->territory;
@@ -3004,7 +3004,7 @@ encodeLatLonToMapcodes(Mapcodes *mapcodes, double latDeg, double lonDeg, enum Te
30043004
// PUBLIC - returns most common alphabets for territory, NULL if error
30053005
const TerritoryAlphabets *getAlphabetsForTerritory(enum Territory territory) {
30063006
if (territory > _TERRITORY_MIN && territory < _TERRITORY_MAX) {
3007-
return &alphabetsForTerritory[INDEX_OF_TERRITORY(territory)];
3007+
return &ALPHABETS_FOR_TERRITORY[INDEX_OF_TERRITORY(territory)];
30083008
}
30093009
return NULL;
30103010
}
@@ -3079,7 +3079,7 @@ static int getFullTerritoryName_internal(
30793079

30803080

30813081
int getFullTerritoryNameEnglish(char *territoryName, enum Territory territory, int alternative) {
3082-
return getFullTerritoryName_internal(territoryName, territory, alternative, -1, isofullname);
3082+
return getFullTerritoryName_internal(territoryName, territory, alternative, -1, TERRITORY_FULL_NAME);
30833083
}
30843084

30853085

@@ -3093,12 +3093,12 @@ int getFullTerritoryNameLocalInAlphabet(char *territoryName, enum Territory terr
30933093
*territoryName = 0;
30943094
return 0;
30953095
}
3096-
return getFullTerritoryName_internal(territoryName, territory, alternative, (int) alphabet, localname_utf8);
3096+
return getFullTerritoryName_internal(territoryName, territory, alternative, (int) alphabet, TERRITORY_LOCAL_NAME_UTF8);
30973097
}
30983098

30993099

31003100
int getFullTerritoryNameLocal(char *territoryName, enum Territory territory, int alternative) {
3101-
return getFullTerritoryName_internal(territoryName, territory, alternative, -1, localname_utf8);
3101+
return getFullTerritoryName_internal(territoryName, territory, alternative, -1, TERRITORY_LOCAL_NAME_UTF8);
31023102
}
31033103

31043104

utility/mapcode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ int main(const int argc, const char **argv) {
557557
}
558558
printf(",");
559559

560-
// Use internal knowledge of isofullname to show aliases of full territory name.
561-
char *names = strdup(isofullname[INDEX_OF_TERRITORY(ccode)]);
560+
// Use internal knowledge of TERRITORY_FULL_NAME to show aliases of full territory name.
561+
char *names = strdup(TERRITORY_FULL_NAME[INDEX_OF_TERRITORY(ccode)]);
562562
char *s = names;
563563
while (s) {
564564
if (s != names) {
@@ -714,7 +714,7 @@ int main(const int argc, const char **argv) {
714714
double lat;
715715
double lon;
716716

717-
const TerritoryBoundary *mm = territoryBoundary(i);
717+
const TerritoryBoundary *mm = TERRITORY_BOUNDARY(i);
718718
minLon = ((double) mm->minx) / 1.0E6;
719719
maxLon = ((double) mm->maxx) / 1.0E6;
720720
minLat = ((double) mm->miny) / 1.0E6;

0 commit comments

Comments
 (0)