[GRASS-SVN] r49970 - grass/branches/releasebranch_6_4/display/d.vect.chart

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 30 06:59:54 EST 2011


Author: neteler
Date: 2011-12-30 03:59:54 -0800 (Fri, 30 Dec 2011)
New Revision: 49970

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

Modified: grass/branches/releasebranch_6_4/display/d.vect.chart/pie.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.vect.chart/pie.c	2011-12-30 08:09:59 UTC (rev 49969)
+++ grass/branches/releasebranch_6_4/display/d.vect.chart/pie.c	2011-12-30 11:59:54 UTC (rev 49970)
@@ -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