vasnprintf.m4 8.6 KB

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