printf.m4 55 KB

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