Blame m4/stdio_h.m4

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