diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 17:39:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 17:39:29 +0000 |
commit | 8ffec2a3aba6f114784e11f89ef1d57a096ae540 (patch) | |
tree | ccebcbad06203e8241a8e7249f8e6c478a3682ea /m4/fopen.m4 | |
parent | Initial commit. (diff) | |
download | coreutils-8ffec2a3aba6f114784e11f89ef1d57a096ae540.tar.xz coreutils-8ffec2a3aba6f114784e11f89ef1d57a096ae540.zip |
Adding upstream version 8.32.upstream/8.32upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'm4/fopen.m4')
-rw-r--r-- | m4/fopen.m4 | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/m4/fopen.m4 b/m4/fopen.m4 new file mode 100644 index 0000000..2a4b00d --- /dev/null +++ b/m4/fopen.m4 @@ -0,0 +1,62 @@ +# fopen.m4 serial 10 +dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FOPEN], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | pw*) + dnl Replace fopen, for handling of "/dev/null". + REPLACE_FOPEN=1 + dnl fopen on mingw also has the trailing slash bug. + gl_cv_func_fopen_slash="guessing no" + ;; + *) + dnl fopen("foo/", "w") should not create a file when the file name has a + dnl trailing slash. + AC_CACHE_CHECK([whether fopen recognizes a trailing slash], + [gl_cv_func_fopen_slash], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include <stddef.h> +#include <stdio.h> +int main () +{ + FILE *fp = fopen ("conftest.sl/", "w"); + int result = (fp != NULL); + if (fp != NULL) + fclose (fp); + return result; +}]])], + [gl_cv_func_fopen_slash=yes], + [gl_cv_func_fopen_slash=no], + [ +changequote(,)dnl + case "$host_os" in + aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*) + gl_cv_func_fopen_slash="guessing no" ;; + *) + gl_cv_func_fopen_slash="guessing yes" ;; + esac +changequote([,])dnl + ]) + rm -f conftest.sl + ]) + ;; + esac + case "$gl_cv_func_fopen_slash" in + *no) + AC_DEFINE([FOPEN_TRAILING_SLASH_BUG], [1], + [Define to 1 if fopen() fails to recognize a trailing slash.]) + REPLACE_FOPEN=1 + ;; + esac +]) + +# Prerequisites of lib/fopen.c. +AC_DEFUN([gl_PREREQ_FOPEN], [:]) |