[GRASS-SVN] r70744 - grass/trunk/imagery/i.ortho.photo/lib
    svn_grass at osgeo.org 
    svn_grass at osgeo.org
       
    Sat Mar 11 10:12:57 PST 2017
    
    
  
Author: ychemin
Date: 2017-03-11 10:12:57 -0800 (Sat, 11 Mar 2017)
New Revision: 70744
Modified:
   grass/trunk/imagery/i.ortho.photo/lib/elev.c
Log:
Added error catching on reading elevation paramter file
Modified: grass/trunk/imagery/i.ortho.photo/lib/elev.c
===================================================================
--- grass/trunk/imagery/i.ortho.photo/lib/elev.c	2017-03-11 11:13:12 UTC (rev 70743)
+++ grass/trunk/imagery/i.ortho.photo/lib/elev.c	2017-03-11 18:12:57 UTC (rev 70744)
@@ -42,6 +42,7 @@
 int I_get_group_elev(char *group, char *elev, char *mapset_elev, char *tl,
 		     char *math_exp, char *units, char *nd)
 {
+    char *err;
     char buf[IN_BUF];
     FILE *fd;
 
@@ -65,17 +66,23 @@
 	return 0;
     }
 
-    fgets(buf, IN_BUF, fd);
+    err=fgets(buf, IN_BUF, fd);
+    if(err==NULL) G_fatal_error(_("Unable to read elevation paramter file"));
     sscanf(buf, "elevation layer :%s\n", elev);
-    fgets(buf, IN_BUF, fd);
+    err=fgets(buf, IN_BUF, fd);
+    if(err==NULL) G_fatal_error(_("Unable to read elevation paramter file"));
     sscanf(buf, "mapset elevation:%s\n", mapset_elev);
-    fgets(buf, IN_BUF, fd);
+    err=fgets(buf, IN_BUF, fd);
+    if(err==NULL) G_fatal_error(_("Unable to read elevation paramter file"));
     sscanf(buf, "location        :%s\n", tl);
-    fgets(buf, IN_BUF, fd);
+    err=fgets(buf, IN_BUF, fd);
+    if(err==NULL) G_fatal_error(_("Unable to read elevation paramter file"));
     sscanf(buf, "math expression :%s\n", math_exp);
-    fgets(buf, IN_BUF, fd);
+    err=fgets(buf, IN_BUF, fd);
+    if(err==NULL) G_fatal_error(_("Unable to read elevation paramter file"));
     sscanf(buf, "units           :%s\n", units);
-    fgets(buf, IN_BUF, fd);
+    err=fgets(buf, IN_BUF, fd);
+    if(err==NULL) G_fatal_error(_("Unable to read elevation paramter file"));
     sscanf(buf, "no data values  :%s\n", nd);
     fclose(fd);
 
    
    
More information about the grass-commit
mailing list