vasnprintf.m4 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. # vasnprintf.m4 serial 24
  2. dnl Copyright (C) 2002-2004, 2006-2008 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_REQUIRE([gl_EOVERFLOW])
  9. AC_CHECK_FUNCS_ONCE([vasnprintf])
  10. if test $ac_cv_func_vasnprintf = no; then
  11. gl_REPLACE_VASNPRINTF
  12. fi
  13. ])
  14. AC_DEFUN([gl_REPLACE_VASNPRINTF],
  15. [
  16. AC_CHECK_FUNCS_ONCE([vasnprintf])
  17. AC_LIBOBJ([vasnprintf])
  18. AC_LIBOBJ([printf-args])
  19. AC_LIBOBJ([printf-parse])
  20. AC_LIBOBJ([asnprintf])
  21. if test $ac_cv_func_vasnprintf = yes; then
  22. AC_DEFINE([REPLACE_VASNPRINTF], 1,
  23. [Define if vasnprintf exists but is overridden by gnulib.])
  24. fi
  25. gl_PREREQ_PRINTF_ARGS
  26. gl_PREREQ_PRINTF_PARSE
  27. gl_PREREQ_VASNPRINTF
  28. gl_PREREQ_ASNPRINTF
  29. ])
  30. # Prequisites of lib/printf-args.h, lib/printf-args.c.
  31. AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
  32. [
  33. AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
  34. AC_REQUIRE([gt_TYPE_WCHAR_T])
  35. AC_REQUIRE([gt_TYPE_WINT_T])
  36. ])
  37. # Prequisites of lib/printf-parse.h, lib/printf-parse.c.
  38. AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
  39. [
  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([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 wcslen)
  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. ])
  62. # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
  63. # arguments.
  64. AC_DEFUN([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
  65. [
  66. AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
  67. case "$gl_cv_func_printf_long_double" in
  68. *yes)
  69. ;;
  70. *)
  71. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
  72. [Define if the vasnprintf implementation needs special code for
  73. 'long double' arguments.])
  74. ;;
  75. esac
  76. ])
  77. # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
  78. # arguments.
  79. AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
  80. [
  81. AC_REQUIRE([gl_PRINTF_INFINITE])
  82. case "$gl_cv_func_printf_infinite" in
  83. *yes)
  84. ;;
  85. *)
  86. AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], 1,
  87. [Define if the vasnprintf implementation needs special code for
  88. infinite 'double' arguments.])
  89. ;;
  90. esac
  91. ])
  92. # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
  93. # arguments.
  94. AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
  95. [
  96. AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
  97. dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
  98. dnl NEED_PRINTF_LONG_DOUBLE is already set.
  99. AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
  100. case "$gl_cv_func_printf_long_double" in
  101. *yes)
  102. case "$gl_cv_func_printf_infinite_long_double" in
  103. *yes)
  104. ;;
  105. *)
  106. AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], 1,
  107. [Define if the vasnprintf implementation needs special code for
  108. infinite 'long double' arguments.])
  109. ;;
  110. esac
  111. ;;
  112. esac
  113. ])
  114. # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
  115. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
  116. [
  117. AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
  118. case "$gl_cv_func_printf_directive_a" in
  119. *yes)
  120. ;;
  121. *)
  122. AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
  123. [Define if the vasnprintf implementation needs special code for
  124. the 'a' and 'A' directives.])
  125. AC_CHECK_FUNCS([nl_langinfo])
  126. ;;
  127. esac
  128. ])
  129. # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
  130. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
  131. [
  132. AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
  133. case "$gl_cv_func_printf_directive_f" in
  134. *yes)
  135. ;;
  136. *)
  137. AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], 1,
  138. [Define if the vasnprintf implementation needs special code for
  139. the 'F' directive.])
  140. ;;
  141. esac
  142. ])
  143. # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
  144. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
  145. [
  146. AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
  147. case "$gl_cv_func_printf_flag_grouping" in
  148. *yes)
  149. ;;
  150. *)
  151. AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], 1,
  152. [Define if the vasnprintf implementation needs special code for the
  153. ' flag.])
  154. ;;
  155. esac
  156. ])
  157. # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
  158. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
  159. [
  160. AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
  161. case "$gl_cv_func_printf_flag_leftadjust" in
  162. *yes)
  163. ;;
  164. *)
  165. AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], 1,
  166. [Define if the vasnprintf implementation needs special code for the
  167. '-' flag.])
  168. ;;
  169. esac
  170. ])
  171. # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
  172. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
  173. [
  174. AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
  175. case "$gl_cv_func_printf_flag_zero" in
  176. *yes)
  177. ;;
  178. *)
  179. AC_DEFINE([NEED_PRINTF_FLAG_ZERO], 1,
  180. [Define if the vasnprintf implementation needs special code for the
  181. 0 flag.])
  182. ;;
  183. esac
  184. ])
  185. # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
  186. AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
  187. [
  188. AC_REQUIRE([gl_PRINTF_PRECISION])
  189. case "$gl_cv_func_printf_precision" in
  190. *yes)
  191. ;;
  192. *)
  193. AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], 1,
  194. [Define if the vasnprintf implementation needs special code for
  195. supporting large precisions without arbitrary bounds.])
  196. AC_DEFINE([NEED_PRINTF_DOUBLE], 1,
  197. [Define if the vasnprintf implementation needs special code for
  198. 'double' arguments.])
  199. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
  200. [Define if the vasnprintf implementation needs special code for
  201. 'long double' arguments.])
  202. ;;
  203. esac
  204. ])
  205. # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
  206. # conditions.
  207. AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
  208. [
  209. AC_REQUIRE([gl_PRINTF_ENOMEM])
  210. case "$gl_cv_func_printf_enomem" in
  211. *yes)
  212. ;;
  213. *)
  214. AC_DEFINE([NEED_PRINTF_ENOMEM], 1,
  215. [Define if the vasnprintf implementation needs special code for
  216. surviving out-of-memory conditions.])
  217. AC_DEFINE([NEED_PRINTF_DOUBLE], 1,
  218. [Define if the vasnprintf implementation needs special code for
  219. 'double' arguments.])
  220. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
  221. [Define if the vasnprintf implementation needs special code for
  222. 'long double' arguments.])
  223. ;;
  224. esac
  225. ])
  226. # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
  227. AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
  228. [
  229. AC_REQUIRE([gl_PREREQ_VASNPRINTF])
  230. gl_PREREQ_VASNPRINTF_LONG_DOUBLE
  231. gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
  232. gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
  233. gl_PREREQ_VASNPRINTF_DIRECTIVE_A
  234. gl_PREREQ_VASNPRINTF_DIRECTIVE_F
  235. gl_PREREQ_VASNPRINTF_FLAG_GROUPING
  236. gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
  237. gl_PREREQ_VASNPRINTF_FLAG_ZERO
  238. gl_PREREQ_VASNPRINTF_PRECISION
  239. gl_PREREQ_VASNPRINTF_ENOMEM
  240. ])
  241. # Prerequisites of lib/asnprintf.c.
  242. AC_DEFUN([gl_PREREQ_ASNPRINTF],
  243. [
  244. ])