--- cfg_fmt.c 2003/01/06 11:17:43 1.4
+++ cfg_fmt.c 2004/04/23 10:05:58 1.5
@@ -96,7 +96,6 @@
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
-#include <math.h>
#include "cfg_fmt.h"
@@ -162,6 +161,25 @@
#define cfg_fmt_fcvt(arg,ndigits,decpt,sign,buf) \
cfg_fmt_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
+cfg_fmt_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 *
cfg_fmt_cvt(
double arg,
@@ -184,14 +202,14 @@
*sign = TRUE;
arg = -arg;
}
- arg = modf(arg, &fi);
+ arg = cfg_fmt_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 = cfg_fmt_modf(fi / 10, &fi);
*--p1 = (int)((fj + .03) * 10) + '0';
r2++;
}
@@ -214,7 +232,7 @@
}
while (p <= p1 && p < &buf[NDIG]) {
arg *= 10;
- arg = modf(arg, &fj);
+ arg = cfg_fmt_modf(arg, &fj);
*p++ = (int) fj + '0';
}
if (p1 >= &buf[NDIG]) {
|