[GRASS-SVN] r61436 - in grass/branches/releasebranch_7_0: . display/d.mon gui/wxpython/mapdisp include/defs lib/display lib/gis scripts/d.out.file scripts/d.redraw

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 28 15:17:21 PDT 2014


Author: neteler
Date: 2014-07-28 15:17:21 -0700 (Mon, 28 Jul 2014)
New Revision: 61436

Modified:
   grass/branches/releasebranch_7_0/
   grass/branches/releasebranch_7_0/display/d.mon/list.c
   grass/branches/releasebranch_7_0/display/d.mon/start.c
   grass/branches/releasebranch_7_0/display/d.mon/stop.c
   grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/main.py
   grass/branches/releasebranch_7_0/include/defs/gis.h
   grass/branches/releasebranch_7_0/lib/display/r_raster.c
   grass/branches/releasebranch_7_0/lib/gis/strings.c
   grass/branches/releasebranch_7_0/scripts/d.out.file/d.out.file.py
   grass/branches/releasebranch_7_0/scripts/d.redraw/d.redraw.py
Log:
Convert MONITOR_*_*FILE variable names to upper case (trunk, r60203 + r60204)


Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
   - /grass/trunk:59505,59646,60100-60101,60215,60219,60278,60376,60610,60625,60807,60835,60936-60937,61159-61160,61165,61275,61288,61290,61292,61294,61301
   + /grass/trunk:59505,59646,60100-60101,60203-60204,60215,60219,60278,60376,60610,60625,60807,60835,60936-60937,61159-61160,61165,61275,61288,61290,61292,61294,61301

Modified: grass/branches/releasebranch_7_0/display/d.mon/list.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.mon/list.c	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/display/d.mon/list.c	2014-07-28 22:17:21 UTC (rev 61436)
@@ -25,7 +25,9 @@
 		strcmp(tokens[2], "ENVFILE") != 0)
 		continue;
 	    *list = G_realloc(*list, (*n + 1) * sizeof(char *));
-	    (*list)[*n] = G_store(tokens[1]);
+	    /* GRASS variable names are upper case, but monitor names are lower
+	     * case. */
+	    (*list)[*n] = G_store_lower(tokens[1]);
 	    (*n)++;
 	    G_free_tokens(tokens);
 	    tokens = NULL;
@@ -59,7 +61,7 @@
     const char *str;
     
     env_name = NULL;
-    G_asprintf(&env_name, "MONITOR_%s_ENVFILE", name);
+    G_asprintf(&env_name, "MONITOR_%s_ENVFILE", G_store_upper(name));
     str = G__getenv(env_name);
     if (!str)
 	return FALSE;
@@ -76,7 +78,7 @@
     FILE *fd;
 
     cmd_name = NULL;
-    G_asprintf(&cmd_name, "MONITOR_%s_CMDFILE", name);
+    G_asprintf(&cmd_name, "MONITOR_%s_CMDFILE", G_store_upper(name));
     cmd_value = G__getenv(cmd_name);
     if (!cmd_value)
 	G_fatal_error(_("Command file not found"));

Modified: grass/branches/releasebranch_7_0/display/d.mon/start.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.mon/start.c	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/display/d.mon/start.c	2014-07-28 22:17:21 UTC (rev 61436)
@@ -13,13 +13,16 @@
 /* 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", name);
+    G_asprintf(&env_name, "MONITOR_%s_MAPFILE", u_name);
     G_setenv(env_name, output);
 }
 
@@ -28,11 +31,14 @@
 	      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", name);
+    G_asprintf(&env_name, "MONITOR_%s_MAPFILE", u_name);
     G_asprintf(&map_value, "%s.ppm", tempfile);
     G_setenv(env_name, map_value);
     /* close(creat(map_value, 0666)); */
