OSSP CVS Repository

ossp - Check-in [4512]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4512
Date: 2004-Apr-22 12:10:57 (local)
2004-Apr-22 10:10:57 (UTC)
User:rse
Branch:
Comment: Replace modf(3) calls in l2_util_format.c with a hand-crafted inlined l2_util_modf() function to avoid dependency to external libm on systems (like Tru64, QNX, etc) where modf(3) is not part of libc.
Tickets:
Inspections:
Files:
ossp-pkg/l2/ChangeLog      1.12 -> 1.13     7 inserted, 0 deleted
ossp-pkg/l2/l2_ut_format.c      1.8 -> 1.9     22 inserted, 3 deleted

ossp-pkg/l2/ChangeLog 1.12 -> 1.13

--- ChangeLog    2004/04/21 12:19:32     1.12
+++ ChangeLog    2004/04/22 10:10:57     1.13
@@ -9,6 +9,13 @@
   ChangeLog
   =========
 
+  Changes between 0.9.6 and 0.9.7 (21-Apr-2003 to 22-Apr-2004)
+
+    *) Replace modf(3) calls in l2_util_format.c with a hand-crafted
+       inlined l2_util_modf() function to avoid dependency to external libm
+       on systems (like Tru64, QNX, etc) where modf(3) is not part of libc.
+       [Ralf S. Engelschall <rse@engelschall.com>]
+
   Changes between 0.9.5 and 0.9.6 (10-Nov-2003 to 21-Apr-2004)
 
     *) create devtool.conf %import and import OSSP sa 1.2.0


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