[GRASS-SVN] r43636 - in grass/branches/releasebranch_6_4: include lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 22 16:18:42 EDT 2010


Author: neteler
Date: 2010-09-22 20:18:42 +0000 (Wed, 22 Sep 2010)
New Revision: 43636

Modified:
   grass/branches/releasebranch_6_4/include/gis.h
   grass/branches/releasebranch_6_4/lib/gis/parser.c
Log:
backport: G_OPT_V3_TYPE; huhabla: Fixed segfault which appears while automated gui creation; bugfix #928 - fails to pre-seed the GUI; Replace G_pclose() with pclose()

Modified: grass/branches/releasebranch_6_4/include/gis.h
===================================================================
--- grass/branches/releasebranch_6_4/include/gis.h	2010-09-22 20:14:17 UTC (rev 43635)
+++ grass/branches/releasebranch_6_4/include/gis.h	2010-09-22 20:18:42 UTC (rev 43636)
@@ -187,6 +187,7 @@
     G_OPT_V_MAP,		/* old input vector map */
     G_OPT_V_MAPS,		/* old input vector maps */
     G_OPT_V_TYPE,		/* primitive type */
+    G_OPT_V3_TYPE,		/* primitive type, 2D and 3D */
     G_OPT_V_FIELD,		/* layer number (layers used to be called fields) */
     G_OPT_V_CAT,		/* one category */
     G_OPT_V_CATS,		/* more categories */
@@ -454,7 +455,7 @@
 struct Categories
 {
     CELL ncats;			/* total number of categories              */
-    CELL num;			/* the highest cell values. Only exists    
+    CELL num;			/* the highest cell values. Only exists
 				   for backwards compatibility = (CELL)
 				   max_fp_values in quant rules          */
     char *title;		/* name of data layer                      */

Modified: grass/branches/releasebranch_6_4/lib/gis/parser.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/gis/parser.c	2010-09-22 20:14:17 UTC (rev 43635)
+++ grass/branches/releasebranch_6_4/lib/gis/parser.c	2010-09-22 20:18:42 UTC (rev 43636)
@@ -1,12 +1,12 @@
-
-/**
- * \file parser.c
+/*!
+ * \file gis/parser.c
  *
  * \brief GIS Library - Argument parsing functions.
  *
  * Parses the command line provided through argc and argv.  Example:
  * Assume the previous calls:
  *
+ * \code
  *  opt1 = G_define_option() ;
  *  opt1->key        = "map",
  *  opt1->type       = TYPE_STRING,
@@ -29,28 +29,37 @@
  *  opt3->answer     = "12345.67",
  *  opt3->options    = "0-99999",
  *  opt3->description= "Number to test parser" ;
+ * \endcode
  *
  * G_parser() will respond to the following command lines as described:
  *
+ * \verbatim
  * command      (No command line arguments)
+ * \endverbatim
  *    Parser enters interactive mode.
  *
+ * \verbatim
  * command map=map.name
+ * \endverbatim
  *    Parser will accept this line.  Map will be set to "map.name", the
  *    'a' and 'b' flags will remain off and the num option will be set
  *    to the default of 5.
  *
+ * \verbatim
  * command -ab map=map.name num=9
  * command -a -b map=map.name num=9
  * command -ab map.name num=9
  * command map.name num=9 -ab
  * command num=9 -a map=map.name -b
+ * \endverbatim
  *    These are all treated as acceptable and identical. Both flags are
  *    set to on, the map option is "map.name" and the num option is "9".
  *    Note that the "map=" may be omitted from the command line if it
  *    is part of the first option (flags do not count).
  *
+ * \verbatim
  * command num=12
+ * \endverbatim
  *    This command line is in error in two ways.  The user will be told
  *    that the "map" option is required and also that the number 12 is
  *    out of range.  The acceptable range (or list) will be printed.
@@ -60,7 +69,7 @@
  * This program is free software under the GNU General Public License
  * (>=v2). Read the file COPYING that comes with GRASS for details.
  *
- * \author Radim Blazek
+ * \author Original author CERL; enhancements: Radim Blazek
  *
  * \date 2003-2009
  *
@@ -289,7 +298,7 @@
 }
 
 
-/**
+/*!
  * \brief Create standardised Option structure.
  *
  * This function will create a standardised Option structure
@@ -568,6 +577,15 @@
 	Opt->options = "point,line,boundary,centroid,area";
 	Opt->description = _("Feature type");
 	break;
+    case G_OPT_V3_TYPE:
+	Opt->key = "type";
+	Opt->type = TYPE_STRING;
+	Opt->required = NO;
+	Opt->multiple = YES;
+	Opt->answer = "point,line,boundary,centroid,area,face,kernel";
+	Opt->options = "point,line,boundary,centroid,area,face,kernel";
+	Opt->description = _("Feature type");
+	break;
     case G_OPT_V_FIELD:
 	Opt->key = "layer";
 	Opt->type = TYPE_INTEGER;
@@ -949,15 +967,15 @@
 	}
     }
 
+    /* Split options where multiple answers are OK */
+    split_opts();
+
     /* Run the gui if it was specifically requested */
     if (force_gui) {
 	G_gui();
 	return -1;
     }
 
-    /* Split options where multiple answers are OK */
-    split_opts();
-
     /* Check multiple options */
     error += check_multiple_opts();
 
@@ -967,8 +985,7 @@
 
     /* Make sure all required options are set */
     error += check_required();
-
-
+    
     if (error) {
 	if (G_verbose() > G_verbose_min())
 	    G_usage();
@@ -1754,7 +1771,7 @@
     fprintf(fp, "#  GNU General Public License for more details.\n");
     fprintf(fp, "#\n");
     fprintf(fp,
-	    "#############################################################################/\n");
+	    "############################################################################\n");
 
     fprintf(fp, "#%%Module\n");
     if (module_info.label)
@@ -1972,7 +1989,7 @@
 
     generate_tcl(fp);
 
-    G_pclose(fp);
+    pclose(fp);
 }
 
 /**
@@ -1989,7 +2006,7 @@
 
     sprintf(script, "%s/etc/wxpython/gui_modules/menuform.py",
 	    getenv("GISBASE"));
-    G_spawn(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), script, pgm_name, NULL);
+    G_spawn(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), script, G_recreate_command(), NULL);
 }
 
 /**
@@ -2007,7 +2024,7 @@
     if (!gui) {
 	gui = G_getenv("GRASS_GUI");
     }
-    
+
     if (gui && (strcmp(gui, "tcltk") == 0 || strcmp(gui, "oldtcltk") == 0))
 	G_gui_tcltk();
     else
@@ -2846,7 +2863,7 @@
 
     opt = &first_option;
     while (opt != '\0') {
-	if (opt->answer != '\0' && opt->answers[0] != NULL) {
+	if (opt->answer != '\0' && opt->answers && opt->answers[0] != NULL) {
 	    slen = strlen(opt->key) + strlen(opt->answers[0]) + 4;	/* +4 for: ' ' = " " */
 	    if (len + slen >= nalloced) {
 		nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;



More information about the grass-commit mailing list