[GRASS-SVN] r67076 - grass/branches/releasebranch_7_0/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Dec 12 04:48:31 PST 2015


Author: martinl
Date: 2015-12-12 04:48:31 -0800 (Sat, 12 Dec 2015)
New Revision: 67076

Modified:
   grass/branches/releasebranch_7_0/lib/gis/env.c
Log:
libgis: print debug message when GISRC unable to open
        (merge r67044:5 from trunk)


Modified: grass/branches/releasebranch_7_0/lib/gis/env.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/gis/env.c	2015-12-12 12:44:32 UTC (rev 67075)
+++ grass/branches/releasebranch_7_0/lib/gis/env.c	2015-12-12 12:48:31 UTC (rev 67076)
@@ -17,6 +17,8 @@
 #include <stdlib.h>
 #include <unistd.h>		/* for sleep() */
 #include <string.h>
+#include <errno.h>
+
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
@@ -150,7 +152,7 @@
         parse_env(fd, loc);
         fclose(fd);
     }
-
+    
     G_initialize_done(&st->init[loc]);
     return 0;
 }
@@ -302,11 +304,12 @@
 static FILE *open_env(const char *mode, int loc)
 {
     char buf[GPATH_MAX];
+    FILE *fd;
 
     if (loc == G_VAR_GISRC) {
 	if (!st->gisrc)
 	    st->gisrc = getenv("GISRC");
-
+        
 	if (!st->gisrc) {
 	    G_fatal_error(_("GISRC - variable not set"));
 	    return NULL;
@@ -321,7 +324,11 @@
 	sprintf(buf, "%s/%s/VAR", G_location_path(), G_mapset());
     }
 
-    return fopen(buf, mode);
+    fd = fopen(buf, mode);
+    if (!fd) /* reading failed, call fatal error */
+      G_debug(1, "Unable to read GISRC <%s>: %s", buf, strerror(errno));
+
+    return fd;
 }
 
 /*!



More information about the grass-commit mailing list