1 # vasnprintf.m4 serial 36
2 dnl Copyright (C) 2002-2004, 2006-2017 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([AC_TYPE_LONG_LONG_INT])
36 AC_REQUIRE([gt_TYPE_WCHAR_T])
37 AC_REQUIRE([gt_TYPE_WINT_T])
40 # Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
41 AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
43 AC_REQUIRE([gl_FEATURES_H])
44 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
45 AC_REQUIRE([gt_TYPE_WCHAR_T])
46 AC_REQUIRE([gt_TYPE_WINT_T])
47 AC_REQUIRE([AC_TYPE_SIZE_T])
48 AC_CHECK_TYPE([ptrdiff_t], ,
49 [AC_DEFINE([ptrdiff_t], [long],
50 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
52 AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
55 # Prerequisites of lib/vasnprintf.c.
56 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
58 AC_REQUIRE([AC_FUNC_ALLOCA])
59 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
60 AC_REQUIRE([gt_TYPE_WCHAR_T])
61 AC_REQUIRE([gt_TYPE_WINT_T])
62 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
63 dnl Use the _snprintf function only if it is declared (because on NetBSD it
64 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
65 AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]])
66 dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization
67 dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE.
68 AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
69 dnl We can avoid a lot of code by assuming that snprintf's return value
70 dnl conforms to ISO C99. So check that.
71 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
72 case "$gl_cv_func_snprintf_retval_c99" in
74 AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
75 [Define if the return value of the snprintf function is the number of
76 of bytes (excluding the terminating NUL) that would have been produced
77 if the buffer had been large enough.])
82 # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
84 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
86 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
87 case "$gl_cv_func_printf_long_double" in
91 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
92 [Define if the vasnprintf implementation needs special code for
93 'long double' arguments.])
98 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
100 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
102 AC_REQUIRE([gl_PRINTF_INFINITE])
103 case "$gl_cv_func_printf_infinite" in
107 AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
108 [Define if the vasnprintf implementation needs special code for
109 infinite 'double' arguments.])
114 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
116 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
118 AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
119 dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
120 dnl NEED_PRINTF_LONG_DOUBLE is already set.
121 AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
122 case "$gl_cv_func_printf_long_double" in
124 case "$gl_cv_func_printf_infinite_long_double" in
128 AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
129 [Define if the vasnprintf implementation needs special code for
130 infinite 'long double' arguments.])
137 # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
138 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
140 AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
141 case "$gl_cv_func_printf_directive_a" in
145 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
146 [Define if the vasnprintf implementation needs special code for
147 the 'a' and 'A' directives.])
148 AC_CHECK_FUNCS([nl_langinfo])
153 # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
154 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
156 AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
157 case "$gl_cv_func_printf_directive_f" in
161 AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
162 [Define if the vasnprintf implementation needs special code for
168 # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
169 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
171 AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
172 case "$gl_cv_func_printf_directive_ls" in
176 AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
177 [Define if the vasnprintf implementation needs special code for
178 the 'ls' directive.])
183 # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
184 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
186 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
187 case "$gl_cv_func_printf_flag_grouping" in
191 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
192 [Define if the vasnprintf implementation needs special code for the
198 # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
199 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
201 AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
202 case "$gl_cv_func_printf_flag_leftadjust" in
206 AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
207 [Define if the vasnprintf implementation needs special code for the
213 # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
214 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
216 AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
217 case "$gl_cv_func_printf_flag_zero" in
221 AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
222 [Define if the vasnprintf implementation needs special code for the
228 # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
229 AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
231 AC_REQUIRE([gl_PRINTF_PRECISION])
232 case "$gl_cv_func_printf_precision" in
236 AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
237 [Define if the vasnprintf implementation needs special code for
238 supporting large precisions without arbitrary bounds.])
239 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
240 [Define if the vasnprintf implementation needs special code for
241 'double' arguments.])
242 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
243 [Define if the vasnprintf implementation needs special code for
244 'long double' arguments.])
249 # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
251 AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
253 AC_REQUIRE([gl_PRINTF_ENOMEM])
254 case "$gl_cv_func_printf_enomem" in
258 AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
259 [Define if the vasnprintf implementation needs special code for
260 surviving out-of-memory conditions.])
261 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
262 [Define if the vasnprintf implementation needs special code for
263 'double' arguments.])
264 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
265 [Define if the vasnprintf implementation needs special code for
266 'long double' arguments.])
271 # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
272 AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
274 AC_REQUIRE([gl_PREREQ_VASNPRINTF])
275 gl_PREREQ_VASNPRINTF_LONG_DOUBLE
276 gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
277 gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
278 gl_PREREQ_VASNPRINTF_DIRECTIVE_A
279 gl_PREREQ_VASNPRINTF_DIRECTIVE_F
280 gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
281 gl_PREREQ_VASNPRINTF_FLAG_GROUPING
282 gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
283 gl_PREREQ_VASNPRINTF_FLAG_ZERO
284 gl_PREREQ_VASNPRINTF_PRECISION
285 gl_PREREQ_VASNPRINTF_ENOMEM
288 # Prerequisites of lib/asnprintf.c.
289 AC_DEFUN([gl_PREREQ_ASNPRINTF],