Bläddra i källkod

Only treat an argument as an option if there is no space before the first '='

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32259 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 17 år sedan
förälder
incheckning
4cde542b8d
1 ändrade filer med 17 tillägg och 1 borttagningar
  1. 17 1
      lib/gis/parser.c

+ 17 - 1
lib/gis/parser.c

@@ -121,6 +121,7 @@ static int show_options(int ,const char *);
 static int show(const char *,int);
 static int set_flag (int);
 static int contains (const char *,int);
+static int is_option(const char *);
 static int set_option( char *);
 static int check_opts();
 static int check_an_opt(const char *, int , const char *,const char *);
@@ -938,7 +939,7 @@ int G_parser (int argc, char **argv)
 
 			}
 			/* If we see standard option format (option=val) */
-			else if (contains(ptr, '='))
+			else if (is_option(ptr))
 			{
 				error += set_option(ptr) ;
 				need_first_opt = 0 ;
@@ -2149,6 +2150,21 @@ static int contains (const char *s, int c)
 	return(0) ;
 }
 
+static int is_option(const char *string)
+{
+	const char *p = strchr(string, '=');
+
+	if (!p)
+		return 0;
+	if (p == string)
+		return 0;
+	p--;
+	if (*p == ' ' || *p == '\t')
+		return 0;
+
+	return 1;
+}
+
 static int set_option (char *string)
 {
 	struct Option *at_opt = NULL;