Browse Source

ps.map: require input=file/-
some minor changes in messages


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@45581 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 years ago
parent
commit
1003287d82
2 changed files with 23 additions and 11 deletions
  1. 19 8
      ps/ps.map/main.c
  2. 4 3
      ps/ps.map/ps_raster.c

+ 19 - 8
ps/ps.map/main.c

@@ -133,6 +133,8 @@ int main(int argc, char *argv[])
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
     
+    G_zero(&PS, sizeof(struct PS_data));
+    
     /* Print papers */
     if (pflag->answer) {
 	print_papers();
@@ -175,7 +177,7 @@ int main(int argc, char *argv[])
     ct.fontsize = 10;
     ct.cols = 1;
     tracefd = NULL;
-    inputfd = stdin;
+    inputfd = NULL;
     labels.count = 0;
     labels.other = NULL;
     can_reset_scale = 1;
@@ -183,8 +185,7 @@ int main(int argc, char *argv[])
     grp.do_group = 0;
     brd.R = brd.G = brd.B = 0.;
     brd.width = 1.;
-
-    G_zero(&PS, sizeof(struct PS_data));
+    
     PS.grid_color = BLACK;
     PS.min_y = 72.0 * (PS.page_height - PS.top_marg);
     PS.set_y = 100.0 * PS.min_y;
@@ -196,12 +197,22 @@ int main(int argc, char *argv[])
      * reset_map_location() to reset map size to fit to paper */
     
     /* arguments */
-    if (input_file->answer && strcmp(input_file->answer, "-")) {
-	if (NULL == freopen(input_file->answer, "r", stdin))
-	    G_fatal_error(_("Unable to open file '%s': %s"), 
-			  input_file->answer, strerror(errno));
+    if (input_file->answer) {
+	if (strcmp(input_file->answer, "-")) {
+	    inputfd = fopen(input_file->answer, "r");
+	    if (!inputfd)
+		G_fatal_error(_("Unable to open file '%s': %s"), 
+			      input_file->answer, strerror(errno));
+	}
+	else {
+	    inputfd = stdin;
+	}
     }
-
+    else {
+	G_fatal_error(_("Required parameter <%s> not set:\n\t(%s)"),
+		      input_file->key, input_file->label);
+    }
+    
     if (copies->answer) {
 	if (sscanf(copies->answer, "%d", &ps_copies) != 1) {
 	    ps_copies = 1;

+ 4 - 3
ps/ps.map/ps_raster.c

@@ -99,10 +99,11 @@ int PS_raster_plot(void)
 
     /* let user know what's happenning */
     if (PS.do_raster)
-	G_message(_("Reading raster map <%s in %s> ..."),
-		  PS.cell_name, PS.cell_mapset);
+	G_message(_("Reading raster map <%s>..."),
+		  G_fully_qualified_name(PS.cell_name, PS.cell_mapset));
     else
-	G_message(_("Reading raster maps in group <%s> ..."), grp.group_name);
+	G_message(_("Reading raster maps in group <%s>..."),
+		  grp.group_name);
 
     /* build the image RGB string */
     if (PS.do_raster) {