| 1 | # vasnprintf.m4 serial 36 |
| 2 | dnl Copyright (C) 2002-2004, 2006-2013 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. |
| 6 | |
| 7 | AC_DEFUN([gl_FUNC_VASNPRINTF], |
| 8 | [ |
| 9 | AC_CHECK_FUNCS_ONCE([vasnprintf]) |
| 10 | if test $ac_cv_func_vasnprintf = no; then |
| 11 | gl_REPLACE_VASNPRINTF |
| 12 | fi |
| 13 | ]) |
| 14 | |
| 15 | AC_DEFUN([gl_REPLACE_VASNPRINTF], |
| 16 | [ |
| 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.]) |
| 25 | fi |
| 26 | gl_PREREQ_PRINTF_ARGS |
| 27 | gl_PREREQ_PRINTF_PARSE |
| 28 | gl_PREREQ_VASNPRINTF |
| 29 | gl_PREREQ_ASNPRINTF |
| 30 | ]) |
| 31 | |
| 32 | # Prerequisites of lib/printf-args.h, lib/printf-args.c. |
| 33 | AC_DEFUN([gl_PREREQ_PRINTF_ARGS], |
| 34 | [ |
| 35 | AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) |
| 36 | AC_REQUIRE([gt_TYPE_WCHAR_T]) |
| 37 | AC_REQUIRE([gt_TYPE_WINT_T]) |
| 38 | ]) |
| 39 | |
| 40 | # Prerequisites of lib/printf-parse.h, lib/printf-parse.c. |
| 41 | AC_DEFUN([gl_PREREQ_PRINTF_PARSE], |
| 42 | [ |
| 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.]) |
| 51 | ]) |
| 52 | AC_REQUIRE([gt_AC_TYPE_INTMAX_T]) |
| 53 | ]) |
| 54 | |
| 55 | # Prerequisites of lib/vasnprintf.c. |
| 56 | AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], |
| 57 | [ |
| 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 |
| 73 | *yes) |
| 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.]) |
| 78 | ;; |
| 79 | esac |
| 80 | ]) |
| 81 | |
| 82 | # Extra prerequisites of lib/vasnprintf.c for supporting 'long double' |
| 83 | # arguments. |
| 84 | AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE], |
| 85 | [ |
| 86 | AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) |
| 87 | case "$gl_cv_func_printf_long_double" in |
| 88 | *yes) |
| 89 | ;; |
| 90 | *) |
| 91 | AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], |
| 92 | [Define if the vasnprintf implementation needs special code for |
| 93 | 'long double' arguments.]) |
| 94 | ;; |
| 95 | esac |
| 96 | ]) |
| 97 | |
| 98 | # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double' |
| 99 | # arguments. |
| 100 | AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE], |
| 101 | [ |
| 102 | AC_REQUIRE([gl_PRINTF_INFINITE]) |
| 103 | case "$gl_cv_func_printf_infinite" in |
| 104 | *yes) |
| 105 | ;; |
| 106 | *) |
| 107 | AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1], |
| 108 | [Define if the vasnprintf implementation needs special code for |
| 109 | infinite 'double' arguments.]) |
| 110 | ;; |
| 111 | esac |
| 112 | ]) |
| 113 | |
| 114 | # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double' |
| 115 | # arguments. |
| 116 | AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE], |
| 117 | [ |
| 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 |
| 123 | *yes) |
| 124 | case "$gl_cv_func_printf_infinite_long_double" in |
| 125 | *yes) |
| 126 | ;; |
| 127 | *) |
| 128 | AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1], |
| 129 | [Define if the vasnprintf implementation needs special code for |
| 130 | infinite 'long double' arguments.]) |
| 131 | ;; |
| 132 | esac |
| 133 | ;; |
| 134 | esac |
| 135 | ]) |
| 136 | |
| 137 | # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive. |
| 138 | AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A], |
| 139 | [ |
| 140 | AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) |
| 141 | case "$gl_cv_func_printf_directive_a" in |
| 142 | *yes) |
| 143 | ;; |
| 144 | *) |
| 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]) |
| 149 | ;; |
| 150 | esac |
| 151 | ]) |
| 152 | |
| 153 | # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive. |
| 154 | AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F], |
| 155 | [ |
| 156 | AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) |
| 157 | case "$gl_cv_func_printf_directive_f" in |
| 158 | *yes) |
| 159 | ;; |
| 160 | *) |
| 161 | AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1], |
| 162 | [Define if the vasnprintf implementation needs special code for |
| 163 | the 'F' directive.]) |
| 164 | ;; |
| 165 | esac |
| 166 | ]) |
| 167 | |
| 168 | # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive. |
| 169 | AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS], |
| 170 | [ |
| 171 | AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS]) |
| 172 | case "$gl_cv_func_printf_directive_ls" in |
| 173 | *yes) |
| 174 | ;; |
| 175 | *) |
| 176 | AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1], |
| 177 | [Define if the vasnprintf implementation needs special code for |
| 178 | the 'ls' directive.]) |
| 179 | ;; |
| 180 | esac |
| 181 | ]) |
| 182 | |
| 183 | # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag. |
| 184 | AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING], |
| 185 | [ |
| 186 | AC_REQUIRE([gl_PRINTF_FLAG_GROUPING]) |
| 187 | case "$gl_cv_func_printf_flag_grouping" in |
| 188 | *yes) |
| 189 | ;; |
| 190 | *) |
| 191 | AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1], |
| 192 | [Define if the vasnprintf implementation needs special code for the |
| 193 | ' flag.]) |
| 194 | ;; |
| 195 | esac |
| 196 | ]) |
| 197 | |
| 198 | # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag. |
| 199 | AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST], |
| 200 | [ |
| 201 | AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST]) |
| 202 | case "$gl_cv_func_printf_flag_leftadjust" in |
| 203 | *yes) |
| 204 | ;; |
| 205 | *) |
| 206 | AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1], |
| 207 | [Define if the vasnprintf implementation needs special code for the |
| 208 | '-' flag.]) |
| 209 | ;; |
| 210 | esac |
| 211 | ]) |
| 212 | |
| 213 | # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag. |
| 214 | AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO], |
| 215 | [ |
| 216 | AC_REQUIRE([gl_PRINTF_FLAG_ZERO]) |
| 217 | case "$gl_cv_func_printf_flag_zero" in |
| 218 | *yes) |
| 219 | ;; |
| 220 | *) |
| 221 | AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1], |
| 222 | [Define if the vasnprintf implementation needs special code for the |
| 223 | 0 flag.]) |
| 224 | ;; |
| 225 | esac |
| 226 | ]) |
| 227 | |
| 228 | # Extra prerequisites of lib/vasnprintf.c for supporting large precisions. |
| 229 | AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION], |
| 230 | [ |
| 231 | AC_REQUIRE([gl_PRINTF_PRECISION]) |
| 232 | case "$gl_cv_func_printf_precision" in |
| 233 | *yes) |
| 234 | ;; |
| 235 | *) |
| 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.]) |
| 245 | ;; |
| 246 | esac |
| 247 | ]) |
| 248 | |
| 249 | # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory |
| 250 | # conditions. |
| 251 | AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM], |
| 252 | [ |
| 253 | AC_REQUIRE([gl_PRINTF_ENOMEM]) |
| 254 | case "$gl_cv_func_printf_enomem" in |
| 255 | *yes) |
| 256 | ;; |
| 257 | *) |
| 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.]) |
| 267 | ;; |
| 268 | esac |
| 269 | ]) |
| 270 | |
| 271 | # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance. |
| 272 | AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS], |
| 273 | [ |
| 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 |
| 286 | ]) |
| 287 | |
| 288 | # Prerequisites of lib/asnprintf.c. |
| 289 | AC_DEFUN([gl_PREREQ_ASNPRINTF], |
| 290 | [ |
| 291 | ]) |