aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2024-10-18 23:33:49 +0300
committerthegeorg <thegeorg@yandex-team.com>2024-10-18 23:42:50 +0300
commit1e95bf12278f195bc3450875f66f7304b8b269b9 (patch)
tree3058b269d5c203a1e079411bc86b99640ebe9a5b
parent2a43a3e9b68e16667f292702458482a8e6539e50 (diff)
downloadydb-1e95bf12278f195bc3450875f66f7304b8b269b9.tar.gz
contrib/tools/m4: Remove windows-specific libc replacements
commit_hash:ec4d153d072b7dc65470431459aa432df6b2e82a
-rw-r--r--contrib/tools/m4/lib/config-win.h2
-rw-r--r--contrib/tools/m4/lib/fpurge.c150
-rw-r--r--contrib/tools/m4/lib/freading.c76
-rw-r--r--contrib/tools/m4/lib/lseek.c67
-rw-r--r--contrib/tools/m4/lib/open.c181
-rw-r--r--contrib/tools/m4/lib/platform/win64/fcntl.h2
-rw-r--r--contrib/tools/m4/lib/platform/win64/sys/stat.h2
-rw-r--r--contrib/tools/m4/lib/platform/win64/unistd.h4
-rw-r--r--contrib/tools/m4/lib/rmdir.c53
-rw-r--r--contrib/tools/m4/lib/stat.c138
-rw-r--r--contrib/tools/m4/lib/ya.make6
11 files changed, 5 insertions, 676 deletions
diff --git a/contrib/tools/m4/lib/config-win.h b/contrib/tools/m4/lib/config-win.h
index fb0568c1e5..ec0f1bc242 100644
--- a/contrib/tools/m4/lib/config-win.h
+++ b/contrib/tools/m4/lib/config-win.h
@@ -1282,7 +1282,7 @@ char *strsignal (int signum);
/* Define to 1 if stat needs help when passed a directory name with a trailing
slash */
-#define REPLACE_FUNC_STAT_DIR 1
+/* #undef REPLACE_FUNC_STAT_DIR */
/* Define to 1 if stat needs help when passed a file name with a trailing
slash */
diff --git a/contrib/tools/m4/lib/fpurge.c b/contrib/tools/m4/lib/fpurge.c
deleted file mode 100644
index 139a43627f..0000000000
--- a/contrib/tools/m4/lib/fpurge.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Flushing buffers of a FILE stream.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <stdio.h>
-
-#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
-# if HAVE_STDIO_EXT_H
-# include <stdio_ext.h>
-# endif
-#endif
-#include <stdlib.h>
-
-#include "stdio-impl.h"
-
-int
-fpurge (FILE *fp)
-{
-#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
-
- __fpurge (fp);
- /* The __fpurge function does not have a return value. */
- return 0;
-
-#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */
-
- /* Call the system's fpurge function. */
-# undef fpurge
-# if !HAVE_DECL_FPURGE
- extern int fpurge (FILE *);
-# endif
- int result = fpurge (fp);
-# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
- /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
- if (result == 0)
- /* Correct the invariants that fpurge broke.
- <stdio.h> on BSD systems says:
- "The following always hold: if _flags & __SRD, _w is 0."
- If this invariant is not fulfilled and the stream is read-write but
- currently reading, subsequent putc or fputc calls will write directly
- into the buffer, although they shouldn't be allowed to. */
- if ((fp_->_flags & __SRD) != 0)
- fp_->_w = 0;
-# endif
- return result;
-
-#else
-
- /* Most systems provide FILE as a struct and the necessary bitmask in
- <stdio.h>, because they need it for implementing getc() and putc() as
- fast macros. */
-# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
- /* GNU libc, BeOS, Haiku, Linux libc5 */
- fp->_IO_read_end = fp->_IO_read_ptr;
- fp->_IO_write_ptr = fp->_IO_write_base;
- /* Avoid memory leak when there is an active ungetc buffer. */
- if (fp->_IO_save_base != NULL)
- {
- free (fp->_IO_save_base);
- fp->_IO_save_base = NULL;
- }
- return 0;
-# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
- /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
- fp_->_p = fp_->_bf._base;
- fp_->_r = 0;
- fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
- ? fp_->_bf._size
- : 0);
- /* Avoid memory leak when there is an active ungetc buffer. */
- if (fp_ub._base != NULL)
- {
- if (fp_ub._base != fp_->_ubuf)
- free (fp_ub._base);
- fp_ub._base = NULL;
- }
- return 0;
-# elif defined __EMX__ /* emx+gcc */
- fp->_ptr = fp->_buffer;
- fp->_rcount = 0;
- fp->_wcount = 0;
- fp->_ungetc_count = 0;
- return 0;
-# elif defined __minix /* Minix */
- fp->_ptr = fp->_buf;
- if (fp->_ptr != NULL)
- fp->_count = 0;
- return 0;
-# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
- fp_->_ptr = fp_->_base;
- if (fp_->_ptr != NULL)
- fp_->_cnt = 0;
- return 0;
-# elif defined __UCLIBC__ /* uClibc */
-# ifdef __STDIO_BUFFERS
- if (fp->__modeflags & __FLAG_WRITING)
- fp->__bufpos = fp->__bufstart;
- else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING))
- fp->__bufpos = fp->__bufread;
-# endif
- return 0;
-# elif defined __QNX__ /* QNX */
- fp->_Rback = fp->_Back + sizeof (fp->_Back);
- fp->_Rsave = NULL;
- if (fp->_Mode & 0x2000 /* _MWRITE */)
- /* fp->_Buf <= fp->_Next <= fp->_Wend */
- fp->_Next = fp->_Buf;
- else
- /* fp->_Buf <= fp->_Next <= fp->_Rend */
- fp->_Rend = fp->_Next;
- return 0;
-# elif defined __MINT__ /* Atari FreeMiNT */
- if (fp->__pushed_back)
- {
- fp->__bufp = fp->__pushback_bufp;
- fp->__pushed_back = 0;
- }
- /* Preserve the current file position. */
- if (fp->__target != -1)
- fp->__target += fp->__bufp - fp->__buffer;
- fp->__bufp = fp->__buffer;
- /* Nothing in the buffer, next getc is nontrivial. */
- fp->__get_limit = fp->__bufp;
- /* Nothing in the buffer, next putc is nontrivial. */
- fp->__put_limit = fp->__buffer;
- return 0;
-# elif defined EPLAN9 /* Plan9 */
- fp->rp = fp->wp = fp->lp = fp->buf;
- return 0;
-# else
-# error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
-# endif
-
-#endif
-}
diff --git a/contrib/tools/m4/lib/freading.c b/contrib/tools/m4/lib/freading.c
deleted file mode 100644
index 2c342cddb3..0000000000
--- a/contrib/tools/m4/lib/freading.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Retrieve information about a FILE stream.
- Copyright (C) 2007-2021 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include "freading.h"
-
-#include "stdio-impl.h"
-
-/* Don't use glibc's __freading function in glibc < 2.7, see
- <https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */
-#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
-
-bool
-freading (FILE *fp)
-{
- /* Most systems provide FILE as a struct and the necessary bitmask in
- <stdio.h>, because they need it for implementing getc() and putc() as
- fast macros. */
-# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
- /* GNU libc, BeOS, Haiku, Linux libc5 */
- return ((fp->_flags & _IO_NO_WRITES) != 0
- || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
- && fp->_IO_read_base != NULL));
-# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
- /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
- return (fp_->_flags & __SRD) != 0;
-# elif defined __EMX__ /* emx+gcc */
- return (fp->_flags & _IOREAD) != 0;
-# elif defined __minix /* Minix */
- return (fp->_flags & _IOREADING) != 0;
-# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
-# if defined __sun /* Solaris */
- return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0;
-# else
- return (fp_->_flag & _IOREAD) != 0;
-# endif
-# elif defined __UCLIBC__ /* uClibc */
- return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
-# elif defined __QNX__ /* QNX */
- return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
- || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
-# elif defined __MINT__ /* Atari FreeMiNT */
- if (!fp->__mode.__write)
- return 1;
- if (!fp->__mode.__read)
- return 0;
-# ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
- return (fp->__flags & _IO_CURRENTLY_GETTING) != 0;
-# else
- return (fp->__buffer < fp->__get_limit /*|| fp->__bufp == fp->__put_limit ??*/);
-# endif
-# elif defined EPLAN9 /* Plan9 */
- if (fp->state == 0 /* CLOSED */ || fp->state == 4 /* WR */)
- return 0;
- return (fp->state == 3 /* RD */ && (fp->bufl == 0 || fp->rp < fp->wp));
-# else
-# error "Please port gnulib freading.c to your platform!"
-# endif
-}
-
-#endif
diff --git a/contrib/tools/m4/lib/lseek.c b/contrib/tools/m4/lib/lseek.c
deleted file mode 100644
index fa7440d151..0000000000
--- a/contrib/tools/m4/lib/lseek.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* An lseek() function that detects pipes.
- Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <unistd.h>
-
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* Windows platforms. */
-/* Get GetFileType. */
-# include <windows.h>
-/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
-#else
-# include <sys/stat.h>
-#endif
-#include <errno.h>
-
-#undef lseek
-
-off_t
-rpl_lseek (int fd, off_t offset, int whence)
-{
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- /* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
- HANDLE h = (HANDLE) _get_osfhandle (fd);
- if (h == INVALID_HANDLE_VALUE)
- {
- errno = EBADF;
- return -1;
- }
- if (GetFileType (h) != FILE_TYPE_DISK)
- {
- errno = ESPIPE;
- return -1;
- }
-#else
- /* BeOS lseek mistakenly succeeds on pipes... */
- struct stat statbuf;
- if (fstat (fd, &statbuf) < 0)
- return -1;
- if (!S_ISREG (statbuf.st_mode))
- {
- errno = ESPIPE;
- return -1;
- }
-#endif
-#if _GL_WINDOWS_64_BIT_OFF_T
- return _lseeki64 (fd, offset, whence);
-#else
- return lseek (fd, offset, whence);
-#endif
-}
diff --git a/contrib/tools/m4/lib/open.c b/contrib/tools/m4/lib/open.c
deleted file mode 100644
index a0c43eadf9..0000000000
--- a/contrib/tools/m4/lib/open.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/* Open a descriptor to a file.
- Copyright (C) 2007-2013 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-/* If the user's config.h happens to include <fcntl.h>, let it include only
- the system's <fcntl.h> here, so that orig_open doesn't recurse to
- rpl_open. */
-#define __need_system_fcntl_h
-#include <config.h>
-
-/* Get the original definition of open. It might be defined as a macro. */
-#include <fcntl.h>
-#include <sys/types.h>
-#undef __need_system_fcntl_h
-
-static int
-orig_open (const char *filename, int flags, mode_t mode)
-{
- return open (filename, flags, mode);
-}
-
-/* Specification. */
-/* Write "fcntl.h" here, not <fcntl.h>, otherwise OSF/1 5.1 DTK cc eliminates
- this include because of the preliminary #include <fcntl.h> above. */
-#include "fcntl.h"
-
-#include <errno.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#ifndef REPLACE_OPEN_DIRECTORY
-# define REPLACE_OPEN_DIRECTORY 0
-#endif
-
-int
-open (const char *filename, int flags, ...)
-{
- mode_t mode;
- int fd;
-
- mode = 0;
- if (flags & O_CREAT)
- {
- va_list arg;
- va_start (arg, flags);
-
- /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
- creates crashing code when 'mode_t' is smaller than 'int'. */
- mode = va_arg (arg, PROMOTED_MODE_T);
-
- va_end (arg);
- }
-
-#if GNULIB_defined_O_NONBLOCK
- /* The only known platform that lacks O_NONBLOCK is mingw, but it
- also lacks named pipes and Unix sockets, which are the only two
- file types that require non-blocking handling in open().
- Therefore, it is safe to ignore O_NONBLOCK here. It is handy
- that mingw also lacks openat(), so that is also covered here. */
- flags &= ~O_NONBLOCK;
-#endif
-
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- if (strcmp (filename, "/dev/null") == 0)
- filename = "NUL";
-#endif
-
-#if OPEN_TRAILING_SLASH_BUG
- /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
- is specified, then fail.
- Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
- says that
- "A pathname that contains at least one non-slash character and that
- ends with one or more trailing slashes shall be resolved as if a
- single dot character ( '.' ) were appended to the pathname."
- and
- "The special filename dot shall refer to the directory specified by
- its predecessor."
- If the named file already exists as a directory, then
- - if O_CREAT is specified, open() must fail because of the semantics
- of O_CREAT,
- - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
- <http://www.opengroup.org/susv3/functions/open.html> says that it
- fails with errno = EISDIR in this case.
- If the named file does not exist or does not name a directory, then
- - if O_CREAT is specified, open() must fail since open() cannot create
- directories,
- - if O_WRONLY or O_RDWR is specified, open() must fail because the
- file does not contain a '.' directory. */
- if (flags & (O_CREAT | O_WRONLY | O_RDWR))
- {
- size_t len = strlen (filename);
- if (len > 0 && filename[len - 1] == '/')
- {
- errno = EISDIR;
- return -1;
- }
- }
-#endif
-
- fd = orig_open (filename, flags, mode);
-
-#if REPLACE_FCHDIR
- /* Implementing fchdir and fdopendir requires the ability to open a
- directory file descriptor. If open doesn't support that (as on
- mingw), we use a dummy file that behaves the same as directories
- on Linux (ie. always reports EOF on attempts to read()), and
- override fstat() in fchdir.c to hide the fact that we have a
- dummy. */
- if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
- && ((flags & O_ACCMODE) == O_RDONLY
- || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH)))
- {
- struct stat statbuf;
- if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
- {
- /* Maximum recursion depth of 1. */
- fd = open ("/dev/null", flags, mode);
- if (0 <= fd)
- fd = _gl_register_fd (fd, filename);
- }
- else
- errno = EACCES;
- }
-#endif
-
-#if OPEN_TRAILING_SLASH_BUG
- /* If the filename ends in a slash and fd does not refer to a directory,
- then fail.
- Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
- says that
- "A pathname that contains at least one non-slash character and that
- ends with one or more trailing slashes shall be resolved as if a
- single dot character ( '.' ) were appended to the pathname."
- and
- "The special filename dot shall refer to the directory specified by
- its predecessor."
- If the named file without the slash is not a directory, open() must fail
- with ENOTDIR. */
- if (fd >= 0)
- {
- /* We know len is positive, since open did not fail with ENOENT. */
- size_t len = strlen (filename);
- if (filename[len - 1] == '/')
- {
- struct stat statbuf;
-
- if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
- {
- close (fd);
- errno = ENOTDIR;
- return -1;
- }
- }
- }
-#endif
-
-#if REPLACE_FCHDIR
- if (!REPLACE_OPEN_DIRECTORY && 0 <= fd)
- fd = _gl_register_fd (fd, filename);
-#endif
-
- return fd;
-}
diff --git a/contrib/tools/m4/lib/platform/win64/fcntl.h b/contrib/tools/m4/lib/platform/win64/fcntl.h
index 0637e64b9f..ffb456dfe5 100644
--- a/contrib/tools/m4/lib/platform/win64/fcntl.h
+++ b/contrib/tools/m4/lib/platform/win64/fcntl.h
@@ -426,7 +426,7 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
#endif
#if 1
-# if 1
+# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef open
# define open rpl_open
diff --git a/contrib/tools/m4/lib/platform/win64/sys/stat.h b/contrib/tools/m4/lib/platform/win64/sys/stat.h
index bf7dc29f6e..14f1f4cc32 100644
--- a/contrib/tools/m4/lib/platform/win64/sys/stat.h
+++ b/contrib/tools/m4/lib/platform/win64/sys/stat.h
@@ -944,7 +944,7 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
#if 1
-# if 1
+# if 0
/* We can't use the object-like #define stat rpl_stat, because of
struct stat. This means that rpl_stat will not be used if the user
does (stat)(a,b). Oh well. */
diff --git a/contrib/tools/m4/lib/platform/win64/unistd.h b/contrib/tools/m4/lib/platform/win64/unistd.h
index 3980820c14..5b809eb4f5 100644
--- a/contrib/tools/m4/lib/platform/win64/unistd.h
+++ b/contrib/tools/m4/lib/platform/win64/unistd.h
@@ -1325,7 +1325,7 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
Return the new offset if successful, otherwise -1 and errno set.
See the POSIX:2008 specification
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
-# if 1
+# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define lseek rpl_lseek
# endif
@@ -1537,7 +1537,7 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
#if 1
/* Remove the directory DIR. */
-# if 1
+# if 0
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define rmdir rpl_rmdir
# endif
diff --git a/contrib/tools/m4/lib/rmdir.c b/contrib/tools/m4/lib/rmdir.c
deleted file mode 100644
index a8d907ebf0..0000000000
--- a/contrib/tools/m4/lib/rmdir.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Work around rmdir bugs.
-
- Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2013 Free Software
- Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include <unistd.h>
-
-#include <errno.h>
-#include <string.h>
-
-#include "dosname.h"
-
-#undef rmdir
-
-/* Remove directory DIR.
- Return 0 if successful, -1 if not. */
-
-int
-rpl_rmdir (char const *dir)
-{
- /* Work around cygwin 1.5.x bug where rmdir("dir/./") succeeds. */
- size_t len = strlen (dir);
- int result;
- while (len && ISSLASH (dir[len - 1]))
- len--;
- if (len && dir[len - 1] == '.' && (1 == len || ISSLASH (dir[len - 2])))
- {
- errno = EINVAL;
- return -1;
- }
- result = rmdir (dir);
- /* Work around mingw bug, where rmdir("file/") fails with EINVAL
- instead of ENOTDIR. We've already filtered out trailing ., the
- only reason allowed by POSIX for EINVAL. */
- if (result == -1 && errno == EINVAL)
- errno = ENOTDIR;
- return result;
-}
diff --git a/contrib/tools/m4/lib/stat.c b/contrib/tools/m4/lib/stat.c
deleted file mode 100644
index f888130d26..0000000000
--- a/contrib/tools/m4/lib/stat.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/* Work around platform bugs in stat.
- Copyright (C) 2009-2013 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* written by Eric Blake */
-
-/* If the user's config.h happens to include <sys/stat.h>, let it include only
- the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
- rpl_stat. */
-#define __need_system_sys_stat_h
-#include <config.h>
-
-/* Get the original definition of stat. It might be defined as a macro. */
-#include <sys/types.h>
-#include <sys/stat.h>
-#undef __need_system_sys_stat_h
-
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# if _GL_WINDOWS_64_BIT_ST_SIZE
-# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */
-# define stat _stati64
-# define REPLACE_FUNC_STAT_DIR 1
-# undef REPLACE_FUNC_STAT_FILE
-# elif REPLACE_FUNC_STAT_FILE
-/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a.
- Bypass it. */
-# define stat _stat
-# define REPLACE_FUNC_STAT_DIR 1
-# undef REPLACE_FUNC_STAT_FILE
-# endif
-#endif
-
-static int
-orig_stat (const char *filename, struct stat *buf)
-{
- return stat (filename, buf);
-}
-
-/* Specification. */
-/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
- eliminates this include because of the preliminary #include <sys/stat.h>
- above. */
-#include "sys/stat.h"
-
-#include <errno.h>
-#include <limits.h>
-#include <stdbool.h>
-#include <string.h>
-#include "dosname.h"
-#include "verify.h"
-
-#if REPLACE_FUNC_STAT_DIR
-# include "pathmax.h"
- /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
- have a constant PATH_MAX. */
-# ifndef PATH_MAX
-# error "Please port this replacement to your platform"
-# endif
-#endif
-
-/* Store information about NAME into ST. Work around bugs with
- trailing slashes. Mingw has other bugs (such as st_ino always
- being 0 on success) which this wrapper does not work around. But
- at least this implementation provides the ability to emulate fchdir
- correctly. */
-
-int
-rpl_stat (char const *name, struct stat *st)
-{
- int result = orig_stat (name, st);
-#if REPLACE_FUNC_STAT_FILE
- /* Solaris 9 mistakenly succeeds when given a non-directory with a
- trailing slash. */
- if (result == 0 && !S_ISDIR (st->st_mode))
- {
- size_t len = strlen (name);
- if (ISSLASH (name[len - 1]))
- {
- errno = ENOTDIR;
- return -1;
- }
- }
-#endif /* REPLACE_FUNC_STAT_FILE */
-#if REPLACE_FUNC_STAT_DIR
-
- if (result == -1 && errno == ENOENT)
- {
- /* Due to mingw's oddities, there are some directories (like
- c:\) where stat() only succeeds with a trailing slash, and
- other directories (like c:\windows) where stat() only
- succeeds without a trailing slash. But we want the two to be
- synonymous, since chdir() manages either style. Likewise, Mingw also
- reports ENOENT for names longer than PATH_MAX, when we want
- ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR.
- Fortunately, mingw PATH_MAX is small enough for stack
- allocation. */
- char fixed_name[PATH_MAX + 1] = {0};
- size_t len = strlen (name);
- bool check_dir = false;
- verify (PATH_MAX <= 4096);
- if (PATH_MAX <= len)
- errno = ENAMETOOLONG;
- else if (len)
- {
- strcpy (fixed_name, name);
- if (ISSLASH (fixed_name[len - 1]))
- {
- check_dir = true;
- while (len && ISSLASH (fixed_name[len - 1]))
- fixed_name[--len] = '\0';
- if (!len)
- fixed_name[0] = '/';
- }
- else
- fixed_name[len++] = '/';
- result = orig_stat (fixed_name, st);
- if (result == 0 && check_dir && !S_ISDIR (st->st_mode))
- {
- result = -1;
- errno = ENOTDIR;
- }
- }
- }
-#endif /* REPLACE_FUNC_STAT_DIR */
- return result;
-}
diff --git a/contrib/tools/m4/lib/ya.make b/contrib/tools/m4/lib/ya.make
index 2cad7e5ba8..08270b4b33 100644
--- a/contrib/tools/m4/lib/ya.make
+++ b/contrib/tools/m4/lib/ya.make
@@ -74,8 +74,6 @@ SRCS(
filenamecat-lgpl.c
filenamecat.c
fopen-safer.c
- fpurge.c
- freading.c
fstat.c
getdtablesize.c
gl_avltree_oset.c
@@ -85,7 +83,6 @@ SRCS(
gl_xlist.c
gl_xoset.c
localcharset.c
- lseek.c
malloca.c
memchr2.c
mkstemp-safer.c
@@ -100,11 +97,9 @@ SRCS(
quotearg.c
raise.c
regex.c
- rmdir.c
secure_getenv.c
sig-handler.c
spawn-pipe.c
- stat.c
stripslash.c
tempname.c
tmpdir.c
@@ -149,7 +144,6 @@ IF (OS_WINDOWS)
localeconv.c
msvc-inval.c
msvc-nothrow.c
- open.c
sigaction.c
sigprocmask.c
waitpid.c