changeset 1878:a5b86414303c

Change the API of mapBlockClean(), and adjust accordingly.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 04 Nov 2017 20:10:05 +0200
parents 14af1881e1df
children ec322c22ed59
files combine.c libmaputils.c libmaputils.h mapsearch.c mkspecial.c
diffstat 5 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/combine.c	Sat Nov 04 18:47:08 2017 +0200
+++ b/combine.c	Sat Nov 04 20:10:05 2017 +0200
@@ -255,7 +255,7 @@
             exit(1);
         }
 
-        mapBlockClean(srcFiles[i].b, " ");
+        mapBlockClean(srcFiles[i].b, (unsigned char *) " ", 1);
         srcFiles[i].b->x = srcFiles[i].x;
         srcFiles[i].b->y = srcFiles[i].y;
     }
--- a/libmaputils.c	Sat Nov 04 18:47:08 2017 +0200
+++ b/libmaputils.c	Sat Nov 04 20:10:05 2017 +0200
@@ -769,18 +769,17 @@
 
 /* Clean given block from position markers and whitespaces
  */
-void mapBlockClean(MapBlock *map, const char *symbols)
+void mapBlockClean(MapBlock *map, const unsigned char *symbols, const size_t nsymbols)
 {
     assert(map != NULL);
     assert(symbols != NULL);
 
-    const size_t nsymbols = strlen(symbols);
     for (int y = 0; y < map->height; y++)
     {
         unsigned char *dp = map->data + (y * map->scansize);
         for (int x = 0; x < map->width; x++)
         {
-            if (muStrChr((unsigned char*) symbols, nsymbols, *dp))
+            if (muStrChr(symbols, nsymbols, *dp))
                 *dp = 0;
             dp++;
         }
--- a/libmaputils.h	Sat Nov 04 18:47:08 2017 +0200
+++ b/libmaputils.h	Sat Nov 04 20:10:05 2017 +0200
@@ -124,7 +124,7 @@
 void        mapBlockPrint(FILE *fh, const MapBlock *block);
 int         mapBlockPutDo(MapBlock *map, const MapBlock *src, const int ox, const int oy);
 int         mapBlockPut(MapBlock **pmap, const MapBlock *src, const int ox, const int oy);
-void        mapBlockClean(MapBlock *block, const char *symbols);
+void        mapBlockClean(MapBlock *block, const unsigned char *symbols, const size_t nsymbols);
 void        mapBlockPrintRaw(FILE *fh, const MapBlock *block);
 
 
--- a/mapsearch.c	Sat Nov 04 18:47:08 2017 +0200
+++ b/mapsearch.c	Sat Nov 04 20:10:05 2017 +0200
@@ -877,7 +877,7 @@
         mapMSG(2, "Center @ %d, %d\n", centerX, centerY);
 
     // Clean the pattern from characters we do not want to match
-    mapBlockClean(pattern, optCleanChars);
+    mapBlockClean(pattern, (unsigned char *) optCleanChars, strlen(optCleanChars));
 
     //
     // Search the maps .. enabled or if none specified, all of them
--- a/mkspecial.c	Sat Nov 04 18:47:08 2017 +0200
+++ b/mkspecial.c	Sat Nov 04 20:10:05 2017 +0200
@@ -432,7 +432,7 @@
             THMSG(2, "Initial dimensions %d x %d\n",
                 initialMap->width, initialMap->height);
 
-            mapBlockClean(initialMap, " ");
+            mapBlockClean(initialMap, (unsigned char*) " ", 1);
         }
         else
         {
@@ -490,7 +490,7 @@
                         exit(3);
                     }
 
-                    mapBlockClean(tmp, optCleanChars);
+                    mapBlockClean(tmp, (unsigned char *) optCleanChars, strlen(optCleanChars));
                     mapBlocks[nmapBlocks - 1] = tmp;
                 }
             }