[Git][debian-gis-team/mapcode][master] 4 commits: New upstream version 2.5.7

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Fri May 29 14:06:15 BST 2026



Bas Couwenberg pushed to branch master at Debian GIS Project / mapcode


Commits:
a82e5b47 by Bas Couwenberg at 2026-05-29T15:01:26+02:00
New upstream version 2.5.7
- - - - -
485dba6a by Bas Couwenberg at 2026-05-29T15:01:30+02:00
Update upstream source from tag 'upstream/2.5.7'

Update to upstream version '2.5.7'
with Debian dir 30d303156d69e60ebcb3aa6eb9e509be30b795c5
- - - - -
b175913e by Bas Couwenberg at 2026-05-29T15:02:17+02:00
New upstream release.

- - - - -
0cadb066 by Bas Couwenberg at 2026-05-29T15:02:48+02:00
Set distribution to unstable.

- - - - -


6 changed files:

- .gitignore
- debian/changelog
- mapcodelib/mapcode_legacy.c
- mapcodelib/mapcoder.c
- mapcodelib/mapcoder.h
- test/unittest.c


Changes:

=====================================
.gitignore
=====================================
@@ -132,3 +132,4 @@ Release
 # -----------------------------------------------------------------------------
 nb-configuration.xml
 *.orig
+.gitnexus


=====================================
debian/changelog
=====================================
@@ -1,13 +1,14 @@
-mapcode (2.5.6-2) UNRELEASED; urgency=medium
+mapcode (2.5.7-1) unstable; urgency=medium
 
   * Team upload.
+  * New upstream release.
   * Update lintian overrides.
   * Drop Rules-Requires-Root: no, default since dpkg 1.22.13.
   * Use test-build-validate-cleanup instead of test-build-twice.
   * Drop Priority: optional, default since dpkg 1.22.13.
   * Bump Standards-Version to 4.7.4, changes: priority.
 
- -- Bas Couwenberg <sebastic at debian.org>  Fri, 12 Sep 2025 17:39:48 +0200
+ -- Bas Couwenberg <sebastic at debian.org>  Fri, 29 May 2026 15:02:39 +0200
 
 mapcode (2.5.6-1) unstable; urgency=medium
 


=====================================
mapcodelib/mapcode_legacy.c
=====================================
@@ -23,7 +23,7 @@
  */
 static Mapcodes GLOBAL_RESULT;
 static char GLOBAL_MAKEISO_BUFFER[2 * (MAX_ISOCODE_LEN + 1)];
