Hi,

Attaching a patch that introduces a macro called "isfinite", which is
used if the actual C99 macro with the same name is not available.
Originally defined in the GNU coreutils:

http://cvs.savannah.gnu.org/viewvc/coreutils/coreutils/src/seq.c?revision=1.95&view=markup

/* Roll our own isfinite rather than using <math.h>, so that we don't
   have to worry about linking -lm just for isfinite.  */
#ifndef isfinite
# define isfinite(x) ((x) * 0 == 0)
#endif

This works because in the world of floating point numbers, anything
multiplied by zero is not always zero. If x is a NaN then the result
is a NaN and if it is infinite then the result is infinite. So the
multiplication cannot be optimised away by the compiler.

This definition is supposed to work on all platforms (unless there is
a bug in the compiler).  The reason we might want to use the system
definition of isfinite is probably only for performance, which is not
a very big priority here. Hence removed #include <math.h> and #include
<float.h> since the only purpose of these files was to introduce
suitable macros for checking finiteness. Also removed the check for
OS/2.

This change compiles correctly on GCC ... needs checking on other platforms.

Sameer.
-- 
http://www.it.iitb.ac.in/~sameerds/
=== modified file 'lib/arrows.c'
--- lib/arrows.c	2007-10-06 20:06:42 +0000
+++ lib/arrows.c	2008-12-05 08:56:35 +0000
@@ -21,25 +21,19 @@
 #include <stdio.h>
 #include <string.h>
 #include <glib.h>
-#include <math.h>
 #include "message.h"
 #include "boundingbox.h"
 
-#ifdef G_OS_WIN32
-#include <float.h>
-#define finite(d) _finite(d)
-#endif
-
-#ifdef __EMX__
-#define finite(d) isfinite(d)
-#endif
-
 #include "arrows.h"
 #include "diarenderer.h"
 #include "attributes.h"
 #include "widgets.h"
 #include "intl.h"
 
+#ifndef isfinite
+# define isfinite(x) ((x)*0 == 0)
+#endif
+
 /**** prototypes ****/
 static void 
 draw_empty_ellipse(DiaRenderer *renderer, Point *to, Point *from,
@@ -419,7 +413,7 @@
   else {
     vl.x = 1.0; vl.y = 0.0;
   }
-  if (!finite(vl.x)) {
+  if (!isfinite(vl.x)) {
     vl.x = 1.0; vl.y = 0.0;
   }
   point_get_perp(&vt,&vl);
@@ -496,7 +490,7 @@
   else {
     vl.x = 1.0; vl.y = 0.0;
   }
-  if (!finite(vl.x)) {
+  if (!isfinite(vl.x)) {
     vl.x = 1.0; vl.y = 0.0;
   }
   point_get_perp(&vt,&vl);
@@ -608,7 +602,7 @@
   else {
     vl.x = 1.0; vl.y = 0.0;
   }
-  if (!finite(vl.x)) {
+  if (!isfinite(vl.x)) {
     vl.x = 1.0; vl.y = 0.0;
   }
   point_get_perp(&vt,&vl);
@@ -670,7 +664,7 @@
   else {
     vl.x = 1.0; vl.y = 0.0;
   }
-  if (!finite(vl.x)) {
+  if (!isfinite(vl.x)) {
     vl.x = 1.0; vl.y = 0.0;
   }
 
@@ -716,7 +710,7 @@
   else {
     vl.x = 1.0; vl.y = 0.0;
   }
-  if (!finite(vl.x)) {
+  if (!isfinite(vl.x)) {
     vl.x = 1.0; vl.y = 0.0;
   }
   point_get_perp(&vt,&vl);
@@ -830,7 +824,7 @@
   else {
     vl.x = 1.0; vl.y = 0.0;
   }
-  if (!finite(vl.x)) {
+  if (!isfinite(vl.x)) {
     vl.x = 1.0; vl.y = 0.0;
   }
   point_get_perp(&vt,&vl);
@@ -906,7 +900,7 @@
   else {
     vl.x = 1.0; vl.y = 0.0;
   }
-  if (!finite(vl.x)) {
+  if (!isfinite(vl.x)) {
     vl.x = 1.0; vl.y = 0.0;
   }
   point_get_perp(&vt,&vl);
@@ -944,7 +938,7 @@
   else {
     vl.x = 1.0; vl.y = 0.0;
   }
-  if (!finite(vl.x)) {
+  if (!isfinite(vl.x)) {
     vl.x = 1.0; vl.y = 0.0;
   }
   point_get_perp(&vt,&vl);

_______________________________________________
dia-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia

Reply via email to