[GRASS-SVN] r46378 - grass/branches/releasebranch_6_4/ps/ps.map

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 23 04:12:43 EDT 2011


Author: hamish
Date: 2011-05-23 01:12:43 -0700 (Mon, 23 May 2011)
New Revision: 46378

Modified:
   grass/branches/releasebranch_6_4/ps/ps.map/main.c
   grass/branches/releasebranch_6_4/ps/ps.map/map_setup.c
Log:
don't require output file if the -b flag is used.
G_important_message() does not survive --quiet, so use fprintf(stderr,...) instead. (match parser.c)


Modified: grass/branches/releasebranch_6_4/ps/ps.map/main.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/main.c	2011-05-23 07:38:50 UTC (rev 46377)
+++ grass/branches/releasebranch_6_4/ps/ps.map/main.c	2011-05-23 08:12:43 UTC (rev 46378)
@@ -259,16 +259,20 @@
 	copies_set = 1;
     }
 
-    if (output_file->answer) {
-	if ((PS.fp = fopen(output_file->answer, "w")) == NULL)
-	    G_fatal_error("%s - %s: %s", G_program_name(),
-			  output_file->answer, strerror(errno));
+    if (!bflag->answer) {
+	if (output_file->answer) {
+	    if ((PS.fp = fopen(output_file->answer, "w")) == NULL)
+		G_fatal_error("%s - %s: %s", G_program_name(),
+			      output_file->answer, strerror(errno));
+	}
+	else {
+	    fprintf(stderr, _("ERROR: Required parameter <%s> not set:\n\t(%s)\n"),
+		    output_file->key, output_file->description);
+	    usage(1);
+	}
     }
-    else {
-	G_important_message(_("\nERROR: Required parameter <%s> not set:\n    (%s).\n"),
-		  output_file->key, output_file->description);
-	usage(1);
-    }
+    else
+	PS.fp = NULL;
 
 
     /* get current mapset */
@@ -730,7 +734,6 @@
 		PS.page_height - (PS.map_bot / 72.0), PS.map_right / 72.0,
 		PS.page_height - (PS.map_top / 72.0));
 		/* +/- 0.5 ? see ps.map.c brd.* */
-	unlink(output_file->answer); /* fixme: don't open it in the first place */
 	exit(EXIT_SUCCESS);
     }
 

Modified: grass/branches/releasebranch_6_4/ps/ps.map/map_setup.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/map_setup.c	2011-05-23 07:38:50 UTC (rev 46377)
+++ grass/branches/releasebranch_6_4/ps/ps.map/map_setup.c	2011-05-23 08:12:43 UTC (rev 46378)
@@ -105,6 +105,11 @@
        PS.map_bot, PS.map_left, PS.map_right);
      */
 
+    /* no need to go on if we're just here for a look-see. (-b flag) */
+    if (!PS.fp)
+	return 0;
+
+
     /* save original graphics state */
     fprintf(PS.fp, "gsave ");
 



More information about the grass-commit mailing list