[GRASS-SVN] r34420 - grass/branches/develbranch_6/raster/r.in.poly

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Nov 21 06:20:24 EST 2008


Author: hamish
Date: 2008-11-21 06:20:24 -0500 (Fri, 21 Nov 2008)
New Revision: 34420

Modified:
   grass/branches/develbranch_6/raster/r.in.poly/main.c
   grass/branches/develbranch_6/raster/r.in.poly/poly2rast.c
Log:
input=- reads from stdin

Modified: grass/branches/develbranch_6/raster/r.in.poly/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.in.poly/main.c	2008-11-21 00:42:56 UTC (rev 34419)
+++ grass/branches/develbranch_6/raster/r.in.poly/main.c	2008-11-21 11:20:24 UTC (rev 34420)
@@ -32,7 +32,8 @@
 
 
     input = G_define_standard_option(G_OPT_F_INPUT);
-
+    input->description = _("Name of input file; or \"-\" to read from stdin");
+ 
     output = G_define_standard_option(G_OPT_R_OUTPUT);
 
     title = G_define_option();

Modified: grass/branches/develbranch_6/raster/r.in.poly/poly2rast.c
===================================================================
--- grass/branches/develbranch_6/raster/r.in.poly/poly2rast.c	2008-11-21 00:42:56 UTC (rev 34419)
+++ grass/branches/develbranch_6/raster/r.in.poly/poly2rast.c	2008-11-21 11:20:24 UTC (rev 34420)
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <string.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
 #include "format.h"
@@ -18,10 +19,16 @@
     int pass, npasses;
     struct History history;
 
-    ifd = fopen(input_file, "r");
+
+   /* open input file */
+    if (strcmp("-", input_file) == 0)
+	ifd = stdin;
+    else
+	ifd = fopen(input_file, "r");
+
     if (ifd == NULL) {
 	perror(input_file);
-	exit(1);
+	exit(EXIT_FAILURE);
     }
 
     rfd = G_open_cell_new(raster_map);
@@ -31,10 +38,13 @@
     if (title == NULL)
 	title = "";
     G_strip(title);
+
     G_init_cats((CELL) 0, title, &labels);
+
     format = getformat(ifd);
     npasses = begin_rasterization(nrows, format);
     pass = 0;
+
     do {
 	pass++;
 	if (npasses > 1)
@@ -61,6 +71,7 @@
 	}
 
 	G_message(_("Writing raster map..."));
+
 	stat = output_raster(rfd);
     } while (stat == 0);
     /* stat: 0 means repeat



More information about the grass-commit mailing list