diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-08-01 18:53:31 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-08-01 19:01:51 -0700 |
commit | d216d7d248199aa6c99cd642116717c5b301ae6d (patch) | |
tree | 687b9efadbb87fa1095fb0a2e0569e625856e15a /src/print.c | |
parent | 2f37ecaefcc61b0bf389f1c1eb3ac1b15105f056 (diff) | |
download | emacs-d216d7d248199aa6c99cd642116717c5b301ae6d.tar.gz emacs-d216d7d248199aa6c99cd642116717c5b301ae6d.tar.bz2 emacs-d216d7d248199aa6c99cd642116717c5b301ae6d.zip |
Substitute a <ieee754.h> on hosts lacking it
* .gitignore: Add lib/ieee754.h.
* admin/merge-gnulib (GNULIB_MODULES): Add ieee754-h.
* configure.ac: Remove ieee754.h check, as Gnulib now does that.
* etc/NEWS: Mention this.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lib/ieee754.in.h, m4/ieee754-h.m4: New files, from Gnulib.
* src/lisp.h (IEEE_FLOATING_POINT): Now a macro so that it
can be used in #if.
* src/lread.c, src/print.c: Include <ieee754.h> if
IEEE_FLOATING_POINT, not if HAVE_IEEE754_H.
* src/lread.c (string_to_number):
* src/print.c (float_to_string):
Process NaNs only on IEEE hosts, and assume <ieee754.h>
in that case.
Diffstat (limited to 'src/print.c')
-rw-r--r-- | src/print.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/src/print.c b/src/print.c index add21609cc5..34c7fa12b6e 100644 --- a/src/print.c +++ b/src/print.c @@ -40,7 +40,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <ftoastr.h> #include <math.h> -#if HAVE_IEEE754_H +#if IEEE_FLOATING_POINT # include <ieee754.h> #endif @@ -1013,34 +1013,15 @@ float_to_string (char *buf, double data) strcpy (buf, minus_infinity_string + positive); return sizeof minus_infinity_string - 1 - positive; } +#if IEEE_FLOATING_POINT if (isnan (data)) { -#if HAVE_IEEE754_H union ieee754_double u = { .d = data }; uprintmax_t hi = u.ieee_nan.mantissa0; return sprintf (buf, &"-%"pMu".0e+NaN"[!u.ieee_nan.negative], (hi << 31 << 1) + u.ieee_nan.mantissa1); -#else - /* Prepend "-" if the NaN's sign bit is negative. - The sign bit of a double is the bit that is 1 in -0.0. */ - static char const NaN_string[] = "0.0e+NaN"; - int i; - union { double d; char c[sizeof (double)]; } u_data, u_minus_zero; - bool negative = 0; - u_data.d = data; - u_minus_zero.d = - 0.0; - for (i = 0; i < sizeof (double); i++) - if (u_data.c[i] & u_minus_zero.c[i]) - { - *buf = '-'; - negative = 1; - break; - } - - strcpy (buf + negative, NaN_string); - return negative + sizeof NaN_string - 1; -#endif } +#endif if (NILP (Vfloat_output_format) || !STRINGP (Vfloat_output_format)) |