OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_ut_format.c versions 1.8 and 1.9
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/l2/l2_ut_format.c 1.8 -> 1.9

--- l2_ut_format.c       2003/01/06 11:41:52     1.8
+++ l2_ut_format.c       2004/04/22 10:10:57     1.9
@@ -162,6 +162,25 @@
 #define l2_util_fcvt(arg,ndigits,decpt,sign,buf) \
         l2_util_cvt((arg), (ndigits), (decpt), (sign), 0, (buf))
 
+/* inlined modf(3) to avoid dependency to external libm on systems
+   (like Tru64, QNX, etc) where modf(3) is not part of libc. */
+static double
+l2_util_modf(
+    double arg,
+    double *iptr)
+{
+    double fraction;
+    double integral;
+    long trunc;
+
+    trunc = (long)arg;
+    integral = (double)trunc;
+    fraction = arg - integral;
+    if (iptr != NULL)
+        *iptr = integral;
+    return fraction;
+}
+
 static char *
 l2_util_cvt(
     double arg,
@@ -184,14 +203,14 @@
         *sign = TRUE;
         arg = -arg;
     }
-    arg = modf(arg, &fi);
+    arg = l2_util_modf(arg, &fi);
     p1 = &buf[NDIG];
 
     /* Do integer part */
     if (fi != 0) {
         p1 = &buf[NDIG];
         while (fi != 0 && p1 > &buf[0]) {
-            fj = modf(fi / 10, &fi);
+            fj = l2_util_modf(fi / 10, &fi);
             *--p1 = (int)((fj + .03) * 10) + '0';
             r2++;
         }
@@ -214,7 +233,7 @@
     }
     while (p <= p1 && p < &buf[NDIG]) {
         arg *= 10;
-        arg = modf(arg, &fj);
+        arg = l2_util_modf(arg, &fj);
         *p++ = (int) fj + '0';
     }
     if (p1 >= &buf[NDIG]) {

CVSTrac 2.0.1