Blame m4/stdio_h.m4

Packit 33f14e
# stdio_h.m4 serial 48
Packit 33f14e
dnl Copyright (C) 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
AC_DEFUN([gl_STDIO_H],
Packit 33f14e
[
Packit 33f14e
  AH_VERBATIM([MINGW_ANSI_STDIO],
Packit 33f14e
[/* Use GNU style printf and scanf.  */
Packit 33f14e
#ifndef __USE_MINGW_ANSI_STDIO
Packit 33f14e
# undef __USE_MINGW_ANSI_STDIO
Packit 33f14e
#endif
Packit 33f14e
])
Packit 33f14e
  AC_DEFINE([__USE_MINGW_ANSI_STDIO])
Packit 33f14e
  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
Packit 33f14e
  gl_NEXT_HEADERS([stdio.h])
Packit 33f14e
Packit 33f14e
  dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and
Packit 33f14e
  dnl inttypes.h behave like gnu instead of system; we must give our
Packit 33f14e
  dnl printf wrapper the right attribute to match.
Packit 33f14e
  AC_CACHE_CHECK([which flavor of printf attribute matches inttypes macros],
Packit 33f14e
    [gl_cv_func_printf_attribute_flavor],
Packit 33f14e
    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Packit 33f14e
       #define __STDC_FORMAT_MACROS 1
Packit 33f14e
       #include <stdio.h>
Packit 33f14e
       #include <inttypes.h>
Packit 33f14e
       /* For non-mingw systems, compilation will trivially succeed.
Packit 33f14e
          For mingw, compilation will succeed for older mingw (system
Packit 33f14e
          printf, "I64d") and fail for newer mingw (gnu printf, "lld"). */
Packit 33f14e
       #if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) && \
Packit 33f14e
         (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
Packit 33f14e
       extern char PRIdMAX_probe[sizeof PRIdMAX == sizeof "I64d" ? 1 : -1];
Packit 33f14e
       #endif
Packit 33f14e
      ]])], [gl_cv_func_printf_attribute_flavor=system],
Packit 33f14e
      [gl_cv_func_printf_attribute_flavor=gnu])])
Packit 33f14e
  if test "$gl_cv_func_printf_attribute_flavor" = gnu; then
Packit 33f14e
    AC_DEFINE([GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU], [1],
Packit 33f14e
      [Define to 1 if printf and friends should be labeled with
Packit 33f14e
       attribute "__gnu_printf__" instead of "__printf__"])
Packit 33f14e
  fi
Packit 33f14e
Packit 33f14e
  dnl No need to create extra modules for these functions. Everyone who uses
Packit 33f14e
  dnl <stdio.h> likely needs them.
Packit 33f14e
  GNULIB_FSCANF=1
Packit 33f14e
  gl_MODULE_INDICATOR([fscanf])
Packit 33f14e
  GNULIB_SCANF=1
Packit 33f14e
  gl_MODULE_INDICATOR([scanf])
Packit 33f14e
  GNULIB_FGETC=1
Packit 33f14e
  GNULIB_GETC=1
Packit 33f14e
  GNULIB_GETCHAR=1
Packit 33f14e
  GNULIB_FGETS=1
Packit 33f14e
  GNULIB_FREAD=1
Packit 33f14e
  dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c"
Packit 33f14e
  dnl "expected source file, required through AC_LIBSOURCES, not found". It is
Packit 33f14e
  dnl also an optimization, to avoid performing a configure check whose result
Packit 33f14e
  dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
Packit 33f14e
  dnl or GNULIB_NONBLOCKING redundant.
Packit 33f14e
  m4_ifdef([gl_NONBLOCKING_IO], [
Packit 33f14e
    gl_NONBLOCKING_IO
Packit 33f14e
    if test $gl_cv_have_nonblocking != yes; then
Packit 33f14e
      REPLACE_STDIO_READ_FUNCS=1
Packit 33f14e
      AC_LIBOBJ([stdio-read])
Packit 33f14e
    fi
Packit 33f14e
  ])
