[mapcode] 32/32: Fixed warnings for GCC and repaired mapcoder.c to compile in Visual Studio 10

Stefan Fritsch sf at moszumanska.debian.org
Wed Nov 2 23:27:18 UTC 2016


This is an automated email from the git hooks/post-receive script.

sf pushed a commit to annotated tag v1.33
in repository mapcode.

commit 96251b4748d300ca85759079da09d41a7c8dff58
Author: Rijn Buve <rijn at buve.nl>
Date:   Wed Sep 17 10:32:02 2014 +0200

    Fixed warnings for GCC and repaired mapcoder.c to compile in Visual Studio 10
---
 LICENSE               |   0
 NOTICE                |   0
 README                |  23 +++++++++++++++++------
 example/mapcode.cpp   |  19 +++++++++++++++----
 mapcode_library.doc   | Bin
 mapcodelib/basics.h   |  18 +++++++++++++++++-
 mapcodelib/mapcoder.c |  29 +++++++++++++++--------------
 mapcodelib/mapcoder.h |   0
 8 files changed, 64 insertions(+), 25 deletions(-)

diff --git a/LICENSE b/LICENSE
old mode 100755
new mode 100644
diff --git a/NOTICE b/NOTICE
old mode 100755
new mode 100644
diff --git a/README b/README
old mode 100755
new mode 100644
index b5f5b6c..5291e09
--- a/README
+++ b/README
@@ -49,7 +49,7 @@ of how to use the library.
 To build the original Mapcode tool, execute:
 
   cd example
-  gcc mapcode.c -o mapcode
+  gcc mapcode.cpp -o mapcode
 
 For help, simply execute the binary file 'mapcode' without no arguments.
 This tool provides a rather extensive command-line interface to encode and
@@ -61,31 +61,42 @@ MAPCODE LIBRARY - RELEASE NOTES
 -------------------------------------------------------------------------------
 
 1.33
-    Fix to not remove valid results just across the edge of a territory. Iimproved interface readability
-    and renamed methods to more readable forms.
+
+    Fix to not remove valid results just across the edge of a territory. Improved
+    interface readability and renamed methods to more readable forms. Removed
+    several warnings produced by GCC.
 
 1.32
-    Added encodeLatLonToSingleMapcode(); fixed 1.29 so no country-wide alternative is produced in edge cases; prevent FIJI failing to
-    decode at exactly 180 degrees.
+
+    Added encodeLatLonToSingleMapcode(); fixed 1.29 so no country-wide alternative is
+    produced in edge cases; prevent FIJI failing to decode at exactly 180 degrees.
 
 1.31
+
     Added compareWithMapcodeFormat().
 
 1.30
+
     IUpdated the documentation and extended it with examples and suggestions.
 
 1.29
+
     Also generate country-wide alternative mapcodes for states.
 
 1.28
-    Bug fix for the needless generation of 7-letter alternatives to short mapcodes in large states in India.
+
+    Bug fix for the needless generation of 7-letter alternatives to short mapcodes
+    in large states in India.
 
 1.27
+
     Improved (faster) implementation of the function isInArea.
 
 1.26
+
     Added alias OD ("Odisha") for indian state OR ("Orissa").
 
 1.25
+
     Initial release to the public domain.
 
