Blame m4/printf.m4

Packit 33f14e
# printf.m4 serial 53
Packit 33f14e
dnl Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc.
Packit 33f14e
dnl This file is free software; the Free Software Foundation
Packit 33f14e
dnl gives unlimited permission to copy and/or distribute it,
Packit 33f14e
dnl with or without modifications, as long as this notice is preserved.
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports the 'j', 'z', 't',
Packit 33f14e
dnl 'L' size specifiers. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_sizes_c99.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_SIZES_C99],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([gl_AC_HEADER_STDINT_H])
Packit 33f14e
  AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports size specifiers as in C99],
Packit 33f14e
    [gl_cv_func_printf_sizes_c99],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stddef.h>
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
#include <sys/types.h>
Packit 33f14e
#if HAVE_STDINT_H_WITH_UINTMAX
Packit 33f14e
# include <stdint.h>
Packit 33f14e
#endif
Packit 33f14e
#if HAVE_INTTYPES_H_WITH_UINTMAX
Packit 33f14e
# include <inttypes.h>
Packit 33f14e
#endif
Packit 33f14e
static char buf[100];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int result = 0;
Packit 33f14e
#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
Packit 33f14e
  buf[0] = '\0';
Packit 33f14e
  if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "12345671 33") != 0)
Packit 33f14e
    result |= 1;
Packit 33f14e
#else
Packit 33f14e
  result |= 1;
Packit 33f14e
#endif
Packit 33f14e
  buf[0] = '\0';
Packit 33f14e
  if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "12345672 33") != 0)
Packit 33f14e
    result |= 2;
Packit 33f14e
  buf[0] = '\0';
Packit 33f14e
  if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "12345673 33") != 0)
Packit 33f14e
    result |= 4;
Packit 33f14e
  buf[0] = '\0';
Packit 33f14e
  if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "1.5 33") != 0)
Packit 33f14e
    result |= 8;
Packit 33f14e
  return result;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_sizes_c99=yes],
Packit 33f14e
        [gl_cv_func_printf_sizes_c99=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                                 # Guess yes on glibc systems.
Packit 33f14e
           *-gnu*)               gl_cv_func_printf_sizes_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on FreeBSD >= 5.
Packit 33f14e
           freebsd[1-4].*)       gl_cv_func_printf_sizes_c99="guessing no";;
Packit 33f14e
           freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Mac OS X >= 10.3.
Packit 33f14e
           darwin[1-6].*)        gl_cv_func_printf_sizes_c99="guessing no";;
Packit 33f14e
           darwin*)              gl_cv_func_printf_sizes_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on OpenBSD >= 3.9.
Packit 33f14e
           openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
Packit 33f14e
                                 gl_cv_func_printf_sizes_c99="guessing no";;
Packit 33f14e
           openbsd*)             gl_cv_func_printf_sizes_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Solaris >= 2.10.
Packit 33f14e
           solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
Packit 33f14e
           solaris*)             gl_cv_func_printf_sizes_c99="guessing no";;
Packit 33f14e
                                 # Guess yes on NetBSD >= 3.
Packit 33f14e
           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
Packit 33f14e
                                 gl_cv_func_printf_sizes_c99="guessing no";;
Packit 33f14e
           netbsd*)              gl_cv_func_printf_sizes_c99="guessing yes";;
Packit 33f14e
                                 # If we don't know, assume the worst.
Packit 33f14e
           *)                    gl_cv_func_printf_sizes_c99="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports 'long double'
Packit 33f14e
dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_long_double.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_LONG_DOUBLE],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports 'long double' arguments],
Packit 33f14e
    [gl_cv_func_printf_long_double],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static char buf[10000];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int result = 0;
Packit 33f14e
  buf[0] = '\0';
Packit 33f14e
  if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "1.750000 33") != 0)
Packit 33f14e
    result |= 1;
Packit 33f14e
  buf[0] = '\0';
Packit 33f14e
  if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "1.750000e+00 33") != 0)
Packit 33f14e
    result |= 2;
Packit 33f14e
  buf[0] = '\0';
Packit 33f14e
  if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "1.75 33") != 0)
Packit 33f14e
    result |= 4;
Packit 33f14e
  return result;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_long_double=yes],
Packit 33f14e
        [gl_cv_func_printf_long_double=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
           beos*)        gl_cv_func_printf_long_double="guessing no";;
Packit 33f14e
           mingw* | pw*) gl_cv_func_printf_long_double="guessing no";;
Packit 33f14e
           *)            gl_cv_func_printf_long_double="guessing yes";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports infinite and NaN
Packit 33f14e
dnl 'double' arguments and negative zero arguments in the %f, %e, %g
Packit 33f14e
dnl directives. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_infinite.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_INFINITE],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports infinite 'double' arguments],
Packit 33f14e
    [gl_cv_func_printf_infinite],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static int
Packit 33f14e
strisnan (const char *string, size_t start_index, size_t end_index)
Packit 33f14e
{
Packit 33f14e
  if (start_index < end_index)
Packit 33f14e
    {
Packit 33f14e
      if (string[start_index] == '-')
Packit 33f14e
        start_index++;
Packit 33f14e
      if (start_index + 3 <= end_index
Packit 33f14e
          && memcmp (string + start_index, "nan", 3) == 0)
Packit 33f14e
        {
Packit 33f14e
          start_index += 3;
Packit 33f14e
          if (start_index == end_index
Packit 33f14e
              || (string[start_index] == '(' && string[end_index - 1] == ')'))
Packit 33f14e
            return 1;
Packit 33f14e
        }
Packit 33f14e
    }
Packit 33f14e
  return 0;
Packit 33f14e
}
Packit 33f14e
static int
Packit 33f14e
have_minus_zero ()
Packit 33f14e
{
Packit 33f14e
  static double plus_zero = 0.0;
Packit 33f14e
  double minus_zero = - plus_zero;
Packit 33f14e
  return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0;
Packit 33f14e
}
Packit 33f14e
static char buf[10000];
Packit 33f14e
static double zero = 0.0;
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int result = 0;
Packit 33f14e
  if (sprintf (buf, "%f", 1.0 / zero) < 0
Packit 33f14e
      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%f", -1.0 / zero) < 0
Packit 33f14e
      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%f", zero / zero) < 0
Packit 33f14e
      || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
    result |= 2;
Packit 33f14e
  if (sprintf (buf, "%e", 1.0 / zero) < 0
Packit 33f14e
      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
Packit 33f14e
    result |= 4;
Packit 33f14e
  if (sprintf (buf, "%e", -1.0 / zero) < 0
Packit 33f14e
      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
Packit 33f14e
    result |= 4;
Packit 33f14e
  if (sprintf (buf, "%e", zero / zero) < 0
Packit 33f14e
      || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
    result |= 8;
Packit 33f14e
  if (sprintf (buf, "%g", 1.0 / zero) < 0
Packit 33f14e
      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
Packit 33f14e
    result |= 16;
Packit 33f14e
  if (sprintf (buf, "%g", -1.0 / zero) < 0
Packit 33f14e
      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
Packit 33f14e
    result |= 16;
Packit 33f14e
  if (sprintf (buf, "%g", zero / zero) < 0
Packit 33f14e
      || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
    result |= 32;
Packit 33f14e
  /* This test fails on HP-UX 10.20.  */
Packit 33f14e
  if (have_minus_zero ())
Packit 33f14e
    if (sprintf (buf, "%g", - zero) < 0
Packit 33f14e
        || strcmp (buf, "-0") != 0)
Packit 33f14e
    result |= 64;
Packit 33f14e
  return result;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_infinite=yes],
Packit 33f14e
        [gl_cv_func_printf_infinite=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                                 # Guess yes on glibc systems.
Packit 33f14e
           *-gnu*)               gl_cv_func_printf_infinite="guessing yes";;
Packit 33f14e
                                 # Guess yes on FreeBSD >= 6.
Packit 33f14e
           freebsd[1-5].*)       gl_cv_func_printf_infinite="guessing no";;
Packit 33f14e
           freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
Packit 33f14e
                                 # Guess yes on Mac OS X >= 10.3.
Packit 33f14e
           darwin[1-6].*)        gl_cv_func_printf_infinite="guessing no";;
Packit 33f14e
           darwin*)              gl_cv_func_printf_infinite="guessing yes";;
Packit 33f14e
                                 # Guess yes on HP-UX >= 11.
Packit 33f14e
           hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";;
Packit 33f14e
           hpux*)                gl_cv_func_printf_infinite="guessing yes";;
Packit 33f14e
                                 # Guess yes on NetBSD >= 3.
Packit 33f14e
           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
Packit 33f14e
                                 gl_cv_func_printf_infinite="guessing no";;
Packit 33f14e
           netbsd*)              gl_cv_func_printf_infinite="guessing yes";;
Packit 33f14e
                                 # Guess yes on BeOS.
Packit 33f14e
           beos*)                gl_cv_func_printf_infinite="guessing yes";;
