[GRASS-SVN] r31906 - in grass/branches/develbranch_6: include raster/r.statistics

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 30 16:29:19 EDT 2008


Author: neteler
Date: 2008-06-30 16:29:19 -0400 (Mon, 30 Jun 2008)
New Revision: 31906

Modified:
   grass/branches/develbranch_6/include/gis.h
   grass/branches/develbranch_6/raster/r.statistics/main.c
   grass/branches/develbranch_6/raster/r.statistics/o_divr.c
Log:
Add "const" to fields of Option, Flag, Module structs (merge from trunk)

Modified: grass/branches/develbranch_6/include/gis.h
===================================================================
--- grass/branches/develbranch_6/include/gis.h	2008-06-30 20:27:15 UTC (rev 31905)
+++ grass/branches/develbranch_6/include/gis.h	2008-06-30 20:29:19 UTC (rev 31906)
@@ -565,28 +565,28 @@
 
 struct Option                	    /* Structure that stores option info */
 {
-    char *key;                      /* Key word used on command line    */
+    const char *key;                /* Key word used on command line    */
     int type;                       /* Option type                      */
     int required;                   /* REQUIRED or OPTIONAL             */
     int multiple;                   /* Multiple entries OK              */
-    char *options;                  /* Approved values or range or NULL */
-    char **opts;                    /* NULL or NULL terminated array of parsed options */
-    char *key_desc;                 /* one word describing the key      */
-    char *label;                    /* Optional short label, used in GUI as item label */
-    char *description;              /* String describing option         */
-    char *descriptions;             /* ';' separated pairs of option and option descriptions */
+    const char *options;            /* Approved values or range or NULL */
+    const char **opts;              /* NULL or NULL terminated array of parsed options */
+    const char *key_desc;           /* one word describing the key      */
+    const char *label;              /* Optional short label, used in GUI as item label */
+    const char *description;        /* String describing option         */
+    const char *descriptions;       /* ';' separated pairs of option and option descriptions */
 				    /* For example: (with ->options = "break,rmdupl")
 				     * "break;break lines on intersections;"
 				     * "rmdupl;remove duplicates"
 				     */
-    char **descs;                   /* parsed descriptions, array of either NULL or string */
+    const char **descs;             /* parsed descriptions, array of either NULL or string */
                                     /* in the same order as options */
     char *answer;                   /* Option answer                    */
-    char *def;                      /* Where original answer gets saved */
+    const char *def;                /* Where original answer gets saved */
     char **answers;                 /* Option answers (for multiple=YES)*/
     struct Option *next_opt;        /* Pointer to next option struct    */
-    char *gisprompt;                /* Interactive prompt guidance      */
-    char *guisection;               /* GUI Layout guidance: ';' delimited heirarchical tree position */
+    const char *gisprompt;          /* Interactive prompt guidance      */
+    const char *guisection;         /* GUI Layout guidance: ';' delimited heirarchical tree position */
     int (*checker)();               /* Routine to check answer or NULL  */
     int count;
 };
@@ -595,17 +595,17 @@
 {
     char key;                       /* Key char used on command line    */
     char answer;                    /* Stores flag state: 0/1           */
-    char *label;                    /* Optional short label, used in GUI as item label */
-    char *description;              /* String describing flag meaning   */
-    char *guisection;               /* GUI Layout guidance: ';' delimited heirarchical tree position */
+    const char *label;              /* Optional short label, used in GUI as item label */
+    const char *description;        /* String describing flag meaning   */
+    const char *guisection;         /* GUI Layout guidance: ';' delimited heirarchical tree position */
     struct Flag *next_flag;         /* Pointer to next flag struct      */
 };
 
 struct GModule                      /* Structure that stores module info  */
 {
-    char *label;                    /* Optional short description for GUI */
-    char *description;              /* String describing module */
-    char *keywords;                 /* Keywords describing module */
+    const char *label;              /* Optional short description for GUI */
+    const char *description;        /* String describing module */
+    const char *keywords;           /* Keywords describing module */
 	/* further items are possible: author(s), version */
     int overwrite;                  /* overwrite old files */
     int verbose;                    /* print all informations about progress and so on */

Modified: grass/branches/develbranch_6/raster/r.statistics/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.statistics/main.c	2008-06-30 20:27:15 UTC (rev 31905)
+++ grass/branches/develbranch_6/raster/r.statistics/main.c	2008-06-30 20:29:19 UTC (rev 31906)
@@ -34,6 +34,7 @@
     struct Option *method, *basemap, *covermap, *outputmap;
     struct Flag *flag_c;
     struct Categories cats;
+    char methods[1024];
 
     G_gisinit (argv[0]);
 
@@ -46,20 +47,21 @@
 
     covermap = G_define_standard_option (G_OPT_R_COVER);
 
+    for (o_method = 0; menu[o_method].name; o_method++)
+    {
+       if (o_method)
+	  strcat (methods, ",");
+       else
+      	  *(methods) = 0;
+       strcat (methods, menu[o_method].name);
+    }
+
     method = G_define_option();
     method->key         = "method";
     method->type        = TYPE_STRING;
     method->required    = YES;
     method->description = _("Method of object-based statistic");
-    method->options     = G_malloc(1024);
-    for (o_method = 0; menu[o_method].name; o_method++)
-    {
-       if (o_method)
-	  strcat (method->options, ",");
-       else
-      	  *(method->options) = 0;
-	  strcat (method->options, menu[o_method].name);
-    }
+    method->options     = methods;
     
     outputmap = G_define_standard_option (G_OPT_R_OUTPUT);
     outputmap->description = _("Resultant raster map (not used with 'distribution')");

Modified: grass/branches/develbranch_6/raster/r.statistics/o_divr.c
===================================================================
--- grass/branches/develbranch_6/raster/r.statistics/o_divr.c	2008-06-30 20:27:15 UTC (rev 31905)
+++ grass/branches/develbranch_6/raster/r.statistics/o_divr.c	2008-06-30 20:29:19 UTC (rev 31906)
@@ -3,10 +3,6 @@
 #include <grass/gis.h>
 #include "method.h"
 
-/* function prototypes */
-static long divr (struct stats *);
-
-
 int 
 o_divr (char *basemap, char *covermap, char *outputmap, int usecats, struct Categories *cats)
 {



More information about the grass-commit mailing list