@@ -59,6 +65,7 @@
 	      int truecolor)
 {
     const char *curr_mon;
+    char *u_name;
     char *env_name, *env_value, *cmd_value;
     char *tempfile, buf[1024];
     int env_fd;
@@ -69,8 +76,10 @@
     
     tempfile = G_tempfile();
 
+    u_name = G_store_upper(name);
+
     env_name = env_value = NULL;
-    G_asprintf(&env_name, "MONITOR_%s_ENVFILE", name);
+    G_asprintf(&env_name, "MONITOR_%s_ENVFILE", u_name);
     G_asprintf(&env_value, "%s.env", tempfile);
     G_setenv(env_name, env_value);
     env_fd = creat(env_value, 0666);
@@ -101,7 +110,7 @@
     close(env_fd);
 
     cmd_value = NULL;
-    G_asprintf(&env_name, "MONITOR_%s_CMDFILE", name);
+    G_asprintf(&env_name, "MONITOR_%s_CMDFILE", u_name);
     G_asprintf(&cmd_value, "%s.cmd", tempfile);
     G_setenv(env_name, cmd_value);
     close(creat(cmd_value, 0666));

Modified: grass/branches/releasebranch_7_0/display/d.mon/stop.c
===================================================================
--- grass/branches/releasebranch_7_0/display/d.mon/stop.c	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/display/d.mon/stop.c	2014-07-28 22:17:21 UTC (rev 61436)
@@ -26,11 +26,14 @@
 
 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", name);
+    G_asprintf(&env_name, "MONITOR_%s_ENVFILE", u_name);
     
     env_file = G__getenv(env_name);
     if (!env_file)
@@ -43,11 +46,14 @@
 
 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", name);
+    G_asprintf(&env_name, "MONITOR_%s_PID", u_name);
     
     pid = G__getenv(env_name);
     if (!pid) {
@@ -71,11 +77,13 @@
 void clean_env(const char *name)
 {
     int i;
+    char *u_name;
     const char *env_prefix = "MONITOR_";
     const char *env;
     int env_prefix_len;
     char **tokens;
-    
+
+    u_name = G_store_upper(name);
     env_prefix_len = strlen(env_prefix);
     
     tokens = NULL;
@@ -85,7 +93,7 @@
 	
 	tokens = G_tokenize(env, "_");
 	if (G_number_of_tokens(tokens) != 3 ||
-	    strcmp(tokens[1], name) != 0)
+	    strcmp(tokens[1], u_name) != 0)
 	    continue;
 	G_unsetenv(env);
 	i--; /* env has been removed for the list */

Modified: grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/main.py	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/gui/wxpython/mapdisp/main.py	2014-07-28 22:17:21 UTC (rev 61436)
@@ -420,7 +420,7 @@
     grass.verbose(_("Starting map display <%s>...") % (monName))
 
     RunCommand('g.gisenv',
-               set = 'MONITOR_%s_PID=%d' % (monName, os.getpid()))
+               set = 'MONITOR_%s_PID=%d' % (monName.upper(), os.getpid()))
     
     gmMap = MapApp(0)
     # set title
@@ -432,7 +432,7 @@
 
     # clean up GRASS env variables
     env = grass.gisenv()
-    env_name = 'MONITOR_%s' % monName
+    env_name = 'MONITOR_%s' % monName.upper()
     for key in env.keys():
         if key.find(env_name) == 0:
             RunCommand('g.gisenv',

Modified: grass/branches/releasebranch_7_0/include/defs/gis.h
===================================================================
--- grass/branches/releasebranch_7_0/include/defs/gis.h	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/include/defs/gis.h	2014-07-28 22:17:21 UTC (rev 61436)
@@ -612,6 +612,8 @@
 int G_strcasecmp(const char *, const char *);
 int G_strncasecmp(const char *, const char *, int);
 char *G_store(const char *);
+char *G_store_upper(const char *);
+char *G_store_lower(const char *);
 char *G_strchg(char *, char, char);
 char *G_str_replace(const char *, const char *, const char *);
 void G_strip(char *);

Modified: grass/branches/releasebranch_7_0/lib/display/r_raster.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/display/r_raster.c	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/lib/display/r_raster.c	2014-07-28 22:17:21 UTC (rev 61436)
@@ -112,12 +112,16 @@
     } else if (m) {
 	char *env;
 	const char *v;
+	char *u_m;
 	
 	if (p)
 	    G_warning(_("%s variable defined, %s ignored"),
 		      "MONITOR", "GRASS_RENDER_IMMEDIATE");
+	/* GRASS variable names should be upper case. */
+	u_m = G_store_upper(m);
+
 	env = NULL;
-	G_asprintf(&env, "MONITOR_%s_MAPFILE", m);
+	G_asprintf(&env, "MONITOR_%s_MAPFILE", u_m);
 	v = G__getenv(env);
 	p = m;
 
@@ -128,7 +132,7 @@
 		G_putenv("GRASS_PNGFILE", v);
 	}
 	
-	G_asprintf(&env, "MONITOR_%s_ENVFILE", m);
+	G_asprintf(&env, "MONITOR_%s_ENVFILE", u_m);
 	v = G__getenv(env);
 	if (v) 
 	    read_env_file(v);
@@ -177,7 +181,8 @@
   \brief Append command to the cmd file
 
   Cmd file is created by d.mon by defining GRASS variable
-  \c MONITOR_<name>_CMDFILE, where \c \<name\> is name of the monitor.
+  \c MONITOR_<name>_CMDFILE, where \c \<name\> is the upper case name of
+  the monitor.
 
   Command string is usually generated by G_recreate_command(), NULL is
   used to clean up list of commands (see d.erase command).
@@ -191,7 +196,7 @@
 int D_save_command(const char *cmd)
 {
     const char *mon_name, *mon_cmd;
-    char *env, *flag;
+    char *env, *flag, *u_mon_name;
     FILE *fd;
 
     G_debug(1, "D_save_command(): %s", cmd);
@@ -203,8 +208,11 @@
 	 getenv("GRASS_RENDER_IMMEDIATE")))
 	return 0;
 