Packit 33f14e
                                 # If we don't know, assume the worst.
Packit 33f14e
           *)                    gl_cv_func_printf_infinite="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports infinite and NaN
Packit 33f14e
dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_infinite_long_double.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([gl_BIGENDIAN])
Packit 33f14e
  AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  dnl The user can set or unset the variable gl_printf_safe to indicate
Packit 33f14e
  dnl that he wishes a safe handling of non-IEEE-754 'long double' values.
Packit 33f14e
  if test -n "$gl_printf_safe"; then
Packit 33f14e
    AC_DEFINE([CHECK_PRINTF_SAFE], [1],
Packit 33f14e
      [Define if you wish *printf() functions that have a safe handling of
Packit 33f14e
       non-IEEE-754 'long double' values.])
Packit 33f14e
  fi
Packit 33f14e
  case "$gl_cv_func_printf_long_double" in
Packit 33f14e
    *yes)
Packit 33f14e
      AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments],
Packit 33f14e
        [gl_cv_func_printf_infinite_long_double],
Packit 33f14e
        [
Packit 33f14e
          AC_RUN_IFELSE(
Packit 33f14e
            [AC_LANG_SOURCE([[
Packit 33f14e
]GL_NOCRASH[
Packit 33f14e
#include <float.h>
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static int
Packit 33f14e
strisnan (const char *string, size_t start_index, size_t end_index)
Packit 33f14e
{
Packit 33f14e
  if (start_index < end_index)
Packit 33f14e
    {
Packit 33f14e
      if (string[start_index] == '-')
Packit 33f14e
        start_index++;
Packit 33f14e
      if (start_index + 3 <= end_index
Packit 33f14e
          && memcmp (string + start_index, "nan", 3) == 0)
Packit 33f14e
        {
Packit 33f14e
          start_index += 3;
Packit 33f14e
          if (start_index == end_index
Packit 33f14e
              || (string[start_index] == '(' && string[end_index - 1] == ')'))
Packit 33f14e
            return 1;
Packit 33f14e
        }
Packit 33f14e
    }
Packit 33f14e
  return 0;
Packit 33f14e
}
Packit 33f14e
static char buf[10000];
Packit 33f14e
static long double zeroL = 0.0L;
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int result = 0;
Packit 33f14e
  nocrash_init();
Packit 33f14e
  if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0
Packit 33f14e
      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0
Packit 33f14e
      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
Packit 33f14e
      || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%Le", 1.0L / zeroL) < 0
Packit 33f14e
      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%Le", -1.0L / zeroL) < 0
Packit 33f14e
      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%Le", zeroL / zeroL) < 0
Packit 33f14e
      || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0
Packit 33f14e
      || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0
Packit 33f14e
      || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
Packit 33f14e
      || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
    result |= 1;
Packit 33f14e
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
Packit 33f14e
/* Representation of an 80-bit 'long double' as an initializer for a sequence
Packit 33f14e
   of 'unsigned int' words.  */
Packit 33f14e
# ifdef WORDS_BIGENDIAN
Packit 33f14e
#  define LDBL80_WORDS(exponent,manthi,mantlo) \
Packit 33f14e
     { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
Packit 33f14e
       ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16),   \
Packit 33f14e
       (unsigned int) (mantlo) << 16                                        \
Packit 33f14e
     }
Packit 33f14e
# else
Packit 33f14e
#  define LDBL80_WORDS(exponent,manthi,mantlo) \
Packit 33f14e
     { mantlo, manthi, exponent }
Packit 33f14e
# endif
Packit 33f14e
  { /* Quiet NaN.  */
Packit 33f14e
    static union { unsigned int word[4]; long double value; } x =
Packit 33f14e
      { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
Packit 33f14e
    if (sprintf (buf, "%Lf", x.value) < 0
Packit 33f14e
        || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
      result |= 2;
Packit 33f14e
    if (sprintf (buf, "%Le", x.value) < 0
Packit 33f14e
        || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
      result |= 2;
Packit 33f14e
    if (sprintf (buf, "%Lg", x.value) < 0
Packit 33f14e
        || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
      result |= 2;
Packit 33f14e
  }
Packit 33f14e
  {
Packit 33f14e
    /* Signalling NaN.  */
Packit 33f14e
    static union { unsigned int word[4]; long double value; } x =
Packit 33f14e
      { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
Packit 33f14e
    if (sprintf (buf, "%Lf", x.value) < 0
Packit 33f14e
        || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
      result |= 2;
Packit 33f14e
    if (sprintf (buf, "%Le", x.value) < 0
Packit 33f14e
        || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
      result |= 2;
Packit 33f14e
    if (sprintf (buf, "%Lg", x.value) < 0
Packit 33f14e
        || !strisnan (buf, 0, strlen (buf)))
Packit 33f14e
      result |= 2;
Packit 33f14e
  }
Packit 33f14e
  { /* Pseudo-NaN.  */
Packit 33f14e
    static union { unsigned int word[4]; long double value; } x =
Packit 33f14e
      { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
Packit 33f14e
    if (sprintf (buf, "%Lf", x.value) <= 0)
Packit 33f14e
      result |= 4;
Packit 33f14e
    if (sprintf (buf, "%Le", x.value) <= 0)
Packit 33f14e
      result |= 4;
Packit 33f14e
    if (sprintf (buf, "%Lg", x.value) <= 0)
Packit 33f14e
      result |= 4;
Packit 33f14e
  }
Packit 33f14e
  { /* Pseudo-Infinity.  */
Packit 33f14e
    static union { unsigned int word[4]; long double value; } x =
Packit 33f14e
      { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
Packit 33f14e
    if (sprintf (buf, "%Lf", x.value) <= 0)
Packit 33f14e
      result |= 8;
Packit 33f14e
    if (sprintf (buf, "%Le", x.value) <= 0)
Packit 33f14e
      result |= 8;
Packit 33f14e
    if (sprintf (buf, "%Lg", x.value) <= 0)
Packit 33f14e
      result |= 8;
Packit 33f14e
  }
Packit 33f14e
  { /* Pseudo-Zero.  */
Packit 33f14e
    static union { unsigned int word[4]; long double value; } x =
Packit 33f14e
      { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
Packit 33f14e
    if (sprintf (buf, "%Lf", x.value) <= 0)
Packit 33f14e
      result |= 16;
Packit 33f14e
    if (sprintf (buf, "%Le", x.value) <= 0)
Packit 33f14e
      result |= 16;
Packit 33f14e
    if (sprintf (buf, "%Lg", x.value) <= 0)
Packit 33f14e
      result |= 16;
Packit 33f14e
  }
Packit 33f14e
  { /* Unnormalized number.  */
Packit 33f14e
    static union { unsigned int word[4]; long double value; } x =
Packit 33f14e
      { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
Packit 33f14e
    if (sprintf (buf, "%Lf", x.value) <= 0)
Packit 33f14e
      result |= 32;
Packit 33f14e
    if (sprintf (buf, "%Le", x.value) <= 0)
Packit 33f14e
      result |= 32;
Packit 33f14e
    if (sprintf (buf, "%Lg", x.value) <= 0)
Packit 33f14e
      result |= 32;
Packit 33f14e
  }
Packit 33f14e
  { /* Pseudo-Denormal.  */
Packit 33f14e
    static union { unsigned int word[4]; long double value; } x =
Packit 33f14e
      { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
Packit 33f14e
    if (sprintf (buf, "%Lf", x.value) <= 0)
Packit 33f14e
      result |= 64;
Packit 33f14e
    if (sprintf (buf, "%Le", x.value) <= 0)
Packit 33f14e
      result |= 64;
Packit 33f14e
    if (sprintf (buf, "%Lg", x.value) <= 0)
Packit 33f14e
      result |= 64;
Packit 33f14e
  }
Packit 33f14e
#endif
Packit 33f14e
  return result;
Packit 33f14e
}]])],
Packit 33f14e
            [gl_cv_func_printf_infinite_long_double=yes],
Packit 33f14e
            [gl_cv_func_printf_infinite_long_double=no],
Packit 33f14e
            [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
             case "$host_cpu" in
Packit 33f14e
                                     # Guess no on ia64, x86_64, i386.
Packit 33f14e
               ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
Packit 33f14e
               *)
Packit 33f14e
                 case "$host_os" in
Packit 33f14e
                                         # Guess yes on glibc systems.
Packit 33f14e
                   *-gnu*)               gl_cv_func_printf_infinite_long_double="guessing yes";;
Packit 33f14e
                                         # Guess yes on FreeBSD >= 6.
Packit 33f14e
                   freebsd[1-5].*)       gl_cv_func_printf_infinite_long_double="guessing no";;
Packit 33f14e
                   freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
Packit 33f14e
                                         # Guess yes on HP-UX >= 11.
Packit 33f14e
                   hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
Packit 33f14e
                   hpux*)                gl_cv_func_printf_infinite_long_double="guessing yes";;
Packit 33f14e
                                         # If we don't know, assume the worst.
Packit 33f14e
                   *)                    gl_cv_func_printf_infinite_long_double="guessing no";;
Packit 33f14e
                 esac
Packit 33f14e
                 ;;
Packit 33f14e
             esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
            ])
Packit 33f14e
        ])
Packit 33f14e
      ;;
Packit 33f14e
    *)
Packit 33f14e
      gl_cv_func_printf_infinite_long_double="irrelevant"
Packit 33f14e
      ;;
Packit 33f14e
  esac
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports the 'a' and 'A'
Packit 33f14e
dnl conversion specifier for hexadecimal output of floating-point numbers.
Packit 33f14e
dnl (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_directive_a.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives],
Packit 33f14e
    [gl_cv_func_printf_directive_a],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static char buf[100];
Packit 33f14e
static double zero = 0.0;
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int result = 0;
Packit 33f14e
  if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
Packit 33f14e
      || (strcmp (buf, "0x1.922p+1 33") != 0
Packit 33f14e
          && strcmp (buf, "0x3.244p+0 33") != 0
Packit 33f14e
          && strcmp (buf, "0x6.488p-1 33") != 0
Packit 33f14e
          && strcmp (buf, "0xc.91p-2 33") != 0))
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
Packit 33f14e
      || (strcmp (buf, "-0X1.922P+1 33") != 0
Packit 33f14e
          && strcmp (buf, "-0X3.244P+0 33") != 0
Packit 33f14e
          && strcmp (buf, "-0X6.488P-1 33") != 0
Packit 33f14e
          && strcmp (buf, "-0XC.91P-2 33") != 0))
Packit 33f14e
    result |= 2;
Packit 33f14e
  /* This catches a FreeBSD 6.1 bug: it doesn't round.  */
Packit 33f14e
  if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
Packit 33f14e
      || (strcmp (buf, "0x1.83p+0 33") != 0
Packit 33f14e
          && strcmp (buf, "0x3.05p-1 33") != 0
Packit 33f14e
          && strcmp (buf, "0x6.0ap-2 33") != 0
Packit 33f14e
          && strcmp (buf, "0xc.14p-3 33") != 0))
