printf.m4 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  1. # printf.m4 serial 52
  2. dnl Copyright (C) 2003, 2007-2015 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. dnl Test whether the *printf family of functions supports the 'j', 'z', 't',
  7. dnl 'L' size specifiers. (ISO C99, POSIX:2001)
  8. dnl Result is gl_cv_func_printf_sizes_c99.
  9. AC_DEFUN([gl_PRINTF_SIZES_C99],
  10. [
  11. AC_REQUIRE([AC_PROG_CC])
  12. AC_REQUIRE([gl_AC_HEADER_STDINT_H])
  13. AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
  14. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  15. AC_CACHE_CHECK([whether printf supports size specifiers as in C99],
  16. [gl_cv_func_printf_sizes_c99],
  17. [
  18. AC_RUN_IFELSE(
  19. [AC_LANG_SOURCE([[
  20. #include <stddef.h>
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include <sys/types.h>
  24. #if HAVE_STDINT_H_WITH_UINTMAX
  25. # include <stdint.h>
  26. #endif
  27. #if HAVE_INTTYPES_H_WITH_UINTMAX
  28. # include <inttypes.h>
  29. #endif
  30. static char buf[100];
  31. int main ()
  32. {
  33. int result = 0;
  34. #if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
  35. buf[0] = '\0';
  36. if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
  37. || strcmp (buf, "12345671 33") != 0)
  38. result |= 1;
  39. #endif
  40. buf[0] = '\0';
  41. if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
  42. || strcmp (buf, "12345672 33") != 0)
  43. result |= 2;
  44. buf[0] = '\0';
  45. if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0
  46. || strcmp (buf, "12345673 33") != 0)
  47. result |= 4;
  48. buf[0] = '\0';
  49. if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0
  50. || strcmp (buf, "1.5 33") != 0)
  51. result |= 8;
  52. return result;
  53. }]])],
  54. [gl_cv_func_printf_sizes_c99=yes],
  55. [gl_cv_func_printf_sizes_c99=no],
  56. [
  57. changequote(,)dnl
  58. case "$host_os" in
  59. # Guess yes on glibc systems.
  60. *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
  61. # Guess yes on FreeBSD >= 5.
  62. freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";;
  63. freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
  64. # Guess yes on Mac OS X >= 10.3.
  65. darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";;
  66. darwin*) gl_cv_func_printf_sizes_c99="guessing yes";;
  67. # Guess yes on OpenBSD >= 3.9.
  68. openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
  69. gl_cv_func_printf_sizes_c99="guessing no";;
  70. openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
  71. # Guess yes on Solaris >= 2.10.
  72. solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
  73. solaris*) gl_cv_func_printf_sizes_c99="guessing no";;
  74. # Guess yes on NetBSD >= 3.
  75. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
  76. gl_cv_func_printf_sizes_c99="guessing no";;
  77. netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
  78. # If we don't know, assume the worst.
  79. *) gl_cv_func_printf_sizes_c99="guessing no";;
  80. esac
  81. changequote([,])dnl
  82. ])
  83. ])
  84. ])
  85. dnl Test whether the *printf family of functions supports 'long double'
  86. dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
  87. dnl Result is gl_cv_func_printf_long_double.
  88. AC_DEFUN([gl_PRINTF_LONG_DOUBLE],
  89. [
  90. AC_REQUIRE([AC_PROG_CC])
  91. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  92. AC_CACHE_CHECK([whether printf supports 'long double' arguments],
  93. [gl_cv_func_printf_long_double],
  94. [
  95. AC_RUN_IFELSE(
  96. [AC_LANG_SOURCE([[
  97. #include <stdio.h>
  98. #include <string.h>
  99. static char buf[10000];
  100. int main ()
  101. {
  102. int result = 0;
  103. buf[0] = '\0';
  104. if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
  105. || strcmp (buf, "1.750000 33") != 0)
  106. result |= 1;
  107. buf[0] = '\0';
  108. if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
  109. || strcmp (buf, "1.750000e+00 33") != 0)
  110. result |= 2;
  111. buf[0] = '\0';
  112. if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
  113. || strcmp (buf, "1.75 33") != 0)
  114. result |= 4;
  115. return result;
  116. }]])],
  117. [gl_cv_func_printf_long_double=yes],
  118. [gl_cv_func_printf_long_double=no],
  119. [
  120. changequote(,)dnl
  121. case "$host_os" in
  122. beos*) gl_cv_func_printf_long_double="guessing no";;
  123. mingw* | pw*) gl_cv_func_printf_long_double="guessing no";;
  124. *) gl_cv_func_printf_long_double="guessing yes";;
  125. esac
  126. changequote([,])dnl
  127. ])
  128. ])
  129. ])
  130. dnl Test whether the *printf family of functions supports infinite and NaN
  131. dnl 'double' arguments and negative zero arguments in the %f, %e, %g
  132. dnl directives. (ISO C99, POSIX:2001)
  133. dnl Result is gl_cv_func_printf_infinite.
  134. AC_DEFUN([gl_PRINTF_INFINITE],
  135. [
  136. AC_REQUIRE([AC_PROG_CC])
  137. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  138. AC_CACHE_CHECK([whether printf supports infinite 'double' arguments],
  139. [gl_cv_func_printf_infinite],
  140. [
  141. AC_RUN_IFELSE(
  142. [AC_LANG_SOURCE([[
  143. #include <stdio.h>
  144. #include <string.h>
  145. static int
  146. strisnan (const char *string, size_t start_index, size_t end_index)
  147. {
  148. if (start_index < end_index)
  149. {
  150. if (string[start_index] == '-')
  151. start_index++;
  152. if (start_index + 3 <= end_index
  153. && memcmp (string + start_index, "nan", 3) == 0)
  154. {
  155. start_index += 3;
  156. if (start_index == end_index
  157. || (string[start_index] == '(' && string[end_index - 1] == ')'))
  158. return 1;
  159. }
  160. }
  161. return 0;
  162. }
  163. static int
  164. have_minus_zero ()
  165. {
  166. static double plus_zero = 0.0;
  167. double minus_zero = - plus_zero;
  168. return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0;
  169. }
  170. static char buf[10000];
  171. static double zero = 0.0;
  172. int main ()
  173. {
  174. int result = 0;
  175. if (sprintf (buf, "%f", 1.0 / zero) < 0
  176. || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
  177. result |= 1;
  178. if (sprintf (buf, "%f", -1.0 / zero) < 0
  179. || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
  180. result |= 1;
  181. if (sprintf (buf, "%f", zero / zero) < 0
  182. || !strisnan (buf, 0, strlen (buf)))
  183. result |= 2;
  184. if (sprintf (buf, "%e", 1.0 / zero) < 0
  185. || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
  186. result |= 4;
  187. if (sprintf (buf, "%e", -1.0 / zero) < 0
  188. || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
  189. result |= 4;
  190. if (sprintf (buf, "%e", zero / zero) < 0
  191. || !strisnan (buf, 0, strlen (buf)))
  192. result |= 8;
  193. if (sprintf (buf, "%g", 1.0 / zero) < 0
  194. || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
  195. result |= 16;
  196. if (sprintf (buf, "%g", -1.0 / zero) < 0
  197. || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
  198. result |= 16;
  199. if (sprintf (buf, "%g", zero / zero) < 0
  200. || !strisnan (buf, 0, strlen (buf)))
  201. result |= 32;
  202. /* This test fails on HP-UX 10.20. */
  203. if (have_minus_zero ())
  204. if (sprintf (buf, "%g", - zero) < 0
  205. || strcmp (buf, "-0") != 0)
  206. result |= 64;
  207. return result;
  208. }]])],
  209. [gl_cv_func_printf_infinite=yes],
  210. [gl_cv_func_printf_infinite=no],
  211. [
  212. changequote(,)dnl
  213. case "$host_os" in
  214. # Guess yes on glibc systems.
  215. *-gnu*) gl_cv_func_printf_infinite="guessing yes";;
  216. # Guess yes on FreeBSD >= 6.
  217. freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
  218. freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
  219. # Guess yes on Mac OS X >= 10.3.
  220. darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";;
  221. darwin*) gl_cv_func_printf_infinite="guessing yes";;
  222. # Guess yes on HP-UX >= 11.
  223. hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";;
  224. hpux*) gl_cv_func_printf_infinite="guessing yes";;
  225. # Guess yes on NetBSD >= 3.
  226. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
  227. gl_cv_func_printf_infinite="guessing no";;
  228. netbsd*) gl_cv_func_printf_infinite="guessing yes";;
  229. # Guess yes on BeOS.
  230. beos*) gl_cv_func_printf_infinite="guessing yes";;
  231. # If we don't know, assume the worst.
  232. *) gl_cv_func_printf_infinite="guessing no";;
  233. esac
  234. changequote([,])dnl
  235. ])
  236. ])
  237. ])
  238. dnl Test whether the *printf family of functions supports infinite and NaN
  239. dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
  240. dnl Result is gl_cv_func_printf_infinite_long_double.
  241. AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
  242. [
  243. AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
  244. AC_REQUIRE([AC_PROG_CC])
  245. AC_REQUIRE([gl_BIGENDIAN])
  246. AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
  247. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  248. dnl The user can set or unset the variable gl_printf_safe to indicate
  249. dnl that he wishes a safe handling of non-IEEE-754 'long double' values.
  250. if test -n "$gl_printf_safe"; then
  251. AC_DEFINE([CHECK_PRINTF_SAFE], [1],
  252. [Define if you wish *printf() functions that have a safe handling of
  253. non-IEEE-754 'long double' values.])
  254. fi
  255. case "$gl_cv_func_printf_long_double" in
  256. *yes)
  257. AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments],
  258. [gl_cv_func_printf_infinite_long_double],
  259. [
  260. AC_RUN_IFELSE(
  261. [AC_LANG_SOURCE([[
  262. ]GL_NOCRASH[
  263. #include <float.h>
  264. #include <stdio.h>
  265. #include <string.h>
  266. static int
  267. strisnan (const char *string, size_t start_index, size_t end_index)
  268. {
  269. if (start_index < end_index)
  270. {
  271. if (string[start_index] == '-')
  272. start_index++;
  273. if (start_index + 3 <= end_index
  274. && memcmp (string + start_index, "nan", 3) == 0)
  275. {
  276. start_index += 3;
  277. if (start_index == end_index
  278. || (string[start_index] == '(' && string[end_index - 1] == ')'))
  279. return 1;
  280. }
  281. }
  282. return 0;
  283. }
  284. static char buf[10000];
  285. static long double zeroL = 0.0L;
  286. int main ()
  287. {
  288. int result = 0;
  289. nocrash_init();
  290. if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0
  291. || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
  292. result |= 1;
  293. if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0
  294. || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
  295. result |= 1;
  296. if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
  297. || !strisnan (buf, 0, strlen (buf)))
  298. result |= 1;
  299. if (sprintf (buf, "%Le", 1.0L / zeroL) < 0
  300. || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
  301. result |= 1;
  302. if (sprintf (buf, "%Le", -1.0L / zeroL) < 0
  303. || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
  304. result |= 1;
  305. if (sprintf (buf, "%Le", zeroL / zeroL) < 0
  306. || !strisnan (buf, 0, strlen (buf)))
  307. result |= 1;
  308. if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0
  309. || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
  310. result |= 1;
  311. if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0
  312. || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
  313. result |= 1;
  314. if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
  315. || !strisnan (buf, 0, strlen (buf)))
  316. result |= 1;
  317. #if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
  318. /* Representation of an 80-bit 'long double' as an initializer for a sequence
  319. of 'unsigned int' words. */
  320. # ifdef WORDS_BIGENDIAN
  321. # define LDBL80_WORDS(exponent,manthi,mantlo) \
  322. { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
  323. ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \
  324. (unsigned int) (mantlo) << 16 \
  325. }
  326. # else
  327. # define LDBL80_WORDS(exponent,manthi,mantlo) \
  328. { mantlo, manthi, exponent }
  329. # endif
  330. { /* Quiet NaN. */
  331. static union { unsigned int word[4]; long double value; } x =
  332. { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
  333. if (sprintf (buf, "%Lf", x.value) < 0
  334. || !strisnan (buf, 0, strlen (buf)))
  335. result |= 2;
  336. if (sprintf (buf, "%Le", x.value) < 0
  337. || !strisnan (buf, 0, strlen (buf)))
  338. result |= 2;
  339. if (sprintf (buf, "%Lg", x.value) < 0
  340. || !strisnan (buf, 0, strlen (buf)))
  341. result |= 2;
  342. }
  343. {
  344. /* Signalling NaN. */
  345. static union { unsigned int word[4]; long double value; } x =
  346. { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
  347. if (sprintf (buf, "%Lf", x.value) < 0
  348. || !strisnan (buf, 0, strlen (buf)))
  349. result |= 2;
  350. if (sprintf (buf, "%Le", x.value) < 0
  351. || !strisnan (buf, 0, strlen (buf)))
  352. result |= 2;
  353. if (sprintf (buf, "%Lg", x.value) < 0
  354. || !strisnan (buf, 0, strlen (buf)))
  355. result |= 2;
  356. }
  357. { /* Pseudo-NaN. */
  358. static union { unsigned int word[4]; long double value; } x =
  359. { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
  360. if (sprintf (buf, "%Lf", x.value) <= 0)
  361. result |= 4;
  362. if (sprintf (buf, "%Le", x.value) <= 0)
  363. result |= 4;
  364. if (sprintf (buf, "%Lg", x.value) <= 0)
  365. result |= 4;
  366. }
  367. { /* Pseudo-Infinity. */
  368. static union { unsigned int word[4]; long double value; } x =
  369. { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
  370. if (sprintf (buf, "%Lf", x.value) <= 0)
  371. result |= 8;
  372. if (sprintf (buf, "%Le", x.value) <= 0)
  373. result |= 8;
  374. if (sprintf (buf, "%Lg", x.value) <= 0)
  375. result |= 8;
  376. }
  377. { /* Pseudo-Zero. */
  378. static union { unsigned int word[4]; long double value; } x =
  379. { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
  380. if (sprintf (buf, "%Lf", x.value) <= 0)
  381. result |= 16;
  382. if (sprintf (buf, "%Le", x.value) <= 0)
  383. result |= 16;
  384. if (sprintf (buf, "%Lg", x.value) <= 0)
  385. result |= 16;
  386. }
  387. { /* Unnormalized number. */
  388. static union { unsigned int word[4]; long double value; } x =
  389. { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
  390. if (sprintf (buf, "%Lf", x.value) <= 0)
  391. result |= 32;
  392. if (sprintf (buf, "%Le", x.value) <= 0)
  393. result |= 32;
  394. if (sprintf (buf, "%Lg", x.value) <= 0)
  395. result |= 32;
  396. }
  397. { /* Pseudo-Denormal. */
  398. static union { unsigned int word[4]; long double value; } x =
  399. { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
  400. if (sprintf (buf, "%Lf", x.value) <= 0)
  401. result |= 64;
  402. if (sprintf (buf, "%Le", x.value) <= 0)
  403. result |= 64;
  404. if (sprintf (buf, "%Lg", x.value) <= 0)
  405. result |= 64;
  406. }
  407. #endif
  408. return result;
  409. }]])],
  410. [gl_cv_func_printf_infinite_long_double=yes],
  411. [gl_cv_func_printf_infinite_long_double=no],
  412. [
  413. changequote(,)dnl
  414. case "$host_cpu" in
  415. # Guess no on ia64, x86_64, i386.
  416. ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
  417. *)
  418. case "$host_os" in
  419. # Guess yes on glibc systems.
  420. *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
  421. # Guess yes on FreeBSD >= 6.
  422. freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
  423. freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
  424. # Guess yes on HP-UX >= 11.
  425. hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
  426. hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";;
  427. # If we don't know, assume the worst.
  428. *) gl_cv_func_printf_infinite_long_double="guessing no";;
  429. esac
  430. ;;
  431. esac
  432. changequote([,])dnl
  433. ])
  434. ])
  435. ;;
  436. *)
  437. gl_cv_func_printf_infinite_long_double="irrelevant"
  438. ;;
  439. esac
  440. ])
  441. dnl Test whether the *printf family of functions supports the 'a' and 'A'
  442. dnl conversion specifier for hexadecimal output of floating-point numbers.
  443. dnl (ISO C99, POSIX:2001)
  444. dnl Result is gl_cv_func_printf_directive_a.
  445. AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
  446. [
  447. AC_REQUIRE([AC_PROG_CC])
  448. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  449. AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives],
  450. [gl_cv_func_printf_directive_a],
  451. [
  452. AC_RUN_IFELSE(
  453. [AC_LANG_SOURCE([[
  454. #include <stdio.h>
  455. #include <string.h>
  456. static char buf[100];
  457. static double zero = 0.0;
  458. int main ()
  459. {
  460. int result = 0;
  461. if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
  462. || (strcmp (buf, "0x1.922p+1 33") != 0
  463. && strcmp (buf, "0x3.244p+0 33") != 0
  464. && strcmp (buf, "0x6.488p-1 33") != 0
  465. && strcmp (buf, "0xc.91p-2 33") != 0))
  466. result |= 1;
  467. if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
  468. || (strcmp (buf, "-0X1.922P+1 33") != 0
  469. && strcmp (buf, "-0X3.244P+0 33") != 0
  470. && strcmp (buf, "-0X6.488P-1 33") != 0
  471. && strcmp (buf, "-0XC.91P-2 33") != 0))
  472. result |= 2;
  473. /* This catches a FreeBSD 6.1 bug: it doesn't round. */
  474. if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
  475. || (strcmp (buf, "0x1.83p+0 33") != 0
  476. && strcmp (buf, "0x3.05p-1 33") != 0
  477. && strcmp (buf, "0x6.0ap-2 33") != 0
  478. && strcmp (buf, "0xc.14p-3 33") != 0))
  479. result |= 4;
  480. /* This catches a FreeBSD 6.1 bug. See
  481. <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
  482. if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
  483. || buf[0] == '0')
  484. result |= 8;
  485. /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug. */
  486. if (sprintf (buf, "%.1a", 1.999) < 0
  487. || (strcmp (buf, "0x1.0p+1") != 0
  488. && strcmp (buf, "0x2.0p+0") != 0
  489. && strcmp (buf, "0x4.0p-1") != 0
  490. && strcmp (buf, "0x8.0p-2") != 0))
  491. result |= 16;
  492. /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a
  493. glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
  494. if (sprintf (buf, "%.1La", 1.999L) < 0
  495. || (strcmp (buf, "0x1.0p+1") != 0
  496. && strcmp (buf, "0x2.0p+0") != 0
  497. && strcmp (buf, "0x4.0p-1") != 0
  498. && strcmp (buf, "0x8.0p-2") != 0))
  499. result |= 32;
  500. return result;
  501. }]])],
  502. [gl_cv_func_printf_directive_a=yes],
  503. [gl_cv_func_printf_directive_a=no],
  504. [
  505. case "$host_os" in
  506. # Guess yes on glibc >= 2.5 systems.
  507. *-gnu*)
  508. AC_EGREP_CPP([BZ2908], [
  509. #include <features.h>
  510. #ifdef __GNU_LIBRARY__
  511. #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__
  512. BZ2908
  513. #endif
  514. #endif
  515. ],
  516. [gl_cv_func_printf_directive_a="guessing yes"],
  517. [gl_cv_func_printf_directive_a="guessing no"])
  518. ;;
  519. # If we don't know, assume the worst.
  520. *) gl_cv_func_printf_directive_a="guessing no";;
  521. esac
  522. ])
  523. ])
  524. ])
  525. dnl Test whether the *printf family of functions supports the %F format
  526. dnl directive. (ISO C99, POSIX:2001)
  527. dnl Result is gl_cv_func_printf_directive_f.
  528. AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
  529. [
  530. AC_REQUIRE([AC_PROG_CC])
  531. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  532. AC_CACHE_CHECK([whether printf supports the 'F' directive],
  533. [gl_cv_func_printf_directive_f],
  534. [
  535. AC_RUN_IFELSE(
  536. [AC_LANG_SOURCE([[
  537. #include <stdio.h>
  538. #include <string.h>
  539. static char buf[100];
  540. static double zero = 0.0;
  541. int main ()
  542. {
  543. int result = 0;
  544. if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
  545. || strcmp (buf, "1234567.000000 33") != 0)
  546. result |= 1;
  547. if (sprintf (buf, "%F", 1.0 / zero) < 0
  548. || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
  549. result |= 2;
  550. /* This catches a Cygwin 1.5.x bug. */
  551. if (sprintf (buf, "%.F", 1234.0) < 0
  552. || strcmp (buf, "1234") != 0)
  553. result |= 4;
  554. return result;
  555. }]])],
  556. [gl_cv_func_printf_directive_f=yes],
  557. [gl_cv_func_printf_directive_f=no],
  558. [
  559. changequote(,)dnl
  560. case "$host_os" in
  561. # Guess yes on glibc systems.
  562. *-gnu*) gl_cv_func_printf_directive_f="guessing yes";;
  563. # Guess yes on FreeBSD >= 6.
  564. freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
  565. freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
  566. # Guess yes on Mac OS X >= 10.3.
  567. darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
  568. darwin*) gl_cv_func_printf_directive_f="guessing yes";;
  569. # Guess yes on Solaris >= 2.10.
  570. solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
  571. solaris*) gl_cv_func_printf_sizes_c99="guessing no";;
  572. # If we don't know, assume the worst.
  573. *) gl_cv_func_printf_directive_f="guessing no";;
  574. esac
  575. changequote([,])dnl
  576. ])
  577. ])
  578. ])
  579. dnl Test whether the *printf family of functions supports the %n format
  580. dnl directive. (ISO C99, POSIX:2001)
  581. dnl Result is gl_cv_func_printf_directive_n.
  582. AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
  583. [
  584. AC_REQUIRE([AC_PROG_CC])
  585. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  586. AC_CACHE_CHECK([whether printf supports the 'n' directive],
  587. [gl_cv_func_printf_directive_n],
  588. [
  589. AC_RUN_IFELSE(
  590. [AC_LANG_SOURCE([[
  591. #include <stdio.h>
  592. #include <stdlib.h>
  593. #include <string.h>
  594. #ifdef _MSC_VER
  595. /* See page about "Parameter Validation" on msdn.microsoft.com. */
  596. static void cdecl
  597. invalid_parameter_handler (const wchar_t *expression,
  598. const wchar_t *function,
  599. const wchar_t *file, unsigned int line,
  600. uintptr_t dummy)
  601. {
  602. exit (1);
  603. }
  604. #endif
  605. static char fmtstring[10];
  606. static char buf[100];
  607. int main ()
  608. {
  609. int count = -1;
  610. #ifdef _MSC_VER
  611. _set_invalid_parameter_handler (invalid_parameter_handler);
  612. #endif
  613. /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
  614. support %n in format strings in read-only memory but not in writable
  615. memory. */
  616. strcpy (fmtstring, "%d %n");
  617. if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0
  618. || strcmp (buf, "123 ") != 0
  619. || count != 4)
  620. return 1;
  621. return 0;
  622. }]])],
  623. [gl_cv_func_printf_directive_n=yes],
  624. [gl_cv_func_printf_directive_n=no],
  625. [
  626. changequote(,)dnl
  627. case "$host_os" in
  628. mingw*) gl_cv_func_printf_directive_n="guessing no";;
  629. *) gl_cv_func_printf_directive_n="guessing yes";;
  630. esac
  631. changequote([,])dnl
  632. ])
  633. ])
  634. ])
  635. dnl Test whether the *printf family of functions supports the %ls format
  636. dnl directive and in particular, when a precision is specified, whether
  637. dnl the functions stop converting the wide string argument when the number
  638. dnl of bytes that have been produced by this conversion equals or exceeds
  639. dnl the precision.
  640. dnl Result is gl_cv_func_printf_directive_ls.
  641. AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
  642. [
  643. AC_REQUIRE([AC_PROG_CC])
  644. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  645. AC_CACHE_CHECK([whether printf supports the 'ls' directive],
  646. [gl_cv_func_printf_directive_ls],
  647. [
  648. AC_RUN_IFELSE(
  649. [AC_LANG_SOURCE([[
  650. /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  651. <wchar.h>.
  652. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  653. included before <wchar.h>. */
  654. #include <stddef.h>
  655. #include <stdio.h>
  656. #include <time.h>
  657. #include <wchar.h>
  658. #include <string.h>
  659. int main ()
  660. {
  661. int result = 0;
  662. char buf[100];
  663. /* Test whether %ls works at all.
  664. This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on
  665. Cygwin 1.5. */
  666. {
  667. static const wchar_t wstring[] = { 'a', 'b', 'c', 0 };
  668. buf[0] = '\0';
  669. if (sprintf (buf, "%ls", wstring) < 0
  670. || strcmp (buf, "abc") != 0)
  671. result |= 1;
  672. }
  673. /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an
  674. assertion failure inside libc), but not on OpenBSD 4.0. */
  675. {
  676. static const wchar_t wstring[] = { 'a', 0 };
  677. buf[0] = '\0';
  678. if (sprintf (buf, "%ls", wstring) < 0
  679. || strcmp (buf, "a") != 0)
  680. result |= 2;
  681. }
  682. /* Test whether precisions in %ls are supported as specified in ISO C 99
  683. section 7.19.6.1:
  684. "If a precision is specified, no more than that many bytes are written
  685. (including shift sequences, if any), and the array shall contain a
  686. null wide character if, to equal the multibyte character sequence
  687. length given by the precision, the function would need to access a
  688. wide character one past the end of the array."
  689. This test fails on Solaris 10. */
  690. {
  691. static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 };
  692. buf[0] = '\0';
  693. if (sprintf (buf, "%.2ls", wstring) < 0
  694. || strcmp (buf, "ab") != 0)
  695. result |= 8;
  696. }
  697. return result;
  698. }]])],
  699. [gl_cv_func_printf_directive_ls=yes],
  700. [gl_cv_func_printf_directive_ls=no],
  701. [
  702. changequote(,)dnl
  703. case "$host_os" in
  704. openbsd*) gl_cv_func_printf_directive_ls="guessing no";;
  705. irix*) gl_cv_func_printf_directive_ls="guessing no";;
  706. solaris*) gl_cv_func_printf_directive_ls="guessing no";;
  707. cygwin*) gl_cv_func_printf_directive_ls="guessing no";;
  708. beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
  709. *) gl_cv_func_printf_directive_ls="guessing yes";;
  710. esac
  711. changequote([,])dnl
  712. ])
  713. ])
  714. ])
  715. dnl Test whether the *printf family of functions supports POSIX/XSI format
  716. dnl strings with positions. (POSIX:2001)
  717. dnl Result is gl_cv_func_printf_positions.
  718. AC_DEFUN([gl_PRINTF_POSITIONS],
  719. [
  720. AC_REQUIRE([AC_PROG_CC])
  721. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  722. AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions],
  723. [gl_cv_func_printf_positions],
  724. [
  725. AC_RUN_IFELSE(
  726. [AC_LANG_SOURCE([[
  727. #include <stdio.h>
  728. #include <string.h>
  729. /* The string "%2$d %1$d", with dollar characters protected from the shell's
  730. dollar expansion (possibly an autoconf bug). */
  731. static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
  732. static char buf[100];
  733. int main ()
  734. {
  735. sprintf (buf, format, 33, 55);
  736. return (strcmp (buf, "55 33") != 0);
  737. }]])],
  738. [gl_cv_func_printf_positions=yes],
  739. [gl_cv_func_printf_positions=no],
  740. [
  741. changequote(,)dnl
  742. case "$host_os" in
  743. netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
  744. gl_cv_func_printf_positions="guessing no";;
  745. beos*) gl_cv_func_printf_positions="guessing no";;
  746. mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
  747. *) gl_cv_func_printf_positions="guessing yes";;
  748. esac
  749. changequote([,])dnl
  750. ])
  751. ])
  752. ])
  753. dnl Test whether the *printf family of functions supports POSIX/XSI format
  754. dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001)
  755. dnl Result is gl_cv_func_printf_flag_grouping.
  756. AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
  757. [
  758. AC_REQUIRE([AC_PROG_CC])
  759. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  760. AC_CACHE_CHECK([whether printf supports the grouping flag],
  761. [gl_cv_func_printf_flag_grouping],
  762. [
  763. AC_RUN_IFELSE(
  764. [AC_LANG_SOURCE([[
  765. #include <stdio.h>
  766. #include <string.h>
  767. static char buf[100];
  768. int main ()
  769. {
  770. if (sprintf (buf, "%'d %d", 1234567, 99) < 0
  771. || buf[strlen (buf) - 1] != '9')
  772. return 1;
  773. return 0;
  774. }]])],
  775. [gl_cv_func_printf_flag_grouping=yes],
  776. [gl_cv_func_printf_flag_grouping=no],
  777. [
  778. changequote(,)dnl
  779. case "$host_os" in
  780. cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
  781. netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
  782. mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
  783. *) gl_cv_func_printf_flag_grouping="guessing yes";;
  784. esac
  785. changequote([,])dnl
  786. ])
  787. ])
  788. ])
  789. dnl Test whether the *printf family of functions supports the - flag correctly.
  790. dnl (ISO C99.) See
  791. dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html>
  792. dnl Result is gl_cv_func_printf_flag_leftadjust.
  793. AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
  794. [
  795. AC_REQUIRE([AC_PROG_CC])
  796. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  797. AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly],
  798. [gl_cv_func_printf_flag_leftadjust],
  799. [
  800. AC_RUN_IFELSE(
  801. [AC_LANG_SOURCE([[
  802. #include <stdio.h>
  803. #include <string.h>
  804. static char buf[100];
  805. int main ()
  806. {
  807. /* Check that a '-' flag is not annihilated by a negative width. */
  808. if (sprintf (buf, "a%-*sc", -3, "b") < 0
  809. || strcmp (buf, "ab c") != 0)
  810. return 1;
  811. return 0;
  812. }]])],
  813. [gl_cv_func_printf_flag_leftadjust=yes],
  814. [gl_cv_func_printf_flag_leftadjust=no],
  815. [
  816. changequote(,)dnl
  817. case "$host_os" in
  818. # Guess yes on HP-UX 11.
  819. hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
  820. # Guess no on HP-UX 10 and older.
  821. hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";;
  822. # Guess yes otherwise.
  823. *) gl_cv_func_printf_flag_leftadjust="guessing yes";;
  824. esac
  825. changequote([,])dnl
  826. ])
  827. ])
  828. ])
  829. dnl Test whether the *printf family of functions supports padding of non-finite
  830. dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
  831. dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html>
  832. dnl Result is gl_cv_func_printf_flag_zero.
  833. AC_DEFUN([gl_PRINTF_FLAG_ZERO],
  834. [
  835. AC_REQUIRE([AC_PROG_CC])
  836. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  837. AC_CACHE_CHECK([whether printf supports the zero flag correctly],
  838. [gl_cv_func_printf_flag_zero],
  839. [
  840. AC_RUN_IFELSE(
  841. [AC_LANG_SOURCE([[
  842. #include <stdio.h>
  843. #include <string.h>
  844. static char buf[100];
  845. static double zero = 0.0;
  846. int main ()
  847. {
  848. if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
  849. || (strcmp (buf, " inf") != 0
  850. && strcmp (buf, " infinity") != 0))
  851. return 1;
  852. return 0;
  853. }]])],
  854. [gl_cv_func_printf_flag_zero=yes],
  855. [gl_cv_func_printf_flag_zero=no],
  856. [
  857. changequote(,)dnl
  858. case "$host_os" in
  859. # Guess yes on glibc systems.
  860. *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
  861. # Guess yes on BeOS.
  862. beos*) gl_cv_func_printf_flag_zero="guessing yes";;
  863. # If we don't know, assume the worst.
  864. *) gl_cv_func_printf_flag_zero="guessing no";;
  865. esac
  866. changequote([,])dnl
  867. ])
  868. ])
  869. ])
  870. dnl Test whether the *printf family of functions supports large precisions.
  871. dnl On mingw, precisions larger than 512 are treated like 512, in integer,
  872. dnl floating-point or pointer output. On Solaris 10/x86, precisions larger
  873. dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC,
  874. dnl precisions larger than 510 in floating-point output yield wrong results.
  875. dnl On AIX 7.1, precisions larger than 998 in floating-point output yield
  876. dnl wrong results. On BeOS, precisions larger than 1044 crash the program.
  877. dnl Result is gl_cv_func_printf_precision.
  878. AC_DEFUN([gl_PRINTF_PRECISION],
  879. [
  880. AC_REQUIRE([AC_PROG_CC])
  881. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  882. AC_CACHE_CHECK([whether printf supports large precisions],
  883. [gl_cv_func_printf_precision],
  884. [
  885. AC_RUN_IFELSE(
  886. [AC_LANG_SOURCE([[
  887. #include <stdio.h>
  888. #include <string.h>
  889. static char buf[5000];
  890. int main ()
  891. {
  892. int result = 0;
  893. #ifdef __BEOS__
  894. /* On BeOS, this would crash and show a dialog box. Avoid the crash. */
  895. return 1;
  896. #endif
  897. if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
  898. result |= 1;
  899. if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
  900. result |= 2;
  901. if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5
  902. || buf[0] != '1')
  903. result |= 4;
  904. if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5
  905. || buf[0] != '1')
  906. result |= 4;
  907. return result;
  908. }]])],
  909. [gl_cv_func_printf_precision=yes],
  910. [gl_cv_func_printf_precision=no],
  911. [
  912. changequote(,)dnl
  913. case "$host_os" in
  914. # Guess no only on Solaris, native Windows, and BeOS systems.
  915. solaris*) gl_cv_func_printf_precision="guessing no" ;;
  916. mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
  917. beos*) gl_cv_func_printf_precision="guessing no" ;;
  918. *) gl_cv_func_printf_precision="guessing yes" ;;
  919. esac
  920. changequote([,])dnl
  921. ])
  922. ])
  923. ])
  924. dnl Test whether the *printf family of functions recovers gracefully in case
  925. dnl of an out-of-memory condition, or whether it crashes the entire program.
  926. dnl Result is gl_cv_func_printf_enomem.
  927. AC_DEFUN([gl_PRINTF_ENOMEM],
  928. [
  929. AC_REQUIRE([AC_PROG_CC])
  930. AC_REQUIRE([gl_MULTIARCH])
  931. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  932. AC_CACHE_CHECK([whether printf survives out-of-memory conditions],
  933. [gl_cv_func_printf_enomem],
  934. [
  935. gl_cv_func_printf_enomem="guessing no"
  936. if test "$cross_compiling" = no; then
  937. if test $APPLE_UNIVERSAL_BUILD = 0; then
  938. AC_LANG_CONFTEST([AC_LANG_SOURCE([
  939. ]GL_NOCRASH[
  940. changequote(,)dnl
  941. #include <stdio.h>
  942. #include <sys/types.h>
  943. #include <sys/time.h>
  944. #include <sys/resource.h>
  945. #include <errno.h>
  946. int main()
  947. {
  948. struct rlimit limit;
  949. int ret;
  950. nocrash_init ();
  951. /* Some printf implementations allocate temporary space with malloc. */
  952. /* On BSD systems, malloc() is limited by RLIMIT_DATA. */
  953. #ifdef RLIMIT_DATA
  954. if (getrlimit (RLIMIT_DATA, &limit) < 0)
  955. return 77;
  956. if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
  957. limit.rlim_max = 5000000;
  958. limit.rlim_cur = limit.rlim_max;
  959. if (setrlimit (RLIMIT_DATA, &limit) < 0)
  960. return 77;
  961. #endif
  962. /* On Linux systems, malloc() is limited by RLIMIT_AS. */
  963. #ifdef RLIMIT_AS
  964. if (getrlimit (RLIMIT_AS, &limit) < 0)
  965. return 77;
  966. if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
  967. limit.rlim_max = 5000000;
  968. limit.rlim_cur = limit.rlim_max;
  969. if (setrlimit (RLIMIT_AS, &limit) < 0)
  970. return 77;
  971. #endif
  972. /* Some printf implementations allocate temporary space on the stack. */
  973. #ifdef RLIMIT_STACK
  974. if (getrlimit (RLIMIT_STACK, &limit) < 0)
  975. return 77;
  976. if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
  977. limit.rlim_max = 5000000;
  978. limit.rlim_cur = limit.rlim_max;
  979. if (setrlimit (RLIMIT_STACK, &limit) < 0)
  980. return 77;
  981. #endif
  982. ret = printf ("%.5000000f", 1.0);
  983. return !(ret == 5000002 || (ret < 0 && errno == ENOMEM));
  984. }
  985. changequote([,])dnl
  986. ])])
  987. if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
  988. (./conftest 2>&AS_MESSAGE_LOG_FD
  989. result=$?
  990. _AS_ECHO_LOG([\$? = $result])
  991. if test $result != 0 && test $result != 77; then result=1; fi
  992. exit $result
  993. ) >/dev/null 2>/dev/null
  994. case $? in
  995. 0) gl_cv_func_printf_enomem="yes" ;;
  996. 77) gl_cv_func_printf_enomem="guessing no" ;;
  997. *) gl_cv_func_printf_enomem="no" ;;
  998. esac
  999. else
  1000. gl_cv_func_printf_enomem="guessing no"
  1001. fi
  1002. rm -fr conftest*
  1003. else
  1004. dnl A universal build on Apple Mac OS X platforms.
  1005. dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode.
  1006. dnl But we need a configuration result that is valid in both modes.
  1007. gl_cv_func_printf_enomem="guessing no"
  1008. fi
  1009. fi
  1010. if test "$gl_cv_func_printf_enomem" = "guessing no"; then
  1011. changequote(,)dnl
  1012. case "$host_os" in
  1013. # Guess yes on glibc systems.
  1014. *-gnu*) gl_cv_func_printf_enomem="guessing yes";;
  1015. # Guess yes on Solaris.
  1016. solaris*) gl_cv_func_printf_enomem="guessing yes";;
  1017. # Guess yes on AIX.
  1018. aix*) gl_cv_func_printf_enomem="guessing yes";;
  1019. # Guess yes on HP-UX/hppa.
  1020. hpux*) case "$host_cpu" in
  1021. hppa*) gl_cv_func_printf_enomem="guessing yes";;
  1022. *) gl_cv_func_printf_enomem="guessing no";;
  1023. esac
  1024. ;;
  1025. # Guess yes on IRIX.
  1026. irix*) gl_cv_func_printf_enomem="guessing yes";;
  1027. # Guess yes on OSF/1.
  1028. osf*) gl_cv_func_printf_enomem="guessing yes";;
  1029. # Guess yes on BeOS.
  1030. beos*) gl_cv_func_printf_enomem="guessing yes";;
  1031. # Guess yes on Haiku.
  1032. haiku*) gl_cv_func_printf_enomem="guessing yes";;
  1033. # If we don't know, assume the worst.
  1034. *) gl_cv_func_printf_enomem="guessing no";;
  1035. esac
  1036. changequote([,])dnl
  1037. fi
  1038. ])
  1039. ])
  1040. dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001)
  1041. dnl Result is ac_cv_func_snprintf.
  1042. AC_DEFUN([gl_SNPRINTF_PRESENCE],
  1043. [
  1044. AC_CHECK_FUNCS_ONCE([snprintf])
  1045. ])
  1046. dnl Test whether the string produced by the snprintf function is always NUL
  1047. dnl terminated. (ISO C99, POSIX:2001)
  1048. dnl Result is gl_cv_func_snprintf_truncation_c99.
  1049. AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
  1050. [
  1051. AC_REQUIRE([AC_PROG_CC])
  1052. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  1053. AC_REQUIRE([gl_SNPRINTF_PRESENCE])
  1054. AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
  1055. [gl_cv_func_snprintf_truncation_c99],
  1056. [
  1057. AC_RUN_IFELSE(
  1058. [AC_LANG_SOURCE([[
  1059. #include <stdio.h>
  1060. #include <string.h>
  1061. #if HAVE_SNPRINTF
  1062. # define my_snprintf snprintf
  1063. #else
  1064. # include <stdarg.h>
  1065. static int my_snprintf (char *buf, int size, const char *format, ...)
  1066. {
  1067. va_list args;
  1068. int ret;
  1069. va_start (args, format);
  1070. ret = vsnprintf (buf, size, format, args);
  1071. va_end (args);
  1072. return ret;
  1073. }
  1074. #endif
  1075. static char buf[100];
  1076. int main ()
  1077. {
  1078. strcpy (buf, "ABCDEF");
  1079. my_snprintf (buf, 3, "%d %d", 4567, 89);
  1080. if (memcmp (buf, "45\0DEF", 6) != 0)
  1081. return 1;
  1082. return 0;
  1083. }]])],
  1084. [gl_cv_func_snprintf_truncation_c99=yes],
  1085. [gl_cv_func_snprintf_truncation_c99=no],
  1086. [
  1087. changequote(,)dnl
  1088. case "$host_os" in
  1089. # Guess yes on glibc systems.
  1090. *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1091. # Guess yes on FreeBSD >= 5.
  1092. freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
  1093. freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1094. # Guess yes on Mac OS X >= 10.3.
  1095. darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
  1096. darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1097. # Guess yes on OpenBSD >= 3.9.
  1098. openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
  1099. gl_cv_func_snprintf_truncation_c99="guessing no";;
  1100. openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1101. # Guess yes on Solaris >= 2.6.
  1102. solaris2.[0-5] | solaris2.[0-5].*)
  1103. gl_cv_func_snprintf_truncation_c99="guessing no";;
  1104. solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1105. # Guess yes on AIX >= 4.
  1106. aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
  1107. aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1108. # Guess yes on HP-UX >= 11.
  1109. hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
  1110. hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1111. # Guess yes on IRIX >= 6.5.
  1112. irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1113. # Guess yes on OSF/1 >= 5.
  1114. osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
  1115. osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1116. # Guess yes on NetBSD >= 3.
  1117. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
  1118. gl_cv_func_snprintf_truncation_c99="guessing no";;
  1119. netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1120. # Guess yes on BeOS.
  1121. beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
  1122. # If we don't know, assume the worst.
  1123. *) gl_cv_func_snprintf_truncation_c99="guessing no";;
  1124. esac
  1125. changequote([,])dnl
  1126. ])
  1127. ])
  1128. ])
  1129. dnl Test whether the return value of the snprintf function is the number
  1130. dnl of bytes (excluding the terminating NUL) that would have been produced
  1131. dnl if the buffer had been large enough. (ISO C99, POSIX:2001)
  1132. dnl For example, this test program fails on IRIX 6.5:
  1133. dnl ---------------------------------------------------------------------
  1134. dnl #include <stdio.h>
  1135. dnl int main()
  1136. dnl {
  1137. dnl static char buf[8];
  1138. dnl int retval = snprintf (buf, 3, "%d", 12345);
  1139. dnl return retval >= 0 && retval < 3;
  1140. dnl }
  1141. dnl ---------------------------------------------------------------------
  1142. dnl Result is gl_cv_func_snprintf_retval_c99.
  1143. AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99],
  1144. [
  1145. AC_REQUIRE([AC_PROG_CC])
  1146. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  1147. AC_REQUIRE([gl_SNPRINTF_PRESENCE])
  1148. AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
  1149. [gl_cv_func_snprintf_retval_c99],
  1150. [
  1151. AC_RUN_IFELSE(
  1152. [AC_LANG_SOURCE([[
  1153. #include <stdio.h>
  1154. #include <string.h>
  1155. #if HAVE_SNPRINTF
  1156. # define my_snprintf snprintf
  1157. #else
  1158. # include <stdarg.h>
  1159. static int my_snprintf (char *buf, int size, const char *format, ...)
  1160. {
  1161. va_list args;
  1162. int ret;
  1163. va_start (args, format);
  1164. ret = vsnprintf (buf, size, format, args);
  1165. va_end (args);
  1166. return ret;
  1167. }
  1168. #endif
  1169. static char buf[100];
  1170. int main ()
  1171. {
  1172. strcpy (buf, "ABCDEF");
  1173. if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7)
  1174. return 1;
  1175. if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7)
  1176. return 2;
  1177. if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7)
  1178. return 3;
  1179. return 0;
  1180. }]])],
  1181. [gl_cv_func_snprintf_retval_c99=yes],
  1182. [gl_cv_func_snprintf_retval_c99=no],
  1183. [
  1184. changequote(,)dnl
  1185. case "$host_os" in
  1186. # Guess yes on glibc systems.
  1187. *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
  1188. # Guess yes on FreeBSD >= 5.
  1189. freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";;
  1190. freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
  1191. # Guess yes on Mac OS X >= 10.3.
  1192. darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
  1193. darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
  1194. # Guess yes on OpenBSD >= 3.9.
  1195. openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
  1196. gl_cv_func_snprintf_retval_c99="guessing no";;
  1197. openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
  1198. # Guess yes on Solaris >= 2.10.
  1199. solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
  1200. solaris*) gl_cv_func_printf_sizes_c99="guessing no";;
  1201. # Guess yes on AIX >= 4.
  1202. aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";;
  1203. aix*) gl_cv_func_snprintf_retval_c99="guessing yes";;
  1204. # Guess yes on NetBSD >= 3.
  1205. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
  1206. gl_cv_func_snprintf_retval_c99="guessing no";;
  1207. netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
  1208. # Guess yes on BeOS.
  1209. beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
  1210. # If we don't know, assume the worst.
  1211. *) gl_cv_func_snprintf_retval_c99="guessing no";;
  1212. esac
  1213. changequote([,])dnl
  1214. ])
  1215. ])
  1216. ])
  1217. dnl Test whether the snprintf function supports the %n format directive
  1218. dnl also in truncated portions of the format string. (ISO C99, POSIX:2001)
  1219. dnl Result is gl_cv_func_snprintf_directive_n.
  1220. AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
  1221. [
  1222. AC_REQUIRE([AC_PROG_CC])
  1223. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  1224. AC_REQUIRE([gl_SNPRINTF_PRESENCE])
  1225. AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
  1226. [gl_cv_func_snprintf_directive_n],
  1227. [
  1228. AC_RUN_IFELSE(
  1229. [AC_LANG_SOURCE([[
  1230. #include <stdio.h>
  1231. #include <string.h>
  1232. #if HAVE_SNPRINTF
  1233. # define my_snprintf snprintf
  1234. #else
  1235. # include <stdarg.h>
  1236. static int my_snprintf (char *buf, int size, const char *format, ...)
  1237. {
  1238. va_list args;
  1239. int ret;
  1240. va_start (args, format);
  1241. ret = vsnprintf (buf, size, format, args);
  1242. va_end (args);
  1243. return ret;
  1244. }
  1245. #endif
  1246. static char fmtstring[10];
  1247. static char buf[100];
  1248. int main ()
  1249. {
  1250. int count = -1;
  1251. /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
  1252. support %n in format strings in read-only memory but not in writable
  1253. memory. */
  1254. strcpy (fmtstring, "%d %n");
  1255. my_snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55);
  1256. if (count != 6)
  1257. return 1;
  1258. return 0;
  1259. }]])],
  1260. [gl_cv_func_snprintf_directive_n=yes],
  1261. [gl_cv_func_snprintf_directive_n=no],
  1262. [
  1263. changequote(,)dnl
  1264. case "$host_os" in
  1265. # Guess yes on glibc systems.
  1266. *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";;
  1267. # Guess yes on FreeBSD >= 5.
  1268. freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";;
  1269. freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
  1270. # Guess yes on Mac OS X >= 10.3.
  1271. darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
  1272. darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
  1273. # Guess yes on Solaris >= 2.6.
  1274. solaris2.[0-5] | solaris2.[0-5].*)
  1275. gl_cv_func_snprintf_directive_n="guessing no";;
  1276. solaris*) gl_cv_func_snprintf_directive_n="guessing yes";;
  1277. # Guess yes on AIX >= 4.
  1278. aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";;
  1279. aix*) gl_cv_func_snprintf_directive_n="guessing yes";;
  1280. # Guess yes on IRIX >= 6.5.
  1281. irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";;
  1282. # Guess yes on OSF/1 >= 5.
  1283. osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
  1284. osf*) gl_cv_func_snprintf_directive_n="guessing yes";;
  1285. # Guess yes on NetBSD >= 3.
  1286. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
  1287. gl_cv_func_snprintf_directive_n="guessing no";;
  1288. netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
  1289. # Guess yes on BeOS.
  1290. beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
  1291. # If we don't know, assume the worst.
  1292. *) gl_cv_func_snprintf_directive_n="guessing no";;
  1293. esac
  1294. changequote([,])dnl
  1295. ])
  1296. ])
  1297. ])
  1298. dnl Test whether the snprintf function, when passed a size = 1, writes any
  1299. dnl output without bounds in this case, behaving like sprintf. This is the
  1300. dnl case on Linux libc5.
  1301. dnl Result is gl_cv_func_snprintf_size1.
  1302. AC_DEFUN([gl_SNPRINTF_SIZE1],
  1303. [
  1304. AC_REQUIRE([AC_PROG_CC])
  1305. AC_REQUIRE([gl_SNPRINTF_PRESENCE])
  1306. AC_CACHE_CHECK([whether snprintf respects a size of 1],
  1307. [gl_cv_func_snprintf_size1],
  1308. [
  1309. AC_RUN_IFELSE(
  1310. [AC_LANG_SOURCE([[
  1311. #include <stdio.h>
  1312. #if HAVE_SNPRINTF
  1313. # define my_snprintf snprintf
  1314. #else
  1315. # include <stdarg.h>
  1316. static int my_snprintf (char *buf, int size, const char *format, ...)
  1317. {
  1318. va_list args;
  1319. int ret;
  1320. va_start (args, format);
  1321. ret = vsnprintf (buf, size, format, args);
  1322. va_end (args);
  1323. return ret;
  1324. }
  1325. #endif
  1326. int main()
  1327. {
  1328. static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
  1329. my_snprintf (buf, 1, "%d", 12345);
  1330. return buf[1] != 'E';
  1331. }]])],
  1332. [gl_cv_func_snprintf_size1=yes],
  1333. [gl_cv_func_snprintf_size1=no],
  1334. [gl_cv_func_snprintf_size1="guessing yes"])
  1335. ])
  1336. ])
  1337. dnl Test whether the vsnprintf function, when passed a zero size, produces no
  1338. dnl output. (ISO C99, POSIX:2001)
  1339. dnl For example, snprintf nevertheless writes a NUL byte in this case
  1340. dnl on OSF/1 5.1:
  1341. dnl ---------------------------------------------------------------------
  1342. dnl #include <stdio.h>
  1343. dnl int main()
  1344. dnl {
  1345. dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
  1346. dnl snprintf (buf, 0, "%d", 12345);
  1347. dnl return buf[0] != 'D';
  1348. dnl }
  1349. dnl ---------------------------------------------------------------------
  1350. dnl And vsnprintf writes any output without bounds in this case, behaving like
  1351. dnl vsprintf, on HP-UX 11 and OSF/1 5.1:
  1352. dnl ---------------------------------------------------------------------
  1353. dnl #include <stdarg.h>
  1354. dnl #include <stdio.h>
  1355. dnl static int my_snprintf (char *buf, int size, const char *format, ...)
  1356. dnl {
  1357. dnl va_list args;
  1358. dnl int ret;
  1359. dnl va_start (args, format);
  1360. dnl ret = vsnprintf (buf, size, format, args);
  1361. dnl va_end (args);
  1362. dnl return ret;
  1363. dnl }
  1364. dnl int main()
  1365. dnl {
  1366. dnl static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
  1367. dnl my_snprintf (buf, 0, "%d", 12345);
  1368. dnl return buf[0] != 'D';
  1369. dnl }
  1370. dnl ---------------------------------------------------------------------
  1371. dnl Result is gl_cv_func_vsnprintf_zerosize_c99.
  1372. AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99],
  1373. [
  1374. AC_REQUIRE([AC_PROG_CC])
  1375. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  1376. AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99],
  1377. [gl_cv_func_vsnprintf_zerosize_c99],
  1378. [
  1379. AC_RUN_IFELSE(
  1380. [AC_LANG_SOURCE([[
  1381. #include <stdarg.h>
  1382. #include <stdio.h>
  1383. static int my_snprintf (char *buf, int size, const char *format, ...)
  1384. {
  1385. va_list args;
  1386. int ret;
  1387. va_start (args, format);
  1388. ret = vsnprintf (buf, size, format, args);
  1389. va_end (args);
  1390. return ret;
  1391. }
  1392. int main()
  1393. {
  1394. static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
  1395. my_snprintf (buf, 0, "%d", 12345);
  1396. return buf[0] != 'D';
  1397. }]])],
  1398. [gl_cv_func_vsnprintf_zerosize_c99=yes],
  1399. [gl_cv_func_vsnprintf_zerosize_c99=no],
  1400. [
  1401. changequote(,)dnl
  1402. case "$host_os" in
  1403. # Guess yes on glibc systems.
  1404. *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1405. # Guess yes on FreeBSD >= 5.
  1406. freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
  1407. freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1408. # Guess yes on Mac OS X >= 10.3.
  1409. darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
  1410. darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1411. # Guess yes on Cygwin.
  1412. cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1413. # Guess yes on Solaris >= 2.6.
  1414. solaris2.[0-5] | solaris2.[0-5].*)
  1415. gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
  1416. solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1417. # Guess yes on AIX >= 4.
  1418. aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
  1419. aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1420. # Guess yes on IRIX >= 6.5.
  1421. irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1422. # Guess yes on NetBSD >= 3.
  1423. netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
  1424. gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
  1425. netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1426. # Guess yes on BeOS.
  1427. beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1428. # Guess yes on mingw.
  1429. mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
  1430. # If we don't know, assume the worst.
  1431. *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
  1432. esac
  1433. changequote([,])dnl
  1434. ])
  1435. ])
  1436. ])
  1437. dnl The results of these tests on various platforms are:
  1438. dnl
  1439. dnl 1 = gl_PRINTF_SIZES_C99
  1440. dnl 2 = gl_PRINTF_LONG_DOUBLE
  1441. dnl 3 = gl_PRINTF_INFINITE
  1442. dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE
  1443. dnl 5 = gl_PRINTF_DIRECTIVE_A
  1444. dnl 6 = gl_PRINTF_DIRECTIVE_F
  1445. dnl 7 = gl_PRINTF_DIRECTIVE_N
  1446. dnl 8 = gl_PRINTF_DIRECTIVE_LS
  1447. dnl 9 = gl_PRINTF_POSITIONS
  1448. dnl 10 = gl_PRINTF_FLAG_GROUPING
  1449. dnl 11 = gl_PRINTF_FLAG_LEFTADJUST
  1450. dnl 12 = gl_PRINTF_FLAG_ZERO
  1451. dnl 13 = gl_PRINTF_PRECISION
  1452. dnl 14 = gl_PRINTF_ENOMEM
  1453. dnl 15 = gl_SNPRINTF_PRESENCE
  1454. dnl 16 = gl_SNPRINTF_TRUNCATION_C99
  1455. dnl 17 = gl_SNPRINTF_RETVAL_C99
  1456. dnl 18 = gl_SNPRINTF_DIRECTIVE_N
  1457. dnl 19 = gl_SNPRINTF_SIZE1
  1458. dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99
  1459. dnl
  1460. dnl 1 = checking whether printf supports size specifiers as in C99...
  1461. dnl 2 = checking whether printf supports 'long double' arguments...
  1462. dnl 3 = checking whether printf supports infinite 'double' arguments...
  1463. dnl 4 = checking whether printf supports infinite 'long double' arguments...
  1464. dnl 5 = checking whether printf supports the 'a' and 'A' directives...
  1465. dnl 6 = checking whether printf supports the 'F' directive...
  1466. dnl 7 = checking whether printf supports the 'n' directive...
  1467. dnl 8 = checking whether printf supports the 'ls' directive...
  1468. dnl 9 = checking whether printf supports POSIX/XSI format strings with positions...
  1469. dnl 10 = checking whether printf supports the grouping flag...
  1470. dnl 11 = checking whether printf supports the left-adjust flag correctly...
  1471. dnl 12 = checking whether printf supports the zero flag correctly...
  1472. dnl 13 = checking whether printf supports large precisions...
  1473. dnl 14 = checking whether printf survives out-of-memory conditions...
  1474. dnl 15 = checking for snprintf...
  1475. dnl 16 = checking whether snprintf truncates the result as in C99...
  1476. dnl 17 = checking whether snprintf returns a byte count as in C99...
  1477. dnl 18 = checking whether snprintf fully supports the 'n' directive...
  1478. dnl 19 = checking whether snprintf respects a size of 1...
  1479. dnl 20 = checking whether vsnprintf respects a zero size as in C99...
  1480. dnl
  1481. dnl . = yes, # = no.
  1482. dnl
  1483. dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  1484. dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . .
  1485. dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . .
  1486. dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . .
  1487. dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . .
  1488. dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . .
  1489. dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . .
  1490. dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . .
  1491. dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . .
  1492. dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . .
  1493. dnl Solaris 11 2011-11 . . # # # . . # . . . # . . . . . . . .
  1494. dnl Solaris 10 . . # # # . . # . . . # # . . . . . . .
  1495. dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . .
  1496. dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # #
  1497. dnl AIX 7.1 . . # # # . . . . . . # # . . . . . . .
  1498. dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . .
  1499. dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . # . . .
  1500. dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . .
  1501. dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . #
  1502. dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? #
  1503. dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . .
  1504. dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . #
  1505. dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # #
  1506. dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . .
  1507. dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ?
  1508. dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . .
  1509. dnl Haiku . . . # # # . # . . . . . ? . . ? . . .
  1510. dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . .
  1511. dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . .
  1512. dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . .
  1513. dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . .
  1514. dnl mingw-w64 2011 # # # # # # . . # # . # # ? . # # # . .