[GRASS-SVN] r51157 - sandbox/martinl/v.test

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 23 17:06:34 EDT 2012


Author: martinl
Date: 2012-03-23 14:06:34 -0700 (Fri, 23 Mar 2012)
New Revision: 51157

Modified:
   sandbox/martinl/v.test/main.c
Log:
v.test: add shell script style output


Modified: sandbox/martinl/v.test/main.c
===================================================================
--- sandbox/martinl/v.test/main.c	2012-03-23 18:00:11 UTC (rev 51156)
+++ sandbox/martinl/v.test/main.c	2012-03-23 21:06:34 UTC (rev 51157)
@@ -41,7 +41,7 @@
 	struct Option *input, *num, *type, *field, *id;
     } opt;
     struct {
-	struct Flag *s, *r, *l;
+	struct Flag *s, *r, *l, *g;
     } flag;
     
     int i, line, number;
@@ -92,6 +92,10 @@
     flag.l->key = '1';
     flag.l->description = _("Force level 1 (without topology)");
 
+    flag.g = G_define_flag();
+    flag.g->key = 'g';
+    flag.g->description = _("Shell script style output");
+    
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
     
@@ -224,25 +228,30 @@
 	}
     }
     
-    if (npoints > 0)
-	fprintf(stdout, "npoints=%d\t", npoints);
-    if (nlines > 0)
-	fprintf(stdout, "nlines=%d\t", nlines);
-    if (ncentroids > 0)
-	fprintf(stdout, "ncentroids=%d\t", ncentroids);
-    if (nboundaries > 0)
-	fprintf(stdout, "nboundaries=%d\t", nboundaries);
-    
-    fprintf(stdout, "\n");
-    fprintf(stdout, SEP);
-    if (npoints + nlines + ncentroids + nboundaries > 0) { 
-	fprintf(stdout, "%10d msec\t(%s)\n", (int) (sdiff / number),
-		Vect_maptype_info(&Map));
+    if (flag.g->answer) {
+	fprintf(stdout, "%d\n", (int) (sdiff / number));
     }
     else {
-	G_message(_("No feature read"));
+	if (npoints > 0)
+	    fprintf(stdout, "npoints=%d\t", npoints);
+	if (nlines > 0)
+	    fprintf(stdout, "nlines=%d\t", nlines);
+	if (ncentroids > 0)
+	    fprintf(stdout, "ncentroids=%d\t", ncentroids);
+	if (nboundaries > 0)
+	    fprintf(stdout, "nboundaries=%d\t", nboundaries);
+	
+	fprintf(stdout, "\n");
+	fprintf(stdout, SEP);
+	if (npoints + nlines + ncentroids + nboundaries > 0) { 
+	    fprintf(stdout, "%10d msec\t(%s)\n", (int) (sdiff / number),
+		    Vect_maptype_info(&Map));
+	}
+	else {
+	    G_message(_("No feature read"));
+	}
+	fprintf(stdout, SEP);
     }
-    fprintf(stdout, SEP);
     
     Vect_close(&Map);
     



More information about the grass-commit mailing list