Packit 33f14e
    result |= 4;
Packit 33f14e
  /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round.  */
Packit 33f14e
  if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0
Packit 33f14e
      || (strcmp (buf, "0x2p+0 33") != 0
Packit 33f14e
          && strcmp (buf, "0x3p-1 33") != 0
Packit 33f14e
          && strcmp (buf, "0x6p-2 33") != 0
Packit 33f14e
          && strcmp (buf, "0xcp-3 33") != 0))
Packit 33f14e
    result |= 4;
Packit 33f14e
  /* This catches a FreeBSD 6.1 bug.  See
Packit 33f14e
     <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
Packit 33f14e
  if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
Packit 33f14e
      || buf[0] == '0')
Packit 33f14e
    result |= 8;
Packit 33f14e
  /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug.  */
Packit 33f14e
  if (sprintf (buf, "%.1a", 1.999) < 0
Packit 33f14e
      || (strcmp (buf, "0x1.0p+1") != 0
Packit 33f14e
          && strcmp (buf, "0x2.0p+0") != 0
Packit 33f14e
          && strcmp (buf, "0x4.0p-1") != 0
Packit 33f14e
          && strcmp (buf, "0x8.0p-2") != 0))
Packit 33f14e
    result |= 16;
Packit 33f14e
  /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a
Packit 33f14e
     glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>.  */
Packit 33f14e
  if (sprintf (buf, "%.1La", 1.999L) < 0
Packit 33f14e
      || (strcmp (buf, "0x1.0p+1") != 0
Packit 33f14e
          && strcmp (buf, "0x2.0p+0") != 0
Packit 33f14e
          && strcmp (buf, "0x4.0p-1") != 0
Packit 33f14e
          && strcmp (buf, "0x8.0p-2") != 0))
Packit 33f14e
    result |= 32;
Packit 33f14e
  return result;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_directive_a=yes],
Packit 33f14e
        [gl_cv_func_printf_directive_a=no],
Packit 33f14e
        [
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                                 # Guess yes on glibc >= 2.5 systems.
Packit 33f14e
           *-gnu*)
Packit 33f14e
             AC_EGREP_CPP([BZ2908], [
Packit 33f14e
               #include <features.h>
Packit 33f14e
               #ifdef __GNU_LIBRARY__
Packit 33f14e
                #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__
Packit 33f14e
                 BZ2908
Packit 33f14e
                #endif
Packit 33f14e
               #endif
Packit 33f14e
               ],
Packit 33f14e
               [gl_cv_func_printf_directive_a="guessing yes"],
Packit 33f14e
               [gl_cv_func_printf_directive_a="guessing no"])
Packit 33f14e
             ;;
Packit 33f14e
                                 # If we don't know, assume the worst.
Packit 33f14e
           *)                    gl_cv_func_printf_directive_a="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports the %F format
Packit 33f14e
dnl directive. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_directive_f.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports the 'F' directive],
Packit 33f14e
    [gl_cv_func_printf_directive_f],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static char buf[100];
Packit 33f14e
static double zero = 0.0;
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int result = 0;
Packit 33f14e
  if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "1234567.000000 33") != 0)
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%F", 1.0 / zero) < 0
Packit 33f14e
      || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
Packit 33f14e
    result |= 2;
Packit 33f14e
  /* This catches a Cygwin 1.5.x bug.  */
Packit 33f14e
  if (sprintf (buf, "%.F", 1234.0) < 0
Packit 33f14e
      || strcmp (buf, "1234") != 0)
Packit 33f14e
    result |= 4;
Packit 33f14e
  return result;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_directive_f=yes],
Packit 33f14e
        [gl_cv_func_printf_directive_f=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                                 # Guess yes on glibc systems.
Packit 33f14e
           *-gnu*)               gl_cv_func_printf_directive_f="guessing yes";;
Packit 33f14e
                                 # Guess yes on FreeBSD >= 6.
Packit 33f14e
           freebsd[1-5].*)       gl_cv_func_printf_directive_f="guessing no";;
Packit 33f14e
           freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
Packit 33f14e
                                 # Guess yes on Mac OS X >= 10.3.
Packit 33f14e
           darwin[1-6].*)        gl_cv_func_printf_directive_f="guessing no";;
Packit 33f14e
           darwin*)              gl_cv_func_printf_directive_f="guessing yes";;
Packit 33f14e
                                 # Guess yes on Solaris >= 2.10.
Packit 33f14e
           solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
Packit 33f14e
           solaris*)             gl_cv_func_printf_sizes_c99="guessing no";;
Packit 33f14e
                                 # If we don't know, assume the worst.
Packit 33f14e
           *)                    gl_cv_func_printf_directive_f="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports the %n format
Packit 33f14e
dnl directive. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_directive_n.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports the 'n' directive],
Packit 33f14e
    [gl_cv_func_printf_directive_n],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <stdlib.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
#ifdef _MSC_VER
Packit 33f14e
/* See page about "Parameter Validation" on msdn.microsoft.com.  */
Packit 33f14e
static void cdecl
Packit 33f14e
invalid_parameter_handler (const wchar_t *expression,
Packit 33f14e
                           const wchar_t *function,
Packit 33f14e
                           const wchar_t *file, unsigned int line,
Packit 33f14e
                           uintptr_t dummy)
