[GRASS-SVN] r68061 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 15 01:56:29 PDT 2016


Author: hcho
Date: 2016-03-15 01:56:28 -0700 (Tue, 15 Mar 2016)
New Revision: 68061

Modified:
   grass/trunk/lib/gis/parser.c
Log:
G_recreate_command: Add empty answers.
Fix the command history for e.g., v.edit where="". Without this fix, where="" is not included, which makes an invalid command.


Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c	2016-03-15 08:48:28 UTC (rev 68060)
+++ grass/trunk/lib/gis/parser.c	2016-03-15 08:56:28 UTC (rev 68061)
@@ -706,7 +706,25 @@
 
     opt = &st->first_option;
     while (st->n_opts && opt) {
-	if (opt->answer && opt->answers && opt->answers[0]) {
+	if (opt->answer && opt->answer[0] == '\0') {	/* answer = "" */
+	    slen = strlen(opt->key) + 4;	/* +4 for: ' ' = " " */
+	    if (len + slen >= nalloced) {
+		nalloced += (nalloced + 1024 > len + slen) ? 1024 : slen + 1;
+		buff = G_realloc(buff, nalloced);
+		cur = buff + len;
+	    }
+	    strcpy(cur, " ");
+	    cur++;
+	    strcpy(cur, opt->key);
+	    cur = strchr(cur, '\0');
+	    strcpy(cur, "=");
+	    cur++;
+	    if (opt->type == TYPE_STRING) {
+		strcpy(cur, "\"\"");
+		cur += 2;
+	    }
+	    len = cur - buff;
+	} else if (opt->answer && opt->answers && opt->answers[0]) {
 	    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