[GRASS-SVN] r49972 - grass/trunk/display/d.vect.chart

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 30 07:00:25 EST 2011


Author: neteler
Date: 2011-12-30 04:00:24 -0800 (Fri, 30 Dec 2011)
New Revision: 49972

Modified:
   grass/trunk/display/d.vect.chart/pie.c
Log:
avoid division by zero

Modified: grass/trunk/display/d.vect.chart/pie.c
===================================================================
--- grass/trunk/display/d.vect.chart/pie.c	2011-12-30 12:00:11 UTC (rev 49971)
+++ grass/trunk/display/d.vect.chart/pie.c	2011-12-30 12:00:24 UTC (rev 49972)
@@ -33,7 +33,10 @@
     ang = 0;
     for (i = 0; i < ncols; i++) {
 	sum += val[i];
-	end_ang = 2 * PI * sum / tot_sum;
+	if (tot_sum > 0.0)
+           end_ang = 2 * PI * sum / tot_sum;
+        else
+           end_ang = 0;
 	Vect_reset_line(Points);
 
 	if (val[0] != tot_sum)	/* all in one slice, don't draw line to center */



More information about the grass-commit mailing list