aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-01-08 17:20:28 -0800
committerPaul Eggert2011-01-08 17:20:28 -0800
commita451f14b09368f4b9f96d61ddb2ee69ac048c414 (patch)
treed4076c67607428c2bd10d0d69bf763504c42ef06
parentfa2c4f5619481856c8cdf33be987d5785f51b750 (diff)
downloademacs-a451f14b09368f4b9f96d61ddb2ee69ac048c414.tar.gz
emacs-a451f14b09368f4b9f96d61ddb2ee69ac048c414.zip
Regenerate.
-rw-r--r--aclocal.m43
-rwxr-xr-xconfigure69
-rw-r--r--lib/Makefile.in19
-rw-r--r--lib/dtoastr.c2
-rw-r--r--lib/dummy.c42
-rw-r--r--lib/ftoastr.c136
-rw-r--r--lib/ftoastr.h144
-rw-r--r--lib/gnulib.mk15
-rw-r--r--lib/intprops.h86
-rw-r--r--lib/ldtoastr.c2
-rw-r--r--m4/c-strtod.m459
-rw-r--r--m4/gnulib-cache.m44
-rw-r--r--m4/gnulib-comp.m414
-rw-r--r--src/config.in26
14 files changed, 559 insertions, 62 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index e2e5e558797..4f728365ef9 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -984,4 +984,7 @@ AC_SUBST([am__tar])
984AC_SUBST([am__untar]) 984AC_SUBST([am__untar])
985]) # _AM_PROG_TAR 985]) # _AM_PROG_TAR
986 986
987m4_include([m4/00gnulib.m4])
988m4_include([m4/c-strtod.m4])
989m4_include([m4/gnulib-common.m4])
987m4_include([m4/gnulib-comp.m4]) 990m4_include([m4/gnulib-comp.m4])
diff --git a/configure b/configure
index 93b001f3f84..7ddac56a48f 100755
--- a/configure
+++ b/configure
@@ -2943,6 +2943,7 @@ fi
2943{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 2943{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
2944$as_echo "$MKDIR_P" >&6; } 2944$as_echo "$MKDIR_P" >&6; }
2945 2945
2946
2946mkdir_p="$MKDIR_P" 2947mkdir_p="$MKDIR_P"
2947case $mkdir_p in 2948case $mkdir_p in
2948 [\\/$]* | ?:[\\/]*) ;; 2949 [\\/$]* | ?:[\\/]*) ;;
@@ -5183,7 +5184,8 @@ fi
5183 5184
5184 5185
5185 5186
5186 # Code from module dummy: 5187 # Code from module ftoastr:
5188 # Code from module intprops:
5187 5189
5188 5190
5189# On Suns, sometimes $CPP names a directory. 5191# On Suns, sometimes $CPP names a directory.
@@ -13737,6 +13739,57 @@ fi
13737 13739
13738# Configure gnulib. 13740# Configure gnulib.
13739 13741
13742
13743
13744
13745 LIBC_FATAL_STDERR_=1
13746 export LIBC_FATAL_STDERR_
13747
13748
13749 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strtold conforms to C99" >&5
13750$as_echo_n "checking whether strtold conforms to C99... " >&6; }
13751if ${gl_cv_func_c99_strtold+:} false; then :
13752 $as_echo_n "(cached) " >&6
13753else
13754 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13755/* end confdefs.h. */
13756/* On HP-UX before 11.23, strtold returns a struct instead of
13757 long double. Reject implementations like that, by requiring
13758 compatibility with the C99 prototype. */
13759 #include <stdlib.h>
13760 static long double (*p) (char const *, char **) = strtold;
13761 static long double
13762 test (char const *nptr, char **endptr)
13763 {
13764 long double r;
13765 r = strtold (nptr, endptr);
13766 return r;
13767 }
13768int
13769main ()
13770{
13771return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;
13772 ;
13773 return 0;
13774}
13775_ACEOF
13776if ac_fn_c_try_link "$LINENO"; then :
13777 gl_cv_func_c99_strtold=yes
13778else
13779 gl_cv_func_c99_strtold=no
13780fi
13781rm -f core conftest.err conftest.$ac_objext \
13782 conftest$ac_exeext conftest.$ac_ext
13783fi
13784{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_c99_strtold" >&5
13785$as_echo "$gl_cv_func_c99_strtold" >&6; }
13786 if test $gl_cv_func_c99_strtold = yes; then
13787
13788$as_echo "#define HAVE_C99_STRTOLD 1" >>confdefs.h
13789
13790 fi
13791
13792
13740 if false; then 13793 if false; then
13741 GL_COND_LIBTOOL_TRUE= 13794 GL_COND_LIBTOOL_TRUE=
13742 GL_COND_LIBTOOL_FALSE='#' 13795 GL_COND_LIBTOOL_FALSE='#'
@@ -13754,9 +13807,14 @@ fi
13754 13807
13755 13808
13756 13809
13757 gl_COMMON 13810
13811
13812
13813
13758 gl_source_base='lib' 13814 gl_source_base='lib'
13759 # Code from module dummy: 13815 # Code from module ftoastr:
13816
13817 # Code from module intprops:
13760 # End of code from modules 13818 # End of code from modules
13761 13819
13762 13820
@@ -13772,7 +13830,10 @@ fi
13772 13830
13773 13831
13774 13832
13775 gl_COMMON 13833
13834
13835
13836
13776 gl_source_base='tests' 13837 gl_source_base='tests'
13777 gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS 13838 gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
13778 13839
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 0fff5b2c813..d1d6e4f8417 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -24,7 +24,7 @@
24# the same distribution terms as the rest of that program. 24# the same distribution terms as the rest of that program.
25# 25#
26# Generated by gnulib-tool. 26# Generated by gnulib-tool.
27# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dummy 27# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr
28 28
29VPATH = @srcdir@ 29VPATH = @srcdir@
30pkgdatadir = $(datadir)/@PACKAGE@ 30pkgdatadir = $(datadir)/@PACKAGE@
@@ -49,8 +49,10 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
49 $(srcdir)/gnulib.mk 49 $(srcdir)/gnulib.mk
50subdir = lib 50subdir = lib
51ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 51ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
52am__aclocal_m4_deps = $(top_srcdir)/m4/gnulib-comp.m4 \ 52am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
53 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/configure.in 53 $(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/gnulib-common.m4 \
54 $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/getopt.m4 \
55 $(top_srcdir)/configure.in
54am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 56am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
55 $(ACLOCAL_M4) 57 $(ACLOCAL_M4)
56mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs 58mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -62,7 +64,8 @@ AR = ar
62ARFLAGS = cru 64ARFLAGS = cru
63libgnu_a_AR = $(AR) $(ARFLAGS) 65libgnu_a_AR = $(AR) $(ARFLAGS)
64am__DEPENDENCIES_1 = 66am__DEPENDENCIES_1 =
65am_libgnu_a_OBJECTS = dummy.$(OBJEXT) 67am_libgnu_a_OBJECTS = ftoastr.$(OBJEXT) dtoastr.$(OBJEXT) \
68 ldtoastr.$(OBJEXT)
66libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS) 69libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
67depcomp = $(SHELL) $(top_srcdir)/depcomp 70depcomp = $(SHELL) $(top_srcdir)/depcomp
68am__depfiles_maybe = depfiles 71am__depfiles_maybe = depfiles
@@ -311,11 +314,11 @@ top_srcdir = @top_srcdir@
311version = @version@ 314version = @version@
312x_default_search_path = @x_default_search_path@ 315x_default_search_path = @x_default_search_path@
313BUILT_SOURCES = 316BUILT_SOURCES =
314EXTRA_DIST = 317EXTRA_DIST = intprops.h
315MOSTLYCLEANFILES = core *.stackdump 318MOSTLYCLEANFILES = core *.stackdump
316noinst_LIBRARIES = libgnu.a 319noinst_LIBRARIES = libgnu.a
317DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src 320DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src
318libgnu_a_SOURCES = dummy.c 321libgnu_a_SOURCES = ftoastr.h ftoastr.c dtoastr.c ldtoastr.c
319libgnu_a_LIBADD = $(gl_LIBOBJS) 322libgnu_a_LIBADD = $(gl_LIBOBJS)
320libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 323libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
321EXTRA_libgnu_a_SOURCES = 324EXTRA_libgnu_a_SOURCES =
@@ -368,7 +371,9 @@ mostlyclean-compile:
368distclean-compile: 371distclean-compile:
369 -rm -f *.tab.c 372 -rm -f *.tab.c
370 373
371@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy.Po@am__quote@ 374@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtoastr.Po@am__quote@
375@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftoastr.Po@am__quote@
376@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ldtoastr.Po@am__quote@
372 377
373.c.o: 378.c.o:
374@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 379@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/lib/dtoastr.c b/lib/dtoastr.c
new file mode 100644
index 00000000000..aed181d66b1
--- /dev/null
+++ b/lib/dtoastr.c
@@ -0,0 +1,2 @@
1#define LENGTH 2
2#include "ftoastr.c"
diff --git a/lib/dummy.c b/lib/dummy.c
deleted file mode 100644
index c958ea05d86..00000000000
--- a/lib/dummy.c
+++ /dev/null
@@ -1,42 +0,0 @@
1/* A dummy file, to prevent empty libraries from breaking builds.
2 Copyright (C) 2004, 2007, 2009-2011 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create
18 libraries without any object files. You might get an error like:
19
20 > ar cru .libs/libgl.a
21 > ar: no archive members specified
22
23 Compiling this file, and adding its object file to the library, will
24 prevent the library from being empty. */
25
26/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries
27 that don't export any symbol. You might get an error like:
28
29 > cc ... libgnu.a
30 > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a
31
32 Compiling this file, and adding its object file to the library, will
33 prevent the library from exporting no symbols. */
34
35#ifdef __sun
36/* This declaration ensures that the library will export at least 1 symbol. */
37int gl_dummy_symbol;
38#else
39/* This declaration is solely to ensure that after preprocessing
40 this file is never empty. */
41typedef int dummy;
42#endif
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
new file mode 100644
index 00000000000..ff3d87ce22d
--- /dev/null
+++ b/lib/ftoastr.c
@@ -0,0 +1,136 @@
1/* floating point to accurate string
2
3 Copyright (C) 2010-2011 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20/* This code can misbehave on some buggy or older platforms, when
21 operating on arguments on floating types other than 'double', or
22 when given unusual combinations of options. Gnulib's
23 snprintf-posix module works around many of these problems.
24
25 This code relies on sprintf, strtod, etc. operating accurately;
26 otherwise, the resulting strings could be inaccurate or too long. */
27
28#include <config.h>
29
30#include "ftoastr.h"
31
32#include "intprops.h"
33#include <float.h>
34#include <stdio.h>
35#include <stdlib.h>
36
37#if LENGTH == 3
38# define FLOAT long double
39# define FLOAT_DIG LDBL_DIG
40# define FLOAT_MIN LDBL_MIN
41# define FLOAT_PREC_BOUND _GL_LDBL_PREC_BOUND
42# define FTOASTR ldtoastr
43# define STRTOF strtold
44#elif LENGTH == 2
45# define FLOAT double
46# define FLOAT_DIG DBL_DIG
47# define FLOAT_MIN DBL_MIN
48# define FLOAT_PREC_BOUND _GL_DBL_PREC_BOUND
49# define FTOASTR dtoastr
50# define STRTOF strtod
51#else
52# define LENGTH 1
53# define FLOAT float
54# define FLOAT_DIG FLT_DIG
55# define FLOAT_MIN FLT_MIN
56# define FLOAT_PREC_BOUND _GL_FLT_PREC_BOUND
57# define FTOASTR ftoastr
58# define STRTOF strtof
59#endif
60
61/* On pre-C99 hosts, approximate strtof and strtold with strtod. This
62 may generate one or two extra digits, but that's better than not
63 working at all. Assume that strtof works if strtold does. */
64#if LENGTH != 2 && ! HAVE_C99_STRTOLD
65# undef STRTOF
66# define STRTOF strtod
67#endif
68
69/* On hosts where it's not known that snprintf works, use sprintf to
70 implement the subset needed here. Typically BUFSIZE is big enough
71 and there's little or no performance hit. */
72#if ! GNULIB_SNPRINTF
73# undef snprintf
74# define snprintf ftoastr_snprintf
75static int
76ftoastr_snprintf (char *buf, size_t bufsize, char const *format,
77 int width, int prec, FLOAT x)
78{
79 char width_0_buffer[LENGTH == 1 ? FLT_BUFSIZE_BOUND
80 : LENGTH == 2 ? DBL_BUFSIZE_BOUND
81 : LDBL_BUFSIZE_BOUND];
82 int n = width;
83 if (bufsize < sizeof width_0_buffer)
84 {
85 n = sprintf (width_0_buffer, format, 0, prec, x);
86 if (n < 0)
87 return n;
88 if (n < width)
89 n = width;
90 }
91 if (n < bufsize)
92 n = sprintf (buf, format, width, prec, x);
93 return n;
94}
95#endif
96
97int
98FTOASTR (char *buf, size_t bufsize, int flags, int width, FLOAT x)
99{
100 /* The following method is simple but slow.
101 For ideas about speeding things up, please see:
102
103 Florian Loitsch, Printing floating-point numbers quickly and accurately
104 with integers. ACM SIGPLAN notices 46, 6 (June 2010), 233-243
105 <http://dx.doi.org/10.1145/1809028.1806623>; also see the
106 2010-03-21 draft <http://florian.loitsch.com/tmp/article.pdf>. */
107
108 char format[sizeof "%-+ 0*.*Lg"];
109 FLOAT abs_x = x < 0 ? -x : x;
110 int prec;
111
112 char *p = format;
113 *p++ = '%';
114
115 /* Support flags that generate output parsable by strtof. */
116 *p = '-'; p += (flags & FTOASTR_LEFT_JUSTIFY ) != 0;
117 *p = '+'; p += (flags & FTOASTR_ALWAYS_SIGNED ) != 0;
118 *p = ' '; p += (flags & FTOASTR_SPACE_POSITIVE) != 0;
119 *p = '0'; p += (flags & FTOASTR_ZERO_PAD ) != 0;
120
121 *p++ = '*';
122 *p++ = '.';
123 *p++ = '*';
124 *p = 'L'; p += 2 < LENGTH;
125 *p++ = flags & FTOASTR_UPPER_E ? 'G' : 'g';
126 *p = '\0';
127
128 for (prec = abs_x < FLOAT_MIN ? 1 : FLOAT_DIG; ; prec++)
129 {
130 int n = snprintf (buf, bufsize, format, width, prec, x);
131 if (n < 0
132 || FLOAT_PREC_BOUND <= prec
133 || (n < bufsize && STRTOF (buf, NULL) == x))
134 return n;
135 }
136}
diff --git a/lib/ftoastr.h b/lib/ftoastr.h
new file mode 100644
index 00000000000..6264952e8e9
--- /dev/null
+++ b/lib/ftoastr.h
@@ -0,0 +1,144 @@
1/* floating point to accurate string
2
3 Copyright (C) 2010-2011 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20#ifndef _GL_FTOASTR_H
21
22#include "intprops.h"
23#include <float.h>
24#include <stddef.h>
25
26/* Store into BUF (of size BUFSIZE) an accurate minimal-precision
27 string representation of a floating point number. FLAGS affect the
28 formatting of the number. Pad the output string with spaces as
29 necessary to width WIDTH bytes, in the style of printf. WIDTH must
30 be nonnegative. X is the floating-point number to be converted.
31
32 Return the number of bytes stored into BUF, not counting the
33 terminating null. However, do not overrun BUF: if BUF is too
34 small, return a fairly tight (but not necessarily exact) upper
35 bound on the value that would have been returned if BUF had been
36 big enough. If SIZE is zero, BUF may be a null pointer. On error
37 (e.g., returned value would exceed INT_MAX), return -1 and set
38 errno.
39
40 Example:
41
42 char buf[DBL_BUFSIZE_BOUND];
43 int r = dtoastr (buf, sizeof buf, 0, 0, 0.1);
44
45 In the C locale, this sets R to 3 and stores "0.1" into BUF. */
46
47int ftoastr (char *buf, size_t bufsize, int flags, int width, float x);
48int dtoastr (char *buf, size_t bufsize, int flags, int width, double x);
49int ldtoastr (char *buf, size_t bufsize, int flags, int width, long double x);
50
51/* Flag values for ftoastr etc. These can be ORed together. */
52enum
53 {
54 /* Left justify within the width; the default is right justification. */
55 FTOASTR_LEFT_JUSTIFY = 1,
56
57 /* Output "+" before positive numbers; the default outputs nothing. */
58 FTOASTR_ALWAYS_SIGNED = 2,
59
60 /* Output " " before positive numbers; ignored if
61 FTOASTER_ALWAYS_SIGNED is also given. */
62 FTOASTR_SPACE_POSITIVE = 4,
63
64 /* Pad with zeros instead of spaces; ignored if FTOASTR_LEFT_JUSTIFY
65 is also given. */
66 FTOASTR_ZERO_PAD = 8,
67
68 /* Use 'E' instead of 'e' before the exponent. */
69 FTOASTR_UPPER_E = 16
70 };
71
72
73/* _GL_FLT_PREC_BOUND is an upper bound on the precision needed to
74 represent a float value without losing information. Likewise for
75 _GL_DBL_PREC_BOUND and double, and _GL_LDBL_PREC_BOUND and long double. */
76
77#if FLT_RADIX == 10 /* decimal floating point */
78 enum { _GL_FLT_PREC_BOUND = FLT_MANT_DIG };
79 enum { _GL_DBL_PREC_BOUND = DBL_MANT_DIG };
80 enum { _GL_LDBL_PREC_BOUND = LDBL_MANT_DIG };
81#else
82
83/* An upper bound on the number of bits needed to represent a single
84 digit in a floating-point fraction. */
85# if FLT_RADIX == 2 /* IEEE 754 floating point, VAX floating point, etc. */
86# define _GL_FLOAT_DIG_BITS_BOUND 1
87# elif FLT_RADIX <= 16 /* IBM hex floating point has FLT_RADIX == 16. */
88# define _GL_FLOAT_DIG_BITS_BOUND 4
89# else /* no machine is this bad, but let's be complete */
90# define _GL_FLOAT_DIG_BITS_BOUND (CHAR_BIT * (int) sizeof (int) - 1)
91# endif
92
93/* An upper bound on the number of decimal digits needed to represent
94 a floating point number accurately, assuming a fraction contains
95 DIG digits. For why the "+ 1" is needed, see "Binary to Decimal
96 Conversion" in David Goldberg's paper "What Every Computer
97 Scientist Should Know About Floating-Point Arithmetic"
98 <http://docs.sun.com/source/806-3568/ncg_goldberg.html>. */
99# define _GL_FLOAT_PREC_BOUND(dig) \
100 (INT_BITS_STRLEN_BOUND ((dig) * _GL_FLOAT_DIG_BITS_BOUND) + 1)
101
102 enum { _GL_FLT_PREC_BOUND = _GL_FLOAT_PREC_BOUND ( FLT_MANT_DIG) };
103 enum { _GL_DBL_PREC_BOUND = _GL_FLOAT_PREC_BOUND ( DBL_MANT_DIG) };
104 enum { _GL_LDBL_PREC_BOUND = _GL_FLOAT_PREC_BOUND (LDBL_MANT_DIG) };
105#endif
106
107
108/* Bound on the number of bytes printed for an exponent in the range
109 MIN..MAX, where MIN < 0 < MAX; printf always prints a sign and at
110 least 2 digits. Although the maximum known exponent is 4932 for
111 IEEE 754 binary128, support tight bounds for exponents up to a
112 million, just in case. */
113#define _GL_FLOAT_EXPONENT_STRLEN_BOUND(min, max) \
114 ( -100 < (min) && (max) < 100 ? 3 \
115 : -1000 < (min) && (max) < 1000 ? 4 \
116 : -10000 < (min) && (max) < 10000 ? 5 \
117 : -100000 < (min) && (max) < 100000 ? 6 \
118 : -1000000 < (min) && (max) < 1000000 ? 7 \
119 : INT_STRLEN_BOUND (int) /* not a tight bound */)
120
121/* A reasonably tight bound on the length of a type-T floating value
122 formatted with ftoastr etc. Room is needed for sign, fraction
123 digits, decimal point, "e", and exponent. POINTLEN should be a
124 reasonably tight bound on the string length of the decimal
125 point. */
126#define _GL_FLOAT_STRLEN_BOUND_L(t, pointlen) \
127 (1 + _GL_##t##_PREC_BOUND + pointlen + 1 \
128 + _GL_FLOAT_EXPONENT_STRLEN_BOUND (t##_MIN_10_EXP, t##_MAX_10_EXP))
129#define FLT_STRLEN_BOUND_L(pointlen) _GL_FLOAT_STRLEN_BOUND_L ( FLT, pointlen)
130#define DBL_STRLEN_BOUND_L(pointlen) _GL_FLOAT_STRLEN_BOUND_L ( DBL, pointlen)
131#define LDBL_STRLEN_BOUND_L(pointlen) _GL_FLOAT_STRLEN_BOUND_L (LDBL, pointlen)
132
133/* Looser bounds that are locale-independent and are integral constant
134 expressions. */
135#define FLT_STRLEN_BOUND FLT_STRLEN_BOUND_L (MB_LEN_MAX)
136#define DBL_STRLEN_BOUND DBL_STRLEN_BOUND_L (MB_LEN_MAX)
137#define LDBL_STRLEN_BOUND LDBL_STRLEN_BOUND_L (MB_LEN_MAX)
138
139/* Looser, locale-independent bounds that include the trailing null byte. */
140#define FLT_BUFSIZE_BOUND ( FLT_STRLEN_BOUND + 1)
141#define DBL_BUFSIZE_BOUND ( DBL_STRLEN_BOUND + 1)
142#define LDBL_BUFSIZE_BOUND (LDBL_STRLEN_BOUND + 1)
143
144#endif /* _GL_FTOASTR_H */
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 1f5efc12e86..78d89d99281 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -9,7 +9,7 @@
9# the same distribution terms as the rest of that program. 9# the same distribution terms as the rest of that program.
10# 10#
11# Generated by gnulib-tool. 11# Generated by gnulib-tool.
12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dummy 12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr
13 13
14 14
15MOSTLYCLEANFILES += core *.stackdump 15MOSTLYCLEANFILES += core *.stackdump
@@ -21,11 +21,18 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
21libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 21libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
22EXTRA_libgnu_a_SOURCES = 22EXTRA_libgnu_a_SOURCES =
23 23
24## begin gnulib module dummy 24## begin gnulib module ftoastr
25 25
26libgnu_a_SOURCES += dummy.c 26libgnu_a_SOURCES += ftoastr.h ftoastr.c dtoastr.c ldtoastr.c
27 27
28## end gnulib module dummy 28## end gnulib module ftoastr
29
30## begin gnulib module intprops
31
32
33EXTRA_DIST += intprops.h
34
35## end gnulib module intprops
29 36
30 37
31mostlyclean-local: mostlyclean-generic 38mostlyclean-local: mostlyclean-generic
diff --git a/lib/intprops.h b/lib/intprops.h
new file mode 100644
index 00000000000..511a5aa9890
--- /dev/null
+++ b/lib/intprops.h
@@ -0,0 +1,86 @@
1/* intprops.h -- properties of integer types
2
3 Copyright (C) 2001-2005, 2009-2011 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20#ifndef GL_INTPROPS_H
21# define GL_INTPROPS_H
22
23# include <limits.h>
24
25/* The extra casts in the following macros work around compiler bugs,
26 e.g., in Cray C 5.0.3.0. */
27
28/* True if the arithmetic type T is an integer type. bool counts as
29 an integer. */
30# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
31
32/* True if negative values of the signed integer type T use two's
33 complement, ones' complement, or signed magnitude representation,
34 respectively. Much GNU code assumes two's complement, but some
35 people like to be portable to all possible C hosts. */
36# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
37# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
38# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
39
40/* True if the arithmetic type T is signed. */
41# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
42
43/* The maximum and minimum values for the integer type T. These
44 macros have undefined behavior if T is signed and has padding bits.
45 If this is a problem for you, please let us know how to fix it for
46 your host. */
47# define TYPE_MINIMUM(t) \
48 ((t) (! TYPE_SIGNED (t) \
49 ? (t) 0 \
50 : TYPE_SIGNED_MAGNITUDE (t) \
51 ? ~ (t) 0 \
52 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
53# define TYPE_MAXIMUM(t) \
54 ((t) (! TYPE_SIGNED (t) \
55 ? (t) -1 \
56 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
57
58/* Return zero if T can be determined to be an unsigned type.
59 Otherwise, return 1.
60 When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a
61 tighter bound. Otherwise, it overestimates the true bound by one byte
62 when applied to unsigned types of size 2, 4, 16, ... bytes.
63 The symbol signed_type_or_expr__ is private to this header file. */
64# if __GNUC__ >= 2
65# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
66# else
67# define signed_type_or_expr__(t) 1
68# endif
69
70/* Bound on length of the string representing an unsigned integer
71 value representable in B bits. log10 (2.0) < 146/485. The
72 smallest value of B where this bound is not tight is 2621. */
73# define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
74
75/* Bound on length of the string representing an integer type or expression T.
76 Subtract 1 for the sign bit if T is signed, and then add 1 more for
77 a minus sign if needed. */
78# define INT_STRLEN_BOUND(t) \
79 (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) \
80 + signed_type_or_expr__ (t))
81
82/* Bound on buffer size needed to represent an integer type or expression T,
83 including the terminating null. */
84# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
85
86#endif /* GL_INTPROPS_H */
diff --git a/lib/ldtoastr.c b/lib/ldtoastr.c
new file mode 100644
index 00000000000..bf54a3582e3
--- /dev/null
+++ b/lib/ldtoastr.c
@@ -0,0 +1,2 @@
1#define LENGTH 3
2#include "ftoastr.c"
diff --git a/m4/c-strtod.m4 b/m4/c-strtod.m4
new file mode 100644
index 00000000000..d5f5f502cba
--- /dev/null
+++ b/m4/c-strtod.m4
@@ -0,0 +1,59 @@
1# c-strtod.m4 serial 12
2
3# Copyright (C) 2004-2006, 2009-2011 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# Written by Paul Eggert.
9
10AC_DEFUN([gl_C99_STRTOLD],
11[
12 AC_CACHE_CHECK([whether strtold conforms to C99],
13 [gl_cv_func_c99_strtold],
14 [AC_LINK_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[/* On HP-UX before 11.23, strtold returns a struct instead of
17 long double. Reject implementations like that, by requiring
18 compatibility with the C99 prototype. */
19 #include <stdlib.h>
20 static long double (*p) (char const *, char **) = strtold;
21 static long double
22 test (char const *nptr, char **endptr)
23 {
24 long double r;
25 r = strtold (nptr, endptr);
26 return r;
27 }]],
28 [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
29 [gl_cv_func_c99_strtold=yes],
30 [gl_cv_func_c99_strtold=no])])
31 if test $gl_cv_func_c99_strtold = yes; then
32 AC_DEFINE([HAVE_C99_STRTOLD], [1], [Define to 1 if strtold conforms to C99.])
33 fi
34])
35
36AC_DEFUN([gl_C_STRTOD],
37[
38 AC_LIBOBJ([c-strtod])
39
40 dnl Prerequisites of lib/c-strtod.c.
41 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
42 AC_CHECK_FUNCS([strtod_l])
43
44 AC_REQUIRE([AC_C_INLINE])
45 :
46])
47
48AC_DEFUN([gl_C_STRTOLD],
49[
50 AC_LIBOBJ([c-strtold])
51
52 dnl Prerequisites of lib/c-strtold.c.
53 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
54 AC_REQUIRE([gl_C99_STRTOLD])
55 AC_CHECK_FUNCS([strtold_l])
56
57 AC_REQUIRE([AC_C_INLINE])
58 :
59])
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 24226f593fd..104536eba99 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,12 +15,12 @@
15 15
16 16
17# Specification in the form of a command-line invocation: 17# Specification in the form of a command-line invocation:
18# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dummy 18# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files ftoastr
19 19
20# Specification in the form of a few gnulib-tool.m4 macro invocations: 20# Specification in the form of a few gnulib-tool.m4 macro invocations:
21gl_LOCAL_DIR([]) 21gl_LOCAL_DIR([])
22gl_MODULES([ 22gl_MODULES([
23 dummy 23 ftoastr
24]) 24])
25gl_AVOID([]) 25gl_AVOID([])
26gl_SOURCE_BASE([lib]) 26gl_SOURCE_BASE([lib])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 2104e77b81b..6995e1b0098 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -26,7 +26,8 @@ AC_DEFUN([gl_EARLY],
26 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable 26 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
27 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable 27 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
28 AC_REQUIRE([AC_PROG_RANLIB]) 28 AC_REQUIRE([AC_PROG_RANLIB])
29 # Code from module dummy: 29 # Code from module ftoastr:
30 # Code from module intprops:
30]) 31])
31 32
32# This macro should be invoked from ./configure.in, in the section 33# This macro should be invoked from ./configure.in, in the section
@@ -45,7 +46,9 @@ AC_DEFUN([gl_INIT],
45 m4_pushdef([gl_LIBSOURCES_DIR], []) 46 m4_pushdef([gl_LIBSOURCES_DIR], [])
46 gl_COMMON 47 gl_COMMON
47 gl_source_base='lib' 48 gl_source_base='lib'
48 # Code from module dummy: 49 # Code from module ftoastr:
50 AC_REQUIRE([gl_C99_STRTOLD])
51 # Code from module intprops:
49 # End of code from modules 52 # End of code from modules
50 m4_ifval(gl_LIBSOURCES_LIST, [ 53 m4_ifval(gl_LIBSOURCES_LIST, [
51 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || 54 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
@@ -186,7 +189,12 @@ AC_DEFUN([gltests_LIBSOURCES], [
186# This macro records the list of files which have been installed by 189# This macro records the list of files which have been installed by
187# gnulib-tool and may be removed by future gnulib-tool invocations. 190# gnulib-tool and may be removed by future gnulib-tool invocations.
188AC_DEFUN([gl_FILE_LIST], [ 191AC_DEFUN([gl_FILE_LIST], [
189 lib/dummy.c 192 lib/dtoastr.c
193 lib/ftoastr.c
194 lib/ftoastr.h
195 lib/intprops.h
196 lib/ldtoastr.c
190 m4/00gnulib.m4 197 m4/00gnulib.m4
198 m4/c-strtod.m4
191 m4/gnulib-common.m4 199 m4/gnulib-common.m4
192]) 200])
diff --git a/src/config.in b/src/config.in
index 0e7ba9d2b99..e50e1e5af45 100644
--- a/src/config.in
+++ b/src/config.in
@@ -105,6 +105,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
105/* Define to 1 if ALSA is available. */ 105/* Define to 1 if ALSA is available. */
106#undef HAVE_ALSA 106#undef HAVE_ALSA
107 107
108/* Define to 1 if strtold conforms to C99. */
109#undef HAVE_C99_STRTOLD
110
108/* Define to 1 if you have the `cbrt' function. */ 111/* Define to 1 if you have the `cbrt' function. */
109#undef HAVE_CBRT 112#undef HAVE_CBRT
110 113
@@ -1059,6 +1062,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1059/* Define to empty if `const' does not conform to ANSI C. */ 1062/* Define to empty if `const' does not conform to ANSI C. */
1060#undef const 1063#undef const
1061 1064
1065/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
1066 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
1067 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
1068 __APPLE__ && __MACH__ test for MacOS X.
1069 __APPLE_CC__ tests for the Apple compiler and its version.
1070 __STDC_VERSION__ tests for the C99 mode. */
1071#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
1072# define __GNUC_STDC_INLINE__ 1
1073#endif
1074
1062/* Define to a type if <wchar.h> does not define. */ 1075/* Define to a type if <wchar.h> does not define. */
1063#undef mbstate_t 1076#undef mbstate_t
1064 1077
@@ -1071,6 +1084,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
1071/* Define to any substitute for sys_siglist. */ 1084/* Define to any substitute for sys_siglist. */
1072#undef sys_siglist 1085#undef sys_siglist
1073 1086
1087/* Define as a marker that can be attached to declarations that might not
1088 be used. This helps to reduce warnings, such as from
1089 GCC -Wunused-parameter. */
1090#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
1091# define _GL_UNUSED __attribute__ ((__unused__))
1092#else
1093# define _GL_UNUSED
1094#endif
1095/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
1096 is a misnomer outside of parameter lists. */
1097#define _UNUSED_PARAMETER_ _GL_UNUSED
1098
1099
1074/* Define as `fork' if `vfork' does not work. */ 1100/* Define as `fork' if `vfork' does not work. */
1075#undef vfork 1101#undef vfork
1076 1102