[GRASS-SVN] r50188 - grass/trunk/lib/raster3d
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jan 14 19:43:23 EST 2012
Author: huhabla
Date: 2012-01-14 16:43:23 -0800 (Sat, 14 Jan 2012)
New Revision: 50188
Modified:
grass/trunk/lib/raster3d/range.c
Log:
Fixed NULL range handling
Modified: grass/trunk/lib/raster3d/range.c
===================================================================
--- grass/trunk/lib/raster3d/range.c 2012-01-15 00:42:44 UTC (rev 50187)
+++ grass/trunk/lib/raster3d/range.c 2012-01-15 00:43:23 UTC (rev 50188)
@@ -62,6 +62,7 @@
/* adapted from Rast_read_fp_range */
{
int fd;
+ int bytes_read;
char xdr_buf[100];
DCELL dcell1, dcell2;
XDR xdr_str;
@@ -76,8 +77,17 @@
return -1;
}
- if (read(fd, xdr_buf, 2 * RASTER3D_XDR_DOUBLE_LENGTH) != 2 * RASTER3D_XDR_DOUBLE_LENGTH) {
+ bytes_read = read(fd, xdr_buf, 2 * RASTER3D_XDR_DOUBLE_LENGTH);
+
+ /* if the f_range file exists, but empty the range is NULL -> a NULL map */
+ if (bytes_read == 0) {
close(fd);
+ return 1;
+ }
+
+
+ if (bytes_read != 2 * RASTER3D_XDR_DOUBLE_LENGTH) {
+ close(fd);
G_warning(_("Error reading range file for [%s in %s]"), name, mapset);
return 2;
}
@@ -85,7 +95,6 @@
xdrmem_create(&xdr_str, xdr_buf, (u_int) RASTER3D_XDR_DOUBLE_LENGTH * 2,
XDR_DECODE);
- /* if the f_range file exists, but empty */
if (!xdr_double(&xdr_str, &dcell1) || !xdr_double(&xdr_str, &dcell2)) {
close(fd);
G_warning(_("Error reading range file for [%s in %s]"), name, mapset);
More information about the grass-commit
mailing list