Packit 33f14e
Packit 33f14e
  dnl No need to create extra modules for these functions. Everyone who uses
Packit 33f14e
  dnl <stdio.h> likely needs them.
Packit 33f14e
  GNULIB_FPRINTF=1
Packit 33f14e
  GNULIB_PRINTF=1
Packit 33f14e
  GNULIB_VFPRINTF=1
Packit 33f14e
  GNULIB_VPRINTF=1
Packit 33f14e
  GNULIB_FPUTC=1
Packit 33f14e
  GNULIB_PUTC=1
Packit 33f14e
  GNULIB_PUTCHAR=1
Packit 33f14e
  GNULIB_FPUTS=1
Packit 33f14e
  GNULIB_PUTS=1
Packit 33f14e
  GNULIB_FWRITE=1
Packit 33f14e
  dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
Packit 33f14e
  dnl "expected source file, required through AC_LIBSOURCES, not found". It is
Packit 33f14e
  dnl also an optimization, to avoid performing a configure check whose result
Packit 33f14e
  dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
Packit 33f14e
  dnl GNULIB_SIGPIPE redundant.
Packit 33f14e
  m4_ifdef([gl_SIGNAL_SIGPIPE], [
Packit 33f14e
    gl_SIGNAL_SIGPIPE
Packit 33f14e
    if test $gl_cv_header_signal_h_SIGPIPE != yes; then
Packit 33f14e
      REPLACE_STDIO_WRITE_FUNCS=1
Packit 33f14e
      AC_LIBOBJ([stdio-write])
Packit 33f14e
    fi
Packit 33f14e
  ])
Packit 33f14e
  dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
Packit 33f14e
  dnl "expected source file, required through AC_LIBSOURCES, not found". It is
Packit 33f14e
  dnl also an optimization, to avoid performing a configure check whose result
Packit 33f14e
  dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
Packit 33f14e
  dnl or GNULIB_NONBLOCKING redundant.
Packit 33f14e
  m4_ifdef([gl_NONBLOCKING_IO], [
Packit 33f14e
    gl_NONBLOCKING_IO
Packit 33f14e
    if test $gl_cv_have_nonblocking != yes; then
Packit 33f14e
      REPLACE_STDIO_WRITE_FUNCS=1
Packit 33f14e
      AC_LIBOBJ([stdio-write])
Packit 33f14e
    fi
Packit 33f14e
  ])
Packit 33f14e
Packit 33f14e
  dnl Check for declarations of anything we want to poison if the
Packit 33f14e
  dnl corresponding gnulib module is not in use, and which is not
Packit 33f14e
  dnl guaranteed by both C89 and C11.
Packit 33f14e
  gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
Packit 33f14e
    ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen
Packit 33f14e
    renameat snprintf tmpfile vdprintf vsnprintf])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
