[goffice] dtoa: don't assume LDBL_MANT_DIG is a base-10 constant.



commit 5002b06d983ed31125b93d516d944c95e33fe9f2
Author: Morten Welinder <terra gnome org>
Date:   Mon Apr 14 08:41:50 2014 -0400

    dtoa: don't assume LDBL_MANT_DIG is a base-10 constant.
    
    It can be any constant expression with the right value.

 ChangeLog              |    4 ++++
 NEWS                   |    5 ++++-
 goffice/math/go-dtoa.c |    6 +++++-
 3 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a1ba5e3..f3e28a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-04-14  Morten Welinder  <terra gnome org>
+
+       * goffice/math/go-dtoa.c (fmt_fp): Portability improvement.
+
 2014-04-14  Jean Brefort  <jean brefort normalesup org>
 
        * goffice/graph/gog-graph.c (gog_graph_class_init): explicitly allow manual
diff --git a/NEWS b/NEWS
index 694ba2d..167e8e0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,10 @@
 goffice 0.10.15:
 
 Jean:
-       * Explicitly allow manual charts size. [728134]
+       * Explicitly allow manual charts size. [#728134]
+
+Morten:
+       * Portability improvement.
 
 --------------------------------------------------------------------------
 goffice 0.10.14:
diff --git a/goffice/math/go-dtoa.c b/goffice/math/go-dtoa.c
index e44af34..72db547 100644
--- a/goffice/math/go-dtoa.c
+++ b/goffice/math/go-dtoa.c
@@ -51,9 +51,9 @@ typedef GString FAKE_FILE;
 #ifdef MUSL_ORIGINAL
 #define MAX(a,b) ((a)>(b) ? (a) : (b))
 #define MIN(a,b) ((a)<(b) ? (a) : (b))
-#endif
 #define CONCAT2(x,y) x ## y
 #define CONCAT(x,y) CONCAT2(x,y)
+#endif
 
 /* Convenient bit representation for modifier flags, which all fall
  * within 31 codepoints of the space character. */
@@ -282,7 +282,11 @@ static int fmt_fp(FAKE_FILE *f, long double y, int w, int p, int fl, int t)
                x = *d % i;
                /* Are there any significant digits past j? */
                if (x || d+1!=z) {
+#ifdef MUSL_ORIGINAL
                        long double round = CONCAT(0x1p,LDBL_MANT_DIG);
+#else
+                       long double round = 2 / LDBL_EPSILON;
+#endif
                        long double small;
 #ifdef MUSL_ORIGINAL
                        if (*d/i & 1) round += 2;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]