Blame m4/printf.m4

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