[GRASS-SVN] r65181 - grass/trunk/display/d.mon

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 3 07:11:53 PDT 2015


Author: martinl
Date: 2015-05-03 07:11:53 -0700 (Sun, 03 May 2015)
New Revision: 65181

Modified:
   grass/trunk/display/d.mon/proto.h
   grass/trunk/display/d.mon/start.c
Log:
d.mon: write WIDTH/HEIGHT variables to env file also on default value 


Modified: grass/trunk/display/d.mon/proto.h
===================================================================
--- grass/trunk/display/d.mon/proto.h	2015-05-03 11:24:32 UTC (rev 65180)
+++ grass/trunk/display/d.mon/proto.h	2015-05-03 14:11:53 UTC (rev 65181)
@@ -1,3 +1,9 @@
+#ifndef __PROTO_H__
+#define __PROTO_H__
+#define DEFAULT_WIDTH 640
+#define DEFAULT_HEIGHT 480
+
+
 /* start */
 int start_mon(const char *, const char *, int, int, int,
 	      const char *, int, int, int);
@@ -15,3 +21,4 @@
 void list_cmd(const char *, FILE *);
 char *get_path(const char *, int);
 void list_files(const char *, FILE *);
+#endif

Modified: grass/trunk/display/d.mon/start.c
===================================================================
--- grass/trunk/display/d.mon/start.c	2015-05-03 11:24:32 UTC (rev 65180)
+++ grass/trunk/display/d.mon/start.c	2015-05-03 14:11:53 UTC (rev 65181)
@@ -115,6 +115,7 @@
 {
     char *mon_path;
     char *out_file, *env_file, *cmd_file;
+    char *env_width, *env_height;
     char  buf[1024];
     char file_path[GPATH_MAX];
     char *pycode;
@@ -214,16 +215,14 @@
     write(fd, buf, strlen(buf));
     sprintf(buf, "GRASS_RENDER_FILE_READ=TRUE\n");
     write(fd, buf, strlen(buf));
-    if (width > 0 || getenv("GRASS_RENDER_WIDTH")) {
-	sprintf(buf, "GRASS_RENDER_WIDTH=%d\n",
-                width > 0 ? width : atoi(getenv("GRASS_RENDER_WIDTH")));
-	write(fd, buf, strlen(buf));
-    }
-    if (height > 0 || getenv("GRASS_RENDER_HEIGHT")) {
-	sprintf(buf, "GRASS_RENDER_HEIGHT=%d\n",
-                height > 0? height : atoi(getenv("GRASS_RENDER_HEIGHT")));
-	write(fd, buf, strlen(buf));
-    }
+    env_width = getenv("GRASS_RENDER_WIDTH");
+    sprintf(buf, "GRASS_RENDER_WIDTH=%d\n",
+            width > 0 ? width : (env_width ? atoi(env_width) : DEFAULT_WIDTH));
+    write(fd, buf, strlen(buf));
+    env_height = getenv("GRASS_RENDER_HEIGHT");
+    sprintf(buf, "GRASS_RENDER_HEIGHT=%d\n",
+            height > 0 ? height : (env_height ? atoi(env_height) : DEFAULT_HEIGHT));
+    write(fd, buf, strlen(buf));
     if (bgcolor) {
 	if (strcmp(bgcolor, "none") == 0)
 	    sprintf(buf, "GRASS_RENDER_TRANSPARENT=TRUE\n");



More information about the grass-commit mailing list