[GRASS-SVN] r60727 - in grass/trunk: general/g.mlist general/g.mremove general/g.parser include lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jun 6 00:47:53 PDT 2014
Author: glynn
Date: 2014-06-06 00:47:53 -0700 (Fri, 06 Jun 2014)
New Revision: 60727
Modified:
grass/trunk/general/g.mlist/main.c
grass/trunk/general/g.mremove/main.c
grass/trunk/general/g.parser/main.c
grass/trunk/general/g.parser/parse.c
grass/trunk/include/gis.h
grass/trunk/lib/gis/parser.c
grass/trunk/lib/gis/parser_local_proto.h
Log:
Revert attempt to impose option dependency mechanism without discussion
Modified: grass/trunk/general/g.mlist/main.c
===================================================================
--- grass/trunk/general/g.mlist/main.c 2014-06-05 21:49:09 UTC (rev 60726)
+++ grass/trunk/general/g.mlist/main.c 2014-06-06 07:47:53 UTC (rev 60727)
@@ -101,27 +101,23 @@
opt.output->required = NO;
opt.output->label = _("Name for output file");
opt.output->description = _("If not given or '-' then standard output");
- opt.output->exclusive = "format";
flag.regex = G_define_flag();
flag.regex->key = 'r';
flag.regex->description =
_("Use basic regular expressions instead of wildcards");
flag.regex->guisection = _("Pattern");
- flag.regex->exclusive = "regex";
flag.extended = G_define_flag();
flag.extended->key = 'e';
flag.extended->description =
_("Use extended regular expressions instead of wildcards");
flag.extended->guisection = _("Pattern");
- flag.extended->exclusive = "regex";
flag.type = G_define_flag();
flag.type->key = 't';
flag.type->description = _("Print data types");
flag.type->guisection = _("Print");
- flag.type->exclusive = "format";
flag.mapset = G_define_flag();
flag.mapset->key = 'm';
@@ -132,17 +128,31 @@
flag.pretty->key = 'p';
flag.pretty->description = _("Pretty printing in human readable format");
flag.pretty->guisection = _("Print");
- flag.pretty->exclusive = "format";
flag.full = G_define_flag();
flag.full->key = 'f';
flag.full->description = _("Verbose listing (also list map titles)");
flag.full->guisection = _("Print");
- flag.full->exclusive = "format";
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if ((flag.pretty->answer || flag.full->answer) && opt.output->answer)
+ G_fatal_error(_("-%c/-%c and %s= are mutually exclusive"),
+ flag.pretty->key, flag.full->key, opt.output->key);
+
+ if ((flag.pretty->answer || flag.full->answer) && flag.type->answer)
+ G_fatal_error(_("-%c/-%c and -%c are mutually exclusive"),
+ flag.pretty->key, flag.full->key, flag.type->key);
+
+ if (flag.pretty->answer && flag.full->answer)
+ G_fatal_error(_("-%c and -%c are mutually exclusive"),
+ flag.pretty->key, flag.full->key);
+
+ if (flag.regex->answer && flag.extended->answer)
+ G_fatal_error(_("-%c and -%c are mutually exclusive"),
+ flag.regex->key, flag.extended->key);
+
if (opt.pattern->answer) {
if (flag.regex->answer || flag.extended->answer)
filter = G_ls_regex_filter(opt.pattern->answer, 0,
Modified: grass/trunk/general/g.mremove/main.c
===================================================================
--- grass/trunk/general/g.mremove/main.c 2014-06-05 21:49:09 UTC (rev 60726)
+++ grass/trunk/general/g.mremove/main.c 2014-06-06 07:47:53 UTC (rev 60727)
@@ -68,13 +68,11 @@
flag.regex->key = 'r';
flag.regex->description =
_("Use basic regular expressions instead of wildcards");
- flag.regex->exclusive = "regex";
flag.extended = G_define_flag();
flag.extended->key = 'e';
flag.extended->description =
_("Use extended regular expressions instead of wildcards");
- flag.extended->exclusive = "regex";
flag.force = G_define_flag();
flag.force->key = 'f';
@@ -97,6 +95,10 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ if (flag.regex->answer && flag.extended->answer)
+ G_fatal_error(_("-%c and -%c are mutually exclusive"),
+ flag.regex->key, flag.extended->key);
+
if (!flag.force->answer)
G_message(_("The following data base element files would be deleted:"));
Modified: grass/trunk/general/g.parser/main.c
===================================================================
--- grass/trunk/general/g.parser/main.c 2014-06-05 21:49:09 UTC (rev 60726)
+++ grass/trunk/general/g.parser/main.c 2014-06-06 07:47:53 UTC (rev 60727)
@@ -7,10 +7,9 @@
* Cedric Shock <cedricgrass shockfamily.net>,
* Hamish Bowman <hamish_b yahoo.com>,
* Paul Kelly <paul-grass stjohnspoint.co.uk>,
- * Radim Blazek <radim.blazek gmail.com>,
- * Huidae Cho <grass4u gmail.com>
+ * Radim Blazek <radim.blazek gmail.com>
* PURPOSE:
- * COPYRIGHT: (C) 2001-2007, 2010-2014 by the GRASS Development Team
+ * COPYRIGHT: (C) 2001-2007, 2010-2011 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
Modified: grass/trunk/general/g.parser/parse.c
===================================================================
--- grass/trunk/general/g.parser/parse.c 2014-06-05 21:49:09 UTC (rev 60726)
+++ grass/trunk/general/g.parser/parse.c 2014-06-06 07:47:53 UTC (rev 60727)
@@ -126,11 +126,6 @@
return;
}
- if (G_strcasecmp(cmd, "exclusive") == 0) {
- ctx->flag->exclusive = xstrdup(arg);
- return;
- }
-
if (G_strcasecmp(cmd, "end") == 0) {
ctx->state = S_TOPLEVEL;
return;
@@ -224,11 +219,6 @@
return;
}
- if (G_strcasecmp(cmd, "exclusive") == 0) {
- ctx->option->exclusive = xstrdup(arg);
- return;
- }
-
if (G_strcasecmp(cmd, "end") == 0) {
ctx->state = S_TOPLEVEL;
return;
Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h 2014-06-05 21:49:09 UTC (rev 60726)
+++ grass/trunk/include/gis.h 2014-06-06 07:47:53 UTC (rev 60727)
@@ -75,12 +75,12 @@
#define U_RADIANS 7
#define U_DEGREES 8
/* Temporal units from the datetime library */
-#define U_YEARS DATETIME_YEAR
-#define U_MONTHS DATETIME_MONTH
-#define U_DAYS DATETIME_DAY
-#define U_HOURS DATETIME_HOUR
-#define U_MINUTES DATETIME_MINUTE
-#define U_SECONDS DATETIME_SECOND
+#define U_YEARS DATETIME_YEAR
+#define U_MONTHS DATETIME_MONTH
+#define U_DAYS DATETIME_DAY
+#define U_HOURS DATETIME_HOUR
+#define U_MINUTES DATETIME_MINUTE
+#define U_SECONDS DATETIME_SECOND
/*! \brief Projection code - XY coordinate system (unreferenced data) */
#define PROJECTION_XY 0
@@ -256,7 +256,7 @@
G_OPT_M_MAPSET, /*!< mapset */
G_OPT_M_COORDS, /*!< coordinates */
G_OPT_M_COLR, /*!< color rules */
- G_OPT_M_DIR, /*!< directory input */
+ G_OPT_M_DIR, /*!< directory input */
G_OPT_M_REGION, /*!< saved region */
G_OPT_STDS_INPUT, /*!< old input space time dataset of type strds, str3ds or stvds */
@@ -273,7 +273,7 @@
G_OPT_STVDS_OUTPUT, /*!< new output space time vector dataset */
G_OPT_MAP_INPUT, /*!< old input map of type raster, vector or raster3d */
G_OPT_MAP_INPUTS, /*!< old input maps of type raster, vector or raster3d */
- G_OPT_STDS_TYPE, /*!< the type of a space time dataset: strds, str3ds, stvds */
+ G_OPT_STDS_TYPE, /*!< the type of a space time dataset: strds, str3ds, stvds */
G_OPT_MAP_TYPE, /*!< The type of an input map: raster, vect, rast3d */
G_OPT_T_TYPE, /*!< The temporal type of a space time dataset */
G_OPT_T_WHERE, /*!< A temporal GIS framework SQL WHERE statement */
@@ -393,15 +393,15 @@
/*! \brief Resolution - east to west cell size for 2D data */
double ew_res;
/*! \brief Resolution - east to west cell size for 3D data */
- double ew_res3;
+ double ew_res3;
/*! \brief Resolution - north to south cell size for 2D data */
- double ns_res;
+ double ns_res;
/*! \brief Resolution - north to south cell size for 3D data */
- double ns_res3;
+ double ns_res3;
/*! \brief Resolution - top to bottom cell size for 3D data */
- double tb_res;
+ double tb_res;
/*! \brief Extent coordinates (north) */
- double north;
+ double north;
/*! \brief Extent coordinates (south) */
double south;
/*! \brief Extent coordinates (east) */
@@ -472,11 +472,6 @@
GUI dependency is a list of options (separated by commas) to be updated
if the value is changed.
- The exclusive member of the Option and Flag structures is a comma-separated
- string. Whitespaces are not ignored. Each name separated by comma can be used
- to group options/flags together, make them mutually exclusive, or make one of
- them conditionally required. See lib/gis/parser.c for examples.
-
Used by the G_parser() system.
*/
struct Option
@@ -485,7 +480,6 @@
int type; /*!< Option type */
int required; /*!< REQUIRED or OPTIONAL */
int multiple; /*!< Multiple entries OK */
- const char *exclusive; /*!< Exclusive option/flag groups */
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 */
@@ -514,7 +508,6 @@
char key; /*!< Key char used on command line */
char answer; /*!< Stores flag state: 0/1 */
char suppress_required; /*!< Suppresses checking of required options */
- const char *exclusive; /*!< Exclusive option/flag groups */
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 hierarchical tree position */
Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c 2014-06-05 21:49:09 UTC (rev 60726)
+++ grass/trunk/lib/gis/parser.c 2014-06-06 07:47:53 UTC (rev 60727)
@@ -6,123 +6,66 @@
* 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,
- opt1->required = YES,
- opt1->checker = sub,
- opt1->description= "Name of an existing raster map" ;
-
- opt2 = G_define_option() ;
- opt2->key = "color",
- opt2->type = TYPE_STRING,
- opt2->required = NO,
- opt2->answer = "white",
- opt2->options = "red,orange,blue,white,black",
- opt2->description= "Color used to display the map" ;
-
- opt3 = G_define_option() ;
- opt3->key = "number",
- opt3->type = TYPE_DOUBLE,
- opt3->required = NO,
- opt3->answer = "12345.67",
- opt3->options = "0-99999",
- opt3->description= "Number to test parser" ;
- \endcode
+ * \code
+ * opt1 = G_define_option() ;
+ * opt1->key = "map",
+ * opt1->type = TYPE_STRING,
+ * opt1->required = YES,
+ * opt1->checker = sub,
+ * opt1->description= "Name of an existing raster map" ;
*
+ * opt2 = G_define_option() ;
+ * opt2->key = "color",
+ * opt2->type = TYPE_STRING,
+ * opt2->required = NO,
+ * opt2->answer = "white",
+ * opt2->options = "red,orange,blue,white,black",
+ * opt2->description= "Color used to display the map" ;
+ *
+ * opt3 = G_define_option() ;
+ * opt3->key = "number",
+ * opt3->type = TYPE_DOUBLE,
+ * opt3->required = NO,
+ * 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
+ * \verbatim
+ * command (No command line arguments)
+ * \endverbatim
* Parser enters interactive mode.
*
- \verbatim
- command map=map.name
- \endverbatim
+ * \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
+ * \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
+ * \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.
- *
- * The exclusive member of the Option and Flag structures is a comma-separated
- * string. Whitespaces are not ignored. Each name separated by comma can be
- * used to group options/flags together, make them mutually exclusive, or make
- * one of them conditionally required. Names starting with "+" tie together
- * options/flags and names starting with "*" (name ignored) make them
- * conditionally required (not always required, but if some other options/flags
- * are not used, they become required). Other names make options/flags mutually
- * exclusive in the same group. These three different types of grouping can be
- * mixed. G_parser() raises a fatal error if any violations are found.
*
- * Examples
+ * (C) 2001-2009, 2011 by the GRASS Development Team
*
- * 1. opt1 & opt2 are mutually exclusive and opt2 & opt3 are mutually exclusive.
- *
- \code
- opt1->exclusive = "1";
- opt2->exclusive = "1,2";
- opt3->exclusive = "2";
- \endcode
- *
- * 2. opt1 & opt2 must be used together.
- *
- \code
- opt1->exclusive = "+1";
- opt2->exclusive = "+1";
- opt3->exclusive = "";
- \endcode
- *
- * 3. opt1 or opt2 must be used. Both can be used together. Naming ignored.
- *
- \code
- opt1->exclusive = "*ignored";
- opt2->exclusive = "*";
- opt3->exclusive = "";
- \endcode
- *
- * 4. (opt1 & opt2 together) or (opt3 & opt4 together) must be used. All four
- * can be used together.
- *
- \code
- opt1->exclusive = "+1,*";
- opt2->exclusive = "+1"; // * is optional because opt2 is tied with opt1
- opt3->exclusive = "+2,*";
- opt4->exclusive = "+2";
- \endcode
- *
- * 5. Only one of (opt1 & opt2 together) or (opt3 & opt4 together) must be used.
- * All four cannot be used together.
- *
- \code
- opt1->exclusive = "+1,*,1";
- opt2->exclusive = "+1"; // * is optional because opt2 is tied with opt1
- opt3->exclusive = "+2,*,1";
- opt4->exclusive = "+2"; // 1 is optional because opt4 is tied with opt3
- \endcode
- *
- *
- * (C) 2001-2009, 2011-2014 by the GRASS Development Team
- *
* This program is free software under the GNU General Public License
* (>=v2). Read the file COPYING that comes with GRASS for details.
*
@@ -170,17 +113,8 @@
static void check_multiple_opts(void);
static int check_overwrite(void);
static void define_keywords(void);
-static void split_gisprompt(const char *, char *, char *, char *);
+static void split_gisprompt(const char *gisprompt, char *age, char *element, char *desc);
static void module_gui_wx(void);
-static void add_exclusive(const char *, int, const char *);
-static struct Exclusive *find_exclusive(char *);
-static int has_exclusive_name(const char *, char *);
-static int has_exclusive_key(int, char **, char *);
-static int has_either_or(const char *);
-static void check_exclusive();
-static void check_mutually_exclusive_inputs();
-static void check_tied_together_inputs();
-static void check_either_or_inputs();
static void append_error(const char *);
/*!
@@ -385,11 +319,6 @@
G_basename(tmp_name, "exe");
st->pgm_name = tmp_name;
- st->allocated_exclusive = 10;
- st->n_exclusive = 0;
- st->exclusive = G_malloc(st->allocated_exclusive *
- sizeof(struct Exclusive));
-
/* Stash default answers */
opt = &st->first_option;
@@ -587,8 +516,8 @@
else if (*ptr == '-') {
while (*(++ptr))
set_flag(*ptr);
- }
+ }
/* If we see standard option format (option=val) */
else if (is_option(ptr)) {
set_option(ptr);
@@ -600,19 +529,15 @@
st->first_option.answer = G_store(ptr);
st->first_option.count++;
need_first_opt = 0;
- add_exclusive(st->first_option.key, 0,
- st->first_option.exclusive);
}
/* If we see the non valid argument (no "=", just argument) */
else {
- G_asprintf(&err, _("Sorry, <%s> is not a valid option"), ptr);
+ G_asprintf(&err, _("Sorry <%s> is not a valid option"), ptr);
append_error(err);
}
}
-
- check_exclusive();
}
/* Split options where multiple answers are OK */
@@ -885,358 +810,6 @@
G_spawn(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), script, G_recreate_command(), NULL);
}
-static void add_exclusive(const char *option_key, int flag_key,
- const char *names)
-{
- char *keyname, *ptr1;
-
- if (!names || !*names)
- return;
-
- if (option_key)
- G_asprintf(&keyname, "%s=", option_key);
- else
- G_asprintf(&keyname, "-%c", flag_key);
-
- for (ptr1 = (char *)names;;) {
- int len;
- char *ptr2;
-
- for (len = 0, ptr2 = ptr1; *ptr2 != '\0' && *ptr2 != ',';
- ptr2++, len++) ;
-
- if (len > 0) { /* skip ,, */
- char *name;
- struct Exclusive *exclusive;
-
- name = G_malloc(len + 1);
- memcpy(name, ptr1, len);
- name[len] = 0;
-
- if (!(exclusive = find_exclusive(name))) {
- if (st->n_exclusive >= st->allocated_exclusive) {
- st->allocated_exclusive += 10;
- st->exclusive = G_realloc(st->exclusive,
- st->allocated_exclusive *
- sizeof(struct Exclusive));
- }
-
- exclusive = &st->exclusive[st->n_exclusive++];
- exclusive->name = name;
- exclusive->allocated_keys = 10;
- exclusive->n_keys = 0;
- exclusive->keys = G_malloc(exclusive->allocated_keys *
- sizeof(char *));
- }
-
- if (!has_exclusive_key(exclusive->n_keys, exclusive->keys,
- keyname)) {
- exclusive->keys[exclusive->n_keys++] = keyname;
-
- if (exclusive->n_keys >= exclusive->allocated_keys) {
- exclusive->allocated_keys += 10;
- exclusive->keys = G_realloc(exclusive->keys,
- exclusive->allocated_keys *
- sizeof(char *));
- }
- }
- }
-
- if (*ptr2 == '\0')
- break;
-
- ptr1 = ptr2 + 1;
-
- if (*ptr1 == '\0')
- break;
- }
-}
-
-static struct Exclusive *find_exclusive(char *name)
-{
- int i;
-
- for (i = 0; i < st->n_exclusive; i++) {
- if (strcmp(st->exclusive[i].name, name) == 0)
- return &st->exclusive[i];
- }
-
- return NULL;
-}
-
-static int has_exclusive_name(const char *names, char *name)
-{
- char *ptr1;
-
- for (ptr1 = (char *)names;;) {
- int len;
- char *ptr2;
-
- for (len = 0, ptr2 = ptr1; *ptr2 != '\0' && *ptr2 != ',';
- ptr2++, len++) ;
-
- if (len > 0) { /* skip ,, */
- char *aname;
-
- aname = G_malloc(len + 1);
- memcpy(aname, ptr1, len);
- aname[len] = 0;
-
- if (strcmp(name, aname) == 0) {
- G_free(aname);
- return 1;
- }
-
- G_free(aname);
- }
-
- if (*ptr2 == '\0')
- break;
-
- ptr1 = ptr2 + 1;
-
- if (*ptr1 == '\0')
- break;
- }
-
- return 0;
-}
-
-static int has_exclusive_key(int n_keys, char **keys, char *key)
-{
- int i;
-
- for (i = 0; i < n_keys; i++) {
- if (strcmp(keys[i], key) == 0)
- return 1;
- }
-
- return 0;
-}
-
-static int has_either_or(const char *names)
-{
- return names && (names[0] == '*' || strstr(names, ",*"));
-}
-
-static void check_exclusive()
-{
- check_mutually_exclusive_inputs();
- check_tied_together_inputs();
- check_either_or_inputs();
-}
-
-static void check_mutually_exclusive_inputs()
-{
- int i;
-
- for (i = 0; i < st->n_exclusive; i++) {
- struct Exclusive *exclusive;
-
- exclusive = &st->exclusive[i];
-
- if (exclusive->name[0] == '+' || exclusive->name[0] == '*')
- continue;
-
- G_debug(1, "check_exclusive(): Mutually exclusive option/flag group: "
- "%s", exclusive->name);
- G_debug(1, "check_exclusive():\t%s", exclusive->keys[0]);
-
- if (exclusive->n_keys > 1) {
- int len, j;
- char *err;
-
- len = 0;
- for (j = 0; j < exclusive->n_keys; j++) {
- len += strlen(exclusive->keys[j]) + 2; /* 2 for comma adn space
- */
- if (j > 0)
- G_debug(1, "check_exclusive():\t%s", exclusive->keys[j]);
- }
-
- err = G_malloc(len + 100);
- sprintf(err, _("The following options/flags cannot be used "
- "together: "));
-
- len = strlen(err);
- for (j = 0; j < exclusive->n_keys - 2; j++) {
- sprintf(err + len, "%s, ", exclusive->keys[j]);
- len = strlen(err);
- }
-
- sprintf(err + len, _("%s and %s"), exclusive->keys[j],
- exclusive->keys[j + 1]);
-
- append_error(err);
- G_free(err);
- }
- }
-}
-
-static void check_tied_together_inputs()
-{
- int i;
-
- for (i = 0; i < st->n_exclusive; i++) {
- struct Exclusive *exclusive;
- struct Option *opt;
- struct Flag *flag;
- int n, n_keys, len;
- char *err;
-
- exclusive = &st->exclusive[i];
-
- if (exclusive->name[0] != '+')
- continue;
-
- G_debug(1, "check_exclusive(): Tied-together option/flag group: %s",
- exclusive->name);
-
- n_keys = 0;
- len = 0;
- opt = &st->first_option;
- while (opt) {
- if (has_exclusive_name(opt->exclusive, exclusive->name)) {
- n_keys++;
- len += strlen(opt->key) + 3; /* 3 for =, comma and space */
- G_debug(1, "check_exclusive():\t%s=", opt->key);
- }
- opt = opt->next_opt;
- }
-
- flag = &st->first_flag;
- while (flag) {
- if (has_exclusive_name(flag->exclusive, exclusive->name)) {
- n_keys++;
- len += 4; /* 4 for -, flag, comma and space */
- G_debug(1, "check_exclusive():\t-%c", flag->key);
- }
- flag = flag->next_flag;
- }
-
- if (n_keys == 1 || exclusive->n_keys == n_keys)
- continue;
-
- err = G_malloc(len + 100);
- sprintf(err, _("The following options/flags must be used together: "));
-
- n = 0;
- len = strlen(err);
- opt = &st->first_option;
- while (opt) {
- if (has_exclusive_name(opt->exclusive, exclusive->name)) {
- n++;
- if (n <= n_keys - 2)
- sprintf(err + len, "%s=, ", opt->key);
- else if (n == n_keys - 1)
- sprintf(err + len, "%s= ", opt->key);
- else
- sprintf(err + len, "and %s=", opt->key);
- len = strlen(err);
- }
- opt = opt->next_opt;
- }
-
- flag = &st->first_flag;
- while (flag) {
- if (has_exclusive_name(flag->exclusive, exclusive->name)) {
- n++;
- if (n <= n_keys - 2)
- sprintf(err + len, "-%c, ", flag->key);
- else if (n == n_keys - 1)
- sprintf(err + len, "-%c ", flag->key);
- else
- sprintf(err + len, "and -%c", flag->key);
- len = strlen(err);
- }
- flag = flag->next_flag;
- }
-
- append_error(err);
- G_free(err);
- }
-}
-
-static void check_either_or_inputs()
-{
- int n_keys, len, i, n;
- struct Option *opt;
- struct Flag *flag;
- char *err;
-
- G_debug(1, "check_exclusive(): Either-or options/flags "
- "(group names ignored)");
-
- n_keys = 0;
- len = 0;
- opt = &st->first_option;
- while (opt) {
- if (has_either_or(opt->exclusive)) {
- n_keys++;
- len += strlen(opt->key) + 3; /* 3 for =, comma and space */
- G_debug(1, "check_exclusive():\t%s=", opt->key);
- }
- opt = opt->next_opt;
- }
-
- flag = &st->first_flag;
- while (flag) {
- if (has_either_or(flag->exclusive)) {
- n_keys++;
- len += 4; /* 4 for -, flag, comma and space */
- G_debug(1, "check_exclusive():\t-%c", flag->key);
- }
- flag = flag->next_flag;
- }
-
- if (n_keys == 0)
- return;
-
- for (i = 0; i < st->n_exclusive; i++) {
- if (st->exclusive[i].name[0] == '*')
- return;
- }
-
- err = G_malloc(len + 100);
- sprintf(err, _("One or more of the following options/flags "
- "must be used: "));
-
- n = 0;
- len = strlen(err);
- opt = &st->first_option;
- while (opt) {
- if (has_either_or(opt->exclusive)) {
- n++;
- if (n <= n_keys - 2)
- sprintf(err + len, "%s=, ", opt->key);
- else if (n == n_keys - 1)
- sprintf(err + len, "%s= ", opt->key);
- else
- sprintf(err + len, "or %s=", opt->key);
- len = strlen(err);
- }
- opt = opt->next_opt;
- }
-
- flag = &st->first_flag;
- while (flag) {
- if (has_either_or(flag->exclusive)) {
- n++;
- if (n <= n_keys - 2)
- sprintf(err + len, "-%c, ", flag->key);
- else if (n == n_keys - 1)
- sprintf(err + len, "-%c ", flag->key);
- else
- sprintf(err + len, "or -%c", flag->key);
- len = strlen(err);
- }
- flag = flag->next_flag;
- }
-
- append_error(err);
- G_free(err);
-}
-
static void set_flag(int f)
{
struct Flag *flag;
@@ -1258,7 +831,6 @@
flag->answer = 1;
if (flag->suppress_required)
st->suppress_required = 1;
- add_exclusive(NULL, f, flag->exclusive);
return;
}
flag = flag->next_flag;
@@ -1389,8 +961,6 @@
}
else
opt->answer = G_store(string);
-
- add_exclusive(opt->key, 0, opt->exclusive);
}
static void check_opts(void)
Modified: grass/trunk/lib/gis/parser_local_proto.h
===================================================================
--- grass/trunk/lib/gis/parser_local_proto.h 2014-06-05 21:49:09 UTC (rev 60726)
+++ grass/trunk/lib/gis/parser_local_proto.h 2014-06-06 07:47:53 UTC (rev 60727)
@@ -11,13 +11,6 @@
struct Item *next_item;
};
-struct Exclusive {
- int allocated_keys;
- int n_keys;
- char *name;
- char **keys;
-};
-
struct state {
int no_interactive;
int n_opts;
@@ -40,10 +33,6 @@
struct Option first_option;
struct Option *current_option;
- int allocated_exclusive;
- int n_exclusive;
- struct Exclusive *exclusive;
-
struct Item first_item;
struct Item *current_item;
int n_items;
More information about the grass-commit
mailing list