浏览代码

gislib: allow opt='-' also for multiple options (reserved for standard input/output)

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

+ 10 - 1
lib/gis/parser.c

@@ -1036,6 +1036,10 @@ static int check_int(const char *ans, const char **opts)
 {
     int d, i;
 
+    /* "-" is reserved for standard input */
+    if (strcmp(ans, "-") == 0)
+	return 0;
+
     if (sscanf(ans, "%d", &d) != 1)
 	return MISSING_VALUE;
 
@@ -1080,6 +1084,10 @@ static int check_double(const char *ans, const char **opts)
     double d;
     int i;
 
+    /* "-" is reserved for standard input */
+    if (strcmp(ans, "-") == 0)
+	return 0;
+    
     if (sscanf(ans, "%lf", &d) != 1)
 	return MISSING_VALUE;
 
@@ -1237,7 +1245,8 @@ static void check_multiple_opts(void)
     err = NULL;
     opt = &st->first_option;
     while (opt) {
-	if (opt->answer && opt->key_desc) {
+	/* "-" is reserved from standard input/output */
+	if (opt->answer && strcmp(opt->answer, "-") && opt->key_desc) {
 	    /* count commas */
 	    n_commas = 1;
 	    for (ptr = opt->key_desc; *ptr != '\0'; ptr++)