[GRASS-SVN] r61442 - grass/branches/releasebranch_7_0/display/d.mon

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 28 21:56:09 PDT 2014


Author: neteler
Date: 2014-07-28 21:56:09 -0700 (Mon, 28 Jul 2014)
New Revision: 61442

Modified:
   grass/branches/releasebranch_7_0/display/d.mon/start.c
   grass/branches/releasebranch_7_0/display/d.mon/stop.c
Log:
d.mon: removed unnecessary variables (trunk, r60205); prevent starting the same monitor multiple times (trunk, r60207)

Modified: grass/branches/releasebranch_7_0/display/d.mon/start.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.mon/start.c	2014-07-29 04:41:35 UTC (rev 61441)
+++ grass/branches/releasebranch_7_0/display/d.mon/start.c	2014-07-29 04:56:09 UTC (rev 61442)
@@ -13,16 +13,13 @@
 /* start file-based monitor */
 void start(const char *name, const char *output)
 {
-    char *u_name;
     char *env_name;
 
     if (!output)
 	return;
 
-    u_name = G_store_upper(name);
-
     env_name = NULL;
-    G_asprintf(&env_name, "MONITOR_%s_MAPFILE", u_name);
+    G_asprintf(&env_name, "MONITOR_%s_MAPFILE", G_store_upper(name));
     G_setenv(env_name, output);
 }
 
@@ -31,14 +28,11 @@
 	      const char *env_value, const char *cmd_value,
 	      int width, int height)
 {
-    char *u_name;
     char progname[GPATH_MAX];
     char *env_name, *map_value, str_width[1024], str_height[1024];
 
-    u_name = G_store_upper(name);
-
     env_name = NULL;
-    G_asprintf(&env_name, "MONITOR_%s_MAPFILE", u_name);
+    G_asprintf(&env_name, "MONITOR_%s_MAPFILE", G_store_upper(name));
     G_asprintf(&map_value, "%s.ppm", tempfile);
     G_setenv(env_name, map_value);
     /* close(creat(map_value, 0666)); */
@@ -64,16 +58,21 @@
 	      int width, int height, const char *bgcolor,
 	      int truecolor)
 {
-    const char *curr_mon;
     char *u_name;
     char *env_name, *env_value, *cmd_value;
     char *tempfile, buf[1024];
     int env_fd;
-    
-    curr_mon = G__getenv("MONITOR");
-    if (curr_mon && strcmp(curr_mon, name) == 0 && check_mon(curr_mon))
-	G_fatal_error(_("Monitor <%s> already running"), name);
-    
+
+    if (check_mon(name)) {
+        const char *curr_mon;
+
+        curr_mon = G__getenv("MONITOR");
+	if (select && (!curr_mon || strcmp(curr_mon, name) != 0))
+	    G_setenv("MONITOR", name);
+
+        G_fatal_error(_("Monitor <%s> already running"), name);
+    }
+
     tempfile = G_tempfile();
 
     u_name = G_store_upper(name);
@@ -115,7 +114,7 @@
     G_setenv(env_name, cmd_value);
     close(creat(cmd_value, 0666));
 
-    G_verbose_message(_("Staring monitor <%s> with env file '%s'"), name, env_value);
+    G_verbose_message(_("Starting monitor <%s> with env file '%s'"), name, env_value);
     if (G_verbose() > G_verbose_std()) {
         FILE *fd;
         

Modified: grass/branches/releasebranch_7_0/display/d.mon/stop.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.mon/stop.c	2014-07-29 04:41:35 UTC (rev 61441)
+++ grass/branches/releasebranch_7_0/display/d.mon/stop.c	2014-07-29 04:56:09 UTC (rev 61442)
@@ -26,14 +26,11 @@
 
 int stop(const char *name)
 {
-    char *u_name;
     char *env_name;
     const char *env_file;
 
-    u_name = G_store_upper(name);
-
     env_name = NULL;
-    G_asprintf(&env_name, "MONITOR_%s_ENVFILE", u_name);
+    G_asprintf(&env_name, "MONITOR_%s_ENVFILE", G_store_upper(name));
     
     env_file = G__getenv(env_name);
     if (!env_file)
@@ -46,14 +43,11 @@
 
 int stop_wx(const char *name)
 {
-    char *u_name;
     char *env_name;
     const char *pid;
 
-    u_name = G_store_upper(name);
-
     env_name = NULL;
-    G_asprintf(&env_name, "MONITOR_%s_PID", u_name);
+    G_asprintf(&env_name, "MONITOR_%s_PID", G_store_upper(name));
     
     pid = G__getenv(env_name);
     if (!pid) {



More information about the grass-commit mailing list