1# vasnprintf.m4 serial 35 2dnl Copyright (C) 2002-2004, 2006-2012 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7AC_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 15AC_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. 33AC_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. 41AC_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. 56AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], 57[ 58 AC_REQUIRE([AC_C_INLINE]) 59 AC_REQUIRE([AC_FUNC_ALLOCA]) 60 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 61 AC_REQUIRE([gt_TYPE_WCHAR_T]) 62 AC_REQUIRE([gt_TYPE_WINT_T]) 63 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) 64 dnl Use the _snprintf function only if it is declared (because on NetBSD it 65 dnl is defined as a weak alias of snprintf; we prefer to use the latter). 66 AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]]) 67 dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization 68 dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE. 69 AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION]) 70 dnl We can avoid a lot of code by assuming that snprintf's return value 71 dnl conforms to ISO C99. So check that. 72 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99]) 73 case "$gl_cv_func_snprintf_retval_c99" in 74 *yes) 75 AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1], 76 [Define if the return value of the snprintf function is the number of 77 of bytes (excluding the terminating NUL) that would have been produced 78 if the buffer had been large enough.]) 79 ;; 80 esac 81]) 82 83# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' 84# arguments. 85AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE], 86[ 87 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) 88 case "$gl_cv_func_printf_long_double" in 89 *yes) 90 ;; 91 *) 92 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], 93 [Define if the vasnprintf implementation needs special code for 94 'long double' arguments.]) 95 ;; 96 esac 97]) 98 99# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double' 100# arguments. 101AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE], 102[ 103 AC_REQUIRE([gl_PRINTF_INFINITE]) 104 case "$gl_cv_func_printf_infinite" in 105 *yes) 106 ;; 107 *) 108 AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1], 109 [Define if the vasnprintf implementation needs special code for 110 infinite 'double' arguments.]) 111 ;; 112 esac 113]) 114 115# Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double' 116# arguments. 117AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE], 118[ 119 AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE]) 120 dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if 121 dnl NEED_PRINTF_LONG_DOUBLE is already set. 122 AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE]) 123 case "$gl_cv_func_printf_long_double" in 124 *yes) 125 case "$gl_cv_func_printf_infinite_long_double" in 126 *yes) 127 ;; 128 *) 129 AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1], 130 [Define if the vasnprintf implementation needs special code for 131 infinite 'long double' arguments.]) 132 ;; 133 esac 134 ;; 135 esac 136]) 137 138# Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive. 139AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A], 140[ 141 AC_REQUIRE([gl_PRINTF_DIRECTIVE_A]) 142 case "$gl_cv_func_printf_directive_a" in 143 *yes) 144 ;; 145 *) 146 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1], 147 [Define if the vasnprintf implementation needs special code for 148 the 'a' and 'A' directives.]) 149 AC_CHECK_FUNCS([nl_langinfo]) 150 ;; 151 esac 152]) 153 154# Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive. 155AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F], 156[ 157 AC_REQUIRE([gl_PRINTF_DIRECTIVE_F]) 158 case "$gl_cv_func_printf_directive_f" in 159 *yes) 160 ;; 161 *) 162 AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1], 163 [Define if the vasnprintf implementation needs special code for 164 the 'F' directive.]) 165 ;; 166 esac 167]) 168 169# Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive. 170AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS], 171[ 172 AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS]) 173 case "$gl_cv_func_printf_directive_ls" in 174 *yes) 175 ;; 176 *) 177 AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1], 178 [Define if the vasnprintf implementation needs special code for 179 the 'ls' directive.]) 180 ;; 181 esac 182]) 183 184# Extra prerequisites of lib/vasnprintf.c for supporting the ' flag. 185AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING], 186[ 187 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING]) 188 case "$gl_cv_func_printf_flag_grouping" in 189 *yes) 190 ;; 191 *) 192 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1], 193 [Define if the vasnprintf implementation needs special code for the 194 ' flag.]) 195 ;; 196 esac 197]) 198 199# Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag. 200AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST], 201[ 202 AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST]) 203 case "$gl_cv_func_printf_flag_leftadjust" in 204 *yes) 205 ;; 206 *) 207 AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1], 208 [Define if the vasnprintf implementation needs special code for the 209 '-' flag.]) 210 ;; 211 esac 212]) 213 214# Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag. 215AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO], 216[ 217 AC_REQUIRE([gl_PRINTF_FLAG_ZERO]) 218 case "$gl_cv_func_printf_flag_zero" in 219 *yes) 220 ;; 221 *) 222 AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1], 223 [Define if the vasnprintf implementation needs special code for the 224 0 flag.]) 225 ;; 226 esac 227]) 228 229# Extra prerequisites of lib/vasnprintf.c for supporting large precisions. 230AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION], 231[ 232 AC_REQUIRE([gl_PRINTF_PRECISION]) 233 case "$gl_cv_func_printf_precision" in 234 *yes) 235 ;; 236 *) 237 AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1], 238 [Define if the vasnprintf implementation needs special code for 239 supporting large precisions without arbitrary bounds.]) 240 AC_DEFINE([NEED_PRINTF_DOUBLE], [1], 241 [Define if the vasnprintf implementation needs special code for 242 'double' arguments.]) 243 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], 244 [Define if the vasnprintf implementation needs special code for 245 'long double' arguments.]) 246 ;; 247 esac 248]) 249 250# Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory 251# conditions. 252AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM], 253[ 254 AC_REQUIRE([gl_PRINTF_ENOMEM]) 255 case "$gl_cv_func_printf_enomem" in 256 *yes) 257 ;; 258 *) 259 AC_DEFINE([NEED_PRINTF_ENOMEM], [1], 260 [Define if the vasnprintf implementation needs special code for 261 surviving out-of-memory conditions.]) 262 AC_DEFINE([NEED_PRINTF_DOUBLE], [1], 263 [Define if the vasnprintf implementation needs special code for 264 'double' arguments.]) 265 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1], 266 [Define if the vasnprintf implementation needs special code for 267 'long double' arguments.]) 268 ;; 269 esac 270]) 271 272# Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance. 273AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS], 274[ 275 AC_REQUIRE([gl_PREREQ_VASNPRINTF]) 276 gl_PREREQ_VASNPRINTF_LONG_DOUBLE 277 gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE 278 gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE 279 gl_PREREQ_VASNPRINTF_DIRECTIVE_A 280 gl_PREREQ_VASNPRINTF_DIRECTIVE_F 281 gl_PREREQ_VASNPRINTF_DIRECTIVE_LS 282 gl_PREREQ_VASNPRINTF_FLAG_GROUPING 283 gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST 284 gl_PREREQ_VASNPRINTF_FLAG_ZERO 285 gl_PREREQ_VASNPRINTF_PRECISION 286 gl_PREREQ_VASNPRINTF_ENOMEM 287]) 288 289# Prerequisites of lib/asnprintf.c. 290AC_DEFUN([gl_PREREQ_ASNPRINTF], 291[ 292]) 293