Blame m4/stdio_h.m4

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