This function wraps dtoastr (from gnulib) replacing the first occurance of
, by . Thanks to Ben Pfaff for this suggested implementation.
#include <config.h>
#include "misc.h"
+#include <gl/ftoastr.h>
/* Returns the number of digits in X. */
int
return digits;
}
+
+/* A locale independent version of dtoastr (from gnulib) */
+int
+c_dtoastr (char *buf, size_t bufsize, int flags, int width, double x)
+{
+ int i;
+ int result = dtoastr (buf, bufsize, flags, width, x);
+
+ /* Replace the first , (if any) by a . */
+ for (i = 0; i < result; ++i)
+ {
+ if (buf[i] == ',')
+ {
+ buf[i] = '.';
+ break;
+ }
+ }
+
+ return result;
+}
#if !libpspp_misc_h
#define libpspp_misc_h 1
+#include <stddef.h>
#include <float.h>
#include <math.h>
*dest = src;
}
+int c_dtoastr (char *buf, size_t bufsize, int flags, int width, double x);
+
#endif /* libpspp/misc.h */