diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-05-25 09:36:18 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-05-25 09:48:38 +0300 |
commit | e728ca9a8c24962048e32fea61a43a1b00d1c654 (patch) | |
tree | 016cb25e3fbb613ad10d65eb4a4921e4acaf6979 | |
parent | 3e42aa91c70358fdd3ec39d0ac23072fc230b209 (diff) | |
download | ydb-e728ca9a8c24962048e32fea61a43a1b00d1c654.tar.gz |
Remove more of unused bison srcs
ec341d5b3591dde87f6f7c171e12aa7f45a2da12
-rw-r--r-- | build/sysincl/misc-win.yml | 1 | ||||
-rw-r--r-- | contrib/tools/bison/lib/fopen.c | 110 | ||||
-rw-r--r-- | contrib/tools/bison/lib/fseeko.c | 162 | ||||
-rw-r--r-- | contrib/tools/bison/lib/ftello.c | 85 | ||||
-rw-r--r-- | contrib/tools/bison/lib/malloc.c | 56 | ||||
-rw-r--r-- | contrib/tools/bison/lib/malloca.c | 149 | ||||
-rw-r--r-- | contrib/tools/bison/lib/malloca.h | 133 | ||||
-rw-r--r-- | contrib/tools/bison/lib/mbrtowc.c | 402 | ||||
-rw-r--r-- | contrib/tools/bison/lib/platform/win64/config.h | 2 | ||||
-rw-r--r-- | contrib/tools/bison/lib/platform/win64/stdbool.h | 133 | ||||
-rw-r--r-- | contrib/tools/bison/lib/stdio-write.c | 198 | ||||
-rw-r--r-- | contrib/tools/bison/lib/wcrtomb.c | 56 | ||||
-rw-r--r-- | contrib/tools/bison/lib/xmalloca.c | 38 | ||||
-rw-r--r-- | contrib/tools/bison/lib/xmalloca.h | 64 | ||||
-rw-r--r-- | contrib/tools/bison/lib/xstrndup.c | 17 | ||||
-rw-r--r-- | contrib/tools/bison/lib/ya.make | 14 | ||||
-rw-r--r-- | contrib/tools/bison/src/uniqstr.c | 11 | ||||
-rw-r--r-- | contrib/tools/bison/src/uniqstr.h | 5 |
18 files changed, 4 insertions, 1632 deletions
diff --git a/build/sysincl/misc-win.yml b/build/sysincl/misc-win.yml index 8e1a37cd52..e73dabe78a 100644 --- a/build/sysincl/misc-win.yml +++ b/build/sysincl/misc-win.yml @@ -89,7 +89,6 @@ - sched.h: contrib/tools/bison/lib/platform/win64/sched.h - signal.h: contrib/tools/bison/lib/platform/win64/signal.h - spawn.h: contrib/tools/bison/lib/platform/win64/spawn.h - - stdbool.h: contrib/tools/bison/lib/platform/win64/stdbool.h - sys/stat.h: contrib/tools/bison/lib/platform/win64/sys/stat.h - sys/time.h: contrib/tools/bison/lib/platform/win64/sys/time.h - sys/wait.h: contrib/tools/bison/lib/platform/win64/sys/wait.h diff --git a/contrib/tools/bison/lib/fopen.c b/contrib/tools/bison/lib/fopen.c deleted file mode 100644 index f9d6763d21..0000000000 --- a/contrib/tools/bison/lib/fopen.c +++ /dev/null @@ -1,110 +0,0 @@ -/* Open a stream 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 <stdio.h>, let it include only - the system's <stdio.h> here, so that orig_fopen doesn't recurse to - rpl_fopen. */ -#define __need_FILE -#include <config.h> - -/* Get the original definition of fopen. It might be defined as a macro. */ -#include <stdio.h> -#undef __need_FILE - -static FILE * -orig_fopen (const char *filename, const char *mode) -{ - return fopen (filename, mode); -} - -/* Specification. */ -/* Write "stdio.h" here, not <stdio.h>, otherwise OSF/1 5.1 DTK cc eliminates - this include because of the preliminary #include <stdio.h> above. */ -#include "stdio.h" - -#include <errno.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> - -FILE * -rpl_fopen (const char *filename, const char *mode) -{ -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - if (strcmp (filename, "/dev/null") == 0) - filename = "NUL"; -#endif - -#if FOPEN_TRAILING_SLASH_BUG - /* If the filename ends in a slash and a mode that requires write access 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 a mode that - requires write access is specified, fopen() must fail because POSIX - <http://www.opengroup.org/susv3/functions/fopen.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 - fopen() must fail since the file does not contain a '.' directory. */ - { - size_t len = strlen (filename); - if (len > 0 && filename[len - 1] == '/') - { - int fd; - struct stat statbuf; - FILE *fp; - - if (mode[0] == 'w' || mode[0] == 'a') - { - errno = EISDIR; - return NULL; - } - - fd = open (filename, O_RDONLY); - if (fd < 0) - return NULL; - - if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) - { - close (fd); - errno = ENOTDIR; - return NULL; - } - - fp = fdopen (fd, mode); - if (fp == NULL) - { - int saved_errno = errno; - close (fd); - errno = saved_errno; - } - return fp; - } - } -# endif - - return orig_fopen (filename, mode); -} diff --git a/contrib/tools/bison/lib/fseeko.c b/contrib/tools/bison/lib/fseeko.c deleted file mode 100644 index 0c326592b9..0000000000 --- a/contrib/tools/bison/lib/fseeko.c +++ /dev/null @@ -1,162 +0,0 @@ -/* An fseeko() function that, together with fflush(), is POSIX compliant. - 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, 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 <stdio.h> - -/* Get off_t, lseek, _POSIX_VERSION. */ -#include <unistd.h> - -#include "stdio-impl.h" - -int -fseeko (FILE *fp, off_t offset, int whence) -#undef fseeko -#if !HAVE_FSEEKO -# undef fseek -# define fseeko fseek -#endif -#if _GL_WINDOWS_64_BIT_OFF_T -# undef fseeko -# if HAVE__FSEEKI64 /* msvc, mingw64 */ -# define fseeko _fseeki64 -# else /* mingw */ -# define fseeko fseeko64 -# endif -#endif -{ -#if LSEEK_PIPE_BROKEN - /* mingw gives bogus answers rather than failure on non-seekable files. */ - if (lseek (fileno (fp), 0, SEEK_CUR) == -1) - return EOF; -#endif - - /* These tests are based on fpurge.c. */ -#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ - if (fp->_IO_read_end == fp->_IO_read_ptr - && fp->_IO_write_ptr == fp->_IO_write_base - && fp->_IO_save_base == NULL) -#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ -# if defined __SL64 && defined __SCLE /* Cygwin */ - if ((fp->_flags & __SL64) == 0) - { - /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit - mode; but has an fseeko that requires 64-bit mode. */ - FILE *tmp = fopen ("/dev/null", "r"); - if (!tmp) - return -1; - fp->_flags |= __SL64; - fp->_seek64 = tmp->_seek64; - fclose (tmp); - } -# endif - if (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) - && fp_ub._base == NULL) -#elif defined __EMX__ /* emx+gcc */ - if (fp->_ptr == fp->_buffer - && fp->_rcount == 0 - && fp->_wcount == 0 - && fp->_ungetc_count == 0) -#elif defined __minix /* Minix */ - if (fp_->_ptr == fp_->_buf - && (fp_->_ptr == NULL || fp_->_count == 0)) -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ - if (fp_->_ptr == fp_->_base - && (fp_->_ptr == NULL || fp_->_cnt == 0)) -#elif WIN_SDK10 - if (((TWinSdk10File*)fp)->_ptr == ((TWinSdk10File*)fp)->_base - && (((TWinSdk10File*)fp)->_ptr == NULL || ((TWinSdk10File*)fp)->_cnt == 0)) -#elif defined __UCLIBC__ /* uClibc */ - if (((fp->__modeflags & __FLAG_WRITING) == 0 - || fp->__bufpos == fp->__bufstart) - && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0 - || fp->__bufpos == fp->__bufread)) -#elif defined __QNX__ /* QNX */ - if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend) - && fp->_Rback == fp->_Back + sizeof (fp->_Back) - && fp->_Rsave == NULL) -#elif defined __MINT__ /* Atari FreeMiNT */ - if (fp->__bufp == fp->__buffer - && fp->__get_limit == fp->__bufp - && fp->__put_limit == fp->__bufp - && !fp->__pushed_back) -#elif defined EPLAN9 /* Plan9 */ - if (fp->rp == fp->buf - && fp->wp == fp->buf) -#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION - /* Cross-compiling to some other system advertising conformance to - POSIX.1-2008 or later. Assume fseeko and fflush work as advertised. - If this assumption is incorrect, please report the bug to - bug-gnulib. */ - if (0) -#else - #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib." -#endif - { - /* We get here when an fflush() call immediately preceded this one (or - if ftell() has created buffers but no I/O has occurred on a - newly-opened stream). We know there are no buffers. */ - off_t pos = lseek (fileno (fp), offset, whence); - if (pos == -1) - { -#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ - fp_->_flags &= ~__SOFF; -#endif - return -1; - } - -#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */ - fp->_flags &= ~_IO_EOF_SEEN; - fp->_offset = pos; -#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */ -# if defined __CYGWIN__ - /* fp_->_offset is typed as an integer. */ - fp_->_offset = pos; -# else - /* fp_->_offset is an fpos_t. */ - { - /* Use a union, since on NetBSD, the compilation flags - determine whether fpos_t is typedef'd to off_t or a struct - containing a single off_t member. */ - union - { - fpos_t f; - off_t o; - } u; - u.o = pos; - fp_->_offset = u.f; - } -# endif - fp_->_flags |= __SOFF; - fp_->_flags &= ~__SEOF; -#elif defined __EMX__ /* emx+gcc */ - fp->_flags &= ~_IOEOF; -#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */ - fp->_flag &= ~_IOEOF; -#elif defined __MINT__ /* Atari FreeMiNT */ - fp->__offset = pos; - fp->__eof = 0; -#endif - return 0; - } - return fseeko (fp, offset, whence); -} diff --git a/contrib/tools/bison/lib/ftello.c b/contrib/tools/bison/lib/ftello.c deleted file mode 100644 index 3a2a0f2012..0000000000 --- a/contrib/tools/bison/lib/ftello.c +++ /dev/null @@ -1,85 +0,0 @@ -/* An ftello() function that works around platform bugs. - 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/>. */ - -#include <config.h> - -/* Specification. */ -#include <stdio.h> - -/* Get lseek. */ -#include <unistd.h> - -#include "stdio-impl.h" - -off_t -ftello (FILE *fp) -#undef ftello -#if !HAVE_FTELLO -# undef ftell -# define ftello ftell -#endif -#if _GL_WINDOWS_64_BIT_OFF_T -# undef ftello -# if HAVE__FTELLI64 /* msvc, mingw64 */ -# define ftello _ftelli64 -# else /* mingw */ -# define ftello ftello64 -# endif -#endif -{ -#if LSEEK_PIPE_BROKEN - /* mingw gives bogus answers rather than failure on non-seekable files. */ - if (lseek (fileno (fp), 0, SEEK_CUR) == -1) - return -1; -#endif - -#if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */ - /* The Solaris stdio leaves the _IOREAD flag set after reading from a file - reaches EOF and the program then starts writing to the file. ftello - gets confused by this. */ - if (fp_->_flag & _IOWRT) - { - off_t pos; - - /* Call ftello nevertheless, for the side effects that it does on fp. */ - ftello (fp); - - /* Compute the file position ourselves. */ - pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR); - if (pos >= 0) - { - if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL) - pos += fp_->_ptr - fp_->_base; - } - return pos; - } -#endif - -#if defined __SL64 && defined __SCLE /* Cygwin */ - if ((fp->_flags & __SL64) == 0) - { - /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit - mode; but has an ftello that requires 64-bit mode. */ - FILE *tmp = fopen ("/dev/null", "r"); - if (!tmp) - return -1; - fp->_flags |= __SL64; - fp->_seek64 = tmp->_seek64; - fclose (tmp); - } -#endif - return ftello (fp); -} diff --git a/contrib/tools/bison/lib/malloc.c b/contrib/tools/bison/lib/malloc.c deleted file mode 100644 index 908735d278..0000000000 --- a/contrib/tools/bison/lib/malloc.c +++ /dev/null @@ -1,56 +0,0 @@ -/* malloc() function that is glibc compatible. - - Copyright (C) 1997-1998, 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, 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_MALLOC macro defines 'malloc' already in config.h. */ -#ifdef malloc -# define NEED_MALLOC_GNU 1 -# undef malloc -/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ -#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU -# define NEED_MALLOC_GNU 1 -#endif - -#include <stdlib.h> - -#include <errno.h> - -/* Allocate an N-byte block of memory from the heap. - If N is zero, allocate a 1-byte block. */ - -void * -rpl_malloc (size_t n) -{ - void *result; - -#if NEED_MALLOC_GNU - if (n == 0) - n = 1; -#endif - - result = malloc (n); - -#if !HAVE_MALLOC_POSIX - if (result == NULL) - errno = ENOMEM; -#endif - - return result; -} diff --git a/contrib/tools/bison/lib/malloca.c b/contrib/tools/bison/lib/malloca.c deleted file mode 100644 index 311be569bc..0000000000 --- a/contrib/tools/bison/lib/malloca.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Safe automatic memory allocation. - Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2003. - - 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/>. */ - -#define _GL_USE_STDLIB_ALLOC 1 -#include <config.h> - -/* Specification. */ -#include "malloca.h" - -#include <stdint.h> - -#include "verify.h" - -/* The speed critical point in this file is freea() applied to an alloca() - result: it must be fast, to match the speed of alloca(). The speed of - mmalloca() and freea() in the other case are not critical, because they - are only invoked for big memory sizes. */ - -#if HAVE_ALLOCA - -/* Store the mmalloca() results in a hash table. This is needed to reliably - distinguish a mmalloca() result and an alloca() result. - - Although it is possible that the same pointer is returned by alloca() and - by mmalloca() at different times in the same application, it does not lead - to a bug in freea(), because: - - Before a pointer returned by alloca() can point into malloc()ed memory, - the function must return, and once this has happened the programmer must - not call freea() on it anyway. - - Before a pointer returned by mmalloca() can point into the stack, it - must be freed. The only function that can free it is freea(), and - when freea() frees it, it also removes it from the hash table. */ - -#define MAGIC_NUMBER 0x1415fb4a -#define MAGIC_SIZE sizeof (int) -/* This is how the header info would look like without any alignment - considerations. */ -struct preliminary_header { void *next; int magic; }; -/* But the header's size must be a multiple of sa_alignment_max. */ -#define HEADER_SIZE \ - (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max) -union header { - void *next; - struct { - char room[HEADER_SIZE - MAGIC_SIZE]; - int word; - } magic; -}; -verify (HEADER_SIZE == sizeof (union header)); -/* We make the hash table quite big, so that during lookups the probability - of empty hash buckets is quite high. There is no need to make the hash - table resizable, because when the hash table gets filled so much that the - lookup becomes slow, it means that the application has memory leaks. */ -#define HASH_TABLE_SIZE 257 -static void * mmalloca_results[HASH_TABLE_SIZE]; - -#endif - -void * -mmalloca (size_t n) -{ -#if HAVE_ALLOCA - /* Allocate one more word, that serves as an indicator for malloc()ed - memory, so that freea() of an alloca() result is fast. */ - size_t nplus = n + HEADER_SIZE; - - if (nplus >= n) - { - void *p = malloc (nplus); - - if (p != NULL) - { - size_t slot; - union header *h = p; - - p = h + 1; - - /* Put a magic number into the indicator word. */ - h->magic.word = MAGIC_NUMBER; - - /* Enter p into the hash table. */ - slot = (uintptr_t) p % HASH_TABLE_SIZE; - h->next = mmalloca_results[slot]; - mmalloca_results[slot] = p; - - return p; - } - } - /* Out of memory. */ - return NULL; -#else -# if !MALLOC_0_IS_NONNULL - if (n == 0) - n = 1; -# endif - return malloc (n); -#endif -} - -#if HAVE_ALLOCA -void -freea (void *p) -{ - /* mmalloca() may have returned NULL. */ - if (p != NULL) - { - /* Attempt to quickly distinguish the mmalloca() result - which has - a magic indicator word - and the alloca() result - which has an - uninitialized indicator word. It is for this test that sa_increment - additional bytes are allocated in the alloca() case. */ - if (((int *) p)[-1] == MAGIC_NUMBER) - { - /* Looks like a mmalloca() result. To see whether it really is one, - perform a lookup in the hash table. */ - size_t slot = (uintptr_t) p % HASH_TABLE_SIZE; - void **chain = &mmalloca_results[slot]; - for (; *chain != NULL;) - { - union header *h = p; - if (*chain == p) - { - /* Found it. Remove it from the hash table and free it. */ - union header *p_begin = h - 1; - *chain = p_begin->next; - free (p_begin); - return; - } - h = *chain; - chain = &h[-1].next; - } - } - /* At this point, we know it was not a mmalloca() result. */ - } -} -#endif diff --git a/contrib/tools/bison/lib/malloca.h b/contrib/tools/bison/lib/malloca.h deleted file mode 100644 index 6fbe45eab6..0000000000 --- a/contrib/tools/bison/lib/malloca.h +++ /dev/null @@ -1,133 +0,0 @@ -/* Safe automatic memory allocation. - Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2003. - - 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/>. */ - -#ifndef _MALLOCA_H -#define _MALLOCA_H - -#include <alloca.h> -#include <stddef.h> -#include <stdlib.h> - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call - alloca(N); otherwise it returns NULL. It either returns N bytes of - memory allocated on the stack, that lasts until the function returns, - or NULL. - Use of safe_alloca should be avoided: - - inside arguments of function calls - undefined behaviour, - - in inline functions - the allocation may actually last until the - calling function returns. -*/ -#if HAVE_ALLOCA -/* The OS usually guarantees only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - allocate anything larger than 4096 bytes. Also care for the possibility - of a few compiler-allocated temporary stack slots. - This must be a macro, not a function. */ -# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL) -#else -# define safe_alloca(N) ((void) (N), NULL) -#endif - -/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of - memory allocated on the stack, that must be freed using freea() before - the function returns. Upon failure, it returns NULL. */ -#if HAVE_ALLOCA -# define malloca(N) \ - ((N) < 4032 - sa_increment \ - ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \ - : mmalloca (N)) -#else -# define malloca(N) \ - mmalloca (N) -#endif -extern void * mmalloca (size_t n); - -/* Free a block of memory allocated through malloca(). */ -#if HAVE_ALLOCA -extern void freea (void *p); -#else -# define freea free -#endif - -/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). - It allocates an array of N objects, each with S bytes of memory, - on the stack. S must be positive and N must be nonnegative. - The array must be freed using freea() before the function returns. */ -#if 1 -/* Cf. the definition of xalloc_oversized. */ -# define nmalloca(n, s) \ - ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \ - ? NULL \ - : malloca ((n) * (s))) -#else -extern void * nmalloca (size_t n, size_t s); -#endif - - -#ifdef __cplusplus -} -#endif - - -/* ------------------- Auxiliary, non-public definitions ------------------- */ - -/* Determine the alignment of a type at compile time. */ -#if defined __GNUC__ || defined __IBM__ALIGNOF__ -# define sa_alignof __alignof__ -#elif defined __cplusplus - template <class type> struct sa_alignof_helper { char __slot1; type __slot2; }; -# define sa_alignof(type) offsetof (sa_alignof_helper<type>, __slot2) -#elif defined __hpux - /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof - values. */ -# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) -#elif defined _AIX - /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof - values. */ -# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) -#else -# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) -#endif - -enum -{ -/* The desired alignment of memory allocations is the maximum alignment - among all elementary types. */ - sa_alignment_long = sa_alignof (long), - sa_alignment_double = sa_alignof (double), -#if HAVE_LONG_LONG_INT - sa_alignment_longlong = sa_alignof (long long), -#endif - sa_alignment_longdouble = sa_alignof (long double), - sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) -#if HAVE_LONG_LONG_INT - | (sa_alignment_longlong - 1) -#endif - | (sa_alignment_longdouble - 1) - ) + 1, -/* The increment that guarantees room for a magic word must be >= sizeof (int) - and a multiple of sa_alignment_max. */ - sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max -}; - -#endif /* _MALLOCA_H */ diff --git a/contrib/tools/bison/lib/mbrtowc.c b/contrib/tools/bison/lib/mbrtowc.c deleted file mode 100644 index 5ee44aea48..0000000000 --- a/contrib/tools/bison/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/bison/lib/platform/win64/config.h b/contrib/tools/bison/lib/platform/win64/config.h index a34046c4a9..cb29c4cc78 100644 --- a/contrib/tools/bison/lib/platform/win64/config.h +++ b/contrib/tools/bison/lib/platform/win64/config.h @@ -967,7 +967,7 @@ char *strsignal (int signum); /* Define to 1 if `decimal_point' is a member of `struct lconv'. */ -#define HAVE_STRUCT_LCONV_DECIMAL_POINT 1 +/* #undef HAVE_STRUCT_LCONV_DECIMAL_POINT */ /* Define to 1 if `sa_sigaction' is a member of `struct sigaction'. */ /* #undef HAVE_STRUCT_SIGACTION_SA_SIGACTION */ diff --git a/contrib/tools/bison/lib/platform/win64/stdbool.h b/contrib/tools/bison/lib/platform/win64/stdbool.h deleted file mode 100644 index 8f918a3123..0000000000 --- a/contrib/tools/bison/lib/platform/win64/stdbool.h +++ /dev/null @@ -1,133 +0,0 @@ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -/* Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc. - Written by Bruno Haible <haible@clisp.cons.org>, 2001. - - 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/>. */ - -#ifndef _GL_STDBOOL_H -#define _GL_STDBOOL_H - -/* ISO C 99 <stdbool.h> for platforms that lack it. */ - -/* Usage suggestions: - - Programs that use <stdbool.h> should be aware of some limitations - and standards compliance issues. - - Standards compliance: - - - <stdbool.h> must be #included before 'bool', 'false', 'true' - can be used. - - - You cannot assume that sizeof (bool) == 1. - - - Programs should not undefine the macros bool, true, and false, - as C99 lists that as an "obsolescent feature". - - Limitations of this substitute, when used in a C89 environment: - - - <stdbool.h> must be #included before the '_Bool' type can be used. - - - You cannot assume that _Bool is a typedef; it might be a macro. - - - Bit-fields of type 'bool' are not supported. Portable code - should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. - - - In C99, casts and automatic conversions to '_Bool' or 'bool' are - performed in such a way that every nonzero value gets converted - to 'true', and zero gets converted to 'false'. This doesn't work - with this substitute. With this substitute, only the values 0 and 1 - give the expected result when converted to _Bool' or 'bool'. - - - C99 allows the use of (_Bool)0.0 in constant expressions, but - this substitute cannot always provide this property. - - Also, it is suggested that programs use 'bool' rather than '_Bool'; - this isn't required, but 'bool' is more common. */ - - -/* 7.16. Boolean type and values */ - -/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same - definitions below, but temporarily we have to #undef them. */ -#if defined __BEOS__ && !defined __HAIKU__ -# error #include <OS.h> /* defines bool but not _Bool */ -# undef false -# undef true -#endif - -#ifdef __cplusplus -# define _Bool bool -# define bool bool -#else -# if defined __BEOS__ && !defined __HAIKU__ - /* A compiler known to have 'bool'. */ - /* If the compiler already has both 'bool' and '_Bool', we can assume they - are the same types. */ -# if !0 -typedef bool _Bool; -# endif -# else -# if !defined __GNUC__ - /* If 0: - Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when - the built-in _Bool type is used. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - Similar bugs are likely with other compilers as well; this file - wouldn't be used if <stdbool.h> was working. - So we override the _Bool type. - If !0: - Need to define _Bool ourselves. As 'signed char' or as an enum type? - Use of a typedef, with SunPRO C, leads to a stupid - "warning: _Bool is a keyword in ISO C99". - Use of an enum type, with IRIX cc, leads to a stupid - "warning(1185): enumerated type mixed with another type". - Even the existence of an enum type, without a typedef, - "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. - The only benefit of the enum, debuggability, is not important - with these compilers. So use 'signed char' and no enum. */ -# define _Bool signed char -# else - /* With this compiler, trust the _Bool type if the compiler has it. */ -# if !0 - /* For the sake of symbolic names in gdb, define true and false as - enum constants, not only as macros. - It is tempting to write - typedef enum { false = 0, true = 1 } _Bool; - so that gdb prints values of type 'bool' symbolically. But then - values of type '_Bool' might promote to 'int' or 'unsigned int' - (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' - (see ISO C 99 6.3.1.1.(2)). So add a negative value to the - enum; this ensures that '_Bool' promotes to 'int'. */ -typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; -# endif -# endif -# endif -# define bool _Bool -#endif - -/* The other macros must be usable in preprocessor directives. */ -#ifdef __cplusplus -# define false false -# define true true -#else -# define false 0 -# define true 1 -#endif - -#define __bool_true_false_are_defined 1 - -#endif /* _GL_STDBOOL_H */ diff --git a/contrib/tools/bison/lib/stdio-write.c b/contrib/tools/bison/lib/stdio-write.c deleted file mode 100644 index 68d54ce93e..0000000000 --- a/contrib/tools/bison/lib/stdio-write.c +++ /dev/null @@ -1,198 +0,0 @@ -/* POSIX compatible FILE stream write function. - Copyright (C) 2008-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 <stdio.h> - -/* Replace these functions only if module 'nonblocking' or module 'sigpipe' is - requested. */ -#if GNULIB_NONBLOCKING || GNULIB_SIGPIPE - -/* On native Windows platforms, SIGPIPE does not exist. When write() is - called on a pipe with no readers, WriteFile() fails with error - GetLastError() = ERROR_NO_DATA, and write() in consequence fails with - error EINVAL. This write() function is at the basis of the function - which flushes the buffer of a FILE stream. */ - -# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ - -# include <errno.h> -# include <signal.h> -# include <io.h> - -# define WIN32_LEAN_AND_MEAN /* avoid including junk */ -# include <windows.h> - -# include "msvc-nothrow.h" - -# if GNULIB_NONBLOCKING -# define CLEAR_ERRNO \ - errno = 0; -# define HANDLE_ENOSPC \ - if (errno == ENOSPC && ferror (stream)) \ - { \ - int fd = fileno (stream); \ - if (fd >= 0) \ - { \ - HANDLE h = (HANDLE) _get_osfhandle (fd); \ - if (GetFileType (h) == FILE_TYPE_PIPE) \ - { \ - /* h is a pipe or socket. */ \ - DWORD state; \ - if (GetNamedPipeHandleState (h, &state, NULL, NULL, \ - NULL, NULL, 0) \ - && (state & PIPE_NOWAIT) != 0) \ - /* h is a pipe in non-blocking mode. \ - Change errno from ENOSPC to EAGAIN. */ \ - errno = EAGAIN; \ - } \ - } \ - } \ - else -# else -# define CLEAR_ERRNO -# define HANDLE_ENOSPC -# endif - -# if GNULIB_SIGPIPE -# define CLEAR_LastError \ - SetLastError (0); -# define HANDLE_ERROR_NO_DATA \ - if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \ - { \ - int fd = fileno (stream); \ - if (fd >= 0 \ - && GetFileType ((HANDLE) _get_osfhandle (fd)) \ - == FILE_TYPE_PIPE) \ - { \ - /* Try to raise signal SIGPIPE. */ \ - raise (SIGPIPE); \ - /* If it is currently blocked or ignored, change errno from \ - EINVAL to EPIPE. */ \ - errno = EPIPE; \ - } \ - } \ - else -# else -# define CLEAR_LastError -# define HANDLE_ERROR_NO_DATA -# endif - -# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \ - if (ferror (stream)) \ - return (EXPRESSION); \ - else \ - { \ - RETTYPE ret; \ - CLEAR_ERRNO \ - CLEAR_LastError \ - ret = (EXPRESSION); \ - if (FAILED) \ - { \ - HANDLE_ENOSPC \ - HANDLE_ERROR_NO_DATA \ - ; \ - } \ - return ret; \ - } - -# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ -int -printf (const char *format, ...) -{ - int retval; - va_list args; - - va_start (args, format); - retval = vfprintf (stdout, format, args); - va_end (args); - - return retval; -} -# endif - -# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ -int -fprintf (FILE *stream, const char *format, ...) -{ - int retval; - va_list args; - - va_start (args, format); - retval = vfprintf (stream, format, args); - va_end (args); - - return retval; -} -# endif - -# if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */ -int -vprintf (const char *format, va_list args) -{ - return vfprintf (stdout, format, args); -} -# endif - -# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */ -int -vfprintf (FILE *stream, const char *format, va_list args) -#undef vfprintf -{ - CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF) -} -# endif - -int -putchar (int c) -{ - return fputc (c, stdout); -} - -int -fputc (int c, FILE *stream) -#undef fputc -{ - CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF) -} - -int -fputs (const char *string, FILE *stream) -#undef fputs -{ - CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF) -} - -int -puts (const char *string) -#undef puts -{ - FILE *stream = stdout; - CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF) -} - -size_t -fwrite (const void *ptr, size_t s, size_t n, FILE *stream) -#undef fwrite -{ - CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n) -} - -# endif -#endif diff --git a/contrib/tools/bison/lib/wcrtomb.c b/contrib/tools/bison/lib/wcrtomb.c deleted file mode 100644 index c3cda35803..0000000000 --- a/contrib/tools/bison/lib/wcrtomb.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Convert wide character to multibyte character. - Copyright (C) 2008-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> - -#include <errno.h> -#include <stdlib.h> - - -// wcrtomb is defined for msvs 2017 15.7 -#if _MSC_VER < 1914 -size_t -wcrtomb (char *s, wchar_t wc, mbstate_t *ps) -{ - /* This implementation of wcrtomb on top of wctomb() supports only - stateless encodings. ps must be in the initial state. */ - if (ps != NULL && !mbsinit (ps)) - { - errno = EINVAL; - return (size_t)(-1); - } - - if (s == NULL) - /* We know the NUL wide character corresponds to the NUL character. */ - return 1; - else - { - int ret = wctomb (s, wc); - - if (ret >= 0) - return ret; - else - { - errno = EILSEQ; - return (size_t)(-1); - } - } -} -#endif diff --git a/contrib/tools/bison/lib/xmalloca.c b/contrib/tools/bison/lib/xmalloca.c deleted file mode 100644 index 50ee4807fb..0000000000 --- a/contrib/tools/bison/lib/xmalloca.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Safe automatic memory allocation with out of memory checking. - Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2003. - - 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 "xmalloca.h" - -#include "xalloc.h" - -#if HAVE_ALLOCA - -void * -xmmalloca (size_t n) -{ - void *p; - - p = mmalloca (n); - if (p == NULL) - xalloc_die (); - return p; -} - -#endif diff --git a/contrib/tools/bison/lib/xmalloca.h b/contrib/tools/bison/lib/xmalloca.h deleted file mode 100644 index 2f7567d498..0000000000 --- a/contrib/tools/bison/lib/xmalloca.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Safe automatic memory allocation with out of memory checking. - Copyright (C) 2003, 2005, 2007, 2009-2013 Free Software Foundation, Inc. - Written by Bruno Haible <bruno@clisp.org>, 2003. - - 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 _XMALLOCA_H -#define _XMALLOCA_H - -#include "malloca.h" -#include "xalloc.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* xmalloca(N) is a checking safe variant of alloca(N). It allocates N bytes - of memory allocated on the stack, that must be freed using freea() before - the function returns. Upon failure, it exits with an error message. */ -#if HAVE_ALLOCA -# define xmalloca(N) \ - ((N) < 4032 - sa_increment \ - ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \ - : xmmalloca (N)) -extern void * xmmalloca (size_t n); -#else -# define xmalloca(N) \ - xmalloc (N) -#endif - -/* xnmalloca(N,S) is an overflow-safe variant of xmalloca (N * S). - It allocates an array of N objects, each with S bytes of memory, - on the stack. S must be positive and N must be nonnegative. - The array must be freed using freea() before the function returns. - Upon failure, it exits with an error message. */ -#if HAVE_ALLOCA -/* Rely on xmalloca (SIZE_MAX) calling xalloc_die (). */ -# define xnmalloca(n, s) \ - xmalloca (xalloc_oversized ((n), (s)) ? (size_t) (-1) : (n) * (s)) -#else -# define xnmalloca(n, s) \ - xnmalloc ((n), (s)) -#endif - - -#ifdef __cplusplus -} -#endif - - -#endif /* _XMALLOCA_H */ diff --git a/contrib/tools/bison/lib/xstrndup.c b/contrib/tools/bison/lib/xstrndup.c index 741d5a1b05..eae92d039d 100644 --- a/contrib/tools/bison/lib/xstrndup.c +++ b/contrib/tools/bison/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/bison/lib/ya.make b/contrib/tools/bison/lib/ya.make index 27ea06b0e4..b107ceb150 100644 --- a/contrib/tools/bison/lib/ya.make +++ b/contrib/tools/bison/lib/ya.make @@ -77,10 +77,7 @@ SRCS( isnand.c lbitset.c localcharset.c - malloc.c - malloca.c mbswidth.c - mbrtowc.c nl_langinfo.c pipe-safer.c pipe2-safer.c @@ -103,7 +100,6 @@ SRCS( xalloc-die.c xconcat-filename.c xmalloc.c - xmalloca.c xmemdup0.c xsize.c xstrndup.c @@ -122,19 +118,9 @@ IF (NOT OS_LINUX) ) ENDIF() -IF (NOT OS_WINDOWS) - SRCS( - stdio-write.c - ) -ENDIF() - IF (OS_WINDOWS) SRCS( frexp.c - wcrtomb.c - fseeko.c - fopen.c - ftello.c msvc-inval.c msvc-nothrow.c open.c diff --git a/contrib/tools/bison/src/uniqstr.c b/contrib/tools/bison/src/uniqstr.c index 4a62e989c9..4446c0ed86 100644 --- a/contrib/tools/bison/src/uniqstr.c +++ b/contrib/tools/bison/src/uniqstr.c @@ -24,7 +24,6 @@ #include <hash.h> #include <quotearg.h> #include <stdarg.h> -#include <xmalloca.h> #include "uniqstr.h" @@ -44,7 +43,7 @@ static struct hash_table *uniqstrs_table = NULL; uniqstr uniqstr_new (char const *str) { - uniqstr res = (uniqstr) hash_lookup (uniqstrs_table, str); + uniqstr res = hash_lookup (uniqstrs_table, str); if (!res) { /* First insertion in the hash. */ @@ -60,19 +59,15 @@ uniqstr_vsprintf (char const *format, ...) { va_list args; size_t length; - char* res; - uniqstr str; va_start (args, format); length = vsnprintf (NULL, 0, format, args); va_end (args); - res = xmalloca(length + 1); + char res[length + 1]; va_start (args, format); vsprintf (res, format, args); va_end (args); - str = uniqstr_new (res); - freea(res); - return str; + return uniqstr_new (res); } /*------------------------------. diff --git a/contrib/tools/bison/src/uniqstr.h b/contrib/tools/bison/src/uniqstr.h index f8e59ab24f..006c10f4ad 100644 --- a/contrib/tools/bison/src/uniqstr.h +++ b/contrib/tools/bison/src/uniqstr.h @@ -20,8 +20,6 @@ #ifndef UNIQSTR_H_ # define UNIQSTR_H_ -#include "system.h" - /*-----------------------------------------. | Pointers to unique copies of C strings. | `-----------------------------------------*/ @@ -47,8 +45,6 @@ int uniqstr_cmp (uniqstr u1, uniqstr u2); /* Die if STR is not a uniqstr. */ void uniqstr_assert (char const *str); -#if 0 - // msvc still does not support __VA_ARGS__ /*----------------. | Concatenation. | `----------------*/ @@ -86,7 +82,6 @@ void uniqstr_assert (char const *str); F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 \ F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 -#endif /*--------------------. | Table of uniqstrs. | `--------------------*/ |