[mapserver-commits] r13161 - sandbox/tb-labels

svn at osgeo.org svn at osgeo.org
Wed Feb 22 04:14:09 EST 2012


Author: tbonfort
Date: 2012-02-22 01:14:09 -0800 (Wed, 22 Feb 2012)
New Revision: 13161

Modified:
   sandbox/tb-labels/mapdraw.c
   sandbox/tb-labels/mapfile.c
   sandbox/tb-labels/mapfile.h
   sandbox/tb-labels/maplexer.c
   sandbox/tb-labels/maplexer.l
   sandbox/tb-labels/mapserver.h
Log:
sanitize parsing of FORCE GROUP

Modified: sandbox/tb-labels/mapdraw.c
===================================================================
--- sandbox/tb-labels/mapdraw.c	2012-02-21 18:00:16 UTC (rev 13160)
+++ sandbox/tb-labels/mapdraw.c	2012-02-22 09:14:09 UTC (rev 13161)
@@ -2634,7 +2634,7 @@
                   // RFC 77 TODO: take label_marker_offset_x/y into account
                   labelPtr->annopoint = get_metrics(&(cachePtr->point), positions[i], r, (MS_MAX(label_marker_offset_x, marker_offset_x) + label_offset_x), (MS_MAX(label_marker_offset_y, marker_offset_y) + label_offset_y), labelPtr->angle, label_buffer, poly);
 
