浏览代码

Check option types

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38629 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 年之前
父节点
当前提交
552e2926c0
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      lib/gis/parser.c

+ 10 - 1
lib/gis/parser.c

@@ -2086,7 +2086,7 @@ static int check_opts(void)
     while (opt != NULL) {
 	/* Check answer against options if any */
 
-	if (opt->options && opt->answer) {
+	if (opt->answer) {
 	    if (opt->multiple == 0)
 		error += check_an_opt(opt->key, opt->type,
 				      opt->options, opt->opts, &opt->answer);
@@ -2166,6 +2166,9 @@ static int check_int(const char *ans, const char **opts)
     if (sscanf(ans, "%d", &d) != 1)
 	return MISSING_VALUE;
 
+    if (!opts)
+	return 0;
+
     for (i = 0; opts[i]; i++) {
 	const char *opt = opts[i];
 	int lo, hi;
@@ -2207,6 +2210,9 @@ static int check_double(const char *ans, const char **opts)
     if (sscanf(ans, "%lf", &d) != 1)
 	return MISSING_VALUE;
 
+    if (!opts)
+	return 0;
+
     for (i = 0; opts[i]; i++) {
 	const char *opt = opts[i];
 	double lo, hi;
@@ -2246,6 +2252,9 @@ static int check_string(const char *ans, const char **opts, int *result)
     int found = 0;
     int i;
 
+    if (!opts)
+	return 0;
+
     for (i = 0; opts[i]; i++) {
 	if (strcmp(ans, opts[i]) == 0)
 	    return 0;