+    /* GRASS variable names should be upper case. */
+    u_mon_name = G_store_upper(mon_name);
+
     env = NULL;
-    G_asprintf(&env, "MONITOR_%s_CMDFILE", mon_name);
+    G_asprintf(&env, "MONITOR_%s_CMDFILE", u_mon_name);
     mon_cmd = G__getenv(env);
     if (!mon_cmd)
 	return 0;

Modified: grass/branches/releasebranch_7_0/lib/gis/strings.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/gis/strings.c	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/lib/gis/strings.c	2014-07-28 22:17:21 UTC (rev 61436)
@@ -100,6 +100,54 @@
 }
 
 /*!
+  \brief Copy string to allocated memory and convert copied string
+  to upper case
+  
+  This routine allocates enough memory to hold the string <b>s</b>,
+  copies <em>s</em> to the allocated memory, and returns a pointer
+  to the allocated memory.
+  
+  If <em>s</em> is NULL then empty string is returned.
+  
+  \param s string
+ 
+  \return pointer to newly allocated upper case string
+*/
+char *G_store_upper(const char *s)
+{
+    char *u_s;
+
+    u_s = G_store(s);
+    G_str_to_upper(u_s);
+
+    return u_s;
+}
+
+/*!
+  \brief Copy string to allocated memory and convert copied string
+  to lower case
+  
+  This routine allocates enough memory to hold the string <b>s</b>,
+  copies <em>s</em> to the allocated memory, and returns a pointer
+  to the allocated memory.
+  
+  If <em>s</em> is NULL then empty string is returned.
+  
+  \param s string
+ 
+  \return pointer to newly allocated lower case string
+*/
+char *G_store_lower(const char *s)
+{
+    char *l_s;
+
+    l_s = G_store(s);
+    G_str_to_lower(l_s);
+
+    return l_s;
+}
+
+/*!
   \brief Replace all occurencies of character in string bug with new
   
   \param[in,out] bug base string

Modified: grass/branches/releasebranch_7_0/scripts/d.out.file/d.out.file.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/d.out.file/d.out.file.py	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/scripts/d.out.file/d.out.file.py	2014-07-28 22:17:21 UTC (rev 61436)
@@ -44,7 +44,7 @@
     options, flags = gcore.parser()
     gisenv = gcore.gisenv()
     if 'MONITOR' in gisenv:
-        cmd_file = gisenv['MONITOR_{monitor}_CMDFILE'.format(monitor=gisenv['MONITOR'])]
+        cmd_file = gisenv['MONITOR_{monitor}_CMDFILE'.format(monitor=gisenv['MONITOR'].upper())]
         dout_cmd = 'd.out.file'
         for param, val in options.iteritems():
             if val:

Modified: grass/branches/releasebranch_7_0/scripts/d.redraw/d.redraw.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/d.redraw/d.redraw.py	2014-07-28 22:07:11 UTC (rev 61435)
+++ grass/branches/releasebranch_7_0/scripts/d.redraw/d.redraw.py	2014-07-28 22:17:21 UTC (rev 61436)
@@ -39,7 +39,7 @@
     if not mon:
         grass.fatal(_("No monitor selected. Run `d.mon` to select monitor."))
     
-    monCmd = env.get('MONITOR_%s_CMDFILE' % mon)
+    monCmd = env.get('MONITOR_%s_CMDFILE' % mon.upper())
     if not monCmd:
         grass.fatal(_("No cmd file found for monitor <%s>") % mon)
 



More information about the grass-commit mailing list