diff --git a/example/mapcode.cpp b/example/mapcode.cpp
old mode 100755
new mode 100644
index a33772e..d78fd4d
--- a/example/mapcode.cpp
+++ b/example/mapcode.cpp
@@ -1,6 +1,17 @@
-/**
- * Copyright (C) 2014 Stichting Mapcode Foundation
- * For terms of use refer to http://www.mapcode.com/downloads.html
+/*
+ * Copyright (C) 2014 Stichting Mapcode Foundation (http://www.mapcode.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 /**
@@ -264,7 +275,7 @@ static const char* asCoordinate(double coord, char* target)
         target = &asCoordinateBuffer[ascoptr];
         ascoptr= ((ascoptr != 0) ? 0 : 12);
     }
-    sprintf(target,"%s%d.%06d", (negative ? "-" : ""), c / 1000000, c % 1000000);
+    sprintf(target,"%s%d.%06d", (negative ? "-" : ""), (int) (c / 1000000), (int) (c % 1000000));
     return target;
 }
 
diff --git a/mapcode_library.doc b/mapcode_library.doc
old mode 100755
new mode 100644
diff --git a/mapcodelib/basics.h b/mapcodelib/basics.h
old mode 100755
new mode 100644
index 1dbb933..4ebc3df
--- a/mapcodelib/basics.h
+++ b/mapcodelib/basics.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2014 Stichting Mapcode Foundation (http://www.mapcode.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #define UWORD unsigned short int // 2-byte unsigned integer
 
 #define mapcode_cversion "1.33"
@@ -10,7 +26,7 @@
 #define ALIASES "2UK=2UT,2CG=2CT,1GU=GUM,1UM=UMI,1VI=VIR,1PR=PRI,1AS=ASM,1MP=MNP,4JB=JBT,4QL=QLD,4TS=TAS,4CX=CXR,4CC=CCK,4NF=NFK,4HM=HMD,4NI=NFK,COL=5CL,5ME=5MX,MEX=5MX,5TM=TAM,5AG=AGU,5BC=BCN,5BS=BCS,5CM=CAM,5CS=CHP,5CH=CHH,5CO=COA,5DF=DIF,5DG=DUR,5GT=GUA,5GR=GRO,5HG=HID,5JA=JAL,5MI=MIC,5MO=MOR,5NA=NAY,5NL=NLE,5OA=OAX,5PB=PUE,5QE=QUE,5QR=ROO,5SL=SLP,5SI=SIN,5SO=SON,5TB=TAB,5TL=TLA,5VE=VER,5YU=YUC,5ZA=ZAC,811=8BJ,812=8TJ,813=8HE,814=8SX,815=8NM,821=8LN,822=8JL,823=8HL,831=8SH,832=8JS,833 [...]
 
 #define MAX_CCODE 541 // total number of areas (i.e. recognised iso codes) in this database
-static char *entity_iso = ""
+static const char *entity_iso = ""
 		"VAT,MCO,GIB,TKL,CCK,BLM,NRU,TUV,MAC,SXM,"
 		"MAF,NFK,PCN,BVT,BMU,IOT,SMR,GGY,AIA,MSR,"
 		"JEY,CXR,WLF,VGB,LIE,ABW,MHL,ASM,COK,SPM,"
diff --git a/mapcodelib/mapcoder.c b/mapcodelib/mapcoder.c
old mode 100755
new mode 100644
index a753587..6984b21
--- a/mapcodelib/mapcoder.c
+++ b/mapcodelib/mapcoder.c
@@ -832,16 +832,16 @@ void setup_country( int newccode )
 
         if ( codex==13 ) { iso_count13++; if ( iso_first13<0 ) iso_first13=i; }
 				if ( codex==21 ) { iso_count21++; if ( iso_first21<0 ) iso_first21=i; }
-				if ( codex==22 ) if (pipe) {if (iso_firstpipe22<0) iso_firstpipe22=i; if (pipe<2)       iso_pipeletter22[iso_pipecount22++]=pipeletter(i); else if (iso_firststar22<0) iso_firststar22=i;} else { iso_count22++; if ( iso_first22<0 ) iso_first22=i; }
-				if ( codex==14 ) if (pipe) {if (iso_firstpipe14<0) iso_firstpipe14=i; if (pipe<2)       iso_pipeletter14[iso_pipecount14++]=pipeletter(i); else if (iso_firststar14<0) iso_firststar14=i;} else { iso_count14++; if ( iso_first14<0 ) iso_first14=i; }
-				if ( codex==23 ) if (pipe) {if (iso_firstpipe23<0) iso_firstpipe23=i; if (pipe<2)       iso_pipeletter23[iso_pipecount23++]=pipeletter(i); else if (iso_firststar23<0) iso_firststar23=i;} else { iso_count23++; if ( iso_first23<0 ) iso_first23=i; }
-				if ( codex==32 ) if (pipe) {if (iso_firstpipe32<0) iso_firstpipe32=i; if (pipe<2)       iso_pipeletter32[iso_pipecount32++]=pipeletter(i); else if (iso_firststar32<0) iso_firststar32=i;} else { iso_count32++; if ( iso_first32<0 ) iso_first32=i; }
-				if ( codex==24 ) if (pipe) {if (iso_firstpipe24<0) iso_firstpipe24=i; if (pipe<2)       iso_pipeletter24[iso_pipecount24++]=pipeletter(i); else if (iso_firststar24<0) iso_firststar24=i;} else { iso_count24++; if ( iso_first24<0 ) iso_first24=i; }
-				if ( codex==33 ) if (pipe) {if (iso_firstpipe33<0) iso_firstpipe33=i; if (pipe<2)       iso_pipeletter33[iso_pipecount33++]=pipeletter(i); else if (iso_firststar33<0) iso_firststar33=i;} else { iso_count33++; if ( iso_first33<0 ) iso_first33=i; }
-				if ( codex==34 ) if (pipe) {if (iso_firstpipe34<0) iso_firstpipe34=i; if (pipe<2)       iso_pipeletter34[iso_pipecount34++]=pipeletter(i); else if (iso_firststar34<0) iso_firststar34=i;} else { iso_count34++; if ( iso_first34<0 ) iso_first34=i; }
+				if ( codex==22 ) { if (pipe) {if (iso_firstpipe22<0) iso_firstpipe22=i; if (pipe<2)       iso_pipeletter22[iso_pipecount22++]=pipeletter(i); else if (iso_firststar22<0) iso_firststar22=i;} else { iso_count22++; if ( iso_first22<0 ) iso_first22=i; } }
+				if ( codex==14 ) { if (pipe) {if (iso_firstpipe14<0) iso_firstpipe14=i; if (pipe<2)       iso_pipeletter14[iso_pipecount14++]=pipeletter(i); else if (iso_firststar14<0) iso_firststar14=i;} else { iso_count14++; if ( iso_first14<0 ) iso_first14=i; } }
+				if ( codex==23 ) { if (pipe) {if (iso_firstpipe23<0) iso_firstpipe23=i; if (pipe<2)       iso_pipeletter23[iso_pipecount23++]=pipeletter(i); else if (iso_firststar23<0) iso_firststar23=i;} else { iso_count23++; if ( iso_first23<0 ) iso_first23=i; } }
+				if ( codex==32 ) { if (pipe) {if (iso_firstpipe32<0) iso_firstpipe32=i; if (pipe<2)       iso_pipeletter32[iso_pipecount32++]=pipeletter(i); else if (iso_firststar32<0) iso_firststar32=i;} else { iso_count32++; if ( iso_first32<0 ) iso_first32=i; } }
+				if ( codex==24 ) { if (pipe) {if (iso_firstpipe24<0) iso_firstpipe24=i; if (pipe<2)       iso_pipeletter24[iso_pipecount24++]=pipeletter(i); else if (iso_firststar24<0) iso_firststar24=i;} else { iso_count24++; if ( iso_first24<0 ) iso_first24=i; } }
+				if ( codex==33 ) { if (pipe) {if (iso_firstpipe33<0) iso_firstpipe33=i; if (pipe<2)       iso_pipeletter33[iso_pipecount33++]=pipeletter(i); else if (iso_firststar33<0) iso_firststar33=i;} else { iso_count33++; if ( iso_first33<0 ) iso_first33=i; } }
+				if ( codex==34 ) { if (pipe) {if (iso_firstpipe34<0) iso_firstpipe34=i; if (pipe<2)       iso_pipeletter34[iso_pipecount34++]=pipeletter(i); else if (iso_firststar34<0) iso_firststar34=i;} else { iso_count34++; if ( iso_first34<0 ) iso_first34=i; } }
 				if ( codex==42 ) { iso_count42++; if ( iso_first42<0 ) iso_first42=i; }
 				if ( codex==43 ) { iso_count43++; if ( iso_first43<0 ) iso_first43=i; }
-				if ( codex==44 ) if (pipe) {if (iso_firstpipe44<0) iso_firstpipe44=i; if (pipe<2)       iso_pipeletter44[iso_pipecount44++]=pipeletter(i); else if (iso_firststar44<0) iso_firststar44=i;} else { iso_count44++; if ( iso_first44<0 ) iso_first44=i; }
+				if ( codex==44 ) { if (pipe) {if (iso_firstpipe44<0) iso_firstpipe44=i; if (pipe<2)       iso_pipeletter44[iso_pipecount44++]=pipeletter(i); else if (iso_firststar44<0) iso_firststar44=i;} else { iso_count44++; if ( iso_first44<0 ) iso_first44=i; } }
 		  }
     }
 
@@ -1042,7 +1042,7 @@ void repack_if_alldigits(char *input)
   char *e;
   char *dotpos=NULL;
 
-  for (e=s;*e!=0 && *e!='-';e++) if (*e<'0' || *e>'9') if (*e=='.' && !dotpos) dotpos=e; else { alldigits=0; break; }
+  for (e=s;*e!=0 && *e!='-';e++) if (*e<'0' || *e>'9') { if (*e=='.' && !dotpos) dotpos=e; else { alldigits=0; break; } }
   e--; s=e-1;
   if (alldigits && dotpos && s>dotpos) // e is last char, s is one before, both are beyond dot, all characters are digits
   {
@@ -1761,7 +1761,7 @@ void master_encode( char *resultbuffer, int the_ctry, long x, long y, int forcec
       else // must be grid, possibly a multi-area
       {
           int multi_area = (pipetype(m)==1 ? 1 : 0); // has pipe letter?
-          if (codex==21) if (iso_count21==1) codex=22; else continue;
+          if (codex==21) { if (iso_count21==1) codex=22; else continue; }
 
           if ( miny<=y && y<maxy && isInRange(x,minx,maxx) )
           if ( codex!=55 ) // exclude Earth 55
@@ -1941,11 +1941,12 @@ int mapcode_encode(char *result,long y, long x, const char *iso3, char *isofound
   if (isofound)
   {
     *isofound=0;
-    if (*result)
+    if (*result) {
       if (resultlen(result)==10)
         strcpy(isofound,makeiso(ccode_earth,1));
       else
         strcpy(isofound,makeiso(cc,1));
+    }
   }
 	return *result;
 }
@@ -2341,13 +2342,13 @@ int interpret_coord( const unsigned char *i, int islat, double *result )
   #define skipnum(i) {while (isdig(*i)) i++;}
   #define skipfp(i) {skipnum(i); if (*i=='.') {i++;skipnum(i);}}
 
-  char *winds = islat ? "nsNS+- " : "ewEW+- ";
+  const char *winds = islat ? "nsNS+- " : "ewEW+- ";
 
   // skip white spaces, signs and appropriate wind direction letters
   char *p;
   int sign=1;
 
-  while (*i && (p=strchr(winds,*i))!=NULL) { { if ( (p-winds) & 1 ) sign*=-1; } i++; }
+  while (*i && (p=(char*)strchr(winds,*i))!=NULL) { { if ( (p-(char*)winds) & 1 ) sign*=-1; } i++; }
 
   // we are now at a lead digit, or there is an error
   if (!isdig(*i))
@@ -2380,7 +2381,7 @@ int interpret_coord( const unsigned char *i, int islat, double *result )
   }
 
   // allow all posisble final endsigns
-  { while (*i && (p=strchr(winds,*i))!=NULL) { if ( (p-winds) & 1 ) sign*=-1; i++; } }
+  { while (*i && (p=(char*)strchr(winds,*i))!=NULL) { if ( (p-(char*)winds) & 1 ) sign*=-1; i++; } }
 
   // we now MUST be at the end of the string!
   if (*i)
diff --git a/mapcodelib/mapcoder.h b/mapcodelib/mapcoder.h
old mode 100755
new mode 100644

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapcode.git



More information about the Pkg-grass-devel mailing list