1 # vasnprintf.m4 serial 38
2 dnl Copyright (C) 2002-2004, 2006-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_VASNPRINTF],
9 AC_CHECK_FUNCS_ONCE([vasnprintf])
10 if test $ac_cv_func_vasnprintf = no; then
15 AC_DEFUN([gl_REPLACE_VASNPRINTF],
17 AC_CHECK_FUNCS_ONCE([vasnprintf])
18 AC_LIBOBJ([vasnprintf])
19 AC_LIBOBJ([printf-args])
20 AC_LIBOBJ([printf-parse])
21 AC_LIBOBJ([asnprintf])
22 if test $ac_cv_func_vasnprintf = yes; then
23 AC_DEFINE([REPLACE_VASNPRINTF], [1],
24 [Define if vasnprintf exists but is overridden by gnulib.])
27 gl_PREREQ_PRINTF_PARSE
32 # Prerequisites of lib/printf-args.h, lib/printf-args.c.
33 AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
35 AC_REQUIRE([gt_TYPE_WCHAR_T])
36 AC_REQUIRE([gt_TYPE_WINT_T])
39 # Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
40 AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
42 AC_REQUIRE([gl_FEATURES_H])
43 AC_REQUIRE([gt_TYPE_WCHAR_T])
44 AC_REQUIRE([gt_TYPE_WINT_T])
45 AC_REQUIRE([AC_TYPE_SIZE_T])
46 AC_CHECK_TYPE([ptrdiff_t], ,
47 [AC_DEFINE([ptrdiff_t], [long],
48 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
50 AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
53 # Prerequisites of lib/vasnprintf.c.
54 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
56 AC_REQUIRE([AC_FUNC_ALLOCA])
57 AC_REQUIRE([gt_TYPE_WCHAR_T])
58 AC_REQUIRE([gt_TYPE_WINT_T])
59 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
60 dnl Use the _snprintf function only if it is declared (because on NetBSD it
61 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
62 AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]])
63 dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization
64 dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE.
65 AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
66 dnl We can avoid a lot of code by assuming that snprintf's return value
67 dnl conforms to ISO C99. So check that.
68 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
69 case "$gl_cv_func_snprintf_retval_c99" in
71 AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
72 [Define if the return value of the snprintf function is the number of
73 of bytes (excluding the terminating NUL) that would have been produced
74 if the buffer had been large enough.])
77 dnl Additionally, the use of %n can be eliminated by assuming that snprintf
78 dnl always produces NUL-terminated strings (no truncation).
79 AC_REQUIRE([gl_SNPRINTF_TRUNCATION_C99])
80 case "$gl_cv_func_snprintf_truncation_c99" in
82 AC_DEFINE([HAVE_SNPRINTF_TRUNCATION_C99], [1],
83 [Define if the string produced by the snprintf function is always NUL
89 # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
91 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
93 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
94 case "$gl_cv_func_printf_long_double" in
98 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
99 [Define if the vasnprintf implementation needs special code for
100 'long double' arguments.])
105 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
107 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
109 AC_REQUIRE([gl_PRINTF_INFINITE])
110 case "$gl_cv_func_printf_infinite" in
114 AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
115 [Define if the vasnprintf implementation needs special code for
116 infinite 'double' arguments.])
121 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
123 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
125 AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
126 dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
127 dnl NEED_PRINTF_LONG_DOUBLE is already set.
128 AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
129 case "$gl_cv_func_printf_long_double" in
131 case "$gl_cv_func_printf_infinite_long_double" in
135 AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
136 [Define if the vasnprintf implementation needs special code for
137 infinite 'long double' arguments.])
144 # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
145 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
147 AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
148 case "$gl_cv_func_printf_directive_a" in
152 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
153 [Define if the vasnprintf implementation needs special code for
154 the 'a' and 'A' directives.])
155 AC_CHECK_FUNCS([nl_langinfo])
160 # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
161 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
163 AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
164 case "$gl_cv_func_printf_directive_f" in
168 AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
169 [Define if the vasnprintf implementation needs special code for
175 # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
176 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
178 AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
179 case "$gl_cv_func_printf_directive_ls" in
183 AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
184 [Define if the vasnprintf implementation needs special code for
185 the 'ls' directive.])
190 # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
191 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
193 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
194 case "$gl_cv_func_printf_flag_grouping" in
198 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
199 [Define if the vasnprintf implementation needs special code for the
205 # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
206 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
208 AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
209 case "$gl_cv_func_printf_flag_leftadjust" in
213 AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
214 [Define if the vasnprintf implementation needs special code for the
220 # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
221 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
223 AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
224 case "$gl_cv_func_printf_flag_zero" in
228 AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
229 [Define if the vasnprintf implementation needs special code for the
235 # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
236 AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
238 AC_REQUIRE([gl_PRINTF_PRECISION])
239 case "$gl_cv_func_printf_precision" in
243 AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
244 [Define if the vasnprintf implementation needs special code for
245 supporting large precisions without arbitrary bounds.])
246 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
247 [Define if the vasnprintf implementation needs special code for
248 'double' arguments.])
249 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
250 [Define if the vasnprintf implementation needs special code for
251 'long double' arguments.])
256 # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
258 AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
260 AC_REQUIRE([gl_PRINTF_ENOMEM])
261 case "$gl_cv_func_printf_enomem" in
265 AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
266 [Define if the vasnprintf implementation needs special code for
267 surviving out-of-memory conditions.])
268 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
269 [Define if the vasnprintf implementation needs special code for
270 'double' arguments.])
271 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
272 [Define if the vasnprintf implementation needs special code for
273 'long double' arguments.])
278 # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
279 AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
281 AC_REQUIRE([gl_PREREQ_VASNPRINTF])
282 gl_PREREQ_VASNPRINTF_LONG_DOUBLE
283 gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
284 gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
285 gl_PREREQ_VASNPRINTF_DIRECTIVE_A
286 gl_PREREQ_VASNPRINTF_DIRECTIVE_F
287 gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
288 gl_PREREQ_VASNPRINTF_FLAG_GROUPING
289 gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
290 gl_PREREQ_VASNPRINTF_FLAG_ZERO
291 gl_PREREQ_VASNPRINTF_PRECISION
292 gl_PREREQ_VASNPRINTF_ENOMEM
295 # Prerequisites of lib/asnprintf.c.
296 AC_DEFUN([gl_PREREQ_ASNPRINTF],