Packit 33f14e
{
Packit 33f14e
  exit (1);
Packit 33f14e
}
Packit 33f14e
#endif
Packit 33f14e
static char fmtstring[10];
Packit 33f14e
static char buf[100];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int count = -1;
Packit 33f14e
#ifdef _MSC_VER
Packit 33f14e
  _set_invalid_parameter_handler (invalid_parameter_handler);
Packit 33f14e
#endif
Packit 33f14e
  /* Copy the format string.  Some systems (glibc with _FORTIFY_SOURCE=2)
Packit 33f14e
     support %n in format strings in read-only memory but not in writable
Packit 33f14e
     memory.  */
Packit 33f14e
  strcpy (fmtstring, "%d %n");
Packit 33f14e
  if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0
Packit 33f14e
      || strcmp (buf, "123 ") != 0
Packit 33f14e
      || count != 4)
Packit 33f14e
    return 1;
Packit 33f14e
  return 0;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_directive_n=yes],
Packit 33f14e
        [gl_cv_func_printf_directive_n=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
           mingw*) gl_cv_func_printf_directive_n="guessing no";;
Packit 33f14e
           *)      gl_cv_func_printf_directive_n="guessing yes";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports the %ls format
Packit 33f14e
dnl directive and in particular, when a precision is specified, whether
Packit 33f14e
dnl the functions stop converting the wide string argument when the number
Packit 33f14e
dnl of bytes that have been produced by this conversion equals or exceeds
Packit 33f14e
dnl the precision.
Packit 33f14e
dnl Result is gl_cv_func_printf_directive_ls.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports the 'ls' directive],
Packit 33f14e
    [gl_cv_func_printf_directive_ls],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit 33f14e
   <wchar.h>.
Packit 33f14e
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit 33f14e
   included before <wchar.h>.  */
Packit 33f14e
#include <stddef.h>
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <time.h>
Packit 33f14e
#include <wchar.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int result = 0;
Packit 33f14e
  char buf[100];
Packit 33f14e
  /* Test whether %ls works at all.
Packit 33f14e
     This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on
Packit 33f14e
     Cygwin 1.5.  */
Packit 33f14e
  {
Packit 33f14e
    static const wchar_t wstring[] = { 'a', 'b', 'c', 0 };
Packit 33f14e
    buf[0] = '\0';
Packit 33f14e
    if (sprintf (buf, "%ls", wstring) < 0
Packit 33f14e
        || strcmp (buf, "abc") != 0)
Packit 33f14e
      result |= 1;
Packit 33f14e
  }
Packit 33f14e
  /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an
Packit 33f14e
     assertion failure inside libc), but not on OpenBSD 4.0.  */
Packit 33f14e
  {
Packit 33f14e
    static const wchar_t wstring[] = { 'a', 0 };
Packit 33f14e
    buf[0] = '\0';
Packit 33f14e
    if (sprintf (buf, "%ls", wstring) < 0
Packit 33f14e
        || strcmp (buf, "a") != 0)
Packit 33f14e
      result |= 2;
Packit 33f14e
  }
Packit 33f14e
  /* Test whether precisions in %ls are supported as specified in ISO C 99
Packit 33f14e
     section 7.19.6.1:
Packit 33f14e
       "If a precision is specified, no more than that many bytes are written
Packit 33f14e
        (including shift sequences, if any), and the array shall contain a
Packit 33f14e
        null wide character if, to equal the multibyte character sequence
Packit 33f14e
        length given by the precision, the function would need to access a
Packit 33f14e
        wide character one past the end of the array."
Packit 33f14e
     This test fails on Solaris 10.  */
Packit 33f14e
  {
Packit 33f14e
    static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 };
Packit 33f14e
    buf[0] = '\0';
Packit 33f14e
    if (sprintf (buf, "%.2ls", wstring) < 0
Packit 33f14e
        || strcmp (buf, "ab") != 0)
Packit 33f14e
      result |= 8;
Packit 33f14e
  }
Packit 33f14e
  return result;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_directive_ls=yes],
Packit 33f14e
        [gl_cv_func_printf_directive_ls=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
           openbsd*)        gl_cv_func_printf_directive_ls="guessing no";;
Packit 33f14e
           irix*)           gl_cv_func_printf_directive_ls="guessing no";;
Packit 33f14e
           solaris*)        gl_cv_func_printf_directive_ls="guessing no";;
Packit 33f14e
           cygwin*)         gl_cv_func_printf_directive_ls="guessing no";;
Packit 33f14e
           beos* | haiku*)  gl_cv_func_printf_directive_ls="guessing no";;
Packit 33f14e
           *)               gl_cv_func_printf_directive_ls="guessing yes";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports POSIX/XSI format
Packit 33f14e
dnl strings with positions. (POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_positions.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_POSITIONS],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions],
Packit 33f14e
    [gl_cv_func_printf_positions],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
/* The string "%2$d %1$d", with dollar characters protected from the shell's
Packit 33f14e
   dollar expansion (possibly an autoconf bug).  */
Packit 33f14e
static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
Packit 33f14e
static char buf[100];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  sprintf (buf, format, 33, 55);
Packit 33f14e
  return (strcmp (buf, "55 33") != 0);
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_positions=yes],
Packit 33f14e
        [gl_cv_func_printf_positions=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
           netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
Packit 33f14e
                         gl_cv_func_printf_positions="guessing no";;
Packit 33f14e
           beos*)        gl_cv_func_printf_positions="guessing no";;
Packit 33f14e
           mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
Packit 33f14e
           *)            gl_cv_func_printf_positions="guessing yes";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports POSIX/XSI format
Packit 33f14e
dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_printf_flag_grouping.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports the grouping flag],
Packit 33f14e
    [gl_cv_func_printf_flag_grouping],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static char buf[100];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  if (sprintf (buf, "%'d %d", 1234567, 99) < 0
Packit 33f14e
      || buf[strlen (buf) - 1] != '9')
Packit 33f14e
    return 1;
Packit 33f14e
  return 0;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_flag_grouping=yes],
Packit 33f14e
        [gl_cv_func_printf_flag_grouping=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
           cygwin*)      gl_cv_func_printf_flag_grouping="guessing no";;
Packit 33f14e
           netbsd*)      gl_cv_func_printf_flag_grouping="guessing no";;
Packit 33f14e
           mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
Packit 33f14e
           *)            gl_cv_func_printf_flag_grouping="guessing yes";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports the - flag correctly.
Packit 33f14e
dnl (ISO C99.) See
Packit 33f14e
dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html>
Packit 33f14e
dnl Result is gl_cv_func_printf_flag_leftadjust.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly],
Packit 33f14e
    [gl_cv_func_printf_flag_leftadjust],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static char buf[100];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  /* Check that a '-' flag is not annihilated by a negative width.  */
Packit 33f14e
  if (sprintf (buf, "a%-*sc", -3, "b") < 0
Packit 33f14e
      || strcmp (buf, "ab  c") != 0)
Packit 33f14e
    return 1;
Packit 33f14e
  return 0;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_flag_leftadjust=yes],
Packit 33f14e
        [gl_cv_func_printf_flag_leftadjust=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                    # Guess yes on HP-UX 11.
Packit 33f14e
           hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
Packit 33f14e
                    # Guess no on HP-UX 10 and older.
Packit 33f14e
           hpux*)   gl_cv_func_printf_flag_leftadjust="guessing no";;
Packit 33f14e
                    # Guess yes otherwise.
Packit 33f14e
           *)       gl_cv_func_printf_flag_leftadjust="guessing yes";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports padding of non-finite
Packit 33f14e
dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
Packit 33f14e
dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html>
Packit 33f14e
dnl Result is gl_cv_func_printf_flag_zero.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_FLAG_ZERO],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports the zero flag correctly],
Packit 33f14e
    [gl_cv_func_printf_flag_zero],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static char buf[100];
Packit 33f14e
static double zero = 0.0;
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
Packit 33f14e
      || (strcmp (buf, "       inf") != 0
Packit 33f14e
          && strcmp (buf, "  infinity") != 0))
Packit 33f14e
    return 1;
Packit 33f14e
  return 0;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_flag_zero=yes],
Packit 33f14e
        [gl_cv_func_printf_flag_zero=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                   # Guess yes on glibc systems.
Packit 33f14e
           *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
Packit 33f14e
                   # Guess yes on BeOS.
Packit 33f14e
           beos*)  gl_cv_func_printf_flag_zero="guessing yes";;
