vasnprintf.m4 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. # vasnprintf.m4 serial 31
  2. dnl Copyright (C) 2002-2004, 2006-2010 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_C_INLINE])
  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 We can avoid a lot of code by assuming that snprintf's return value
  62. dnl conforms to ISO C99. So check that.
  63. AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
  64. case "$gl_cv_func_snprintf_retval_c99" in
  65. *yes)
  66. AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
  67. [Define if the return value of the snprintf function is the number of
  68. of bytes (excluding the terminating NUL) that would have been produced
  69. if the buffer had been large enough.])
  70. ;;
  71. esac
  72. ])
  73. # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
  74. # arguments.
  75. AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
  76. [
  77. AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
  78. case "$gl_cv_func_printf_long_double" in
  79. *yes)
  80. ;;
  81. *)
  82. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  83. [Define if the vasnprintf implementation needs special code for
  84. 'long double' arguments.])
  85. ;;
  86. esac
  87. ])
  88. # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
  89. # arguments.
  90. AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
  91. [
  92. AC_REQUIRE([gl_PRINTF_INFINITE])
  93. case "$gl_cv_func_printf_infinite" in
  94. *yes)
  95. ;;
  96. *)
  97. AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
  98. [Define if the vasnprintf implementation needs special code for
  99. infinite 'double' arguments.])
  100. ;;
  101. esac
  102. ])
  103. # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
  104. # arguments.
  105. AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
  106. [
  107. AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
  108. dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
  109. dnl NEED_PRINTF_LONG_DOUBLE is already set.
  110. AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
  111. case "$gl_cv_func_printf_long_double" in
  112. *yes)
  113. case "$gl_cv_func_printf_infinite_long_double" in
  114. *yes)
  115. ;;
  116. *)
  117. AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
  118. [Define if the vasnprintf implementation needs special code for
  119. infinite 'long double' arguments.])
  120. ;;
  121. esac
  122. ;;
  123. esac
  124. ])
  125. # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
  126. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
  127. [
  128. AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
  129. case "$gl_cv_func_printf_directive_a" in
  130. *yes)
  131. ;;
  132. *)
  133. AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
  134. [Define if the vasnprintf implementation needs special code for
  135. the 'a' and 'A' directives.])
  136. AC_CHECK_FUNCS([nl_langinfo])
  137. ;;
  138. esac
  139. ])
  140. # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
  141. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
  142. [
  143. AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
  144. case "$gl_cv_func_printf_directive_f" in
  145. *yes)
  146. ;;
  147. *)
  148. AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
  149. [Define if the vasnprintf implementation needs special code for
  150. the 'F' directive.])
  151. ;;
  152. esac
  153. ])
  154. # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
  155. AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
  156. [
  157. AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
  158. case "$gl_cv_func_printf_directive_ls" in
  159. *yes)
  160. ;;
  161. *)
  162. AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
  163. [Define if the vasnprintf implementation needs special code for
  164. the 'ls' directive.])
  165. ;;
  166. esac
  167. ])
  168. # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
  169. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
  170. [
  171. AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
  172. case "$gl_cv_func_printf_flag_grouping" in
  173. *yes)
  174. ;;
  175. *)
  176. AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
  177. [Define if the vasnprintf implementation needs special code for the
  178. ' flag.])
  179. ;;
  180. esac
  181. ])
  182. # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
  183. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
  184. [
  185. AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
  186. case "$gl_cv_func_printf_flag_leftadjust" in
  187. *yes)
  188. ;;
  189. *)
  190. AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
  191. [Define if the vasnprintf implementation needs special code for the
  192. '-' flag.])
  193. ;;
  194. esac
  195. ])
  196. # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
  197. AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
  198. [
  199. AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
  200. case "$gl_cv_func_printf_flag_zero" in
  201. *yes)
  202. ;;
  203. *)
  204. AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
  205. [Define if the vasnprintf implementation needs special code for the
  206. 0 flag.])
  207. ;;
  208. esac
  209. ])
  210. # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
  211. AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
  212. [
  213. AC_REQUIRE([gl_PRINTF_PRECISION])
  214. case "$gl_cv_func_printf_precision" in
  215. *yes)
  216. ;;
  217. *)
  218. AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
  219. [Define if the vasnprintf implementation needs special code for
  220. supporting large precisions without arbitrary bounds.])
  221. AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
  222. [Define if the vasnprintf implementation needs special code for
  223. 'double' arguments.])
  224. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  225. [Define if the vasnprintf implementation needs special code for
  226. 'long double' arguments.])
  227. ;;
  228. esac
  229. ])
  230. # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
  231. # conditions.
  232. AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
  233. [
  234. AC_REQUIRE([gl_PRINTF_ENOMEM])
  235. case "$gl_cv_func_printf_enomem" in
  236. *yes)
  237. ;;
  238. *)
  239. AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
  240. [Define if the vasnprintf implementation needs special code for
  241. surviving out-of-memory conditions.])
  242. AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
  243. [Define if the vasnprintf implementation needs special code for
  244. 'double' arguments.])
  245. AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
  246. [Define if the vasnprintf implementation needs special code for
  247. 'long double' arguments.])
  248. ;;
  249. esac
  250. ])
  251. # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
  252. AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
  253. [
  254. AC_REQUIRE([gl_PREREQ_VASNPRINTF])
  255. gl_PREREQ_VASNPRINTF_LONG_DOUBLE
  256. gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
  257. gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
  258. gl_PREREQ_VASNPRINTF_DIRECTIVE_A
  259. gl_PREREQ_VASNPRINTF_DIRECTIVE_F
  260. gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
  261. gl_PREREQ_VASNPRINTF_FLAG_GROUPING
  262. gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
  263. gl_PREREQ_VASNPRINTF_FLAG_ZERO
  264. gl_PREREQ_VASNPRINTF_PRECISION
  265. gl_PREREQ_VASNPRINTF_ENOMEM
  266. ])
  267. # Prerequisites of lib/asnprintf.c.
  268. AC_DEFUN([gl_PREREQ_ASNPRINTF],
  269. [
  270. ])