1 # vasnprintf.m4 serial 37
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.])
79 # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
81 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
83 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
84 case "$gl_cv_func_printf_long_double" in
88 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
89 [Define if the vasnprintf implementation needs special code for
90 'long double' arguments.])
95 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
97 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
99 AC_REQUIRE([gl_PRINTF_INFINITE])
100 case "$gl_cv_func_printf_infinite" in
104 AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
105 [Define if the vasnprintf implementation needs special code for
106 infinite 'double' arguments.])
111 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
113 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
115 AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
116 dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
117 dnl NEED_PRINTF_LONG_DOUBLE is already set.
118 AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
119 case "$gl_cv_func_printf_long_double" in
121 case "$gl_cv_func_printf_infinite_long_double" in
125 AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
126 [Define if the vasnprintf implementation needs special code for
127 infinite 'long double' arguments.])
134 # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
135 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
137 AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
138 case "$gl_cv_func_printf_directive_a" in
142 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
143 [Define if the vasnprintf implementation needs special code for
144 the 'a' and 'A' directives.])
145 AC_CHECK_FUNCS([nl_langinfo])
150 # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
151 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
153 AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
154 case "$gl_cv_func_printf_directive_f" in
158 AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
159 [Define if the vasnprintf implementation needs special code for
165 # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
166 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
168 AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
169 case "$gl_cv_func_printf_directive_ls" in
173 AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
174 [Define if the vasnprintf implementation needs special code for
175 the 'ls' directive.])
180 # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
181 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
183 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
184 case "$gl_cv_func_printf_flag_grouping" in
188 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
189 [Define if the vasnprintf implementation needs special code for the
195 # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
196 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
198 AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
199 case "$gl_cv_func_printf_flag_leftadjust" in
203 AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
204 [Define if the vasnprintf implementation needs special code for the
210 # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
211 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
213 AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
214 case "$gl_cv_func_printf_flag_zero" in
218 AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
219 [Define if the vasnprintf implementation needs special code for the
225 # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
226 AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
228 AC_REQUIRE([gl_PRINTF_PRECISION])
229 case "$gl_cv_func_printf_precision" in
233 AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
234 [Define if the vasnprintf implementation needs special code for
235 supporting large precisions without arbitrary bounds.])
236 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
237 [Define if the vasnprintf implementation needs special code for
238 'double' arguments.])
239 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
240 [Define if the vasnprintf implementation needs special code for
241 'long double' arguments.])
246 # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
248 AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
250 AC_REQUIRE([gl_PRINTF_ENOMEM])
251 case "$gl_cv_func_printf_enomem" in
255 AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
256 [Define if the vasnprintf implementation needs special code for
257 surviving out-of-memory conditions.])
258 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
259 [Define if the vasnprintf implementation needs special code for
260 'double' arguments.])
261 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
262 [Define if the vasnprintf implementation needs special code for
263 'long double' arguments.])
268 # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
269 AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
271 AC_REQUIRE([gl_PREREQ_VASNPRINTF])
272 gl_PREREQ_VASNPRINTF_LONG_DOUBLE
273 gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
274 gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
275 gl_PREREQ_VASNPRINTF_DIRECTIVE_A
276 gl_PREREQ_VASNPRINTF_DIRECTIVE_F
277 gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
278 gl_PREREQ_VASNPRINTF_FLAG_GROUPING
279 gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
280 gl_PREREQ_VASNPRINTF_FLAG_ZERO
281 gl_PREREQ_VASNPRINTF_PRECISION
282 gl_PREREQ_VASNPRINTF_ENOMEM
285 # Prerequisites of lib/asnprintf.c.
286 AC_DEFUN([gl_PREREQ_ASNPRINTF],