Packit 33f14e
[
Packit 33f14e
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
Packit 33f14e
  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
Packit 33f14e
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
Packit 33f14e
  dnl Define it also as a C macro, for the benefit of the unit tests.
Packit 33f14e
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_STDIO_H_DEFAULTS],
Packit 33f14e
[
Packit 33f14e
  GNULIB_DPRINTF=0;              AC_SUBST([GNULIB_DPRINTF])
Packit 33f14e
  GNULIB_FCLOSE=0;               AC_SUBST([GNULIB_FCLOSE])
Packit 33f14e
  GNULIB_FDOPEN=0;               AC_SUBST([GNULIB_FDOPEN])
Packit 33f14e
  GNULIB_FFLUSH=0;               AC_SUBST([GNULIB_FFLUSH])
Packit 33f14e
  GNULIB_FGETC=0;                AC_SUBST([GNULIB_FGETC])
Packit 33f14e
  GNULIB_FGETS=0;                AC_SUBST([GNULIB_FGETS])
Packit 33f14e
  GNULIB_FOPEN=0;                AC_SUBST([GNULIB_FOPEN])
Packit 33f14e
  GNULIB_FPRINTF=0;              AC_SUBST([GNULIB_FPRINTF])
Packit 33f14e
  GNULIB_FPRINTF_POSIX=0;        AC_SUBST([GNULIB_FPRINTF_POSIX])
Packit 33f14e
  GNULIB_FPURGE=0;               AC_SUBST([GNULIB_FPURGE])
Packit 33f14e
  GNULIB_FPUTC=0;                AC_SUBST([GNULIB_FPUTC])
Packit 33f14e
  GNULIB_FPUTS=0;                AC_SUBST([GNULIB_FPUTS])
Packit 33f14e
  GNULIB_FREAD=0;                AC_SUBST([GNULIB_FREAD])
Packit 33f14e
  GNULIB_FREOPEN=0;              AC_SUBST([GNULIB_FREOPEN])
Packit 33f14e
  GNULIB_FSCANF=0;               AC_SUBST([GNULIB_FSCANF])
Packit 33f14e
  GNULIB_FSEEK=0;                AC_SUBST([GNULIB_FSEEK])
Packit 33f14e
  GNULIB_FSEEKO=0;               AC_SUBST([GNULIB_FSEEKO])
Packit 33f14e
  GNULIB_FTELL=0;                AC_SUBST([GNULIB_FTELL])
Packit 33f14e
  GNULIB_FTELLO=0;               AC_SUBST([GNULIB_FTELLO])
Packit 33f14e
  GNULIB_FWRITE=0;               AC_SUBST([GNULIB_FWRITE])
Packit 33f14e
  GNULIB_GETC=0;                 AC_SUBST([GNULIB_GETC])
Packit 33f14e
  GNULIB_GETCHAR=0;              AC_SUBST([GNULIB_GETCHAR])
Packit 33f14e
  GNULIB_GETDELIM=0;             AC_SUBST([GNULIB_GETDELIM])
Packit 33f14e
  GNULIB_GETLINE=0;              AC_SUBST([GNULIB_GETLINE])
Packit 33f14e
  GNULIB_OBSTACK_PRINTF=0;       AC_SUBST([GNULIB_OBSTACK_PRINTF])
Packit 33f14e
  GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
Packit 33f14e
  GNULIB_PCLOSE=0;               AC_SUBST([GNULIB_PCLOSE])
Packit 33f14e
  GNULIB_PERROR=0;               AC_SUBST([GNULIB_PERROR])
Packit 33f14e
  GNULIB_POPEN=0;                AC_SUBST([GNULIB_POPEN])
Packit 33f14e
  GNULIB_PRINTF=0;               AC_SUBST([GNULIB_PRINTF])
Packit 33f14e
  GNULIB_PRINTF_POSIX=0;         AC_SUBST([GNULIB_PRINTF_POSIX])
Packit 33f14e
  GNULIB_PUTC=0;                 AC_SUBST([GNULIB_PUTC])
Packit 33f14e
  GNULIB_PUTCHAR=0;              AC_SUBST([GNULIB_PUTCHAR])
Packit 33f14e
  GNULIB_PUTS=0;                 AC_SUBST([GNULIB_PUTS])
Packit 33f14e
  GNULIB_REMOVE=0;               AC_SUBST([GNULIB_REMOVE])
Packit 33f14e
  GNULIB_RENAME=0;               AC_SUBST([GNULIB_RENAME])
Packit 33f14e
  GNULIB_RENAMEAT=0;             AC_SUBST([GNULIB_RENAMEAT])
Packit 33f14e
  GNULIB_SCANF=0;                AC_SUBST([GNULIB_SCANF])
Packit 33f14e
  GNULIB_SNPRINTF=0;             AC_SUBST([GNULIB_SNPRINTF])
Packit 33f14e
  GNULIB_SPRINTF_POSIX=0;        AC_SUBST([GNULIB_SPRINTF_POSIX])
Packit 33f14e
  GNULIB_STDIO_H_NONBLOCKING=0;  AC_SUBST([GNULIB_STDIO_H_NONBLOCKING])
Packit 33f14e
  GNULIB_STDIO_H_SIGPIPE=0;      AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
Packit 33f14e
  GNULIB_TMPFILE=0;              AC_SUBST([GNULIB_TMPFILE])
Packit 33f14e
  GNULIB_VASPRINTF=0;            AC_SUBST([GNULIB_VASPRINTF])
Packit 33f14e
  GNULIB_VFSCANF=0;              AC_SUBST([GNULIB_VFSCANF])
Packit 33f14e
  GNULIB_VSCANF=0;               AC_SUBST([GNULIB_VSCANF])
Packit 33f14e
  GNULIB_VDPRINTF=0;             AC_SUBST([GNULIB_VDPRINTF])
Packit 33f14e
  GNULIB_VFPRINTF=0;             AC_SUBST([GNULIB_VFPRINTF])
Packit 33f14e
  GNULIB_VFPRINTF_POSIX=0;       AC_SUBST([GNULIB_VFPRINTF_POSIX])
Packit 33f14e
  GNULIB_VPRINTF=0;              AC_SUBST([GNULIB_VPRINTF])
Packit 33f14e
  GNULIB_VPRINTF_POSIX=0;        AC_SUBST([GNULIB_VPRINTF_POSIX])
Packit 33f14e
  GNULIB_VSNPRINTF=0;            AC_SUBST([GNULIB_VSNPRINTF])
Packit 33f14e
  GNULIB_VSPRINTF_POSIX=0;       AC_SUBST([GNULIB_VSPRINTF_POSIX])
Packit 33f14e
  dnl Assume proper GNU behavior unless another module says otherwise.
Packit 33f14e
  HAVE_DECL_FPURGE=1;            AC_SUBST([HAVE_DECL_FPURGE])
Packit 33f14e
  HAVE_DECL_FSEEKO=1;            AC_SUBST([HAVE_DECL_FSEEKO])
Packit 33f14e
  HAVE_DECL_FTELLO=1;            AC_SUBST([HAVE_DECL_FTELLO])
Packit 33f14e
  HAVE_DECL_GETDELIM=1;          AC_SUBST([HAVE_DECL_GETDELIM])
Packit 33f14e
  HAVE_DECL_GETLINE=1;           AC_SUBST([HAVE_DECL_GETLINE])
Packit 33f14e
  HAVE_DECL_OBSTACK_PRINTF=1;    AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
Packit 33f14e
  HAVE_DECL_SNPRINTF=1;          AC_SUBST([HAVE_DECL_SNPRINTF])
Packit 33f14e
  HAVE_DECL_VSNPRINTF=1;         AC_SUBST([HAVE_DECL_VSNPRINTF])
Packit 33f14e
  HAVE_DPRINTF=1;                AC_SUBST([HAVE_DPRINTF])
Packit 33f14e
  HAVE_FSEEKO=1;                 AC_SUBST([HAVE_FSEEKO])
Packit 33f14e
  HAVE_FTELLO=1;                 AC_SUBST([HAVE_FTELLO])
Packit 33f14e
  HAVE_PCLOSE=1;                 AC_SUBST([HAVE_PCLOSE])
Packit 33f14e
  HAVE_POPEN=1;                  AC_SUBST([HAVE_POPEN])
Packit 33f14e
  HAVE_RENAMEAT=1;               AC_SUBST([HAVE_RENAMEAT])
Packit 33f14e
  HAVE_VASPRINTF=1;              AC_SUBST([HAVE_VASPRINTF])
Packit 33f14e
  HAVE_VDPRINTF=1;               AC_SUBST([HAVE_VDPRINTF])
Packit 33f14e
  REPLACE_DPRINTF=0;             AC_SUBST([REPLACE_DPRINTF])
Packit 33f14e
  REPLACE_FCLOSE=0;              AC_SUBST([REPLACE_FCLOSE])
Packit 33f14e
  REPLACE_FDOPEN=0;              AC_SUBST([REPLACE_FDOPEN])
Packit 33f14e
  REPLACE_FFLUSH=0;              AC_SUBST([REPLACE_FFLUSH])
Packit 33f14e
  REPLACE_FOPEN=0;               AC_SUBST([REPLACE_FOPEN])
Packit 33f14e
  REPLACE_FPRINTF=0;             AC_SUBST([REPLACE_FPRINTF])
Packit 33f14e
  REPLACE_FPURGE=0;              AC_SUBST([REPLACE_FPURGE])
Packit 33f14e
  REPLACE_FREOPEN=0;             AC_SUBST([REPLACE_FREOPEN])
Packit 33f14e
  REPLACE_FSEEK=0;               AC_SUBST([REPLACE_FSEEK])
Packit 33f14e
  REPLACE_FSEEKO=0;              AC_SUBST([REPLACE_FSEEKO])
Packit 33f14e
  REPLACE_FTELL=0;               AC_SUBST([REPLACE_FTELL])
Packit 33f14e
  REPLACE_FTELLO=0;              AC_SUBST([REPLACE_FTELLO])
Packit 33f14e
  REPLACE_GETDELIM=0;            AC_SUBST([REPLACE_GETDELIM])
Packit 33f14e
  REPLACE_GETLINE=0;             AC_SUBST([REPLACE_GETLINE])
Packit 33f14e
  REPLACE_OBSTACK_PRINTF=0;      AC_SUBST([REPLACE_OBSTACK_PRINTF])
Packit 33f14e
  REPLACE_PERROR=0;              AC_SUBST([REPLACE_PERROR])
Packit 33f14e
  REPLACE_POPEN=0;               AC_SUBST([REPLACE_POPEN])
Packit 33f14e
  REPLACE_PRINTF=0;              AC_SUBST([REPLACE_PRINTF])
Packit 33f14e
  REPLACE_REMOVE=0;              AC_SUBST([REPLACE_REMOVE])
Packit 33f14e
  REPLACE_RENAME=0;              AC_SUBST([REPLACE_RENAME])
Packit 33f14e
  REPLACE_RENAMEAT=0;            AC_SUBST([REPLACE_RENAMEAT])
Packit 33f14e
  REPLACE_SNPRINTF=0;            AC_SUBST([REPLACE_SNPRINTF])
Packit 33f14e
  REPLACE_SPRINTF=0;             AC_SUBST([REPLACE_SPRINTF])
Packit 33f14e
  REPLACE_STDIO_READ_FUNCS=0;    AC_SUBST([REPLACE_STDIO_READ_FUNCS])
Packit 33f14e
  REPLACE_STDIO_WRITE_FUNCS=0;   AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
Packit 33f14e
  REPLACE_TMPFILE=0;             AC_SUBST([REPLACE_TMPFILE])
Packit 33f14e
  REPLACE_VASPRINTF=0;           AC_SUBST([REPLACE_VASPRINTF])
Packit 33f14e
  REPLACE_VDPRINTF=0;            AC_SUBST([REPLACE_VDPRINTF])
Packit 33f14e
  REPLACE_VFPRINTF=0;            AC_SUBST([REPLACE_VFPRINTF])
Packit 33f14e
  REPLACE_VPRINTF=0;             AC_SUBST([REPLACE_VPRINTF])
Packit 33f14e
  REPLACE_VSNPRINTF=0;           AC_SUBST([REPLACE_VSNPRINTF])
Packit 33f14e
  REPLACE_VSPRINTF=0;            AC_SUBST([REPLACE_VSPRINTF])
Packit 33f14e
])