Packit 33f14e
                   # If we don't know, assume the worst.
Packit 33f14e
           *)      gl_cv_func_printf_flag_zero="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions supports large precisions.
Packit 33f14e
dnl On mingw, precisions larger than 512 are treated like 512, in integer,
Packit 33f14e
dnl floating-point or pointer output. On Solaris 10/x86, precisions larger
Packit 33f14e
dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC,
Packit 33f14e
dnl precisions larger than 510 in floating-point output yield wrong results.
Packit 33f14e
dnl On AIX 7.1, precisions larger than 998 in floating-point output yield
Packit 33f14e
dnl wrong results. On BeOS, precisions larger than 1044 crash the program.
Packit 33f14e
dnl Result is gl_cv_func_printf_precision.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_PRECISION],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf supports large precisions],
Packit 33f14e
    [gl_cv_func_printf_precision],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
static char buf[5000];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int result = 0;
Packit 33f14e
#ifdef __BEOS__
Packit 33f14e
  /* On BeOS, this would crash and show a dialog box.  Avoid the crash.  */
Packit 33f14e
  return 1;
Packit 33f14e
#endif
Packit 33f14e
  if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
Packit 33f14e
    result |= 1;
Packit 33f14e
  if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
Packit 33f14e
    result |= 2;
Packit 33f14e
  if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5
Packit 33f14e
      || buf[0] != '1')
Packit 33f14e
    result |= 4;
Packit 33f14e
  if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5
Packit 33f14e
      || buf[0] != '1')
Packit 33f14e
    result |= 4;
Packit 33f14e
  return result;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_printf_precision=yes],
Packit 33f14e
        [gl_cv_func_printf_precision=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
           # Guess no only on Solaris, native Windows, and BeOS systems.
Packit 33f14e
           solaris*)     gl_cv_func_printf_precision="guessing no" ;;
Packit 33f14e
           mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
Packit 33f14e
           beos*)        gl_cv_func_printf_precision="guessing no" ;;
Packit 33f14e
           *)            gl_cv_func_printf_precision="guessing yes" ;;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the *printf family of functions recovers gracefully in case
Packit 33f14e
dnl of an out-of-memory condition, or whether it crashes the entire program.
Packit 33f14e
dnl Result is gl_cv_func_printf_enomem.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_PRINTF_ENOMEM],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([gl_MULTIARCH])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether printf survives out-of-memory conditions],
Packit 33f14e
    [gl_cv_func_printf_enomem],
Packit 33f14e
    [
Packit 33f14e
      gl_cv_func_printf_enomem="guessing no"
Packit 33f14e
      if test "$cross_compiling" = no; then
Packit 33f14e
        if test $APPLE_UNIVERSAL_BUILD = 0; then
Packit 33f14e
          AC_LANG_CONFTEST([AC_LANG_SOURCE([
Packit 33f14e
]GL_NOCRASH[
Packit 33f14e
changequote(,)dnl
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <sys/types.h>
Packit 33f14e
#include <sys/time.h>
Packit 33f14e
#include <sys/resource.h>
Packit 33f14e
#include <errno.h>
Packit 33f14e
int main()
Packit 33f14e
{
Packit 33f14e
  struct rlimit limit;
Packit 33f14e
  int ret;
Packit 33f14e
  nocrash_init ();
Packit 33f14e
  /* Some printf implementations allocate temporary space with malloc.  */
Packit 33f14e
  /* On BSD systems, malloc() is limited by RLIMIT_DATA.  */
Packit 33f14e
#ifdef RLIMIT_DATA
Packit 33f14e
  if (getrlimit (RLIMIT_DATA, &limit) < 0)
Packit 33f14e
    return 77;
Packit 33f14e
  if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
Packit 33f14e
    limit.rlim_max = 5000000;
Packit 33f14e
  limit.rlim_cur = limit.rlim_max;
Packit 33f14e
  if (setrlimit (RLIMIT_DATA, &limit) < 0)
Packit 33f14e
    return 77;
Packit 33f14e
#endif
Packit 33f14e
  /* On Linux systems, malloc() is limited by RLIMIT_AS.  */
Packit 33f14e
#ifdef RLIMIT_AS
Packit 33f14e
  if (getrlimit (RLIMIT_AS, &limit) < 0)
Packit 33f14e
    return 77;
Packit 33f14e
  if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
Packit 33f14e
    limit.rlim_max = 5000000;
Packit 33f14e
  limit.rlim_cur = limit.rlim_max;
Packit 33f14e
  if (setrlimit (RLIMIT_AS, &limit) < 0)
Packit 33f14e
    return 77;
Packit 33f14e
#endif
Packit 33f14e
  /* Some printf implementations allocate temporary space on the stack.  */
Packit 33f14e
#ifdef RLIMIT_STACK
Packit 33f14e
  if (getrlimit (RLIMIT_STACK, &limit) < 0)
Packit 33f14e
    return 77;
Packit 33f14e
  if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
Packit 33f14e
    limit.rlim_max = 5000000;
Packit 33f14e
  limit.rlim_cur = limit.rlim_max;
Packit 33f14e
  if (setrlimit (RLIMIT_STACK, &limit) < 0)
Packit 33f14e
    return 77;
Packit 33f14e
#endif
Packit 33f14e
  ret = printf ("%.5000000f", 1.0);
Packit 33f14e
  return !(ret == 5000002 || (ret < 0 && errno == ENOMEM));
Packit 33f14e
}
Packit 33f14e
changequote([,])dnl
Packit 33f14e
          ])])
Packit 33f14e
          if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
Packit 33f14e
            (./conftest 2>&AS_MESSAGE_LOG_FD
Packit 33f14e
             result=$?
Packit 33f14e
             _AS_ECHO_LOG([\$? = $result])
Packit 33f14e
             if test $result != 0 && test $result != 77; then result=1; fi
Packit 33f14e
             exit $result
Packit 33f14e
            ) >/dev/null 2>/dev/null
Packit 33f14e
            case $? in
Packit 33f14e
              0) gl_cv_func_printf_enomem="yes" ;;
Packit 33f14e
              77) gl_cv_func_printf_enomem="guessing no" ;;
Packit 33f14e
              *) gl_cv_func_printf_enomem="no" ;;
Packit 33f14e
            esac
Packit 33f14e
          else
Packit 33f14e
            gl_cv_func_printf_enomem="guessing no"
Packit 33f14e
          fi
Packit 33f14e
          rm -fr conftest*
Packit 33f14e
        else
Packit 33f14e
          dnl A universal build on Apple Mac OS X platforms.
Packit 33f14e
          dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode.
Packit 33f14e
          dnl But we need a configuration result that is valid in both modes.
Packit 33f14e
          gl_cv_func_printf_enomem="guessing no"
Packit 33f14e
        fi
Packit 33f14e
      fi
Packit 33f14e
      if test "$gl_cv_func_printf_enomem" = "guessing no"; then
Packit 33f14e
changequote(,)dnl
Packit 33f14e
        case "$host_os" in
Packit 33f14e
                    # Guess yes on glibc systems.
Packit 33f14e
          *-gnu*)   gl_cv_func_printf_enomem="guessing yes";;
Packit 33f14e
                    # Guess yes on Solaris.
Packit 33f14e
          solaris*) gl_cv_func_printf_enomem="guessing yes";;
Packit 33f14e
                    # Guess yes on AIX.
Packit 33f14e
          aix*)     gl_cv_func_printf_enomem="guessing yes";;
Packit 33f14e
                    # Guess yes on HP-UX/hppa.
Packit 33f14e
          hpux*)    case "$host_cpu" in
Packit 33f14e
                      hppa*) gl_cv_func_printf_enomem="guessing yes";;
Packit 33f14e
                      *)     gl_cv_func_printf_enomem="guessing no";;
Packit 33f14e
                    esac
Packit 33f14e
                    ;;
Packit 33f14e
                    # Guess yes on IRIX.
Packit 33f14e
          irix*)    gl_cv_func_printf_enomem="guessing yes";;
Packit 33f14e
                    # Guess yes on OSF/1.
Packit 33f14e
          osf*)     gl_cv_func_printf_enomem="guessing yes";;
Packit 33f14e
                    # Guess yes on BeOS.
Packit 33f14e
          beos*)    gl_cv_func_printf_enomem="guessing yes";;
