printf.m4 57 KB

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