diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-10-20 00:06:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-20 00:06:50 +0300 |
commit | e0b481c6710337ae655271bbb80afe6ac81a5614 (patch) | |
tree | dba67dc017935800d0c3f8dc967e9522c5302bd2 /contrib/tools/m4/lib | |
parent | 07f2e60d02d95eab14a86a4b9469db1af7795001 (diff) | |
parent | f04ad7e5462f5910ef95f2efd15c509e539ae62d (diff) | |
download | ydb-e0b481c6710337ae655271bbb80afe6ac81a5614.tar.gz |
Merge pull request #10642 from ydb-platform/mergelibs-241019-1758
Library import 241019-1758
Diffstat (limited to 'contrib/tools/m4/lib')
27 files changed, 10 insertions, 1931 deletions
diff --git a/contrib/tools/m4/lib/c-stack.c b/contrib/tools/m4/lib/c-stack.c index 52e46f83de..ac0aacba66 100644 --- a/contrib/tools/m4/lib/c-stack.c +++ b/contrib/tools/m4/lib/c-stack.c @@ -52,10 +52,6 @@ typedef struct sigaltstack stack_t; #endif #ifndef SIGSTKSZ # define SIGSTKSZ 16384 -#elif defined __USE_DYNAMIC_STACK_SIZE -/* Redefining SIGSTKSZ here as dynamic stack size is not supported in this version of bison */ -# undef SIGSTKSZ -# define SIGSTKSZ 16384 #elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384 /* libsigsegv 2.6 through 2.8 have a bug where some architectures use more than the Linux default of an 8k alternate stack when deciding @@ -76,7 +72,7 @@ typedef struct sigaltstack stack_t; #include <unistd.h> #if HAVE_LIBSIGSEGV -# include <sigsegv.h> +# error #include <sigsegv.h> #endif #include "c-stack.h" @@ -327,10 +323,7 @@ c_stack_action (void (*action) (int)) int c_stack_action (void (*action) (int) __attribute__ ((unused))) { -#if (defined _MSC_VER) && (_MSC_VER < 1800) -#else errno = ENOTSUP; -#endif return -1; } diff --git a/contrib/tools/m4/lib/config-win.h b/contrib/tools/m4/lib/config-win.h index 6122ff773c..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 */ @@ -1707,3 +1707,6 @@ char *strsignal (int signum); /* Define as a macro for copying va_list variables. */ #define va_copy gl_va_copy + +#define HAVE_ISNANL_IN_LIBC 1 +#define HAVE_ISNAND_IN_LIBC 1 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/isnand.c b/contrib/tools/m4/lib/isnand.c deleted file mode 100644 index cbad17b583..0000000000 --- a/contrib/tools/m4/lib/isnand.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Test for NaN that does not need libm. - Copyright (C) 2008-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>, 2008. */ - -#include "isnan.c" diff --git a/contrib/tools/m4/lib/isnanf.c b/contrib/tools/m4/lib/isnanf.c deleted file mode 100644 index 946cb69ce0..0000000000 --- a/contrib/tools/m4/lib/isnanf.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Test for NaN that does not need libm. - 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 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. */ - -#define USE_FLOAT -#include "isnan.c" diff --git a/contrib/tools/m4/lib/isnanl.c b/contrib/tools/m4/lib/isnanl.c deleted file mode 100644 index 9d9d84b974..0000000000 --- a/contrib/tools/m4/lib/isnanl.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Test for NaN that does not need libm. - 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 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. */ - -#define USE_LONG_DOUBLE -#include "isnan.c" 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/mbrtowc.c b/contrib/tools/m4/lib/mbrtowc.c deleted file mode 100644 index 5ee44aea48..0000000000 --- a/contrib/tools/m4/lib/mbrtowc.c +++ /dev/null @@ -1,402 +0,0 @@ -/* Convert multibyte character to wide character. - Copyright (C) 1999-2002, 2005-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2008. - - 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> - -/* Specification. */ -#include <wchar.h> - -#if GNULIB_defined_mbstate_t -/* Implement mbrtowc() on top of mbtowc(). */ - -# include <errno.h> -# include <stdlib.h> - -# include "localcharset.h" -# include "streq.h" -# include "verify.h" - - -verify (sizeof (mbstate_t) >= 4); - -static char internal_state[4]; - -size_t -mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) -{ - char *pstate = (char *)ps; - - if (s == NULL) - { - pwc = NULL; - s = ""; - n = 1; - } - - if (n == 0) - return (size_t)(-2); - - /* Here n > 0. */ - - if (pstate == NULL) - pstate = internal_state; - - { - size_t nstate = pstate[0]; - char buf[4]; - const char *p; - size_t m; - - switch (nstate) - { - case 0: - p = s; - m = n; - break; - case 3: - buf[2] = pstate[3]; - /*FALLTHROUGH*/ - case 2: - buf[1] = pstate[2]; - /*FALLTHROUGH*/ - case 1: - buf[0] = pstate[1]; - p = buf; - m = nstate; - buf[m++] = s[0]; - if (n >= 2 && m < 4) - { - buf[m++] = s[1]; - if (n >= 3 && m < 4) - buf[m++] = s[2]; - } - break; - default: - errno = EINVAL; - return (size_t)(-1); - } - - /* Here m > 0. */ - -# if __GLIBC__ || defined __UCLIBC__ - /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */ - mbtowc (NULL, NULL, 0); -# endif - { - int res = mbtowc (pwc, p, m); - - if (res >= 0) - { - if (pwc != NULL && ((*pwc == 0) != (res == 0))) - abort (); - if (nstate >= (res > 0 ? res : 1)) - abort (); - res -= nstate; - pstate[0] = 0; - return res; - } - - /* mbtowc does not distinguish between invalid and incomplete multibyte - sequences. But mbrtowc needs to make this distinction. - There are two possible approaches: - - Use iconv() and its return value. - - Use built-in knowledge about the possible encodings. - Given the low quality of implementation of iconv() on the systems that - lack mbrtowc(), we use the second approach. - The possible encodings are: - - 8-bit encodings, - - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS, - - UTF-8. - Use specialized code for each. */ - if (m >= 4 || m >= MB_CUR_MAX) - goto invalid; - /* Here MB_CUR_MAX > 1 and 0 < m < 4. */ - { - const char *encoding = locale_charset (); - - if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) - { - /* Cf. unistr/u8-mblen.c. */ - unsigned char c = (unsigned char) p[0]; - - if (c >= 0xc2) - { - if (c < 0xe0) - { - if (m == 1) - goto incomplete; - } - else if (c < 0xf0) - { - if (m == 1) - goto incomplete; - if (m == 2) - { - unsigned char c2 = (unsigned char) p[1]; - - if ((c2 ^ 0x80) < 0x40 - && (c >= 0xe1 || c2 >= 0xa0) - && (c != 0xed || c2 < 0xa0)) - goto incomplete; - } - } - else if (c <= 0xf4) - { - if (m == 1) - goto incomplete; - else /* m == 2 || m == 3 */ - { - unsigned char c2 = (unsigned char) p[1]; - - if ((c2 ^ 0x80) < 0x40 - && (c >= 0xf1 || c2 >= 0x90) - && (c < 0xf4 || (c == 0xf4 && c2 < 0x90))) - { - if (m == 2) - goto incomplete; - else /* m == 3 */ - { - unsigned char c3 = (unsigned char) p[2]; - - if ((c3 ^ 0x80) < 0x40) - goto incomplete; - } - } - } - } - } - goto invalid; - } - - /* As a reference for this code, you can use the GNU libiconv - implementation. Look for uses of the RET_TOOFEW macro. */ - - if (STREQ_OPT (encoding, - "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f) - goto incomplete; - } - if (m == 2) - { - unsigned char c = (unsigned char) p[0]; - - if (c == 0x8f) - { - unsigned char c2 = (unsigned char) p[1]; - - if (c2 >= 0xa1 && c2 < 0xff) - goto incomplete; - } - } - goto invalid; - } - if (STREQ_OPT (encoding, - "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) - || STREQ_OPT (encoding, - "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) - || STREQ_OPT (encoding, - "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if (c >= 0xa1 && c < 0xff) - goto incomplete; - } - goto invalid; - } - if (STREQ_OPT (encoding, - "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if ((c >= 0xa1 && c < 0xff) || c == 0x8e) - goto incomplete; - } - else /* m == 2 || m == 3 */ - { - unsigned char c = (unsigned char) p[0]; - - if (c == 0x8e) - goto incomplete; - } - goto invalid; - } - if (STREQ_OPT (encoding, - "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) - goto incomplete; - } - else /* m == 2 || m == 3 */ - { - unsigned char c = (unsigned char) p[0]; - - if (c >= 0x90 && c <= 0xe3) - { - unsigned char c2 = (unsigned char) p[1]; - - if (c2 >= 0x30 && c2 <= 0x39) - { - if (m == 2) - goto incomplete; - else /* m == 3 */ - { - unsigned char c3 = (unsigned char) p[2]; - - if (c3 >= 0x81 && c3 <= 0xfe) - goto incomplete; - } - } - } - } - goto invalid; - } - if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0)) - { - if (m == 1) - { - unsigned char c = (unsigned char) p[0]; - - if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) - || (c >= 0xf0 && c <= 0xf9)) - goto incomplete; - } - goto invalid; - } - - /* An unknown multibyte encoding. */ - goto incomplete; - } - - incomplete: - { - size_t k = nstate; - /* Here 0 <= k < m < 4. */ - pstate[++k] = s[0]; - if (k < m) - { - pstate[++k] = s[1]; - if (k < m) - pstate[++k] = s[2]; - } - if (k != m) - abort (); - } - pstate[0] = m; - return (size_t)(-2); - - invalid: - errno = EILSEQ; - /* The conversion state is undefined, says POSIX. */ - return (size_t)(-1); - } - } -} - -#else -/* Override the system's mbrtowc() function. */ - -# undef mbrtowc - -size_t -rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) -{ -# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG - if (s == NULL) - { - pwc = NULL; - s = ""; - n = 1; - } -# endif - -# if MBRTOWC_RETVAL_BUG - { - static mbstate_t internal_state; - - /* Override mbrtowc's internal state. We cannot call mbsinit() on the - hidden internal state, but we can call it on our variable. */ - if (ps == NULL) - ps = &internal_state; - - if (!mbsinit (ps)) - { - /* Parse the rest of the multibyte character byte for byte. */ - size_t count = 0; - for (; n > 0; s++, n--) - { - wchar_t wc; - size_t ret = mbrtowc (&wc, s, 1, ps); - - if (ret == (size_t)(-1)) - return (size_t)(-1); - count++; - if (ret != (size_t)(-2)) - { - /* The multibyte character has been completed. */ - if (pwc != NULL) - *pwc = wc; - return (wc == 0 ? 0 : count); - } - } - return (size_t)(-2); - } - } -# endif - -# if MBRTOWC_NUL_RETVAL_BUG - { - wchar_t wc; - size_t ret = mbrtowc (&wc, s, n, ps); - - if (ret != (size_t)(-1) && ret != (size_t)(-2)) - { - if (pwc != NULL) - *pwc = wc; - if (wc == 0) - ret = 0; - } - return ret; - } -# else - { -# if MBRTOWC_NULL_ARG1_BUG - wchar_t dummy; - - if (pwc == NULL) - pwc = &dummy; -# endif - - return mbrtowc (pwc, s, n, ps); - } -# endif -} - -#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/printf.c b/contrib/tools/m4/lib/printf.c deleted file mode 100644 index 7f682497cc..0000000000 --- a/contrib/tools/m4/lib/printf.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Formatted output to a stream. - Copyright (C) 2007, 2010-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/>. */ - -#if 1 -# include <config.h> -#endif - -/* Specification. */ -#include <stdio.h> - -#include <stdarg.h> - -/* Print formatted output to standard output. - Return string length of formatted string. On error, return a negative - value. */ -int -printf (const char *format, ...) -{ - int retval; - va_list args; - - va_start (args, format); - retval = vfprintf (stdout, format, args); - va_end (args); - - return retval; -} diff --git a/contrib/tools/m4/lib/realloc.c b/contrib/tools/m4/lib/realloc.c deleted file mode 100644 index b51010a621..0000000000 --- a/contrib/tools/m4/lib/realloc.c +++ /dev/null @@ -1,79 +0,0 @@ -/* realloc() function that is glibc compatible. - - Copyright (C) 1997, 2003-2004, 2006-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 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 Jim Meyering and Bruno Haible */ - -#define _GL_USE_STDLIB_ALLOC 1 -#include <config.h> - -/* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */ -#ifdef realloc -# define NEED_REALLOC_GNU 1 -/* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU. */ -#elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU -# define NEED_REALLOC_GNU 1 -#endif - -/* Infer the properties of the system's malloc function. - The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ -#if GNULIB_MALLOC_GNU && HAVE_MALLOC_GNU -# define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1 -#endif - -#include <stdlib.h> - -#include <errno.h> - -/* Change the size of an allocated block of memory P to N bytes, - with error checking. If N is zero, change it to 1. If P is NULL, - use malloc. */ - -void * -rpl_realloc (void *p, size_t n) -{ - void *result; - -#if NEED_REALLOC_GNU - if (n == 0) - { - n = 1; - - /* In theory realloc might fail, so don't rely on it to free. */ - free (p); - p = NULL; - } -#endif - - if (p == NULL) - { -#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE - if (n == 0) - n = 1; -#endif - result = malloc (n); - } - else - result = realloc (p, n); - -#if !HAVE_REALLOC_POSIX - if (result == NULL) - errno = ENOMEM; -#endif - - return result; -} 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/same-inode.h b/contrib/tools/m4/lib/same-inode.h deleted file mode 100644 index 3843b07078..0000000000 --- a/contrib/tools/m4/lib/same-inode.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Determine whether two stat buffers refer to the same file. - - Copyright (C) 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/>. */ - -#ifndef SAME_INODE_H -# define SAME_INODE_H 1 - -# ifdef __VMS -# define SAME_INODE(a, b) \ - ((a).st_ino[0] == (b).st_ino[0] \ - && (a).st_ino[1] == (b).st_ino[1] \ - && (a).st_ino[2] == (b).st_ino[2] \ - && (a).st_dev == (b).st_dev) -# else -# define SAME_INODE(a, b) \ - ((a).st_ino == (b).st_ino \ - && (a).st_dev == (b).st_dev) -# endif - -#endif diff --git a/contrib/tools/m4/lib/sigsegv.h b/contrib/tools/m4/lib/sigsegv.h deleted file mode 100644 index 29fc128a3e..0000000000 --- a/contrib/tools/m4/lib/sigsegv.h +++ /dev/null @@ -1,243 +0,0 @@ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Page fault handling library. - Copyright (C) 1998-2021 Bruno Haible <bruno@clisp.org> - - 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/>. */ - -#ifndef _SIGSEGV_H -#define _SIGSEGV_H - -/* Get size_t. */ -#include <stddef.h> - -/* Define the fault context structure. */ -#if defined __linux__ || defined __ANDROID__ \ - || (defined __FreeBSD__ && (defined __arm__ || defined __armhf__ || defined __arm64__)) \ - || defined __NetBSD__ \ - || defined _AIX || defined __sun \ - || defined __CYGWIN__ -/* Linux, FreeBSD, NetBSD, AIX, Solaris, Cygwin */ -# include <ucontext.h> -#elif (defined __APPLE__ && defined __MACH__) -/* macOS */ -# include <sys/ucontext.h> -#elif defined __HAIKU__ -/* Haiku */ -# include <signal.h> -#endif - -/* Correct the value of SIGSTKSZ on some systems. - glibc >= 2.34: When _GNU_SOURCE is defined, SIGSTKSZ is no longer a - compile-time constant. But most programs need a simple constant. - AIX 64-bit: original value 4096 is too small. - HP-UX: original value 8192 is too small. - Solaris 11/x86_64: original value 8192 is too small. */ -#include <signal.h> -#if __GLIBC__ >= 2 -# undef SIGSTKSZ -# if defined __ia64__ -# define SIGSTKSZ 262144 -# else -# define SIGSTKSZ 65536 -# endif -#endif -#if defined _AIX && defined _ARCH_PPC64 -# undef SIGSTKSZ -# define SIGSTKSZ 8192 -#endif -#if defined __hpux || (defined __sun && (defined __x86_64__ || defined __amd64__)) -# undef SIGSTKSZ -# define SIGSTKSZ 16384 -#endif - -/* HAVE_SIGSEGV_RECOVERY - is defined if the system supports catching SIGSEGV. */ -#if defined __linux__ || defined __ANDROID__ || defined __GNU__ \ - || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) || defined __DragonFly__ \ - || defined __NetBSD__ \ - || defined __OpenBSD__ \ - || (defined __APPLE__ && defined __MACH__) \ - || defined _AIX || defined __sgi || defined __sun \ - || defined __CYGWIN__ || defined __HAIKU__ -/* Linux, Hurd, GNU/kFreeBSD, FreeBSD, NetBSD, OpenBSD, macOS, AIX, IRIX, Solaris, Cygwin, Haiku */ -# define HAVE_SIGSEGV_RECOVERY 1 -#endif - -/* HAVE_STACK_OVERFLOW_RECOVERY - is defined if stack overflow can be caught. */ -#if defined __linux__ || defined __ANDROID__ || defined __GNU__ \ - || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) || defined __DragonFly__ \ - || (defined __NetBSD__ && !(defined __sparc__ || defined __sparc64__)) \ - || defined __OpenBSD__ \ - || (defined __APPLE__ && defined __MACH__) \ - || defined _AIX || defined __sgi || defined __sun \ - || defined __CYGWIN__ || defined __HAIKU__ -/* Linux, Hurd, GNU/kFreeBSD, FreeBSD, NetBSD, OpenBSD, macOS, AIX, IRIX, Solaris, Cygwin, Haiku */ -# define HAVE_STACK_OVERFLOW_RECOVERY 1 -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -#define LIBSIGSEGV_VERSION 0x020D /* version number: (major<<8) + minor */ -extern int libsigsegv_version; /* Likewise */ - -/* -------------------------------------------------------------------------- */ - -#if 1 /* really only HAVE_SIGSEGV_RECOVERY */ - -/* - * The mask of bits that are set to zero in a fault address that gets passed - * to a global SIGSEGV handler. - * On some platforms, the precise fault address is not known, only the memory - * page into which the fault address falls. This is apparently allowed by POSIX: - * <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html> - * says: "For some implementations, the value of si_addr may be inaccurate." - * In this case, the returned fault address is rounded down to a multiple of - * getpagesize() = sysconf(_SC_PAGESIZE). - * On such platforms, we define SIGSEGV_FAULT_ADDRESS_ALIGNMENT to be an upper - * bound for getpagesize() (and, like getpagesize(), also a power of 2). - * On the platforms where the returned fault address is the precise one, we - * define SIGSEGV_FAULT_ADDRESS_ALIGNMENT to 1. - */ -# if defined __NetBSD__ && (defined __sparc__ || defined __sparc64__) - /* getpagesize () is 0x1000 or 0x2000, depending on hardware. */ -# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 0x2000UL -# elif defined __linux__ && (defined __s390__ || defined __s390x__) - /* getpagesize () is 0x1000. */ -# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 0x1000UL -# else -# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 1UL -# endif - -/* - * The type of a global SIGSEGV handler. - * The fault address, with the bits (SIGSEGV_FAULT_ADDRESS_ALIGNMENT - 1) - * cleared, is passed as argument. - * The access type (read access or write access) is not passed; your handler - * has to know itself how to distinguish these two cases. - * The second argument is 0, meaning it could also be a stack overflow, or 1, - * meaning the handler should seriously try to fix the fault. - * The return value should be nonzero if the handler has done its job - * and no other handler should be called, or 0 if the handler declines - * responsibility for the given address. - * - * The handler is run at a moment when nothing about the global state of the - * program is known. Therefore it cannot use facilities that manipulate global - * variables or locks. In particular, it cannot use malloc(); use mmap() - * instead. It cannot use fopen(); use open() instead. Etc. All global - * variables that are accessed by the handler should be marked 'volatile'. - */ -typedef int (*sigsegv_handler_t) (void* fault_address, int serious); - -/* - * Installs a global SIGSEGV handler. - * This should be called once only, and it ignores any previously installed - * SIGSEGV handler. - * Returns 0 on success, or -1 if the system doesn't support catching SIGSEGV. - */ -extern int sigsegv_install_handler (sigsegv_handler_t handler); - -/* - * Deinstalls the global SIGSEGV handler. - * This goes back to the state where no SIGSEGV handler is installed. - */ -extern void sigsegv_deinstall_handler (void); - -/* - * Prepares leaving a SIGSEGV handler (through longjmp or similar means). - * Control is transferred by calling CONTINUATION with CONT_ARG1, CONT_ARG2, - * CONT_ARG3 as arguments. - * CONTINUATION must not return. - * The sigsegv_leave_handler function may return if called from a SIGSEGV - * handler; its return value should be used as the handler's return value. - * The sigsegv_leave_handler function does not return if called from a - * stack overflow handler. - */ -extern int sigsegv_leave_handler (void (*continuation) (void*, void*, void*), void* cont_arg1, void* cont_arg2, void* cont_arg3); - -#endif /* HAVE_SIGSEGV_RECOVERY */ - -#if 1 /* really only HAVE_STACK_OVERFLOW_RECOVERY */ - -/* - * The type of a context passed to a stack overflow handler. - * This type is system dependent; on some platforms it is an 'ucontext_t *', - * on some platforms it is a 'struct sigcontext *', on others merely an - * opaque 'void *'. - */ -# if defined __linux__ || defined __ANDROID__ \ - || (defined __FreeBSD__ && (defined __arm__ || defined __armhf__ || defined __arm64__)) \ - || defined __NetBSD__ \ - || (defined __APPLE__ && defined __MACH__) \ - || defined _AIX || defined __sun \ - || defined __CYGWIN__ || defined __HAIKU__ -typedef ucontext_t *stackoverflow_context_t; -# elif defined __GNU__ \ - || defined __FreeBSD_kernel__ || (defined __FreeBSD__ && !(defined __sparc__ || defined __sparc64__)) \ - || defined __OpenBSD__ || defined __sgi -typedef struct sigcontext *stackoverflow_context_t; -# else -typedef void *stackoverflow_context_t; -# endif - -/* - * The type of a stack overflow handler. - * Such a handler should perform a longjmp call in order to reduce the amount - * of stack needed. It must not return. - * The emergency argument is 0 when the stack could be repared, or 1 if the - * application should better save its state and exit now. - * - * The handler is run at a moment when nothing about the global state of the - * program is known. Therefore it cannot use facilities that manipulate global - * variables or locks. In particular, it cannot use malloc(); use mmap() - * instead. It cannot use fopen(); use open() instead. Etc. All global - * variables that are accessed by the handler should be marked 'volatile'. - */ -typedef void (*stackoverflow_handler_t) (int emergency, stackoverflow_context_t scp); - -/* - * Installs a stack overflow handler. - * The extra_stack argument is a pointer to a pre-allocated area used as a - * stack for executing the handler. It typically comes from a static variable - * or from heap-allocated memoty; placing it on the main stack may fail on - * some operating systems. - * Its size, passed in extra_stack_size, should be sufficiently large. The - * following code determines an appropriate size: - * #include <signal.h> - * #ifndef SIGSTKSZ / * glibc defines SIGSTKSZ for this purpose * / - * # define SIGSTKSZ 16384 / * on most platforms, 16 KB are sufficient * / - * #endif - * Returns 0 on success, or -1 if the system doesn't support catching stack - * overflow. - */ -extern int stackoverflow_install_handler (stackoverflow_handler_t handler, - void* extra_stack, size_t extra_stack_size); - -/* - * Deinstalls the stack overflow handler. - */ -extern void stackoverflow_deinstall_handler (void); - -#endif /* HAVE_STACK_OVERFLOW_RECOVERY */ - -/* -------------------------------------------------------------------------- */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SIGSEGV_H */ 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/stpcpy.c b/contrib/tools/m4/lib/stpcpy.c deleted file mode 100644 index f5aa8d67e9..0000000000 --- a/contrib/tools/m4/lib/stpcpy.c +++ /dev/null @@ -1,50 +0,0 @@ -/* stpcpy.c -- copy a string and return pointer to end of new string - Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2013 Free Software - Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. - - 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 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 <string.h> -#include <stdlib.h> - -#undef __stpcpy -#if defined(_LIBC) || (defined(__MACH__) && defined(stpcpy)) -# undef stpcpy -#endif - -#ifndef weak_alias -# define __stpcpy stpcpy -#endif - -/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ -char * -__stpcpy (char *dest, const char *src) -{ - char *d = dest; - const char *s = src; - - do - *d++ = *s; - while (*s++ != '\0'); - - return d - 1; -} -#ifdef weak_alias -weak_alias (__stpcpy, stpcpy) -#endif diff --git a/contrib/tools/m4/lib/streq.h b/contrib/tools/m4/lib/streq.h deleted file mode 100644 index 12c1867c83..0000000000 --- a/contrib/tools/m4/lib/streq.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Optimized string comparison. - Copyright (C) 2001-2002, 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 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>. */ - -#ifndef _GL_STREQ_H -#define _GL_STREQ_H - -#include <string.h> - -/* STREQ_OPT allows to optimize string comparison with a small literal string. - STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) - is semantically equivalent to - strcmp (s, "EUC-KR") == 0 - just faster. */ - -/* Help GCC to generate good code for string comparisons with - immediate strings. */ -#if defined (__GNUC__) && defined (__OPTIMIZE__) - -static inline int -streq9 (const char *s1, const char *s2) -{ - return strcmp (s1 + 9, s2 + 9) == 0; -} - -static inline int -streq8 (const char *s1, const char *s2, char s28) -{ - if (s1[8] == s28) - { - if (s28 == 0) - return 1; - else - return streq9 (s1, s2); - } - else - return 0; -} - -static inline int -streq7 (const char *s1, const char *s2, char s27, char s28) -{ - if (s1[7] == s27) - { - if (s27 == 0) - return 1; - else - return streq8 (s1, s2, s28); - } - else - return 0; -} - -static inline int -streq6 (const char *s1, const char *s2, char s26, char s27, char s28) -{ - if (s1[6] == s26) - { - if (s26 == 0) - return 1; - else - return streq7 (s1, s2, s27, s28); - } - else - return 0; -} - -static inline int -streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28) -{ - if (s1[5] == s25) - { - if (s25 == 0) - return 1; - else - return streq6 (s1, s2, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[4] == s24) - { - if (s24 == 0) - return 1; - else - return streq5 (s1, s2, s25, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[3] == s23) - { - if (s23 == 0) - return 1; - else - return streq4 (s1, s2, s24, s25, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[2] == s22) - { - if (s22 == 0) - return 1; - else - return streq3 (s1, s2, s23, s24, s25, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[1] == s21) - { - if (s21 == 0) - return 1; - else - return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28); - } - else - return 0; -} - -static inline int -streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) -{ - if (s1[0] == s20) - { - if (s20 == 0) - return 1; - else - return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28); - } - else - return 0; -} - -#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ - streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28) - -#else - -#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ - (strcmp (s1, s2) == 0) - -#endif - -#endif /* _GL_STREQ_H */ diff --git a/contrib/tools/m4/lib/unsetenv.c b/contrib/tools/m4/lib/unsetenv.c deleted file mode 100644 index cfb800a992..0000000000 --- a/contrib/tools/m4/lib/unsetenv.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright (C) 1992, 1995-2002, 2005-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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/>. */ - -/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc - optimizes away the name == NULL test below. */ -#define _GL_ARG_NONNULL(params) - -#include <config.h> - -/* Specification. */ -#include <stdlib.h> - -#include <errno.h> -#if !_LIBC -# define __set_errno(ev) ((errno) = (ev)) -#endif - -#include <string.h> -#include <unistd.h> - -#if !_LIBC -# define __environ environ -#endif - -#if _LIBC -/* This lock protects against simultaneous modifications of 'environ'. */ -# error #include <bits/libc-lock.h> -__libc_lock_define_initialized (static, envlock) -# define LOCK __libc_lock_lock (envlock) -# define UNLOCK __libc_lock_unlock (envlock) -#else -# define LOCK -# define UNLOCK -#endif - -/* In the GNU C library we must keep the namespace clean. */ -#ifdef _LIBC -# define unsetenv __unsetenv -#endif - -#if _LIBC || !HAVE_UNSETENV - -int -unsetenv (const char *name) -{ - size_t len; - char **ep; - - if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) - { - __set_errno (EINVAL); - return -1; - } - - len = strlen (name); - - LOCK; - - ep = __environ; - while (*ep != NULL) - if (!strncmp (*ep, name, len) && (*ep)[len] == '=') - { - /* Found it. Remove this pointer by moving later ones back. */ - char **dp = ep; - - do - dp[0] = dp[1]; - while (*dp++); - /* Continue the loop in case NAME appears again. */ - } - else - ++ep; - - UNLOCK; - - return 0; -} - -#ifdef _LIBC -# undef unsetenv -weak_alias (__unsetenv, unsetenv) -#endif - -#else /* HAVE_UNSETENV */ - -# undef unsetenv -# if !HAVE_DECL_UNSETENV -# if VOID_UNSETENV -extern void unsetenv (const char *); -# else -extern int unsetenv (const char *); -# endif -# endif - -/* Call the underlying unsetenv, in case there is hidden bookkeeping - that needs updating beyond just modifying environ. */ -int -rpl_unsetenv (const char *name) -{ - int result = 0; - if (!name || !*name || strchr (name, '=')) - { - errno = EINVAL; - return -1; - } - while (getenv (name)) -# if !VOID_UNSETENV - result = -# endif - unsetenv (name); - return result; -} - -#endif /* HAVE_UNSETENV */ diff --git a/contrib/tools/m4/lib/vasnprintf.c b/contrib/tools/m4/lib/vasnprintf.c index 4de22819fa..184937d6f1 100644 --- a/contrib/tools/m4/lib/vasnprintf.c +++ b/contrib/tools/m4/lib/vasnprintf.c @@ -54,7 +54,7 @@ # include <config.h> #endif #ifndef IN_LIBINTL -# include "palloca.h" +# include <alloca.h> #endif /* Specification. */ @@ -5575,10 +5575,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); -#if (defined _MSC_VER) && (_MSC_VER < 1800) -#else errno = EOVERFLOW; -#endif return NULL; #endif diff --git a/contrib/tools/m4/lib/vasprintf.c b/contrib/tools/m4/lib/vasprintf.c index afc8056194..d0d4a11bf7 100644 --- a/contrib/tools/m4/lib/vasprintf.c +++ b/contrib/tools/m4/lib/vasprintf.c @@ -40,10 +40,7 @@ vasprintf (char **resultp, const char *format, va_list args) if (length > INT_MAX) { free (result); -#if (defined _MSC_VER) && (_MSC_VER < 1800) -#else errno = EOVERFLOW; -#endif return -1; } diff --git a/contrib/tools/m4/lib/xstrndup.c b/contrib/tools/m4/lib/xstrndup.c index 741d5a1b05..eae92d039d 100644 --- a/contrib/tools/m4/lib/xstrndup.c +++ b/contrib/tools/m4/lib/xstrndup.c @@ -21,25 +21,8 @@ #include "xstrndup.h" #include <string.h> -#include <stdlib.h> - #include "xalloc.h" -#if defined(_MSC_VER) -static char * -strndup(char const *s, size_t n) -{ - size_t len = strnlen(s, n); - char *new = malloc(len + 1); - - if (new == NULL) - return NULL; - - new[len] = '\0'; - return memcpy(new, s, len); -} -#endif - /* Return a newly allocated copy of at most N bytes of STRING. In other words, return a copy of the initial segment of length N of STRING. */ diff --git a/contrib/tools/m4/lib/xvasprintf.c b/contrib/tools/m4/lib/xvasprintf.c index 9c93492b80..702b5e6b1a 100644 --- a/contrib/tools/m4/lib/xvasprintf.c +++ b/contrib/tools/m4/lib/xvasprintf.c @@ -53,10 +53,7 @@ xstrcat (size_t argcount, va_list args) vasprintf(). */ if (totalsize == SIZE_MAX || totalsize > INT_MAX) { -#if (defined _MSC_VER) && (_MSC_VER < 1800) -#else errno = EOVERFLOW; -#endif return NULL; } @@ -75,10 +72,6 @@ xstrcat (size_t argcount, va_list args) return result; } -#if defined(_MSC_VER) -int vasprintf(char **resultp, const char *format, va_list args); -#endif - char * xvasprintf (const char *format, va_list args) { diff --git a/contrib/tools/m4/lib/ya.make b/contrib/tools/m4/lib/ya.make index ccb5f20ba0..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 @@ -84,13 +82,8 @@ SRCS( gl_oset.c gl_xlist.c gl_xoset.c - isnand.c - isnanl.c - isnanf.c localcharset.c - lseek.c malloca.c - mbrtowc.c memchr2.c mkstemp-safer.c nl_langinfo.c @@ -103,19 +96,14 @@ SRCS( progname.c quotearg.c raise.c - realloc.c regex.c - rmdir.c secure_getenv.c sig-handler.c spawn-pipe.c - stat.c - stpcpy.c stripslash.c tempname.c tmpdir.c unistd.c - unsetenv.c vasnprintf.c verror.c version-etc-fsf.c @@ -156,7 +144,6 @@ IF (OS_WINDOWS) localeconv.c msvc-inval.c msvc-nothrow.c - open.c sigaction.c sigprocmask.c waitpid.c |