Packit 33f14e
                    # Guess yes on Haiku.
Packit 33f14e
          haiku*)   gl_cv_func_printf_enomem="guessing yes";;
Packit 33f14e
                    # If we don't know, assume the worst.
Packit 33f14e
          *)        gl_cv_func_printf_enomem="guessing no";;
Packit 33f14e
        esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
      fi
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is ac_cv_func_snprintf.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_SNPRINTF_PRESENCE],
Packit 33f14e
[
Packit 33f14e
  AC_CHECK_FUNCS_ONCE([snprintf])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the string produced by the snprintf function is always NUL
Packit 33f14e
dnl terminated. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_snprintf_truncation_c99.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_REQUIRE([gl_SNPRINTF_PRESENCE])
Packit 33f14e
  AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
Packit 33f14e
    [gl_cv_func_snprintf_truncation_c99],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
#if HAVE_SNPRINTF
Packit 33f14e
# define my_snprintf snprintf
Packit 33f14e
#else
Packit 33f14e
# include <stdarg.h>
Packit 33f14e
static int my_snprintf (char *buf, int size, const char *format, ...)
Packit 33f14e
{
Packit 33f14e
  va_list args;
Packit 33f14e
  int ret;
Packit 33f14e
  va_start (args, format);
Packit 33f14e
  ret = vsnprintf (buf, size, format, args);
Packit 33f14e
  va_end (args);
Packit 33f14e
  return ret;
Packit 33f14e
}
Packit 33f14e
#endif
Packit 33f14e
static char buf[100];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  strcpy (buf, "ABCDEF");
Packit 33f14e
  my_snprintf (buf, 3, "%d %d", 4567, 89);
Packit 33f14e
  if (memcmp (buf, "45\0DEF", 6) != 0)
Packit 33f14e
    return 1;
Packit 33f14e
  return 0;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_snprintf_truncation_c99=yes],
Packit 33f14e
        [gl_cv_func_snprintf_truncation_c99=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                                 # Guess yes on glibc systems.
Packit 33f14e
           *-gnu*)               gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on FreeBSD >= 5.
Packit 33f14e
           freebsd[1-4].*)       gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
           freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Mac OS X >= 10.3.
Packit 33f14e
           darwin[1-6].*)        gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
           darwin*)              gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on OpenBSD >= 3.9.
Packit 33f14e
           openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
Packit 33f14e
                                 gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
           openbsd*)             gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Solaris >= 2.6.
Packit 33f14e
           solaris2.[0-5] | solaris2.[0-5].*)
Packit 33f14e
                                 gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
           solaris*)             gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on AIX >= 4.
Packit 33f14e
           aix[1-3]*)            gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
           aix*)                 gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on HP-UX >= 11.
Packit 33f14e
           hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
           hpux*)                gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on IRIX >= 6.5.
Packit 33f14e
           irix6.5)              gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on OSF/1 >= 5.
Packit 33f14e
           osf[3-4]*)            gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
           osf*)                 gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on NetBSD >= 3.
Packit 33f14e
           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
Packit 33f14e
                                 gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
           netbsd*)              gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on BeOS.
Packit 33f14e
           beos*)                gl_cv_func_snprintf_truncation_c99="guessing yes";;
Packit 33f14e
                                 # If we don't know, assume the worst.
Packit 33f14e
           *)                    gl_cv_func_snprintf_truncation_c99="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the return value of the snprintf function is the number
Packit 33f14e
dnl of bytes (excluding the terminating NUL) that would have been produced
Packit 33f14e
dnl if the buffer had been large enough. (ISO C99, POSIX:2001)
Packit 33f14e
dnl For example, this test program fails on IRIX 6.5:
Packit 33f14e
dnl     ---------------------------------------------------------------------
Packit 33f14e
dnl     #include <stdio.h>
Packit 33f14e
dnl     int main()
Packit 33f14e
dnl     {
Packit 33f14e
dnl       static char buf[8];
Packit 33f14e
dnl       int retval = snprintf (buf, 3, "%d", 12345);
Packit 33f14e
dnl       return retval >= 0 && retval < 3;
Packit 33f14e
dnl     }
Packit 33f14e
dnl     ---------------------------------------------------------------------
Packit 33f14e
dnl Result is gl_cv_func_snprintf_retval_c99.
Packit 33f14e
Packit 33f14e
AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_REQUIRE([gl_SNPRINTF_PRESENCE])
Packit 33f14e
  AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
Packit 33f14e
    [gl_cv_func_snprintf_retval_c99],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
#if HAVE_SNPRINTF
Packit 33f14e
# define my_snprintf snprintf
Packit 33f14e
#else
Packit 33f14e
# include <stdarg.h>
Packit 33f14e
static int my_snprintf (char *buf, int size, const char *format, ...)
Packit 33f14e
{
Packit 33f14e
  va_list args;
Packit 33f14e
  int ret;
Packit 33f14e
  va_start (args, format);
Packit 33f14e
  ret = vsnprintf (buf, size, format, args);
Packit 33f14e
  va_end (args);
Packit 33f14e
  return ret;
Packit 33f14e
}
Packit 33f14e
#endif
Packit 33f14e
static char buf[100];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  strcpy (buf, "ABCDEF");
Packit 33f14e
  if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7)
Packit 33f14e
    return 1;
Packit 33f14e
  if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7)
Packit 33f14e
    return 2;
Packit 33f14e
  if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7)
Packit 33f14e
    return 3;
Packit 33f14e
  return 0;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_snprintf_retval_c99=yes],
Packit 33f14e
        [gl_cv_func_snprintf_retval_c99=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                                 # Guess yes on glibc systems.
Packit 33f14e
           *-gnu*)               gl_cv_func_snprintf_retval_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on FreeBSD >= 5.
Packit 33f14e
           freebsd[1-4].*)       gl_cv_func_snprintf_retval_c99="guessing no";;
Packit 33f14e
           freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Mac OS X >= 10.3.
Packit 33f14e
           darwin[1-6].*)        gl_cv_func_snprintf_retval_c99="guessing no";;
Packit 33f14e
           darwin*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on OpenBSD >= 3.9.
Packit 33f14e
           openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
Packit 33f14e
                                 gl_cv_func_snprintf_retval_c99="guessing no";;
Packit 33f14e
           openbsd*)             gl_cv_func_snprintf_retval_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Solaris >= 2.10.
Packit 33f14e
           solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
Packit 33f14e
           solaris*)             gl_cv_func_printf_sizes_c99="guessing no";;
Packit 33f14e
                                 # Guess yes on AIX >= 4.
Packit 33f14e
           aix[1-3]*)            gl_cv_func_snprintf_retval_c99="guessing no";;
Packit 33f14e
           aix*)                 gl_cv_func_snprintf_retval_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on NetBSD >= 3.
Packit 33f14e
           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
Packit 33f14e
                                 gl_cv_func_snprintf_retval_c99="guessing no";;
Packit 33f14e
           netbsd*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on BeOS.
Packit 33f14e
           beos*)                gl_cv_func_snprintf_retval_c99="guessing yes";;
Packit 33f14e
                                 # If we don't know, assume the worst.
Packit 33f14e
           *)                    gl_cv_func_snprintf_retval_c99="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the snprintf function supports the %n format directive
Packit 33f14e
dnl also in truncated portions of the format string. (ISO C99, POSIX:2001)
Packit 33f14e
dnl Result is gl_cv_func_snprintf_directive_n.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_REQUIRE([gl_SNPRINTF_PRESENCE])
Packit 33f14e
  AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
Packit 33f14e
    [gl_cv_func_snprintf_directive_n],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#include <string.h>
Packit 33f14e
#if HAVE_SNPRINTF
Packit 33f14e
# define my_snprintf snprintf
Packit 33f14e
#else
Packit 33f14e
# include <stdarg.h>
Packit 33f14e
static int my_snprintf (char *buf, int size, const char *format, ...)
Packit 33f14e
{
Packit 33f14e
  va_list args;
Packit 33f14e
  int ret;
Packit 33f14e
  va_start (args, format);
Packit 33f14e
  ret = vsnprintf (buf, size, format, args);
Packit 33f14e
  va_end (args);
Packit 33f14e
  return ret;
Packit 33f14e
}
Packit 33f14e
#endif
Packit 33f14e
static char fmtstring[10];
Packit 33f14e
static char buf[100];
Packit 33f14e
int main ()
Packit 33f14e
{
Packit 33f14e
  int count = -1;
Packit 33f14e
  /* Copy the format string.  Some systems (glibc with _FORTIFY_SOURCE=2)
Packit 33f14e
     support %n in format strings in read-only memory but not in writable
Packit 33f14e
     memory.  */
Packit 33f14e
  strcpy (fmtstring, "%d %n");
Packit 33f14e
  my_snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55);