-                  if(labelPtr->force != MS_GROUP) {
+                  if(labelPtr->force != MS_LABEL_FORCE_GROUP) {
                      /* check for collisions inside the label group unless the label is FORCE GROUP */
 
                      /* if cachePtr->status we're still working on the first valid label with a valid status value */
@@ -2684,7 +2684,7 @@
                   msCopyShape(poly, cachePtr->poly);
                   cachePtr->status = MS_TRUE;
                 } else {
-                   if(labelPtr->force != MS_GROUP) {
+                   if(labelPtr->force != MS_LABEL_FORCE_GROUP) {
                      /* check for collisions inside the label group unless the label is FORCE GROUP */
 
                       /* if cachePtr->status we're still working on the first valid label with a valid status value */

Modified: sandbox/tb-labels/mapfile.c
===================================================================
--- sandbox/tb-labels/mapfile.c	2012-02-21 18:00:16 UTC (rev 13160)
+++ sandbox/tb-labels/mapfile.c	2012-02-22 09:14:09 UTC (rev 13161)
@@ -1822,7 +1822,20 @@
 #endif
       break;
     case(FORCE):
-      if((label->force = getSymbol(3, MS_TRUE,MS_FALSE, MS_GROUP)) == -1) return(-1);
+      switch(msyylex()) {
+         case MS_ON:
+            label->force = MS_ON;
+            break;
+         case MS_OFF:
+            label->force = MS_OFF;
+            break;
+         case GROUP:
+            label->force = MS_LABEL_FORCE_GROUP;
+            break;
+         default:
+          msSetError(MS_MISCERR, "Invalid FORCE, must be ON,OFF,or GROUP" , "loadLabel()");
+          return(-1);
+      }
       break;
     case(LABEL):
       break; /* for string loads */
@@ -2075,7 +2088,7 @@
 
   writeString(stream, indent, "ENCODING", NULL, label->encoding);
   writeLeader(stream,indent,&(label->leader));
-  writeKeyword(stream, indent, "FORCE", label->force, 2, MS_TRUE, "TRUE", MS_GROUP, "GROUP");
+  writeKeyword(stream, indent, "FORCE", label->force, 2, MS_TRUE, "TRUE", MS_LABEL_FORCE_GROUP, "GROUP");
   writeNumber(stream, indent, "MAXLENGTH", 0, label->maxlength);
   writeNumber(stream, indent, "MAXSCALEDENOM", -1, label->maxscaledenom);
   writeNumber(stream, indent, "MINDISTANCE", -1, label->mindistance);
@@ -2413,7 +2426,7 @@
     case(END):
       return(0);
       break;
-    case(MS_GROUP):
+    case(GROUP):
       if(loadExpression(&(cluster->group)) == -1) return(-1);
       break;
     case(FILTER):
@@ -3275,7 +3288,7 @@
         }
       }
       break;
-    case(MS_GROUP):
+    case(GROUP):
       if(getString(&class->group) == MS_FAILURE) return(-1); /* getString() cleans up previously allocated string */
       if(msyysource == MS_URL_TOKENS) {
         if(msValidateParameter(class->group, msLookupHashTable(&(class->validation), "group"), msLookupHashTable(&(layer->validation), "group"), msLookupHashTable(&(map->web.validation), "group"), NULL) != MS_SUCCESS) {
@@ -3956,7 +3969,7 @@
       initGrid((graticuleObj *) layer->layerinfo);
       loadGrid(layer);
       break;
-    case(MS_GROUP):
+    case(GROUP):
       if(getString(&layer->group) == MS_FAILURE) return(-1); /* getString() cleans up previously allocated string */
       if(msyysource == MS_URL_TOKENS) {
         if(msValidateParameter(layer->group, msLookupHashTable(&(layer->validation), "group"), msLookupHashTable(&(map->web.validation), "group"), NULL, NULL) != MS_SUCCESS) {

Modified: sandbox/tb-labels/mapfile.h
===================================================================
--- sandbox/tb-labels/mapfile.h	2012-02-21 18:00:16 UTC (rev 13160)
+++ sandbox/tb-labels/mapfile.h	2012-02-22 09:14:09 UTC (rev 13161)
@@ -58,7 +58,7 @@
 #define FONT 1018
 #define FONTSET 1019
 #define FROM 1020
-/*#define GROUP 1021  moved to mapserver.h MS_GROUP*/ 
+#define GROUP 1021
 #define HEADER 1022
 #define IMAGE 1023
 #define IMAGECOLOR 1024

Modified: sandbox/tb-labels/maplexer.c
===================================================================
--- sandbox/tb-labels/maplexer.c	2012-02-21 18:00:16 UTC (rev 13160)
+++ sandbox/tb-labels/maplexer.c	2012-02-22 09:14:09 UTC (rev 13161)
@@ -2873,7 +2873,7 @@
 case 82:
 YY_RULE_SETUP
 #line 250 "maplexer.l"
-{ MS_LEXER_RETURN_TOKEN(MS_GROUP); }
+{ MS_LEXER_RETURN_TOKEN(GROUP); }
 	YY_BREAK
 case 83:
 YY_RULE_SETUP

Modified: sandbox/tb-labels/maplexer.l
===================================================================
--- sandbox/tb-labels/maplexer.l	2012-02-21 18:00:16 UTC (rev 13160)
+++ sandbox/tb-labels/maplexer.l	2012-02-22 09:14:09 UTC (rev 13161)
@@ -247,7 +247,7 @@
 <INITIAL>grid                                  { MS_LEXER_RETURN_TOKEN(GRID); }
 <INITIAL>gridstep                              { MS_LEXER_RETURN_TOKEN(GRIDSTEP); }
 <INITIAL>graticule                             { MS_LEXER_RETURN_TOKEN(GRATICULE); }
-<INITIAL,URL_STRING>group                      { MS_LEXER_RETURN_TOKEN(MS_GROUP); }
+<INITIAL,URL_STRING>group                      { MS_LEXER_RETURN_TOKEN(GROUP); }
 <INITIAL,URL_STRING>header                     { MS_LEXER_RETURN_TOKEN(HEADER); }
 <INITIAL>image                                 { MS_LEXER_RETURN_TOKEN(IMAGE); }
 <INITIAL,URL_VARIABLE,URL_STRING>imagecolor    { MS_LEXER_RETURN_TOKEN(IMAGECOLOR); }

Modified: sandbox/tb-labels/mapserver.h
===================================================================
--- sandbox/tb-labels/mapserver.h	2012-02-21 18:00:16 UTC (rev 13160)
+++ sandbox/tb-labels/mapserver.h	2012-02-22 09:14:09 UTC (rev 13161)
@@ -214,7 +214,6 @@
 #define MS_DELETE 4
 #define MS_YES 1
 #define MS_NO 0
-#define MS_GROUP 1021
 
 /* For layer transparency, allows alpha transparent pixmaps to be used
    with RGB map images */
@@ -231,6 +230,7 @@
 #define MS_MAX_LABEL_PRIORITY     10
 #define MS_MAX_LABEL_FONTS     5
 #define MS_DEFAULT_LABEL_PRIORITY 1
+#define MS_LABEL_FORCE_GROUP 2 /* other values are MS_ON/MS_OFF */
 
 /* General defines, not wrapable */
 #ifndef SWIG



More information about the mapserver-commits mailing list