vasnprintf.m4 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. # vasnprintf.m4 serial 29
  2. dnl Copyright (C) 2002-2004, 2006-2009 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. # Prequisites 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. # Prequisites of lib/printf-parse.h, lib/printf-parse.c.
  37. AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
  38. [
  39. AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
  40. AC_REQUIRE([gt_TYPE_WCHAR_T])
  41. AC_REQUIRE([gt_TYPE_WINT_T])
  42. AC_REQUIRE([AC_TYPE_SIZE_T])
  43. AC_CHECK_TYPE([ptrdiff_t], ,
  44. [AC_DEFINE([ptrdiff_t], [long],
  45. [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
  46. ])
  47. AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
  48. ])
  49. # Prerequisites of lib/vasnprintf.c.
  50. AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
  51. [
  52. AC_REQUIRE([AC_FUNC_ALLOCA])
  53. AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
  54. AC_REQUIRE([gt_TYPE_WCHAR_T])
  55. AC_REQUIRE([gt_TYPE_WINT_T])
  56. AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
  57. dnl Use the _snprintf function only if it is declared (because on NetBSD it
  58. dnl is defined as a weak alias of snprintf; we prefer to use the latter).
  59. AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
  60. ])
  61. # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
  62. # arguments.
  63. AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
  64. [
  65. AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
  66. case "$gl_cv_func_printf_long_double" in
  67. *yes)
  68. ;;
  69. *)
  70. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  71. [Define if the vasnprintf implementation needs special code for
  72. 'long double' arguments.])
  73. ;;
  74. esac
  75. ])
  76. # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
  77. # arguments.
  78. AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
  79. [
  80. AC_REQUIRE([gl_PRINTF_INFINITE])
  81. case "$gl_cv_func_printf_infinite" in
  82. *yes)
  83. ;;
  84. *)
  85. AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
  86. [Define if the vasnprintf implementation needs special code for
  87. infinite 'double' arguments.])
  88. ;;
  89. esac
  90. ])
  91. # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
  92. # arguments.
  93. AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
  94. [
  95. AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
  96. dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
  97. dnl NEED_PRINTF_LONG_DOUBLE is already set.
  98. AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
  99. case "$gl_cv_func_printf_long_double" in
  100. *yes)
  101. case "$gl_cv_func_printf_infinite_long_double" in
  102. *yes)
  103. ;;
  104. *)
  105. AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
  106. [Define if the vasnprintf implementation needs special code for
  107. infinite 'long double' arguments.])
  108. ;;
  109. esac
  110. ;;
  111. esac
  112. ])
  113. # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
  114. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
  115. [
  116. AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
  117. case "$gl_cv_func_printf_directive_a" in
  118. *yes)
  119. ;;
  120. *)
  121. AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
  122. [Define if the vasnprintf implementation needs special code for
  123. the 'a' and 'A' directives.])
  124. AC_CHECK_FUNCS([nl_langinfo])
  125. ;;
  126. esac
  127. ])
  128. # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
  129. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
  130. [
  131. AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
  132. case "$gl_cv_func_printf_directive_f" in
  133. *yes)
  134. ;;
  135. *)
  136. AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
  137. [Define if the vasnprintf implementation needs special code for
  138. the 'F' directive.])
  139. ;;
  140. esac
  141. ])
  142. # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
  143. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
  144. [
  145. AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
  146. case "$gl_cv_func_printf_directive_ls" in
  147. *yes)
  148. ;;
  149. *)
  150. AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
  151. [Define if the vasnprintf implementation needs special code for
  152. the 'ls' directive.])
  153. ;;
  154. esac
  155. ])
  156. # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
  157. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
  158. [
  159. AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
  160. case "$gl_cv_func_printf_flag_grouping" in
  161. *yes)
  162. ;;
  163. *)
  164. AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
  165. [Define if the vasnprintf implementation needs special code for the
  166. ' flag.])
  167. ;;
  168. esac
  169. ])
  170. # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
  171. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
  172. [
  173. AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
  174. case "$gl_cv_func_printf_flag_leftadjust" in
  175. *yes)
  176. ;;
  177. *)
  178. AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
  179. [Define if the vasnprintf implementation needs special code for the
  180. '-' flag.])
  181. ;;
  182. esac
  183. ])
  184. # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
  185. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
  186. [
  187. AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
  188. case "$gl_cv_func_printf_flag_zero" in
  189. *yes)
  190. ;;
  191. *)
  192. AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
  193. [Define if the vasnprintf implementation needs special code for the
  194. 0 flag.])
  195. ;;
  196. esac
  197. ])
  198. # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
  199. AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
  200. [
  201. AC_REQUIRE([gl_PRINTF_PRECISION])
  202. case "$gl_cv_func_printf_precision" in
  203. *yes)
  204. ;;
  205. *)
  206. AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
  207. [Define if the vasnprintf implementation needs special code for
  208. supporting large precisions without arbitrary bounds.])
  209. AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
  210. [Define if the vasnprintf implementation needs special code for
  211. 'double' arguments.])
  212. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  213. [Define if the vasnprintf implementation needs special code for
  214. 'long double' arguments.])
  215. ;;
  216. esac
  217. ])
  218. # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
  219. # conditions.
  220. AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
  221. [
  222. AC_REQUIRE([gl_PRINTF_ENOMEM])
  223. case "$gl_cv_func_printf_enomem" in
  224. *yes)
  225. ;;
  226. *)
  227. AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
  228. [Define if the vasnprintf implementation needs special code for
  229. surviving out-of-memory conditions.])
  230. AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
  231. [Define if the vasnprintf implementation needs special code for
  232. 'double' arguments.])
  233. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  234. [Define if the vasnprintf implementation needs special code for
  235. 'long double' arguments.])
  236. ;;
  237. esac
  238. ])
  239. # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
  240. AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
  241. [
  242. AC_REQUIRE([gl_PREREQ_VASNPRINTF])
  243. gl_PREREQ_VASNPRINTF_LONG_DOUBLE
  244. gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
  245. gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
  246. gl_PREREQ_VASNPRINTF_DIRECTIVE_A
  247. gl_PREREQ_VASNPRINTF_DIRECTIVE_F
  248. gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
  249. gl_PREREQ_VASNPRINTF_FLAG_GROUPING
  250. gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
  251. gl_PREREQ_VASNPRINTF_FLAG_ZERO
  252. gl_PREREQ_VASNPRINTF_PRECISION
  253. gl_PREREQ_VASNPRINTF_ENOMEM
  254. ])
  255. # Prerequisites of lib/asnprintf.c.
  256. AC_DEFUN([gl_PREREQ_ASNPRINTF],
  257. [
  258. ])