Packit 33f14e
  if (count != 6)
Packit 33f14e
    return 1;
Packit 33f14e
  return 0;
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_snprintf_directive_n=yes],
Packit 33f14e
        [gl_cv_func_snprintf_directive_n=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                                 # Guess yes on glibc systems.
Packit 33f14e
           *-gnu*)               gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # Guess yes on FreeBSD >= 5.
Packit 33f14e
           freebsd[1-4].*)       gl_cv_func_snprintf_directive_n="guessing no";;
Packit 33f14e
           freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # Guess yes on Mac OS X >= 10.3.
Packit 33f14e
           darwin[1-6].*)        gl_cv_func_snprintf_directive_n="guessing no";;
Packit 33f14e
           darwin*)              gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # Guess yes on Solaris >= 2.6.
Packit 33f14e
           solaris2.[0-5] | solaris2.[0-5].*)
Packit 33f14e
                                 gl_cv_func_snprintf_directive_n="guessing no";;
Packit 33f14e
           solaris*)             gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # Guess yes on AIX >= 4.
Packit 33f14e
           aix[1-3]*)            gl_cv_func_snprintf_directive_n="guessing no";;
Packit 33f14e
           aix*)                 gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # Guess yes on IRIX >= 6.5.
Packit 33f14e
           irix6.5)              gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # Guess yes on OSF/1 >= 5.
Packit 33f14e
           osf[3-4]*)            gl_cv_func_snprintf_directive_n="guessing no";;
Packit 33f14e
           osf*)                 gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # Guess yes on NetBSD >= 3.
Packit 33f14e
           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
Packit 33f14e
                                 gl_cv_func_snprintf_directive_n="guessing no";;
Packit 33f14e
           netbsd*)              gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # Guess yes on BeOS.
Packit 33f14e
           beos*)                gl_cv_func_snprintf_directive_n="guessing yes";;
Packit 33f14e
                                 # If we don't know, assume the worst.
Packit 33f14e
           *)                    gl_cv_func_snprintf_directive_n="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the snprintf function, when passed a size = 1, writes any
Packit 33f14e
dnl output without bounds in this case, behaving like sprintf. This is the
Packit 33f14e
dnl case on Linux libc5.
Packit 33f14e
dnl Result is gl_cv_func_snprintf_size1.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_SNPRINTF_SIZE1],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([gl_SNPRINTF_PRESENCE])
Packit 33f14e
  AC_CACHE_CHECK([whether snprintf respects a size of 1],
Packit 33f14e
    [gl_cv_func_snprintf_size1],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdio.h>
Packit 33f14e
#if HAVE_SNPRINTF
Packit 33f14e
# define my_snprintf snprintf
Packit 33f14e
#else
Packit 33f14e
# include <stdarg.h>
Packit 33f14e
static int my_snprintf (char *buf, int size, const char *format, ...)
Packit 33f14e
{
Packit 33f14e
  va_list args;
Packit 33f14e
  int ret;
Packit 33f14e
  va_start (args, format);
Packit 33f14e
  ret = vsnprintf (buf, size, format, args);
Packit 33f14e
  va_end (args);
Packit 33f14e
  return ret;
Packit 33f14e
}
Packit 33f14e
#endif
Packit 33f14e
int main()
Packit 33f14e
{
Packit 33f14e
  static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
Packit 33f14e
  my_snprintf (buf, 1, "%d", 12345);
Packit 33f14e
  return buf[1] != 'E';
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_snprintf_size1=yes],
Packit 33f14e
        [gl_cv_func_snprintf_size1=no],
Packit 33f14e
        [gl_cv_func_snprintf_size1="guessing yes"])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl Test whether the vsnprintf function, when passed a zero size, produces no
Packit 33f14e
dnl output. (ISO C99, POSIX:2001)
Packit 33f14e
dnl For example, snprintf nevertheless writes a NUL byte in this case
Packit 33f14e
dnl on OSF/1 5.1:
Packit 33f14e
dnl     ---------------------------------------------------------------------
Packit 33f14e
dnl     #include <stdio.h>
Packit 33f14e
dnl     int main()
Packit 33f14e
dnl     {
Packit 33f14e
dnl       static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
Packit 33f14e
dnl       snprintf (buf, 0, "%d", 12345);
Packit 33f14e
dnl       return buf[0] != 'D';
Packit 33f14e
dnl     }
Packit 33f14e
dnl     ---------------------------------------------------------------------
Packit 33f14e
dnl And vsnprintf writes any output without bounds in this case, behaving like
Packit 33f14e
dnl vsprintf, on HP-UX 11 and OSF/1 5.1:
Packit 33f14e
dnl     ---------------------------------------------------------------------
Packit 33f14e
dnl     #include <stdarg.h>
Packit 33f14e
dnl     #include <stdio.h>
Packit 33f14e
dnl     static int my_snprintf (char *buf, int size, const char *format, ...)
Packit 33f14e
dnl     {
Packit 33f14e
dnl       va_list args;
Packit 33f14e
dnl       int ret;
Packit 33f14e
dnl       va_start (args, format);
Packit 33f14e
dnl       ret = vsnprintf (buf, size, format, args);
Packit 33f14e
dnl       va_end (args);
Packit 33f14e
dnl       return ret;
Packit 33f14e
dnl     }
Packit 33f14e
dnl     int main()
Packit 33f14e
dnl     {
Packit 33f14e
dnl       static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
Packit 33f14e
dnl       my_snprintf (buf, 0, "%d", 12345);
Packit 33f14e
dnl       return buf[0] != 'D';
Packit 33f14e
dnl     }
Packit 33f14e
dnl     ---------------------------------------------------------------------
Packit 33f14e
dnl Result is gl_cv_func_vsnprintf_zerosize_c99.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99],
Packit 33f14e
[
Packit 33f14e
  AC_REQUIRE([AC_PROG_CC])
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 33f14e
  AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99],
Packit 33f14e
    [gl_cv_func_vsnprintf_zerosize_c99],
Packit 33f14e
    [
Packit 33f14e
      AC_RUN_IFELSE(
Packit 33f14e
        [AC_LANG_SOURCE([[
Packit 33f14e
#include <stdarg.h>
Packit 33f14e
#include <stdio.h>
Packit 33f14e
static int my_snprintf (char *buf, int size, const char *format, ...)
Packit 33f14e
{
Packit 33f14e
  va_list args;
Packit 33f14e
  int ret;
Packit 33f14e
  va_start (args, format);
Packit 33f14e
  ret = vsnprintf (buf, size, format, args);
Packit 33f14e
  va_end (args);
Packit 33f14e
  return ret;
Packit 33f14e
}
Packit 33f14e
int main()
Packit 33f14e
{
Packit 33f14e
  static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
Packit 33f14e
  my_snprintf (buf, 0, "%d", 12345);
Packit 33f14e
  return buf[0] != 'D';
Packit 33f14e
}]])],
Packit 33f14e
        [gl_cv_func_vsnprintf_zerosize_c99=yes],
Packit 33f14e
        [gl_cv_func_vsnprintf_zerosize_c99=no],
Packit 33f14e
        [
Packit 33f14e
changequote(,)dnl
Packit 33f14e
         case "$host_os" in
Packit 33f14e
                                 # Guess yes on glibc systems.
Packit 33f14e
           *-gnu*)               gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on FreeBSD >= 5.
Packit 33f14e
           freebsd[1-4].*)       gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
Packit 33f14e
           freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Mac OS X >= 10.3.
Packit 33f14e
           darwin[1-6].*)        gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
Packit 33f14e
           darwin*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Cygwin.
Packit 33f14e
           cygwin*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on Solaris >= 2.6.
Packit 33f14e
           solaris2.[0-5] | solaris2.[0-5].*)
Packit 33f14e
                                 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
Packit 33f14e
           solaris*)             gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on AIX >= 4.
Packit 33f14e
           aix[1-3]*)            gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
Packit 33f14e
           aix*)                 gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on IRIX >= 6.5.
Packit 33f14e
           irix6.5)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on NetBSD >= 3.
Packit 33f14e
           netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
