[GRASS-SVN] r59112 - in grass/trunk/lib: raster vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 21 09:52:50 PST 2014


Author: martinl
Date: 2014-02-21 09:52:50 -0800 (Fri, 21 Feb 2014)
New Revision: 59112

Modified:
   grass/trunk/lib/raster/color_read.c
   grass/trunk/lib/vector/Vlib/color_read.c
Log:
vlib: allow colors == NULL for Vect_read_colors()


Modified: grass/trunk/lib/raster/color_read.c
===================================================================
--- grass/trunk/lib/raster/color_read.c	2014-02-21 16:46:02 UTC (rev 59111)
+++ grass/trunk/lib/raster/color_read.c	2014-02-21 17:52:50 UTC (rev 59112)
@@ -131,18 +131,24 @@
 	fclose(fd);
 	return -1;
     }
-    G_fseek(fd, 0L, 0);
+    
+    stat = 1;
+    if (colors) {
+        G_fseek(fd, 0L, 0);
 
-    G_strip(buf);
-    if (*buf == '%') {		/* 4.0 format */
-	stat = read_new_colors(fd, colors);
-	colors->version = 0;	/* 4.0 format */
+        G_strip(buf);
+        if (*buf == '%') {		/* 4.0 format */
+            stat = read_new_colors(fd, colors);
+            colors->version = 0;	/* 4.0 format */
+        }
+        else {
+            stat = read_old_colors(fd, colors);
+            colors->version = -1;	/* pre 4.0 format */
+        }
     }
-    else {
-	stat = read_old_colors(fd, colors);
-	colors->version = -1;	/* pre 4.0 format */
-    }
+
     fclose(fd);
+
     return stat;
 }
 

Modified: grass/trunk/lib/vector/Vlib/color_read.c
===================================================================
--- grass/trunk/lib/vector/Vlib/color_read.c	2014-02-21 16:46:02 UTC (rev 59111)
+++ grass/trunk/lib/vector/Vlib/color_read.c	2014-02-21 17:52:50 UTC (rev 59112)
@@ -33,7 +33,7 @@
   
   \param name vector map name
   \param mapset mapset name ("" for search path)
-  \param[out] colors pointer to Colors structure
+  \param[out] colors pointer to Colors structure (can be NULL)
   
   \return -1 on error
   \return 0 if color table missing
@@ -46,7 +46,8 @@
     char buf[GPATH_MAX];
     char xname[GNAME_MAX];
     
-    Rast_init_colors(colors);
+    if (colors)
+        Rast_init_colors(colors);
     
     strcpy(xname, name);
     mapset = G_find_vector(xname, mapset);



More information about the grass-commit mailing list