[GRASS-SVN] r63465 - grass/trunk/display/d.mon
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Dec 10 01:28:58 PST 2014
Author: martinl
Date: 2014-12-10 01:28:58 -0800 (Wed, 10 Dec 2014)
New Revision: 63465
Modified:
grass/trunk/display/d.mon/start.c
Log:
d.mon: use always full path for output files (even if using default file name) - #2509
Modified: grass/trunk/display/d.mon/start.c
===================================================================
--- grass/trunk/display/d.mon/start.c 2014-12-10 09:21:11 UTC (rev 63464)
+++ grass/trunk/display/d.mon/start.c 2014-12-10 09:28:58 UTC (rev 63465)
@@ -2,6 +2,7 @@
#include <string.h>
#include <grass/gis.h>
#include <grass/spawn.h>
+#include <grass/display.h>
#include <grass/glocale.h>
#include "proto.h"
@@ -14,11 +15,23 @@
void start(const char *name, const char *output)
{
char *env_name, output_path[GPATH_MAX];
+ const char *output_name;
- if (!output)
- return;
+ if (!output) {
+ if (D_open_driver() != 0)
+ G_fatal_error(_("No graphics device selected. "
+ "Use d.mon to select graphics device."));
+ output_name = D_get_file();
+ if (!output_name)
+ return;
+ D_close_driver();
+ }
+ else {
+ output_name = output;
+ }
- if (!strchr(output, HOST_DIRSEP)) { /* relative path */
+
+ if (!strchr(output_name, HOST_DIRSEP)) { /* relative path */
char *ptr;
if (!getcwd(output_path, PATH_MAX))
@@ -28,13 +41,13 @@
*(ptr++) = HOST_DIRSEP;
*(ptr) = '\0';
}
- strcat(output_path, output);
+ strcat(output_path, output_name);
G_message(_("Output file: %s"), output_path);
}
else {
- strcpy(output_path, output); /* already full path */
+ strcpy(output_path, output_name); /* already full path */
}
-
+
env_name = NULL;
G_asprintf(&env_name, "MONITOR_%s_MAPFILE", G_store_upper(name));
G_setenv(env_name, output_path);
More information about the grass-commit
mailing list