Packit 33f14e
                                 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
Packit 33f14e
           netbsd*)              gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on BeOS.
Packit 33f14e
           beos*)                gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # Guess yes on mingw.
Packit 33f14e
           mingw* | pw*)         gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
Packit 33f14e
                                 # If we don't know, assume the worst.
Packit 33f14e
           *)                    gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
Packit 33f14e
         esac
Packit 33f14e
changequote([,])dnl
Packit 33f14e
        ])
Packit 33f14e
    ])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
dnl The results of these tests on various platforms are:
Packit 33f14e
dnl
Packit 33f14e
dnl 1 = gl_PRINTF_SIZES_C99
Packit 33f14e
dnl 2 = gl_PRINTF_LONG_DOUBLE
Packit 33f14e
dnl 3 = gl_PRINTF_INFINITE
Packit 33f14e
dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE
Packit 33f14e
dnl 5 = gl_PRINTF_DIRECTIVE_A
Packit 33f14e
dnl 6 = gl_PRINTF_DIRECTIVE_F
Packit 33f14e
dnl 7 = gl_PRINTF_DIRECTIVE_N
Packit 33f14e
dnl 8 = gl_PRINTF_DIRECTIVE_LS
Packit 33f14e
dnl 9 = gl_PRINTF_POSITIONS
Packit 33f14e
dnl 10 = gl_PRINTF_FLAG_GROUPING
Packit 33f14e
dnl 11 = gl_PRINTF_FLAG_LEFTADJUST
Packit 33f14e
dnl 12 = gl_PRINTF_FLAG_ZERO
Packit 33f14e
dnl 13 = gl_PRINTF_PRECISION
Packit 33f14e
dnl 14 = gl_PRINTF_ENOMEM
Packit 33f14e
dnl 15 = gl_SNPRINTF_PRESENCE
Packit 33f14e
dnl 16 = gl_SNPRINTF_TRUNCATION_C99
Packit 33f14e
dnl 17 = gl_SNPRINTF_RETVAL_C99
Packit 33f14e
dnl 18 = gl_SNPRINTF_DIRECTIVE_N
Packit 33f14e
dnl 19 = gl_SNPRINTF_SIZE1
Packit 33f14e
dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99
Packit 33f14e
dnl
Packit 33f14e
dnl 1 = checking whether printf supports size specifiers as in C99...
Packit 33f14e
dnl 2 = checking whether printf supports 'long double' arguments...
Packit 33f14e
dnl 3 = checking whether printf supports infinite 'double' arguments...
Packit 33f14e
dnl 4 = checking whether printf supports infinite 'long double' arguments...
Packit 33f14e
dnl 5 = checking whether printf supports the 'a' and 'A' directives...
Packit 33f14e
dnl 6 = checking whether printf supports the 'F' directive...
Packit 33f14e
dnl 7 = checking whether printf supports the 'n' directive...
Packit 33f14e
dnl 8 = checking whether printf supports the 'ls' directive...
Packit 33f14e
dnl 9 = checking whether printf supports POSIX/XSI format strings with positions...
Packit 33f14e
dnl 10 = checking whether printf supports the grouping flag...
Packit 33f14e
dnl 11 = checking whether printf supports the left-adjust flag correctly...
Packit 33f14e
dnl 12 = checking whether printf supports the zero flag correctly...
Packit 33f14e
dnl 13 = checking whether printf supports large precisions...
Packit 33f14e
dnl 14 = checking whether printf survives out-of-memory conditions...
Packit 33f14e
dnl 15 = checking for snprintf...
Packit 33f14e
dnl 16 = checking whether snprintf truncates the result as in C99...
Packit 33f14e
dnl 17 = checking whether snprintf returns a byte count as in C99...
Packit 33f14e
dnl 18 = checking whether snprintf fully supports the 'n' directive...
Packit 33f14e
dnl 19 = checking whether snprintf respects a size of 1...
Packit 33f14e
dnl 20 = checking whether vsnprintf respects a zero size as in C99...
Packit 33f14e
dnl
Packit 33f14e
dnl . = yes, # = no.
Packit 33f14e
dnl
Packit 33f14e
dnl                                  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
Packit 33f14e
dnl   glibc 2.5                      .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
Packit 33f14e
dnl   glibc 2.3.6                    .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
Packit 33f14e
dnl   FreeBSD 5.4, 6.1               .  .  .  .  #  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .
Packit 33f14e
dnl   Mac OS X 10.5.8                .  .  .  #  #  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .
Packit 33f14e
dnl   Mac OS X 10.3.9                .  .  .  .  #  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .
Packit 33f14e
dnl   OpenBSD 3.9, 4.0               .  .  #  #  #  #  .  #  .  #  .  #  .  #  .  .  .  .  .  .
Packit 33f14e
dnl   Cygwin 1.7.0 (2009)            .  .  .  #  .  .  .  ?  .  .  .  .  .  ?  .  .  .  .  .  .
Packit 33f14e
dnl   Cygwin 1.5.25 (2008)           .  .  .  #  #  .  .  #  .  .  .  .  .  #  .  .  .  .  .  .
Packit 33f14e
dnl   Cygwin 1.5.19 (2006)           #  .  .  #  #  #  .  #  .  #  .  #  #  #  .  .  .  .  .  .
Packit 33f14e
dnl   Solaris 11 2011-11             .  .  #  #  #  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .
Packit 33f14e
dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  #  .  .  .  .  .  .  .
Packit 33f14e
dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  #  .  .  .  #  #  .  .  .  #  .  .  .
Packit 33f14e
dnl   Solaris 2.5.1                  #  .  #  #  #  #  .  #  .  .  .  #  .  .  #  #  #  #  #  #
Packit 33f14e
dnl   AIX 7.1                        .  .  #  #  #  .  .  .  .  .  .  #  #  .  .  .  .  .  .  .
Packit 33f14e
dnl   AIX 5.2                        .  .  #  #  #  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .
Packit 33f14e
dnl   AIX 4.3.2, 5.1                 #  .  #  #  #  #  .  .  .  .  .  #  .  .  .  .  #  .  .  .
Packit 33f14e
dnl   HP-UX 11.31                    .  .  .  .  #  .  .  .  .  .  .  #  .  .  .  .  #  #  .  .
Packit 33f14e
dnl   HP-UX 11.{00,11,23}            #  .  .  .  #  #  .  .  .  .  .  #  .  .  .  .  #  #  .  #
Packit 33f14e
dnl   HP-UX 10.20                    #  .  #  .  #  #  .  ?  .  .  #  #  .  .  .  .  #  #  ?  #
Packit 33f14e
dnl   IRIX 6.5                       #  .  #  #  #  #  .  #  .  .  .  #  .  .  .  .  #  .  .  .
Packit 33f14e
dnl   OSF/1 5.1                      #  .  #  #  #  #  .  .  .  .  .  #  .  .  .  .  #  .  .  #
Packit 33f14e
dnl   OSF/1 4.0d                     #  .  #  #  #  #  .  .  .  .  .  #  .  .  #  #  #  #  #  #
Packit 33f14e
dnl   NetBSD 5.0                     .  .  .  #  #  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .
Packit 33f14e
dnl   NetBSD 4.0                     .  ?  ?  ?  ?  ?  .  ?  .  ?  ?  ?  ?  ?  .  .  .  ?  ?  ?
Packit 33f14e
dnl   NetBSD 3.0                     .  .  .  .  #  #  .  ?  #  #  ?  #  .  #  .  .  .  .  .  .
Packit 33f14e
dnl   Haiku                          .  .  .  #  #  #  .  #  .  .  .  .  .  ?  .  .  ?  .  .  .
Packit 33f14e
dnl   BeOS                           #  #  .  #  #  #  .  ?  #  .  ?  .  #  ?  .  .  ?  .  .  .
Packit 33f14e
dnl   old mingw / msvcrt             #  #  #  #  #  #  .  .  #  #  .  #  #  ?  .  #  #  #  .  .
Packit 33f14e
dnl   MSVC 9                         #  #  #  #  #  #  #  .  #  #  .  #  #  ?  #  #  #  #  .  .
Packit 33f14e
dnl   mingw 2009-2011                .  #  .  #  .  .  .  .  #  #  .  .  .  ?  .  .  .  .  .  .
Packit 33f14e
dnl   mingw-w64 2011                 #  #  #  #  #  #  .  .  #  #  .  #  #  ?  .  #  #  #  .  .