vasnprintf.m4 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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.
  6. AC_DEFUN([gl_FUNC_VASNPRINTF],
  7. [
  8. AC_CHECK_FUNCS_ONCE([vasnprintf])
  9. if test $ac_cv_func_vasnprintf = no; then
  10. gl_REPLACE_VASNPRINTF
  11. fi
  12. ])
  13. AC_DEFUN([gl_REPLACE_VASNPRINTF],
  14. [
  15. AC_CHECK_FUNCS_ONCE([vasnprintf])
  16. AC_LIBOBJ([vasnprintf])
  17. AC_LIBOBJ([printf-args])
  18. AC_LIBOBJ([printf-parse])
  19. AC_LIBOBJ([asnprintf])
  20. if test $ac_cv_func_vasnprintf = yes; then
  21. AC_DEFINE([REPLACE_VASNPRINTF], [1],
  22. [Define if vasnprintf exists but is overridden by gnulib.])
  23. fi
  24. gl_PREREQ_PRINTF_ARGS
  25. gl_PREREQ_PRINTF_PARSE
  26. gl_PREREQ_VASNPRINTF
  27. gl_PREREQ_ASNPRINTF
  28. ])
  29. # Prerequisites of lib/printf-args.h, lib/printf-args.c.
  30. AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
  31. [
  32. AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
  33. AC_REQUIRE([gt_TYPE_WCHAR_T])
  34. AC_REQUIRE([gt_TYPE_WINT_T])
  35. ])
  36. # Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
  37. AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
  38. [
  39. AC_REQUIRE([gl_FEATURES_H])
  40. AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
  41. AC_REQUIRE([gt_TYPE_WCHAR_T])
  42. AC_REQUIRE([gt_TYPE_WINT_T])
  43. AC_REQUIRE([AC_TYPE_SIZE_T])
  44. AC_CHECK_TYPE([ptrdiff_t], ,
  45. [AC_DEFINE([ptrdiff_t], [long],
  46. [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
  47. ])
  48. AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
  49. ])
  50. # Prerequisites of lib/vasnprintf.c.
  51. AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
  52. [
  53. AC_REQUIRE([AC_FUNC_ALLOCA])
  54. AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
  55. AC_REQUIRE([gt_TYPE_WCHAR_T])
  56. AC_REQUIRE([gt_TYPE_WINT_T])
  57. AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
  58. dnl Use the _snprintf function only if it is declared (because on NetBSD it
  59. dnl is defined as a weak alias of snprintf; we prefer to use the latter).
  60. AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]])
  61. dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization
  62. dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE.
  63. AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
  64. dnl We can avoid a lot of code by assuming that snprintf's return value
  65. dnl conforms to ISO C99. So check that.
  66. AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
  67. case "$gl_cv_func_snprintf_retval_c99" in
  68. *yes)
  69. AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
  70. [Define if the return value of the snprintf function is the number of
  71. of bytes (excluding the terminating NUL) that would have been produced
  72. if the buffer had been large enough.])
  73. ;;
  74. esac
  75. ])
  76. # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
  77. # arguments.
  78. AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
  79. [
  80. AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
  81. case "$gl_cv_func_printf_long_double" in
  82. *yes)
  83. ;;
  84. *)
  85. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  86. [Define if the vasnprintf implementation needs special code for
  87. 'long double' arguments.])
  88. ;;
  89. esac
  90. ])
  91. # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
  92. # arguments.
  93. AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
  94. [
  95. AC_REQUIRE([gl_PRINTF_INFINITE])
  96. case "$gl_cv_func_printf_infinite" in
  97. *yes)
  98. ;;
  99. *)
  100. AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
  101. [Define if the vasnprintf implementation needs special code for
  102. infinite 'double' arguments.])
  103. ;;
  104. esac
  105. ])
  106. # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
  107. # arguments.
  108. AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
  109. [
  110. AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
  111. dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
  112. dnl NEED_PRINTF_LONG_DOUBLE is already set.
  113. AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
  114. case "$gl_cv_func_printf_long_double" in
  115. *yes)
  116. case "$gl_cv_func_printf_infinite_long_double" in
  117. *yes)
  118. ;;
  119. *)
  120. AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
  121. [Define if the vasnprintf implementation needs special code for
  122. infinite 'long double' arguments.])
  123. ;;
  124. esac
  125. ;;
  126. esac
  127. ])
  128. # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
  129. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
  130. [
  131. AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
  132. case "$gl_cv_func_printf_directive_a" in
  133. *yes)
  134. ;;
  135. *)
  136. AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
  137. [Define if the vasnprintf implementation needs special code for
  138. the 'a' and 'A' directives.])
  139. AC_CHECK_FUNCS([nl_langinfo])
  140. ;;
  141. esac
  142. ])
  143. # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
  144. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
  145. [
  146. AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
  147. case "$gl_cv_func_printf_directive_f" in
  148. *yes)
  149. ;;
  150. *)
  151. AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
  152. [Define if the vasnprintf implementation needs special code for
  153. the 'F' directive.])
  154. ;;
  155. esac
  156. ])
  157. # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
  158. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
  159. [
  160. AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
  161. case "$gl_cv_func_printf_directive_ls" in
  162. *yes)
  163. ;;
  164. *)
  165. AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
  166. [Define if the vasnprintf implementation needs special code for
  167. the 'ls' directive.])
  168. ;;
  169. esac
  170. ])
  171. # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
  172. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
  173. [
  174. AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
  175. case "$gl_cv_func_printf_flag_grouping" in
  176. *yes)
  177. ;;
  178. *)
  179. AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
  180. [Define if the vasnprintf implementation needs special code for the
  181. ' flag.])
  182. ;;
  183. esac
  184. ])
  185. # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
  186. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
  187. [
  188. AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
  189. case "$gl_cv_func_printf_flag_leftadjust" in
  190. *yes)
  191. ;;
  192. *)
  193. AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
  194. [Define if the vasnprintf implementation needs special code for the
  195. '-' flag.])
  196. ;;
  197. esac
  198. ])
  199. # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
  200. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
  201. [
  202. AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
  203. case "$gl_cv_func_printf_flag_zero" in
  204. *yes)
  205. ;;
  206. *)
  207. AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
  208. [Define if the vasnprintf implementation needs special code for the
  209. 0 flag.])
  210. ;;
  211. esac
  212. ])
  213. # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
  214. AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
  215. [
  216. AC_REQUIRE([gl_PRINTF_PRECISION])
  217. case "$gl_cv_func_printf_precision" in
  218. *yes)
  219. ;;
  220. *)
  221. AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
  222. [Define if the vasnprintf implementation needs special code for
  223. supporting large precisions without arbitrary bounds.])
  224. AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
  225. [Define if the vasnprintf implementation needs special code for
  226. 'double' arguments.])
  227. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  228. [Define if the vasnprintf implementation needs special code for
  229. 'long double' arguments.])
  230. ;;
  231. esac
  232. ])
  233. # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
  234. # conditions.
  235. AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
  236. [
  237. AC_REQUIRE([gl_PRINTF_ENOMEM])
  238. case "$gl_cv_func_printf_enomem" in
  239. *yes)
  240. ;;
  241. *)
  242. AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
  243. [Define if the vasnprintf implementation needs special code for
  244. surviving out-of-memory conditions.])
  245. AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
  246. [Define if the vasnprintf implementation needs special code for
  247. 'double' arguments.])
  248. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  249. [Define if the vasnprintf implementation needs special code for
  250. 'long double' arguments.])
  251. ;;
  252. esac
  253. ])
  254. # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
  255. AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
  256. [
  257. AC_REQUIRE([gl_PREREQ_VASNPRINTF])
  258. gl_PREREQ_VASNPRINTF_LONG_DOUBLE
  259. gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
  260. gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
  261. gl_PREREQ_VASNPRINTF_DIRECTIVE_A
  262. gl_PREREQ_VASNPRINTF_DIRECTIVE_F
  263. gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
  264. gl_PREREQ_VASNPRINTF_FLAG_GROUPING
  265. gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
  266. gl_PREREQ_VASNPRINTF_FLAG_ZERO
  267. gl_PREREQ_VASNPRINTF_PRECISION
  268. gl_PREREQ_VASNPRINTF_ENOMEM
  269. ])
  270. # Prerequisites of lib/asnprintf.c.
  271. AC_DEFUN([gl_PREREQ_ASNPRINTF],
  272. [
  273. ])