-static char* GLOBAL_MAKEISO_PTR;
+static char* GLOBAL_MAKEISO_PTR = GLOBAL_MAKEISO_BUFFER + (MAX_ISOCODE_LEN + 1);
 
 
 int encodeLatLonToMapcodes_Deprecated(
@@ -97,12 +97,12 @@ char* convertToRoman(char* asciiBuffer, int maxLength, const UWORD* unicodeBuffe
     }
     if (!err) {
         char romanized[MAX_MAPCODE_RESULT_LEN];
-        sprintf(romanized, "%s%s%s%s%s",
-                mapcodeElements.territoryISO,
-                *mapcodeElements.territoryISO ? " " : "",
-                mapcodeElements.properMapcode,
-                *mapcodeElements.precisionExtension ? "-" : "",
-                mapcodeElements.precisionExtension);
+        snprintf(romanized, sizeof(romanized), "%s%s%s%s%s",
+                 mapcodeElements.territoryISO,
+                 *mapcodeElements.territoryISO ? " " : "",
+                 mapcodeElements.properMapcode,
+                 *mapcodeElements.precisionExtension ? "-" : "",
+                 mapcodeElements.precisionExtension);
         if ((int)strlen(romanized) < maxLength) {
             strcpy(asciiBuffer, romanized);
         }


=====================================
mapcodelib/mapcoder.c
=====================================
@@ -534,17 +534,11 @@ static Point convertFractionsToDegrees(const Point* p) {
 }
 
 
-static const unsigned char DOUBLE_NAN[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; // NAN (Not a Number)
-static const unsigned char DOUBLE_INF[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7F}; // +Infinity
-static const unsigned char DOUBLE_MIN_INF[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF}; // -Infinity
-
 static enum MapcodeError
 convertCoordsToMicrosAndFractions(Point32* coord32, int* fracLat, int* fracLon, double latDeg, double lonDeg) {
     double frac;
     ASSERT(coord32);
-    if (memcmp(&lonDeg, DOUBLE_NAN, 8) == 0 || memcmp(&lonDeg, DOUBLE_INF, 8) == 0 ||
-        memcmp(&lonDeg, DOUBLE_MIN_INF, 8) == 0 ||
-        memcmp(&latDeg, DOUBLE_NAN, 8) == 0) {
+    if (isnan(lonDeg) || isinf(lonDeg) || isnan(latDeg) || isinf(latDeg)) {
         return ERR_BAD_COORDINATE;
     }
     if (latDeg < -90) {
@@ -1081,7 +1075,6 @@ static void encodeExtension(char* result, const int extrax4, const int extray, c
             valy -= factory * gy; // for next iteration
         }
         *s = 0; // terminate the result
-        ASSERT((int) strlen(s) == extraDigits);
     }
 }
 
@@ -1487,7 +1480,7 @@ static void encoderEngine(const enum Territory ccode, const EncodeRec* enc, cons
     ///////////////////////////////////////////////////////////
     {
         int i;
-        char result[128];
+        char result[MAX_MAPCODE_RESULT_ASCII_LEN];
         int result_counter = 0;
 
         *result = 0;
@@ -1736,7 +1729,7 @@ static int decodeBase31(const char* code) {
 static void decodeTriple(const char* result, int* difx, int* dify) {
     // decode the first character
     const int c1 = decodeChar(*result++);
-    ASSERT(result);
+    ASSERT(result - 1);
     ASSERT(difx);
     ASSERT(dify);
     if (c1 < 24) {
@@ -2125,7 +2118,10 @@ static unsigned char getRomanVersionOf(UWORD w) {
 static void convertFromAbjad(char* s) {
     int len, dot, form, c;
     char* postfix = strchr(s, '-');
-    dot = (int)(strchr(s, '.') - s);
+    {
+        const char* dotptr = strchr(s, '.');
+        dot = dotptr ? (int)(dotptr - s) : -1;
+    }
     if (dot < 2 || dot > 5) {
         return;
     }
@@ -3020,7 +3016,10 @@ static char* convertToAbjad(char* targetAsciiString, const char* sourceAsciiStri
     unpackIfAllDigits(targetAsciiString);
 
     len = (int)strlen(targetAsciiString);
-    dot = (int)(strchr(targetAsciiString, '.') - targetAsciiString);
+    {
+        const char* dotptr = strchr(targetAsciiString, '.');
+        dot = dotptr ? (int)(dotptr - targetAsciiString) : -1;
+    }
 
     form = dot * 10 + (len - dot - 1);
 
@@ -3297,6 +3296,7 @@ UWORD* convertToAlphabet(UWORD* utf16String, int maxLength, const char* asciiStr
  * Convert a zero-terminated UTF16 to a UTF8 string
  */
 char* convertUtf16ToUtf8(char* utf8, const UWORD* utf16) {
+    char* start = utf8;
     ASSERT(utf16);
     ASSERT(utf8);
     while (*utf16) {
@@ -3315,7 +3315,7 @@ char* convertUtf16ToUtf8(char* utf8, const UWORD* utf16) {
         }
     }
     *utf8 = 0;
-    return utf8;
+    return start;
 }
 
 // Caller must make sure utf8String can hold at least MAX_MAPCODE_RESULT_LEN characters (including 0-terminator).
@@ -3585,9 +3585,6 @@ encodeLatLonToSingleMapcode(char* mapcode, double latDeg, double lonDeg, enum Te
     if (extraDigits > MAX_PRECISION_DIGITS) {
         extraDigits = MAX_PRECISION_DIGITS;
     }
-    if (territory <= TERRITORY_UNKNOWN) {
-        return 0;
-    }
     ret = encodeLatLonToMapcodes_internal(&rlocal, latDeg, lonDeg, territory, 1, DEBUG_STOP_AT, extraDigits);
     *mapcode = 0;
     if (ret <= 0) {
@@ -3608,7 +3605,7 @@ encodeLatLonToSelectedMapcode(char* mapcode, double latDeg, double lonDeg, enum
     int nrOfResults = 0;
     nrOfResults = encodeLatLonToMapcodes(&mapcodes, latDeg, lonDeg, territory, extraDigits);
     ASSERT(nrOfResults == mapcodes.count);
-    if ((nrOfResults <= 0) || (indexOfSelected < 0) || (indexOfSelected > nrOfResults)) {
+    if ((nrOfResults <= 0) || (indexOfSelected < 0) || (indexOfSelected >= nrOfResults)) {
         return 0;
     }
     strcpy(mapcode, mapcodes.mapcode[indexOfSelected]);


=====================================
mapcodelib/mapcoder.h
=====================================
@@ -20,6 +20,7 @@ extern "C" {
 
 #endif
 
+#include <stdint.h>
 #include "mapcode_territories.h"
 #include "mapcode_alphabets.h"
 
@@ -57,8 +58,8 @@ extern "C" {
 #define MAPCODE_SUPPORT_LANGUAGE_UK
 #endif
 
-#define MAPCODE_C_VERSION                   "2.5.6"
-#define UWORD                               unsigned short int  // 2-byte unsigned integer.
+#define MAPCODE_C_VERSION                   "2.5.7"
+#define UWORD                               uint16_t            // 2-byte unsigned integer.
 
 #define MAX_NR_OF_MAPCODE_RESULTS           22                  // Max. number of results ever returned by encoder (e.g. for 26.904899, 95.138515).
 


=====================================
test/unittest.c
=====================================
@@ -2222,6 +2222,78 @@ static int testAlphabetPerTerritory(void) {
 }
 
 
+static int testBugFixes(void) {
+    int nrTests = 0;
+
+    // Issue 1: lat=+Inf or lat=-Inf must return ERR_BAD_COORDINATE (0 results), same as lon=Inf
+    {
+        Mapcodes mapcodes;
+        double pos_inf = 1.0 / 0.0;
+        double neg_inf = -1.0 / 0.0;
+        int n;
+
+        n = encodeLatLonToMapcodes(&mapcodes, pos_inf, 0.0, TERRITORY_NONE, 0);
+        ++nrTests;
+        if (n != 0) {
+            foundError();
+            printf("*** ERROR *** encodeLatLonToMapcodes(lat=+Inf) should return 0, got %d\n", n);
+        }
+
+        n = encodeLatLonToMapcodes(&mapcodes, neg_inf, 0.0, TERRITORY_NONE, 0);
+        ++nrTests;
+        if (n != 0) {
+            foundError();
+            printf("*** ERROR *** encodeLatLonToMapcodes(lat=-Inf) should return 0, got %d\n", n);
+        }
+    }
+
+    // Issue 2: indexOfSelected == nrOfResults is out-of-bounds and must return 0
+    {
+        char mapcode[MAX_MAPCODE_RESULT_ASCII_LEN];
+        // lat=52.158993, lon=4.492346 yields 4 results (verified in testSelectedEncodes)
+        int n = encodeLatLonToSelectedMapcode(mapcode, 52.158993, 4.492346, TERRITORY_NONE, 0, 4);
+        ++nrTests;
+        if (n != 0) {
+            foundError();
+            printf("*** ERROR *** encodeLatLonToSelectedMapcode with indexOfSelected==nrOfResults should return 0, got %d\n", n);
+        }
+    }
+
+    // Issue 7: encodeLatLonToSingleMapcode must accept TERRITORY_NONE and TERRITORY_UNKNOWN
+    {
+        char mapcode[MAX_MAPCODE_RESULT_ASCII_LEN];
+        int n;
+
+        n = encodeLatLonToSingleMapcode(mapcode, 52.3, 4.9, TERRITORY_UNKNOWN, 0);
+        ++nrTests;
+        if (n <= 0) {
+            foundError();
+            printf("*** ERROR *** encodeLatLonToSingleMapcode(TERRITORY_UNKNOWN) should succeed, got %d\n", n);
+        }
+
+        n = encodeLatLonToSingleMapcode(mapcode, 52.3, 4.9, TERRITORY_NONE, 0);
+        ++nrTests;
+        if (n <= 0) {
+            foundError();
+            printf("*** ERROR *** encodeLatLonToSingleMapcode(TERRITORY_NONE) should succeed, got %d\n", n);
+        }
+    }
+
+    // Issue 9: convertMapcodeToAlphabetUtf8 must return the start of the output buffer
+    {
+        char utf8[MAX_MAPCODE_RESULT_UTF8_LEN + 1];
+        char *result = convertMapcodeToAlphabetUtf8(utf8, "NLD 49.4V", ALPHABET_ROMAN);
+        ++nrTests;
+        if (result != utf8) {
+            foundError();
+            printf("*** ERROR *** convertMapcodeToAlphabetUtf8 must return start of buffer, got wrong pointer\n");
+        }
+    }
+
+    return nrTests;
+}
+
+
 int main(const int argc, const char **argv) {
     int nrTests = 0;
 
@@ -2281,6 +2353,9 @@ int main(const int argc, const char **argv) {
     printf("-----------------------------------------------------------\nRe-encode tests\n");
     nrTests += testReEncode();
 
+    printf("-----------------------------------------------------------\nBug-fix regression tests\n");
+    nrTests += testBugFixes();
+
     printf("-----------------------------------------------------------\n");
     printf("Done.\nExecuted %d tests, found %d errors\n", nrTests, nrErrors);
     if (nrErrors > 0) {



View it on GitLab: https://salsa.debian.org/debian-gis-team/mapcode/-/compare/1b4806aff57c6b89784a4f12bd7beb1939315b6d...0cadb0666b555f18100b970ca83d48b232169ac2

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/mapcode/-/compare/1b4806aff57c6b89784a4f12bd7beb1939315b6d...0cadb0666b555f18100b970ca83d48b232169ac2
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20260529/38b4832d/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list