aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/m4
diff options
context:
space:
mode:
authorMaxim Yurchuk <maxim-yurchuk@ydb.tech>2024-10-18 20:31:38 +0300
committerGitHub <noreply@github.com>2024-10-18 20:31:38 +0300
commit2a74bac2d2d3bccb4e10120f1ead805640ec9dd0 (patch)
tree047e4818ced5aaf73f58517629e5260b5291f9f0 /contrib/tools/m4
parent2d9656823e9521d8c29ea4c9a1d0eab78391abfc (diff)
parent3d834a1923bbf9403cd4a448e7f32b670aa4124f (diff)
downloadydb-2a74bac2d2d3bccb4e10120f1ead805640ec9dd0.tar.gz
Merge pull request #10502 from ydb-platform/mergelibs-241016-1210
Library import 241016-1210
Diffstat (limited to 'contrib/tools/m4')
-rw-r--r--contrib/tools/m4/lib/bitrotate.c3
-rw-r--r--contrib/tools/m4/lib/bitrotate.h133
-rw-r--r--contrib/tools/m4/lib/c-strcasecmp.c4
-rw-r--r--contrib/tools/m4/lib/c-strncasecmp.c4
-rw-r--r--contrib/tools/m4/lib/canonicalize-lgpl.c411
-rw-r--r--contrib/tools/m4/lib/clean-temp.c2
-rw-r--r--contrib/tools/m4/lib/closein.c2
-rw-r--r--contrib/tools/m4/lib/concat-filename.c73
-rw-r--r--contrib/tools/m4/lib/concat-filename.h41
-rw-r--r--contrib/tools/m4/lib/filename.h54
-rw-r--r--contrib/tools/m4/lib/hash.c1233
-rw-r--r--contrib/tools/m4/lib/hash.h107
-rw-r--r--contrib/tools/m4/lib/intprops.h319
-rw-r--r--contrib/tools/m4/lib/malloca.h2
-rw-r--r--contrib/tools/m4/lib/obstack.c26
-rw-r--r--contrib/tools/m4/lib/obstack.h4
-rw-r--r--contrib/tools/m4/lib/obstack_printf.c93
-rw-r--r--contrib/tools/m4/lib/tempname.c2
-rw-r--r--contrib/tools/m4/lib/tmpdir.c2
-rw-r--r--contrib/tools/m4/lib/unitypes.h47
-rw-r--r--contrib/tools/m4/lib/uniwidth.h73
-rw-r--r--contrib/tools/m4/lib/uniwidth/cjk.h37
-rw-r--r--contrib/tools/m4/lib/uniwidth/width.c368
-rw-r--r--contrib/tools/m4/lib/ya.make5
-rw-r--r--contrib/tools/m4/src/cpp.cpp3
-rw-r--r--contrib/tools/m4/src/m4.h1
-rw-r--r--contrib/tools/m4/src/symtab.c6
-rw-r--r--contrib/tools/m4/ya.make1
28 files changed, 26 insertions, 3030 deletions
diff --git a/contrib/tools/m4/lib/bitrotate.c b/contrib/tools/m4/lib/bitrotate.c
deleted file mode 100644
index a8f602889d..0000000000
--- a/contrib/tools/m4/lib/bitrotate.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <config.h>
-#define BITROTATE_INLINE _GL_EXTERN_INLINE
-#include "bitrotate.h"
diff --git a/contrib/tools/m4/lib/bitrotate.h b/contrib/tools/m4/lib/bitrotate.h
deleted file mode 100644
index 9e10a45f43..0000000000
--- a/contrib/tools/m4/lib/bitrotate.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* bitrotate.h - Rotate bits in integers
- 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 Simon Josefsson <simon@josefsson.org>, 2008. */
-
-#ifndef _GL_BITROTATE_H
-#define _GL_BITROTATE_H
-
-#include <limits.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-_GL_INLINE_HEADER_BEGIN
-#ifndef BITROTATE_INLINE
-# define BITROTATE_INLINE _GL_INLINE
-#endif
-
-#ifdef UINT64_MAX
-/* Given an unsigned 64-bit argument X, return the value corresponding
- to rotating the bits N steps to the left. N must be between 1 and
- 63 inclusive. */
-BITROTATE_INLINE uint64_t
-rotl64 (uint64_t x, int n)
-{
- return ((x << n) | (x >> (64 - n))) & UINT64_MAX;
-}
-
-/* Given an unsigned 64-bit argument X, return the value corresponding
- to rotating the bits N steps to the right. N must be between 1 to
- 63 inclusive.*/
-BITROTATE_INLINE uint64_t
-rotr64 (uint64_t x, int n)
-{
- return ((x >> n) | (x << (64 - n))) & UINT64_MAX;
-}
-#endif
-
-/* Given an unsigned 32-bit argument X, return the value corresponding
- to rotating the bits N steps to the left. N must be between 1 and
- 31 inclusive. */
-BITROTATE_INLINE uint32_t
-rotl32 (uint32_t x, int n)
-{
- return ((x << n) | (x >> (32 - n))) & UINT32_MAX;
-}
-
-/* Given an unsigned 32-bit argument X, return the value corresponding
- to rotating the bits N steps to the right. N must be between 1 to
- 31 inclusive.*/
-BITROTATE_INLINE uint32_t
-rotr32 (uint32_t x, int n)
-{
- return ((x >> n) | (x << (32 - n))) & UINT32_MAX;
-}
-
-/* Given a size_t argument X, return the value corresponding
- to rotating the bits N steps to the left. N must be between 1 and
- (CHAR_BIT * sizeof (size_t) - 1) inclusive. */
-BITROTATE_INLINE size_t
-rotl_sz (size_t x, int n)
-{
- return ((x << n) | (x >> ((CHAR_BIT * sizeof x) - n))) & SIZE_MAX;
-}
-
-/* Given a size_t argument X, return the value corresponding
- to rotating the bits N steps to the right. N must be between 1 to
- (CHAR_BIT * sizeof (size_t) - 1) inclusive. */
-BITROTATE_INLINE size_t
-rotr_sz (size_t x, int n)
-{
- return ((x >> n) | (x << ((CHAR_BIT * sizeof x) - n))) & SIZE_MAX;
-}
-
-/* Given an unsigned 16-bit argument X, return the value corresponding
- to rotating the bits N steps to the left. N must be between 1 to
- 15 inclusive, but on most relevant targets N can also be 0 and 16
- because 'int' is at least 32 bits and the arguments must widen
- before shifting. */
-BITROTATE_INLINE uint16_t
-rotl16 (uint16_t x, int n)
-{
- return ((x << n) | (x >> (16 - n))) & UINT16_MAX;
-}
-
-/* Given an unsigned 16-bit argument X, return the value corresponding
- to rotating the bits N steps to the right. N must be in 1 to 15
- inclusive, but on most relevant targets N can also be 0 and 16
- because 'int' is at least 32 bits and the arguments must widen
- before shifting. */
-BITROTATE_INLINE uint16_t
-rotr16 (uint16_t x, int n)
-{
- return ((x >> n) | (x << (16 - n))) & UINT16_MAX;
-}
-
-/* Given an unsigned 8-bit argument X, return the value corresponding
- to rotating the bits N steps to the left. N must be between 1 to 7
- inclusive, but on most relevant targets N can also be 0 and 8
- because 'int' is at least 32 bits and the arguments must widen
- before shifting. */
-BITROTATE_INLINE uint8_t
-rotl8 (uint8_t x, int n)
-{
- return ((x << n) | (x >> (8 - n))) & UINT8_MAX;
-}
-
-/* Given an unsigned 8-bit argument X, return the value corresponding
- to rotating the bits N steps to the right. N must be in 1 to 7
- inclusive, but on most relevant targets N can also be 0 and 8
- because 'int' is at least 32 bits and the arguments must widen
- before shifting. */
-BITROTATE_INLINE uint8_t
-rotr8 (uint8_t x, int n)
-{
- return ((x >> n) | (x << (8 - n))) & UINT8_MAX;
-}
-
-_GL_INLINE_HEADER_END
-
-#endif /* _GL_BITROTATE_H */
diff --git a/contrib/tools/m4/lib/c-strcasecmp.c b/contrib/tools/m4/lib/c-strcasecmp.c
index cd4e4d49cb..ef85f0e67d 100644
--- a/contrib/tools/m4/lib/c-strcasecmp.c
+++ b/contrib/tools/m4/lib/c-strcasecmp.c
@@ -26,8 +26,8 @@
int
c_strcasecmp (const char *s1, const char *s2)
{
- const unsigned char *p1 = (const unsigned char *) s1;
- const unsigned char *p2 = (const unsigned char *) s2;
+ register const unsigned char *p1 = (const unsigned char *) s1;
+ register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2)
diff --git a/contrib/tools/m4/lib/c-strncasecmp.c b/contrib/tools/m4/lib/c-strncasecmp.c
index 053c70a73a..04404b00cd 100644
--- a/contrib/tools/m4/lib/c-strncasecmp.c
+++ b/contrib/tools/m4/lib/c-strncasecmp.c
@@ -26,8 +26,8 @@
int
c_strncasecmp (const char *s1, const char *s2, size_t n)
{
- const unsigned char *p1 = (const unsigned char *) s1;
- const unsigned char *p2 = (const unsigned char *) s2;
+ register const unsigned char *p1 = (const unsigned char *) s1;
+ register const unsigned char *p2 = (const unsigned char *) s2;
unsigned char c1, c2;
if (p1 == p2 || n == 0)
diff --git a/contrib/tools/m4/lib/canonicalize-lgpl.c b/contrib/tools/m4/lib/canonicalize-lgpl.c
deleted file mode 100644
index 5cc9c5b4a0..0000000000
--- a/contrib/tools/m4/lib/canonicalize-lgpl.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/* Return the canonical absolute name of a given file.
- Copyright (C) 1996-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/>. */
-
-#ifndef _LIBC
-/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
- optimizes away the name == NULL test below. */
-# define _GL_ARG_NONNULL(params)
-
-# define _GL_USE_STDLIB_ALLOC 1
-# include <config.h>
-#endif
-
-#if !HAVE_CANONICALIZE_FILE_NAME || !FUNC_REALPATH_WORKS || defined _LIBC
-
-/* Specification. */
-#include <stdlib.h>
-
-#include "palloca.h"
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#if HAVE_SYS_PARAM_H || defined _LIBC
-# include <sys/param.h>
-#endif
-#include <sys/stat.h>
-#include <errno.h>
-#include <stddef.h>
-
-#ifdef _LIBC
-# include <shlib-compat.h>
-#else
-# define SHLIB_COMPAT(lib, introduced, obsoleted) 0
-# define versioned_symbol(lib, local, symbol, version) extern int dummy
-# define compat_symbol(lib, local, symbol, version)
-# define weak_alias(local, symbol)
-# define __canonicalize_file_name canonicalize_file_name
-# define __realpath realpath
-# include "pathmax.h"
-# include "malloca.h"
-# include "dosname.h"
-# if HAVE_GETCWD
-# if IN_RELOCWRAPPER
- /* When building the relocatable program wrapper, use the system's getcwd
- function, not the gnulib override, otherwise we would get a link error.
- */
-# undef getcwd
-# endif
-# ifdef VMS
- /* We want the directory in Unix syntax, not in VMS syntax. */
-# define __getcwd(buf, max) getcwd (buf, max, 0)
-# else
-# define __getcwd getcwd
-# endif
-# else
-# define __getcwd(buf, max) getwd (buf)
-# endif
-# define __readlink readlink
-# define __set_errno(e) errno = (e)
-# ifndef MAXSYMLINKS
-# ifdef SYMLOOP_MAX
-# define MAXSYMLINKS SYMLOOP_MAX
-# else
-# define MAXSYMLINKS 20
-# endif
-# endif
-#endif
-
-#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
-# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
-#endif
-
-#if !FUNC_REALPATH_WORKS || defined _LIBC
-/* Return the canonical absolute name of file NAME. A canonical name
- does not contain any ".", ".." components nor any repeated path
- separators ('/') or symlinks. All path components must exist. If
- RESOLVED is null, the result is malloc'd; otherwise, if the
- canonical name is PATH_MAX chars or more, returns null with 'errno'
- set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
- returns the name in RESOLVED. If the name cannot be resolved and
- RESOLVED is non-NULL, it contains the path of the first component
- that cannot be resolved. If the path can be resolved, RESOLVED
- holds the same value as the value returned. */
-
-char *
-__realpath (const char *name, char *resolved)
-{
- char *rpath, *dest, *extra_buf = NULL;
- const char *start, *end, *rpath_limit;
- long int path_max;
- int num_links = 0;
- size_t prefix_len;
-
- if (name == NULL)
- {
- /* As per Single Unix Specification V2 we must return an error if
- either parameter is a null pointer. We extend this to allow
- the RESOLVED parameter to be NULL in case the we are expected to
- allocate the room for the return value. */
- __set_errno (EINVAL);
- return NULL;
- }
-
- if (name[0] == '\0')
- {
- /* As per Single Unix Specification V2 we must return an error if
- the name argument points to an empty string. */
- __set_errno (ENOENT);
- return NULL;
- }
-
-#ifdef PATH_MAX
- path_max = PATH_MAX;
-#else
- path_max = pathconf (name, _PC_PATH_MAX);
- if (path_max <= 0)
- path_max = 8192;
-#endif
-
- if (resolved == NULL)
- {
- rpath = malloc (path_max);
- if (rpath == NULL)
- {
- /* It's easier to set errno to ENOMEM than to rely on the
- 'malloc-posix' gnulib module. */
- errno = ENOMEM;
- return NULL;
- }
- }
- else
- rpath = resolved;
- rpath_limit = rpath + path_max;
-
- /* This is always zero for Posix hosts, but can be 2 for MS-Windows
- and MS-DOS X:/foo/bar file names. */
- prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
-
- if (!IS_ABSOLUTE_FILE_NAME (name))
- {
- if (!__getcwd (rpath, path_max))
- {
- rpath[0] = '\0';
- goto error;
- }
- dest = strchr (rpath, '\0');
- start = name;
- prefix_len = FILE_SYSTEM_PREFIX_LEN (rpath);
- }
- else
- {
- dest = rpath;
- if (prefix_len)
- {
- memcpy (rpath, name, prefix_len);
- dest += prefix_len;
- }
- *dest++ = '/';
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
- {
- if (ISSLASH (name[1]) && !ISSLASH (name[2]) && !prefix_len)
- *dest++ = '/';
- *dest = '\0';
- }
- start = name + prefix_len;
- }
-
- for (end = start; *start; start = end)
- {
-#ifdef _LIBC
- struct stat64 st;
-#else
- struct stat st;
-#endif
- int n;
-
- /* Skip sequence of multiple path-separators. */
- while (ISSLASH (*start))
- ++start;
-
- /* Find end of path component. */
- for (end = start; *end && !ISSLASH (*end); ++end)
- /* Nothing. */;
-
- if (end - start == 0)
- break;
- else if (end - start == 1 && start[0] == '.')
- /* nothing */;
- else if (end - start == 2 && start[0] == '.' && start[1] == '.')
- {
- /* Back up to previous component, ignore if at root already. */
- if (dest > rpath + prefix_len + 1)
- for (--dest; dest > rpath && !ISSLASH (dest[-1]); --dest)
- continue;
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT
- && dest == rpath + 1 && !prefix_len
- && ISSLASH (*dest) && !ISSLASH (dest[1]))
- dest++;
- }
- else
- {
- size_t new_size;
-
- if (!ISSLASH (dest[-1]))
- *dest++ = '/';
-
- if (dest + (end - start) >= rpath_limit)
- {
- ptrdiff_t dest_offset = dest - rpath;
- char *new_rpath;
-
- if (resolved)
- {
- __set_errno (ENAMETOOLONG);
- if (dest > rpath + prefix_len + 1)
- dest--;
- *dest = '\0';
- goto error;
- }
- new_size = rpath_limit - rpath;
- if (end - start + 1 > path_max)
- new_size += end - start + 1;
- else
- new_size += path_max;
- new_rpath = (char *) realloc (rpath, new_size);
- if (new_rpath == NULL)
- {
- /* It's easier to set errno to ENOMEM than to rely on the
- 'realloc-posix' gnulib module. */
- errno = ENOMEM;
- goto error;
- }
- rpath = new_rpath;
- rpath_limit = rpath + new_size;
-
- dest = rpath + dest_offset;
- }
-
-#ifdef _LIBC
- dest = __mempcpy (dest, start, end - start);
-#else
- memcpy (dest, start, end - start);
- dest += end - start;
-#endif
- *dest = '\0';
-
-#ifdef _LIBC
- if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
-#else
- if (lstat (rpath, &st) < 0)
-#endif
- goto error;
-
- if (S_ISLNK (st.st_mode))
- {
- char *buf;
- size_t len;
-
- if (++num_links > MAXSYMLINKS)
- {
- __set_errno (ELOOP);
- goto error;
- }
-
- buf = malloca (path_max);
- if (!buf)
- {
- errno = ENOMEM;
- goto error;
- }
-
- n = __readlink (rpath, buf, path_max - 1);
- if (n < 0)
- {
- int saved_errno = errno;
- freea (buf);
- errno = saved_errno;
- goto error;
- }
- buf[n] = '\0';
-
- if (!extra_buf)
- {
- extra_buf = malloca (path_max);
- if (!extra_buf)
- {
- freea (buf);
- errno = ENOMEM;
- goto error;
- }
- }
-
- len = strlen (end);
- if ((long int) (n + len) >= path_max)
- {
- freea (buf);
- __set_errno (ENAMETOOLONG);
- goto error;
- }
-
- /* Careful here, end may be a pointer into extra_buf... */
- memmove (&extra_buf[n], end, len + 1);
- name = end = memcpy (extra_buf, buf, n);
-
- if (IS_ABSOLUTE_FILE_NAME (buf))
- {
- size_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf);
-
- if (pfxlen)
- memcpy (rpath, buf, pfxlen);
- dest = rpath + pfxlen;
- *dest++ = '/'; /* It's an absolute symlink */
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
- {
- if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen)
- *dest++ = '/';
- *dest = '\0';
- }
- /* Install the new prefix to be in effect hereafter. */
- prefix_len = pfxlen;
- }
- else
- {
- /* Back up to previous component, ignore if at root
- already: */
- if (dest > rpath + prefix_len + 1)
- for (--dest; dest > rpath && !ISSLASH (dest[-1]); --dest)
- continue;
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
- && ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len)
- dest++;
- }
- }
- else if (!S_ISDIR (st.st_mode) && *end != '\0')
- {
- __set_errno (ENOTDIR);
- goto error;
- }
- }
- }
- if (dest > rpath + prefix_len + 1 && ISSLASH (dest[-1]))
- --dest;
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 && !prefix_len
- && ISSLASH (*dest) && !ISSLASH (dest[1]))
- dest++;
- *dest = '\0';
-
- if (extra_buf)
- freea (extra_buf);
-
- return rpath;
-
-error:
- {
- int saved_errno = errno;
- if (extra_buf)
- freea (extra_buf);
- if (resolved == NULL)
- free (rpath);
- errno = saved_errno;
- }
- return NULL;
-}
-versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);
-#endif /* !FUNC_REALPATH_WORKS || defined _LIBC */
-
-
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3)
-char *
-attribute_compat_text_section
-__old_realpath (const char *name, char *resolved)
-{
- if (resolved == NULL)
- {
- __set_errno (EINVAL);
- return NULL;
- }
-
- return __realpath (name, resolved);
-}
-compat_symbol (libc, __old_realpath, realpath, GLIBC_2_0);
-#endif
-
-
-char *
-__canonicalize_file_name (const char *name)
-{
- return __realpath (name, NULL);
-}
-weak_alias (__canonicalize_file_name, canonicalize_file_name)
-
-#else
-
-/* This declaration is solely to ensure that after preprocessing
- this file is never empty. */
-typedef int dummy;
-
-#endif
diff --git a/contrib/tools/m4/lib/clean-temp.c b/contrib/tools/m4/lib/clean-temp.c
index 2961114168..1053312ecb 100644
--- a/contrib/tools/m4/lib/clean-temp.c
+++ b/contrib/tools/m4/lib/clean-temp.c
@@ -26,7 +26,7 @@
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
-#include "stdlib--.h"
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
diff --git a/contrib/tools/m4/lib/closein.c b/contrib/tools/m4/lib/closein.c
index c9bf73781f..20d5035eec 100644
--- a/contrib/tools/m4/lib/closein.c
+++ b/contrib/tools/m4/lib/closein.c
@@ -21,7 +21,7 @@
#include <errno.h>
#include <stdbool.h>
-#include "stdio--.h"
+#include <stdio.h>
#include <unistd.h>
#include "gettext.h"
diff --git a/contrib/tools/m4/lib/concat-filename.c b/contrib/tools/m4/lib/concat-filename.c
deleted file mode 100644
index 68168dcd53..0000000000
--- a/contrib/tools/m4/lib/concat-filename.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Construct a full filename from a directory and a relative filename.
- Copyright (C) 2001-2004, 2006-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 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 <haible@clisp.cons.org>. */
-
-#include <config.h>
-
-/* Specification. */
-#include "concat-filename.h"
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "filename.h"
-
-/* Concatenate a directory filename, a relative filename and an optional
- suffix. The directory may end with the directory separator. The second
- argument may not start with the directory separator (it is relative).
- Return a freshly allocated filename. Return NULL and set errno
- upon memory allocation failure. */
-char *
-concatenated_filename (const char *directory, const char *filename,
- const char *suffix)
-{
- char *result;
- char *p;
-
- if (strcmp (directory, ".") == 0)
- {
- /* No need to prepend the directory. */
- result = (char *) malloc (strlen (filename)
- + (suffix != NULL ? strlen (suffix) : 0)
- + 1);
- if (result == NULL)
- return NULL; /* errno is set here */
- p = result;
- }
- else
- {
- size_t directory_len = strlen (directory);
- int need_slash =
- (directory_len > FILE_SYSTEM_PREFIX_LEN (directory)
- && !ISSLASH (directory[directory_len - 1]));
- result = (char *) malloc (directory_len + need_slash
- + strlen (filename)
- + (suffix != NULL ? strlen (suffix) : 0)
- + 1);
- if (result == NULL)
- return NULL; /* errno is set here */
- memcpy (result, directory, directory_len);
- p = result + directory_len;
- if (need_slash)
- *p++ = '/';
- }
- p = stpcpy (p, filename);
- if (suffix != NULL)
- stpcpy (p, suffix);
- return result;
-}
diff --git a/contrib/tools/m4/lib/concat-filename.h b/contrib/tools/m4/lib/concat-filename.h
deleted file mode 100644
index 898dcee2d6..0000000000
--- a/contrib/tools/m4/lib/concat-filename.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Construct a full filename from a directory and a relative filename.
- Copyright (C) 2001-2004, 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/>. */
-
-#ifndef _CONCAT_FILENAME_H
-#define _CONCAT_FILENAME_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Concatenate a directory filename, a relative filename and an optional
- suffix. Return a freshly allocated filename. Return NULL and set errno
- upon memory allocation failure. */
-extern char *concatenated_filename (const char *directory,
- const char *filename, const char *suffix);
-
-/* Concatenate a directory filename, a relative filename and an optional
- suffix. Return a freshly allocated filename. */
-extern char *xconcatenated_filename (const char *directory,
- const char *filename, const char *suffix);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CONCAT_FILENAME_H */
diff --git a/contrib/tools/m4/lib/filename.h b/contrib/tools/m4/lib/filename.h
deleted file mode 100644
index b82a0ac389..0000000000
--- a/contrib/tools/m4/lib/filename.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Basic filename support macros.
- Copyright (C) 2001-2004, 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/>. */
-
-#ifndef _FILENAME_H
-#define _FILENAME_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Pathname support.
- ISSLASH(C) tests whether C is a directory separator character.
- IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not,
- it may be concatenated to a directory pathname.
- IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
- */
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
- /* Native Windows, Cygwin, OS/2, DOS */
-# define ISSLASH(C) ((C) == '/' || (C) == '\\')
-# define HAS_DEVICE(P) \
- ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
- && (P)[1] == ':')
-# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
-# define IS_PATH_WITH_DIR(P) \
- (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
-# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
-#else
- /* Unix */
-# define ISSLASH(C) ((C) == '/')
-# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
-# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
-# define FILE_SYSTEM_PREFIX_LEN(P) 0
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _FILENAME_H */
diff --git a/contrib/tools/m4/lib/hash.c b/contrib/tools/m4/lib/hash.c
deleted file mode 100644
index 685928ec0c..0000000000
--- a/contrib/tools/m4/lib/hash.c
+++ /dev/null
@@ -1,1233 +0,0 @@
-/* hash - hashing table processing.
-
- Copyright (C) 1998-2004, 2006-2007, 2009-2013 Free Software Foundation, Inc.
-
- Written by Jim Meyering, 1992.
-
- 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/>. */
-
-/* A generic hash table package. */
-
-/* Define USE_OBSTACK to 1 if you want the allocator to use obstacks instead
- of malloc. If you change USE_OBSTACK, you have to recompile! */
-
-#include <config.h>
-
-#include "hash.h"
-
-#include "bitrotate.h"
-#include "xalloc-oversized.h"
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#if USE_OBSTACK
-# include "obstack.h"
-# ifndef obstack_chunk_alloc
-# define obstack_chunk_alloc malloc
-# endif
-# ifndef obstack_chunk_free
-# define obstack_chunk_free free
-# endif
-#endif
-
-struct hash_entry
- {
- void *data;
- struct hash_entry *next;
- };
-
-struct hash_table
- {
- /* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1,
- for a possibility of N_BUCKETS. Among those, N_BUCKETS_USED buckets
- are not empty, there are N_ENTRIES active entries in the table. */
- struct hash_entry *bucket;
- struct hash_entry const *bucket_limit;
- size_t n_buckets;
- size_t n_buckets_used;
- size_t n_entries;
-
- /* Tuning arguments, kept in a physically separate structure. */
- const Hash_tuning *tuning;
-
- /* Three functions are given to 'hash_initialize', see the documentation
- block for this function. In a word, HASHER randomizes a user entry
- into a number up from 0 up to some maximum minus 1; COMPARATOR returns
- true if two user entries compare equally; and DATA_FREER is the cleanup
- function for a user entry. */
- Hash_hasher hasher;
- Hash_comparator comparator;
- Hash_data_freer data_freer;
-
- /* A linked list of freed struct hash_entry structs. */
- struct hash_entry *free_entry_list;
-
-#if USE_OBSTACK
- /* Whenever obstacks are used, it is possible to allocate all overflowed
- entries into a single stack, so they all can be freed in a single
- operation. It is not clear if the speedup is worth the trouble. */
- struct obstack entry_stack;
-#endif
- };
-
-/* A hash table contains many internal entries, each holding a pointer to
- some user-provided data (also called a user entry). An entry indistinctly
- refers to both the internal entry and its associated user entry. A user
- entry contents may be hashed by a randomization function (the hashing
- function, or just "hasher" for short) into a number (or "slot") between 0
- and the current table size. At each slot position in the hash table,
- starts a linked chain of entries for which the user data all hash to this
- slot. A bucket is the collection of all entries hashing to the same slot.
-
- A good "hasher" function will distribute entries rather evenly in buckets.
- In the ideal case, the length of each bucket is roughly the number of
- entries divided by the table size. Finding the slot for a data is usually
- done in constant time by the "hasher", and the later finding of a precise
- entry is linear in time with the size of the bucket. Consequently, a
- larger hash table size (that is, a larger number of buckets) is prone to
- yielding shorter chains, *given* the "hasher" function behaves properly.
-
- Long buckets slow down the lookup algorithm. One might use big hash table
- sizes in hope to reduce the average length of buckets, but this might
- become inordinate, as unused slots in the hash table take some space. The
- best bet is to make sure you are using a good "hasher" function (beware
- that those are not that easy to write! :-), and to use a table size
- larger than the actual number of entries. */
-
-/* If an insertion makes the ratio of nonempty buckets to table size larger
- than the growth threshold (a number between 0.0 and 1.0), then increase
- the table size by multiplying by the growth factor (a number greater than
- 1.0). The growth threshold defaults to 0.8, and the growth factor
- defaults to 1.414, meaning that the table will have doubled its size
- every second time 80% of the buckets get used. */
-#define DEFAULT_GROWTH_THRESHOLD 0.8f
-#define DEFAULT_GROWTH_FACTOR 1.414f
-
-/* If a deletion empties a bucket and causes the ratio of used buckets to
- table size to become smaller than the shrink threshold (a number between
- 0.0 and 1.0), then shrink the table by multiplying by the shrink factor (a
- number greater than the shrink threshold but smaller than 1.0). The shrink
- threshold and factor default to 0.0 and 1.0, meaning that the table never
- shrinks. */
-#define DEFAULT_SHRINK_THRESHOLD 0.0f
-#define DEFAULT_SHRINK_FACTOR 1.0f
-
-/* Use this to initialize or reset a TUNING structure to
- some sensible values. */
-static const Hash_tuning default_tuning =
- {
- DEFAULT_SHRINK_THRESHOLD,
- DEFAULT_SHRINK_FACTOR,
- DEFAULT_GROWTH_THRESHOLD,
- DEFAULT_GROWTH_FACTOR,
- false
- };
-
-/* Information and lookup. */
-
-/* The following few functions provide information about the overall hash
- table organization: the number of entries, number of buckets and maximum
- length of buckets. */
-
-/* Return the number of buckets in the hash table. The table size, the total
- number of buckets (used plus unused), or the maximum number of slots, are
- the same quantity. */
-
-size_t
-hash_get_n_buckets (const Hash_table *table)
-{
- return table->n_buckets;
-}
-
-/* Return the number of slots in use (non-empty buckets). */
-
-size_t
-hash_get_n_buckets_used (const Hash_table *table)
-{
- return table->n_buckets_used;
-}
-
-/* Return the number of active entries. */
-
-size_t
-hash_get_n_entries (const Hash_table *table)
-{
- return table->n_entries;
-}
-
-/* Return the length of the longest chain (bucket). */
-
-size_t
-hash_get_max_bucket_length (const Hash_table *table)
-{
- struct hash_entry const *bucket;
- size_t max_bucket_length = 0;
-
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- {
- if (bucket->data)
- {
- struct hash_entry const *cursor = bucket;
- size_t bucket_length = 1;
-
- while (cursor = cursor->next, cursor)
- bucket_length++;
-
- if (bucket_length > max_bucket_length)
- max_bucket_length = bucket_length;
- }
- }
-
- return max_bucket_length;
-}
-
-/* Do a mild validation of a hash table, by traversing it and checking two
- statistics. */
-
-bool
-hash_table_ok (const Hash_table *table)
-{
- struct hash_entry const *bucket;
- size_t n_buckets_used = 0;
- size_t n_entries = 0;
-
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- {
- if (bucket->data)
- {
- struct hash_entry const *cursor = bucket;
-
- /* Count bucket head. */
- n_buckets_used++;
- n_entries++;
-
- /* Count bucket overflow. */
- while (cursor = cursor->next, cursor)
- n_entries++;
- }
- }
-
- if (n_buckets_used == table->n_buckets_used && n_entries == table->n_entries)
- return true;
-
- return false;
-}
-
-void
-hash_print_statistics (const Hash_table *table, FILE *stream)
-{
- size_t n_entries = hash_get_n_entries (table);
- size_t n_buckets = hash_get_n_buckets (table);
- size_t n_buckets_used = hash_get_n_buckets_used (table);
- size_t max_bucket_length = hash_get_max_bucket_length (table);
-
- fprintf (stream, "# entries: %lu\n", (unsigned long int) n_entries);
- fprintf (stream, "# buckets: %lu\n", (unsigned long int) n_buckets);
- fprintf (stream, "# buckets used: %lu (%.2f%%)\n",
- (unsigned long int) n_buckets_used,
- (100.0 * n_buckets_used) / n_buckets);
- fprintf (stream, "max bucket length: %lu\n",
- (unsigned long int) max_bucket_length);
-}
-
-/* Hash KEY and return a pointer to the selected bucket.
- If TABLE->hasher misbehaves, abort. */
-static struct hash_entry *
-safe_hasher (const Hash_table *table, const void *key)
-{
- size_t n = table->hasher (key, table->n_buckets);
- if (! (n < table->n_buckets))
- abort ();
- return table->bucket + n;
-}
-
-/* If ENTRY matches an entry already in the hash table, return the
- entry from the table. Otherwise, return NULL. */
-
-void *
-hash_lookup (const Hash_table *table, const void *entry)
-{
- struct hash_entry const *bucket = safe_hasher (table, entry);
- struct hash_entry const *cursor;
-
- if (bucket->data == NULL)
- return NULL;
-
- for (cursor = bucket; cursor; cursor = cursor->next)
- if (entry == cursor->data || table->comparator (entry, cursor->data))
- return cursor->data;
-
- return NULL;
-}
-
-/* Walking. */
-
-/* The functions in this page traverse the hash table and process the
- contained entries. For the traversal to work properly, the hash table
- should not be resized nor modified while any particular entry is being
- processed. In particular, entries should not be added, and an entry
- may be removed only if there is no shrink threshold and the entry being
- removed has already been passed to hash_get_next. */
-
-/* Return the first data in the table, or NULL if the table is empty. */
-
-void *
-hash_get_first (const Hash_table *table)
-{
- struct hash_entry const *bucket;
-
- if (table->n_entries == 0)
- return NULL;
-
- for (bucket = table->bucket; ; bucket++)
- if (! (bucket < table->bucket_limit))
- abort ();
- else if (bucket->data)
- return bucket->data;
-}
-
-/* Return the user data for the entry following ENTRY, where ENTRY has been
- returned by a previous call to either 'hash_get_first' or 'hash_get_next'.
- Return NULL if there are no more entries. */
-
-void *
-hash_get_next (const Hash_table *table, const void *entry)
-{
- struct hash_entry const *bucket = safe_hasher (table, entry);
- struct hash_entry const *cursor;
-
- /* Find next entry in the same bucket. */
- cursor = bucket;
- do
- {
- if (cursor->data == entry && cursor->next)
- return cursor->next->data;
- cursor = cursor->next;
- }
- while (cursor != NULL);
-
- /* Find first entry in any subsequent bucket. */
- while (++bucket < table->bucket_limit)
- if (bucket->data)
- return bucket->data;
-
- /* None found. */
- return NULL;
-}
-
-/* Fill BUFFER with pointers to active user entries in the hash table, then
- return the number of pointers copied. Do not copy more than BUFFER_SIZE
- pointers. */
-
-size_t
-hash_get_entries (const Hash_table *table, void **buffer,
- size_t buffer_size)
-{
- size_t counter = 0;
- struct hash_entry const *bucket;
- struct hash_entry const *cursor;
-
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- {
- if (bucket->data)
- {
- for (cursor = bucket; cursor; cursor = cursor->next)
- {
- if (counter >= buffer_size)
- return counter;
- buffer[counter++] = cursor->data;
- }
- }
- }
-
- return counter;
-}
-
-/* Call a PROCESSOR function for each entry of a hash table, and return the
- number of entries for which the processor function returned success. A
- pointer to some PROCESSOR_DATA which will be made available to each call to
- the processor function. The PROCESSOR accepts two arguments: the first is
- the user entry being walked into, the second is the value of PROCESSOR_DATA
- as received. The walking continue for as long as the PROCESSOR function
- returns nonzero. When it returns zero, the walking is interrupted. */
-
-size_t
-hash_do_for_each (const Hash_table *table, Hash_processor processor,
- void *processor_data)
-{
- size_t counter = 0;
- struct hash_entry const *bucket;
- struct hash_entry const *cursor;
-
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- {
- if (bucket->data)
- {
- for (cursor = bucket; cursor; cursor = cursor->next)
- {
- if (! processor (cursor->data, processor_data))
- return counter;
- counter++;
- }
- }
- }
-
- return counter;
-}
-
-/* Allocation and clean-up. */
-
-/* Return a hash index for a NUL-terminated STRING between 0 and N_BUCKETS-1.
- This is a convenience routine for constructing other hashing functions. */
-
-#if USE_DIFF_HASH
-
-/* About hashings, Paul Eggert writes to me (FP), on 1994-01-01: "Please see
- B. J. McKenzie, R. Harries & T. Bell, Selecting a hashing algorithm,
- Software--practice & experience 20, 2 (Feb 1990), 209-224. Good hash
- algorithms tend to be domain-specific, so what's good for [diffutils'] io.c
- may not be good for your application." */
-
-size_t
-hash_string (const char *string, size_t n_buckets)
-{
-# define HASH_ONE_CHAR(Value, Byte) \
- ((Byte) + rotl_sz (Value, 7))
-
- size_t value = 0;
- unsigned char ch;
-
- for (; (ch = *string); string++)
- value = HASH_ONE_CHAR (value, ch);
- return value % n_buckets;
-
-# undef HASH_ONE_CHAR
-}
-
-#else /* not USE_DIFF_HASH */
-
-/* This one comes from 'recode', and performs a bit better than the above as
- per a few experiments. It is inspired from a hashing routine found in the
- very old Cyber 'snoop', itself written in typical Greg Mansfield style.
- (By the way, what happened to this excellent man? Is he still alive?) */
-
-size_t
-hash_string (const char *string, size_t n_buckets)
-{
- size_t value = 0;
- unsigned char ch;
-
- for (; (ch = *string); string++)
- value = (value * 31 + ch) % n_buckets;
- return value;
-}
-
-#endif /* not USE_DIFF_HASH */
-
-/* Return true if CANDIDATE is a prime number. CANDIDATE should be an odd
- number at least equal to 11. */
-
-static bool _GL_ATTRIBUTE_CONST
-is_prime (size_t candidate)
-{
- size_t divisor = 3;
- size_t square = divisor * divisor;
-
- while (square < candidate && (candidate % divisor))
- {
- divisor++;
- square += 4 * divisor;
- divisor++;
- }
-
- return (candidate % divisor ? true : false);
-}
-
-/* Round a given CANDIDATE number up to the nearest prime, and return that
- prime. Primes lower than 10 are merely skipped. */
-
-static size_t _GL_ATTRIBUTE_CONST
-next_prime (size_t candidate)
-{
- /* Skip small primes. */
- if (candidate < 10)
- candidate = 10;
-
- /* Make it definitely odd. */
- candidate |= 1;
-
- while (SIZE_MAX != candidate && !is_prime (candidate))
- candidate += 2;
-
- return candidate;
-}
-
-void
-hash_reset_tuning (Hash_tuning *tuning)
-{
- *tuning = default_tuning;
-}
-
-/* If the user passes a NULL hasher, we hash the raw pointer. */
-static size_t
-raw_hasher (const void *data, size_t n)
-{
- /* When hashing unique pointers, it is often the case that they were
- generated by malloc and thus have the property that the low-order
- bits are 0. As this tends to give poorer performance with small
- tables, we rotate the pointer value before performing division,
- in an attempt to improve hash quality. */
- size_t val = rotr_sz ((size_t) data, 3);
- return val % n;
-}
-
-/* If the user passes a NULL comparator, we use pointer comparison. */
-static bool
-raw_comparator (const void *a, const void *b)
-{
- return a == b;
-}
-
-
-/* For the given hash TABLE, check the user supplied tuning structure for
- reasonable values, and return true if there is no gross error with it.
- Otherwise, definitively reset the TUNING field to some acceptable default
- in the hash table (that is, the user loses the right of further modifying
- tuning arguments), and return false. */
-
-static bool
-check_tuning (Hash_table *table)
-{
- const Hash_tuning *tuning = table->tuning;
- float epsilon;
- if (tuning == &default_tuning)
- return true;
-
- /* Be a bit stricter than mathematics would require, so that
- rounding errors in size calculations do not cause allocations to
- fail to grow or shrink as they should. The smallest allocation
- is 11 (due to next_prime's algorithm), so an epsilon of 0.1
- should be good enough. */
- epsilon = 0.1f;
-
- if (epsilon < tuning->growth_threshold
- && tuning->growth_threshold < 1 - epsilon
- && 1 + epsilon < tuning->growth_factor
- && 0 <= tuning->shrink_threshold
- && tuning->shrink_threshold + epsilon < tuning->shrink_factor
- && tuning->shrink_factor <= 1
- && tuning->shrink_threshold + epsilon < tuning->growth_threshold)
- return true;
-
- table->tuning = &default_tuning;
- return false;
-}
-
-/* Compute the size of the bucket array for the given CANDIDATE and
- TUNING, or return 0 if there is no possible way to allocate that
- many entries. */
-
-static size_t _GL_ATTRIBUTE_PURE
-compute_bucket_size (size_t candidate, const Hash_tuning *tuning)
-{
- if (!tuning->is_n_buckets)
- {
- float new_candidate = candidate / tuning->growth_threshold;
- if (SIZE_MAX <= new_candidate)
- return 0;
- candidate = new_candidate;
- }
- candidate = next_prime (candidate);
- if (xalloc_oversized (candidate, sizeof (struct hash_entry *)))
- return 0;
- return candidate;
-}
-
-/* Allocate and return a new hash table, or NULL upon failure. The initial
- number of buckets is automatically selected so as to _guarantee_ that you
- may insert at least CANDIDATE different user entries before any growth of
- the hash table size occurs. So, if have a reasonably tight a-priori upper
- bound on the number of entries you intend to insert in the hash table, you
- may save some table memory and insertion time, by specifying it here. If
- the IS_N_BUCKETS field of the TUNING structure is true, the CANDIDATE
- argument has its meaning changed to the wanted number of buckets.
-
- TUNING points to a structure of user-supplied values, in case some fine
- tuning is wanted over the default behavior of the hasher. If TUNING is
- NULL, the default tuning parameters are used instead. If TUNING is
- provided but the values requested are out of bounds or might cause
- rounding errors, return NULL.
-
- The user-supplied HASHER function, when not NULL, accepts two
- arguments ENTRY and TABLE_SIZE. It computes, by hashing ENTRY contents, a
- slot number for that entry which should be in the range 0..TABLE_SIZE-1.
- This slot number is then returned.
-
- The user-supplied COMPARATOR function, when not NULL, accepts two
- arguments pointing to user data, it then returns true for a pair of entries
- that compare equal, or false otherwise. This function is internally called
- on entries which are already known to hash to the same bucket index,
- but which are distinct pointers.
-
- The user-supplied DATA_FREER function, when not NULL, may be later called
- with the user data as an argument, just before the entry containing the
- data gets freed. This happens from within 'hash_free' or 'hash_clear'.
- You should specify this function only if you want these functions to free
- all of your 'data' data. This is typically the case when your data is
- simply an auxiliary struct that you have malloc'd to aggregate several
- values. */
-
-Hash_table *
-hash_initialize (size_t candidate, const Hash_tuning *tuning,
- Hash_hasher hasher, Hash_comparator comparator,
- Hash_data_freer data_freer)
-{
- Hash_table *table;
-
- if (hasher == NULL)
- hasher = raw_hasher;
- if (comparator == NULL)
- comparator = raw_comparator;
-
- table = malloc (sizeof *table);
- if (table == NULL)
- return NULL;
-
- if (!tuning)
- tuning = &default_tuning;
- table->tuning = tuning;
- if (!check_tuning (table))
- {
- /* Fail if the tuning options are invalid. This is the only occasion
- when the user gets some feedback about it. Once the table is created,
- if the user provides invalid tuning options, we silently revert to
- using the defaults, and ignore further request to change the tuning
- options. */
- goto fail;
- }
-
- table->n_buckets = compute_bucket_size (candidate, tuning);
- if (!table->n_buckets)
- goto fail;
-
- table->bucket = calloc (table->n_buckets, sizeof *table->bucket);
- if (table->bucket == NULL)
- goto fail;
- table->bucket_limit = table->bucket + table->n_buckets;
- table->n_buckets_used = 0;
- table->n_entries = 0;
-
- table->hasher = hasher;
- table->comparator = comparator;
- table->data_freer = data_freer;
-
- table->free_entry_list = NULL;
-#if USE_OBSTACK
- obstack_init (&table->entry_stack);
-#endif
- return table;
-
- fail:
- free (table);
- return NULL;
-}
-
-/* Make all buckets empty, placing any chained entries on the free list.
- Apply the user-specified function data_freer (if any) to the datas of any
- affected entries. */
-
-void
-hash_clear (Hash_table *table)
-{
- struct hash_entry *bucket;
-
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- {
- if (bucket->data)
- {
- struct hash_entry *cursor;
- struct hash_entry *next;
-
- /* Free the bucket overflow. */
- for (cursor = bucket->next; cursor; cursor = next)
- {
- if (table->data_freer)
- table->data_freer (cursor->data);
- cursor->data = NULL;
-
- next = cursor->next;
- /* Relinking is done one entry at a time, as it is to be expected
- that overflows are either rare or short. */
- cursor->next = table->free_entry_list;
- table->free_entry_list = cursor;
- }
-
- /* Free the bucket head. */
- if (table->data_freer)
- table->data_freer (bucket->data);
- bucket->data = NULL;
- bucket->next = NULL;
- }
- }
-
- table->n_buckets_used = 0;
- table->n_entries = 0;
-}
-
-/* Reclaim all storage associated with a hash table. If a data_freer
- function has been supplied by the user when the hash table was created,
- this function applies it to the data of each entry before freeing that
- entry. */
-
-void
-hash_free (Hash_table *table)
-{
- struct hash_entry *bucket;
- struct hash_entry *cursor;
- struct hash_entry *next;
-
- /* Call the user data_freer function. */
- if (table->data_freer && table->n_entries)
- {
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- {
- if (bucket->data)
- {
- for (cursor = bucket; cursor; cursor = cursor->next)
- table->data_freer (cursor->data);
- }
- }
- }
-
-#if USE_OBSTACK
-
- obstack_free (&table->entry_stack, NULL);
-
-#else
-
- /* Free all bucket overflowed entries. */
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- {
- for (cursor = bucket->next; cursor; cursor = next)
- {
- next = cursor->next;
- free (cursor);
- }
- }
-
- /* Also reclaim the internal list of previously freed entries. */
- for (cursor = table->free_entry_list; cursor; cursor = next)
- {
- next = cursor->next;
- free (cursor);
- }
-
-#endif
-
- /* Free the remainder of the hash table structure. */
- free (table->bucket);
- free (table);
-}
-
-/* Insertion and deletion. */
-
-/* Get a new hash entry for a bucket overflow, possibly by recycling a
- previously freed one. If this is not possible, allocate a new one. */
-
-static struct hash_entry *
-allocate_entry (Hash_table *table)
-{
- struct hash_entry *new;
-
- if (table->free_entry_list)
- {
- new = table->free_entry_list;
- table->free_entry_list = new->next;
- }
- else
- {
-#if USE_OBSTACK
- new = obstack_alloc (&table->entry_stack, sizeof *new);
-#else
- new = malloc (sizeof *new);
-#endif
- }
-
- return new;
-}
-
-/* Free a hash entry which was part of some bucket overflow,
- saving it for later recycling. */
-
-static void
-free_entry (Hash_table *table, struct hash_entry *entry)
-{
- entry->data = NULL;
- entry->next = table->free_entry_list;
- table->free_entry_list = entry;
-}
-
-/* This private function is used to help with insertion and deletion. When
- ENTRY matches an entry in the table, return a pointer to the corresponding
- user data and set *BUCKET_HEAD to the head of the selected bucket.
- Otherwise, return NULL. When DELETE is true and ENTRY matches an entry in
- the table, unlink the matching entry. */
-
-static void *
-hash_find_entry (Hash_table *table, const void *entry,
- struct hash_entry **bucket_head, bool delete)
-{
- struct hash_entry *bucket = safe_hasher (table, entry);
- struct hash_entry *cursor;
-
- *bucket_head = bucket;
-
- /* Test for empty bucket. */
- if (bucket->data == NULL)
- return NULL;
-
- /* See if the entry is the first in the bucket. */
- if (entry == bucket->data || table->comparator (entry, bucket->data))
- {
- void *data = bucket->data;
-
- if (delete)
- {
- if (bucket->next)
- {
- struct hash_entry *next = bucket->next;
-
- /* Bump the first overflow entry into the bucket head, then save
- the previous first overflow entry for later recycling. */
- *bucket = *next;
- free_entry (table, next);
- }
- else
- {
- bucket->data = NULL;
- }
- }
-
- return data;
- }
-
- /* Scan the bucket overflow. */
- for (cursor = bucket; cursor->next; cursor = cursor->next)
- {
- if (entry == cursor->next->data
- || table->comparator (entry, cursor->next->data))
- {
- void *data = cursor->next->data;
-
- if (delete)
- {
- struct hash_entry *next = cursor->next;
-
- /* Unlink the entry to delete, then save the freed entry for later
- recycling. */
- cursor->next = next->next;
- free_entry (table, next);
- }
-
- return data;
- }
- }
-
- /* No entry found. */
- return NULL;
-}
-
-/* Internal helper, to move entries from SRC to DST. Both tables must
- share the same free entry list. If SAFE, only move overflow
- entries, saving bucket heads for later, so that no allocations will
- occur. Return false if the free entry list is exhausted and an
- allocation fails. */
-
-static bool
-transfer_entries (Hash_table *dst, Hash_table *src, bool safe)
-{
- struct hash_entry *bucket;
- struct hash_entry *cursor;
- struct hash_entry *next;
- for (bucket = src->bucket; bucket < src->bucket_limit; bucket++)
- if (bucket->data)
- {
- void *data;
- struct hash_entry *new_bucket;
-
- /* Within each bucket, transfer overflow entries first and
- then the bucket head, to minimize memory pressure. After
- all, the only time we might allocate is when moving the
- bucket head, but moving overflow entries first may create
- free entries that can be recycled by the time we finally
- get to the bucket head. */
- for (cursor = bucket->next; cursor; cursor = next)
- {
- data = cursor->data;
- new_bucket = safe_hasher (dst, data);
-
- next = cursor->next;
-
- if (new_bucket->data)
- {
- /* Merely relink an existing entry, when moving from a
- bucket overflow into a bucket overflow. */
- cursor->next = new_bucket->next;
- new_bucket->next = cursor;
- }
- else
- {
- /* Free an existing entry, when moving from a bucket
- overflow into a bucket header. */
- new_bucket->data = data;
- dst->n_buckets_used++;
- free_entry (dst, cursor);
- }
- }
- /* Now move the bucket head. Be sure that if we fail due to
- allocation failure that the src table is in a consistent
- state. */
- data = bucket->data;
- bucket->next = NULL;
- if (safe)
- continue;
- new_bucket = safe_hasher (dst, data);
-
- if (new_bucket->data)
- {
- /* Allocate or recycle an entry, when moving from a bucket
- header into a bucket overflow. */
- struct hash_entry *new_entry = allocate_entry (dst);
-
- if (new_entry == NULL)
- return false;
-
- new_entry->data = data;
- new_entry->next = new_bucket->next;
- new_bucket->next = new_entry;
- }
- else
- {
- /* Move from one bucket header to another. */
- new_bucket->data = data;
- dst->n_buckets_used++;
- }
- bucket->data = NULL;
- src->n_buckets_used--;
- }
- return true;
-}
-
-/* For an already existing hash table, change the number of buckets through
- specifying CANDIDATE. The contents of the hash table are preserved. The
- new number of buckets is automatically selected so as to _guarantee_ that
- the table may receive at least CANDIDATE different user entries, including
- those already in the table, before any other growth of the hash table size
- occurs. If TUNING->IS_N_BUCKETS is true, then CANDIDATE specifies the
- exact number of buckets desired. Return true iff the rehash succeeded. */
-
-bool
-hash_rehash (Hash_table *table, size_t candidate)
-{
- Hash_table storage;
- Hash_table *new_table;
- size_t new_size = compute_bucket_size (candidate, table->tuning);
-
- if (!new_size)
- return false;
- if (new_size == table->n_buckets)
- return true;
- new_table = &storage;
- new_table->bucket = calloc (new_size, sizeof *new_table->bucket);
- if (new_table->bucket == NULL)
- return false;
- new_table->n_buckets = new_size;
- new_table->bucket_limit = new_table->bucket + new_size;
- new_table->n_buckets_used = 0;
- new_table->n_entries = 0;
- new_table->tuning = table->tuning;
- new_table->hasher = table->hasher;
- new_table->comparator = table->comparator;
- new_table->data_freer = table->data_freer;
-
- /* In order for the transfer to successfully complete, we need
- additional overflow entries when distinct buckets in the old
- table collide into a common bucket in the new table. The worst
- case possible is a hasher that gives a good spread with the old
- size, but returns a constant with the new size; if we were to
- guarantee table->n_buckets_used-1 free entries in advance, then
- the transfer would be guaranteed to not allocate memory.
- However, for large tables, a guarantee of no further allocation
- introduces a lot of extra memory pressure, all for an unlikely
- corner case (most rehashes reduce, rather than increase, the
- number of overflow entries needed). So, we instead ensure that
- the transfer process can be reversed if we hit a memory
- allocation failure mid-transfer. */
-
- /* Merely reuse the extra old space into the new table. */
-#if USE_OBSTACK
- new_table->entry_stack = table->entry_stack;
-#endif
- new_table->free_entry_list = table->free_entry_list;
-
- if (transfer_entries (new_table, table, false))
- {
- /* Entries transferred successfully; tie up the loose ends. */
- free (table->bucket);
- table->bucket = new_table->bucket;
- table->bucket_limit = new_table->bucket_limit;
- table->n_buckets = new_table->n_buckets;
- table->n_buckets_used = new_table->n_buckets_used;
- table->free_entry_list = new_table->free_entry_list;
- /* table->n_entries and table->entry_stack already hold their value. */
- return true;
- }
-
- /* We've allocated new_table->bucket (and possibly some entries),
- exhausted the free list, and moved some but not all entries into
- new_table. We must undo the partial move before returning
- failure. The only way to get into this situation is if new_table
- uses fewer buckets than the old table, so we will reclaim some
- free entries as overflows in the new table are put back into
- distinct buckets in the old table.
-
- There are some pathological cases where a single pass through the
- table requires more intermediate overflow entries than using two
- passes. Two passes give worse cache performance and takes
- longer, but at this point, we're already out of memory, so slow
- and safe is better than failure. */
- table->free_entry_list = new_table->free_entry_list;
- if (! (transfer_entries (table, new_table, true)
- && transfer_entries (table, new_table, false)))
- abort ();
- /* table->n_entries already holds its value. */
- free (new_table->bucket);
- return false;
-}
-
-/* Insert ENTRY into hash TABLE if there is not already a matching entry.
-
- Return -1 upon memory allocation failure.
- Return 1 if insertion succeeded.
- Return 0 if there is already a matching entry in the table,
- and in that case, if MATCHED_ENT is non-NULL, set *MATCHED_ENT
- to that entry.
-
- This interface is easier to use than hash_insert when you must
- distinguish between the latter two cases. More importantly,
- hash_insert is unusable for some types of ENTRY values. When using
- hash_insert, the only way to distinguish those cases is to compare
- the return value and ENTRY. That works only when you can have two
- different ENTRY values that point to data that compares "equal". Thus,
- when the ENTRY value is a simple scalar, you must use
- hash_insert_if_absent. ENTRY must not be NULL. */
-int
-hash_insert_if_absent (Hash_table *table, void const *entry,
- void const **matched_ent)
-{
- void *data;
- struct hash_entry *bucket;
-
- /* The caller cannot insert a NULL entry, since hash_lookup returns NULL
- to indicate "not found", and hash_find_entry uses "bucket->data == NULL"
- to indicate an empty bucket. */
- if (! entry)
- abort ();
-
- /* If there's a matching entry already in the table, return that. */
- if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL)
- {
- if (matched_ent)
- *matched_ent = data;
- return 0;
- }
-
- /* If the growth threshold of the buckets in use has been reached, increase
- the table size and rehash. There's no point in checking the number of
- entries: if the hashing function is ill-conditioned, rehashing is not
- likely to improve it. */
-
- if (table->n_buckets_used
- > table->tuning->growth_threshold * table->n_buckets)
- {
- /* Check more fully, before starting real work. If tuning arguments
- became invalid, the second check will rely on proper defaults. */
- check_tuning (table);
- if (table->n_buckets_used
- > table->tuning->growth_threshold * table->n_buckets)
- {
- const Hash_tuning *tuning = table->tuning;
- float candidate =
- (tuning->is_n_buckets
- ? (table->n_buckets * tuning->growth_factor)
- : (table->n_buckets * tuning->growth_factor
- * tuning->growth_threshold));
-
- if (SIZE_MAX <= candidate)
- return -1;
-
- /* If the rehash fails, arrange to return NULL. */
- if (!hash_rehash (table, candidate))
- return -1;
-
- /* Update the bucket we are interested in. */
- if (hash_find_entry (table, entry, &bucket, false) != NULL)
- abort ();
- }
- }
-
- /* ENTRY is not matched, it should be inserted. */
-
- if (bucket->data)
- {
- struct hash_entry *new_entry = allocate_entry (table);
-
- if (new_entry == NULL)
- return -1;
-
- /* Add ENTRY in the overflow of the bucket. */
-
- new_entry->data = (void *) entry;
- new_entry->next = bucket->next;
- bucket->next = new_entry;
- table->n_entries++;
- return 1;
- }
-
- /* Add ENTRY right in the bucket head. */
-
- bucket->data = (void *) entry;
- table->n_entries++;
- table->n_buckets_used++;
-
- return 1;
-}
-
-/* hash_insert0 is the deprecated name for hash_insert_if_absent.
- . */
-int
-hash_insert0 (Hash_table *table, void const *entry, void const **matched_ent)
-{
- return hash_insert_if_absent (table, entry, matched_ent);
-}
-
-/* If ENTRY matches an entry already in the hash table, return the pointer
- to the entry from the table. Otherwise, insert ENTRY and return ENTRY.
- Return NULL if the storage required for insertion cannot be allocated.
- This implementation does not support duplicate entries or insertion of
- NULL. */
-
-void *
-hash_insert (Hash_table *table, void const *entry)
-{
- void const *matched_ent;
- int err = hash_insert_if_absent (table, entry, &matched_ent);
- return (err == -1
- ? NULL
- : (void *) (err == 0 ? matched_ent : entry));
-}
-
-/* If ENTRY is already in the table, remove it and return the just-deleted
- data (the user may want to deallocate its storage). If ENTRY is not in the
- table, don't modify the table and return NULL. */
-
-void *
-hash_delete (Hash_table *table, const void *entry)
-{
- void *data;
- struct hash_entry *bucket;
-
- data = hash_find_entry (table, entry, &bucket, true);
- if (!data)
- return NULL;
-
- table->n_entries--;
- if (!bucket->data)
- {
- table->n_buckets_used--;
-
- /* If the shrink threshold of the buckets in use has been reached,
- rehash into a smaller table. */
-
- if (table->n_buckets_used
- < table->tuning->shrink_threshold * table->n_buckets)
- {
- /* Check more fully, before starting real work. If tuning arguments
- became invalid, the second check will rely on proper defaults. */
- check_tuning (table);
- if (table->n_buckets_used
- < table->tuning->shrink_threshold * table->n_buckets)
- {
- const Hash_tuning *tuning = table->tuning;
- size_t candidate =
- (tuning->is_n_buckets
- ? table->n_buckets * tuning->shrink_factor
- : (table->n_buckets * tuning->shrink_factor
- * tuning->growth_threshold));
-
- if (!hash_rehash (table, candidate))
- {
- /* Failure to allocate memory in an attempt to
- shrink the table is not fatal. But since memory
- is low, we can at least be kind and free any
- spare entries, rather than keeping them tied up
- in the free entry list. */
-#if ! USE_OBSTACK
- struct hash_entry *cursor = table->free_entry_list;
- struct hash_entry *next;
- while (cursor)
- {
- next = cursor->next;
- free (cursor);
- cursor = next;
- }
- table->free_entry_list = NULL;
-#endif
- }
- }
- }
- }
-
- return data;
-}
-
-/* Testing. */
-
-#if TESTING
-
-void
-hash_print (const Hash_table *table)
-{
- struct hash_entry *bucket = (struct hash_entry *) table->bucket;
-
- for ( ; bucket < table->bucket_limit; bucket++)
- {
- struct hash_entry *cursor;
-
- if (bucket)
- printf ("%lu:\n", (unsigned long int) (bucket - table->bucket));
-
- for (cursor = bucket; cursor; cursor = cursor->next)
- {
- char const *s = cursor->data;
- /* FIXME */
- if (s)
- printf (" %s\n", s);
- }
- }
-}
-
-#endif /* TESTING */
diff --git a/contrib/tools/m4/lib/hash.h b/contrib/tools/m4/lib/hash.h
deleted file mode 100644
index bcd0d1d96b..0000000000
--- a/contrib/tools/m4/lib/hash.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* hash - hashing table processing.
- Copyright (C) 1998-1999, 2001, 2003, 2009-2013 Free Software Foundation,
- Inc.
- Written by Jim Meyering <meyering@ascend.com>, 1998.
-
- 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/>. */
-
-/* A generic hash table package. */
-
-/* Make sure USE_OBSTACK is defined to 1 if you want the allocator to use
- obstacks instead of malloc, and recompile 'hash.c' with same setting. */
-
-#ifndef HASH_H_
-# define HASH_H_
-
-# include <stdio.h>
-# include <stdbool.h>
-
-/* The __attribute__ feature is available in gcc versions 2.5 and later.
- The warn_unused_result attribute appeared first in gcc-3.4.0. */
-# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-# define _GL_ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__))
-# else
-# define _GL_ATTRIBUTE_WUR /* empty */
-# endif
-
-# ifndef _GL_ATTRIBUTE_DEPRECATED
-/* The __attribute__((__deprecated__)) feature
- is available in gcc versions 3.1 and newer. */
-# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
-# define _GL_ATTRIBUTE_DEPRECATED /* empty */
-# else
-# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
-# endif
-# endif
-
-typedef size_t (*Hash_hasher) (const void *, size_t);
-typedef bool (*Hash_comparator) (const void *, const void *);
-typedef void (*Hash_data_freer) (void *);
-typedef bool (*Hash_processor) (void *, void *);
-
-struct hash_tuning
- {
- /* This structure is mainly used for 'hash_initialize', see the block
- documentation of 'hash_reset_tuning' for more complete comments. */
-
- float shrink_threshold; /* ratio of used buckets to trigger a shrink */
- float shrink_factor; /* ratio of new smaller size to original size */
- float growth_threshold; /* ratio of used buckets to trigger a growth */
- float growth_factor; /* ratio of new bigger size to original size */
- bool is_n_buckets; /* if CANDIDATE really means table size */
- };
-
-typedef struct hash_tuning Hash_tuning;
-
-struct hash_table;
-
-typedef struct hash_table Hash_table;
-
-/* Information and lookup. */
-size_t hash_get_n_buckets (const Hash_table *) _GL_ATTRIBUTE_PURE;
-size_t hash_get_n_buckets_used (const Hash_table *) _GL_ATTRIBUTE_PURE;
-size_t hash_get_n_entries (const Hash_table *) _GL_ATTRIBUTE_PURE;
-size_t hash_get_max_bucket_length (const Hash_table *) _GL_ATTRIBUTE_PURE;
-bool hash_table_ok (const Hash_table *) _GL_ATTRIBUTE_PURE;
-void hash_print_statistics (const Hash_table *, FILE *);
-void *hash_lookup (const Hash_table *, const void *);
-
-/* Walking. */
-void *hash_get_first (const Hash_table *) _GL_ATTRIBUTE_PURE;
-void *hash_get_next (const Hash_table *, const void *);
-size_t hash_get_entries (const Hash_table *, void **, size_t);
-size_t hash_do_for_each (const Hash_table *, Hash_processor, void *);
-
-/* Allocation and clean-up. */
-size_t hash_string (const char *, size_t) _GL_ATTRIBUTE_PURE;
-void hash_reset_tuning (Hash_tuning *);
-Hash_table *hash_initialize (size_t, const Hash_tuning *,
- Hash_hasher, Hash_comparator,
- Hash_data_freer) _GL_ATTRIBUTE_WUR;
-void hash_clear (Hash_table *);
-void hash_free (Hash_table *);
-
-/* Insertion and deletion. */
-bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_WUR;
-void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_WUR;
-
-/* Deprecate this interface. It has been renamed to hash_insert_if_absent. */
-int hash_insert0 (Hash_table *table, /* FIXME: remove in 2013 */
- const void *entry,
- const void **matched_ent) _GL_ATTRIBUTE_DEPRECATED;
-int hash_insert_if_absent (Hash_table *table, const void *entry,
- const void **matched_ent);
-void *hash_delete (Hash_table *, const void *);
-
-#endif
diff --git a/contrib/tools/m4/lib/intprops.h b/contrib/tools/m4/lib/intprops.h
deleted file mode 100644
index f57f9b4dda..0000000000
--- a/contrib/tools/m4/lib/intprops.h
+++ /dev/null
@@ -1,319 +0,0 @@
-/* intprops.h -- properties of integer types
-
- Copyright (C) 2001-2005, 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 Paul Eggert. */
-
-#ifndef _GL_INTPROPS_H
-#define _GL_INTPROPS_H
-
-#include <limits.h>
-
-/* Return an integer value, converted to the same type as the integer
- expression E after integer type promotion. V is the unconverted value. */
-#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
-
-/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
- <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
-#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
-
-/* The extra casts in the following macros work around compiler bugs,
- e.g., in Cray C 5.0.3.0. */
-
-/* True if the arithmetic type T is an integer type. bool counts as
- an integer. */
-#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
-
-/* True if negative values of the signed integer type T use two's
- complement, ones' complement, or signed magnitude representation,
- respectively. Much GNU code assumes two's complement, but some
- people like to be portable to all possible C hosts. */
-#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
-#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
-#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
-
-/* True if the signed integer expression E uses two's complement. */
-#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1)
-
-/* True if the arithmetic type T is signed. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-
-/* Return 1 if the integer expression E, after integer promotion, has
- a signed type. */
-#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
-
-
-/* Minimum and maximum values for integer types and expressions. These
- macros have undefined behavior if T is signed and has padding bits.
- If this is a problem for you, please let us know how to fix it for
- your host. */
-
-/* The maximum and minimum values for the integer type T. */
-#define TYPE_MINIMUM(t) \
- ((t) (! TYPE_SIGNED (t) \
- ? (t) 0 \
- : TYPE_SIGNED_MAGNITUDE (t) \
- ? ~ (t) 0 \
- : ~ TYPE_MAXIMUM (t)))
-#define TYPE_MAXIMUM(t) \
- ((t) (! TYPE_SIGNED (t) \
- ? (t) -1 \
- : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
-
-/* The maximum and minimum values for the type of the expression E,
- after integer promotion. E should not have side effects. */
-#define _GL_INT_MINIMUM(e) \
- (_GL_INT_SIGNED (e) \
- ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \
- : _GL_INT_CONVERT (e, 0))
-#define _GL_INT_MAXIMUM(e) \
- (_GL_INT_SIGNED (e) \
- ? _GL_SIGNED_INT_MAXIMUM (e) \
- : _GL_INT_NEGATE_CONVERT (e, 1))
-#define _GL_SIGNED_INT_MAXIMUM(e) \
- (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
-
-
-/* Return 1 if the __typeof__ keyword works. This could be done by
- 'configure', but for now it's easier to do it by hand. */
-#if 2 <= __GNUC__ || defined __IBM__TYPEOF__ || 0x5110 <= __SUNPRO_C
-# define _GL_HAVE___TYPEOF__ 1
-#else
-# define _GL_HAVE___TYPEOF__ 0
-#endif
-
-/* Return 1 if the integer type or expression T might be signed. Return 0
- if it is definitely unsigned. This macro does not evaluate its argument,
- and expands to an integer constant expression. */
-#if _GL_HAVE___TYPEOF__
-# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
-#else
-# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
-#endif
-
-/* Bound on length of the string representing an unsigned integer
- value representable in B bits. log10 (2.0) < 146/485. The
- smallest value of B where this bound is not tight is 2621. */
-#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
-
-/* Bound on length of the string representing an integer type or expression T.
- Subtract 1 for the sign bit if T is signed, and then add 1 more for
- a minus sign if needed.
-
- Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
- signed, this macro may overestimate the true bound by one byte when
- applied to unsigned types of size 2, 4, 16, ... bytes. */
-#define INT_STRLEN_BOUND(t) \
- (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \
- - _GL_SIGNED_TYPE_OR_EXPR (t)) \
- + _GL_SIGNED_TYPE_OR_EXPR (t))
-
-/* Bound on buffer size needed to represent an integer type or expression T,
- including the terminating null. */
-#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
-
-
-/* Range overflow checks.
-
- The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
- operators might not yield numerically correct answers due to
- arithmetic overflow. They do not rely on undefined or
- implementation-defined behavior. Their implementations are simple
- and straightforward, but they are a bit harder to use than the
- INT_<op>_OVERFLOW macros described below.
-
- Example usage:
-
- long int i = ...;
- long int j = ...;
- if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
- printf ("multiply would overflow");
- else
- printf ("product is %ld", i * j);
-
- Restrictions on *_RANGE_OVERFLOW macros:
-
- These macros do not check for all possible numerical problems or
- undefined or unspecified behavior: they do not check for division
- by zero, for bad shift counts, or for shifting negative numbers.
-
- These macros may evaluate their arguments zero or multiple times,
- so the arguments should not have side effects. The arithmetic
- arguments (including the MIN and MAX arguments) must be of the same
- integer type after the usual arithmetic conversions, and the type
- must have minimum value MIN and maximum MAX. Unsigned types should
- use a zero MIN of the proper type.
-
- These macros are tuned for constant MIN and MAX. For commutative
- operations such as A + B, they are also tuned for constant B. */
-
-/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? (a) < (min) - (b) \
- : (max) - (b) < (a))
-
-/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? (max) + (b) < (a) \
- : (a) < (min) + (b))
-
-/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. */
-#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
- ((min) < 0 \
- ? (a) < - (max) \
- : 0 < (a))
-
-/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Avoid && and || as they tickle
- bugs in Sun C 5.11 2010/08/13 and other compilers; see
- <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */
-#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
- ((b) < 0 \
- ? ((a) < 0 \
- ? (a) < (max) / (b) \
- : (b) == -1 \
- ? 0 \
- : (min) / (b) < (a)) \
- : (b) == 0 \
- ? 0 \
- : ((a) < 0 \
- ? (a) < (min) / (b) \
- : (max) / (b) < (a)))
-
-/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Do not check for division by zero. */
-#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
- ((min) < 0 && (b) == -1 && (a) < - (max))
-
-/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Do not check for division by zero.
- Mathematically, % should never overflow, but on x86-like hosts
- INT_MIN % -1 traps, and the C standard permits this, so treat this
- as an overflow too. */
-#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
- INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
-
-/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
- See above for restrictions. Here, MIN and MAX are for A only, and B need
- not be of the same type as the other arguments. The C standard says that
- behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
- A is negative then A << B has undefined behavior and A >> B has
- implementation-defined behavior, but do not check these other
- restrictions. */
-#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
- ((a) < 0 \
- ? (a) < (min) >> (b) \
- : (max) >> (b) < (a))
-
-
-/* The _GL*_OVERFLOW macros have the same restrictions as the
- *_RANGE_OVERFLOW macros, except that they do not assume that operands
- (e.g., A and B) have the same type as MIN and MAX. Instead, they assume
- that the result (e.g., A + B) has that type. */
-#define _GL_ADD_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? (b) <= (a) + (b) \
- : (b) < 0 ? (a) <= (a) + (b) \
- : (a) + (b) < (b))
-#define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? 1 \
- : (b) < 0 ? (a) - (b) <= (a) \
- : (a) < (b))
-#define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
- || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
-#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
- : (a) < 0 ? (b) <= (a) + (b) - 1 \
- : (b) < 0 && (a) + (b) <= (a))
-#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
- : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
- : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
-
-/* Return a nonzero value if A is a mathematical multiple of B, where
- A is unsigned, B is negative, and MAX is the maximum value of A's
- type. A's type must be the same as (A % B)'s type. Normally (A %
- -B == 0) suffices, but things get tricky if -B would overflow. */
-#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
- (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
- ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
- ? (a) \
- : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
- : (a) % - (b)) \
- == 0)
-
-
-/* Integer overflow checks.
-
- The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
- might not yield numerically correct answers due to arithmetic overflow.
- They work correctly on all known practical hosts, and do not rely
- on undefined behavior due to signed arithmetic overflow.
-
- Example usage:
-
- long int i = ...;
- long int j = ...;
- if (INT_MULTIPLY_OVERFLOW (i, j))
- printf ("multiply would overflow");
- else
- printf ("product is %ld", i * j);
-
- These macros do not check for all possible numerical problems or
- undefined or unspecified behavior: they do not check for division
- by zero, for bad shift counts, or for shifting negative numbers.
-
- These macros may evaluate their arguments zero or multiple times, so the
- arguments should not have side effects.
-
- These macros are tuned for their last argument being a constant.
-
- Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
- A % B, and A << B would overflow, respectively. */
-
-#define INT_ADD_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
-#define INT_SUBTRACT_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
-#define INT_NEGATE_OVERFLOW(a) \
- INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
-#define INT_MULTIPLY_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
-#define INT_DIVIDE_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
-#define INT_REMAINDER_OVERFLOW(a, b) \
- _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
-#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
- INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
- _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
-
-/* Return 1 if the expression A <op> B would overflow,
- where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
- assuming MIN and MAX are the minimum and maximum for the result type.
- Arguments should be free of side effects. */
-#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
- op_result_overflow (a, b, \
- _GL_INT_MINIMUM (0 * (b) + (a)), \
- _GL_INT_MAXIMUM (0 * (b) + (a)))
-
-#endif /* _GL_INTPROPS_H */
diff --git a/contrib/tools/m4/lib/malloca.h b/contrib/tools/m4/lib/malloca.h
index 8ec4465dc7..6fbe45eab6 100644
--- a/contrib/tools/m4/lib/malloca.h
+++ b/contrib/tools/m4/lib/malloca.h
@@ -18,7 +18,7 @@
#ifndef _MALLOCA_H
#define _MALLOCA_H
-#include "palloca.h"
+#include <alloca.h>
#include <stddef.h>
#include <stdlib.h>
diff --git a/contrib/tools/m4/lib/obstack.c b/contrib/tools/m4/lib/obstack.c
index 9b2883e4ac..d915449def 100644
--- a/contrib/tools/m4/lib/obstack.c
+++ b/contrib/tools/m4/lib/obstack.c
@@ -143,7 +143,7 @@ _obstack_begin (struct obstack *h,
void *(*chunkfun) (long),
void (*freefun) (void *))
{
- struct _obstack_chunk *chunk; /* points to new chunk */
+ register struct _obstack_chunk *chunk; /* points to new chunk */
if (alignment == 0)
alignment = DEFAULT_ALIGNMENT;
@@ -190,7 +190,7 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
void (*freefun) (void *, void *),
void *arg)
{
- struct _obstack_chunk *chunk; /* points to new chunk */
+ register struct _obstack_chunk *chunk; /* points to new chunk */
if (alignment == 0)
alignment = DEFAULT_ALIGNMENT;
@@ -241,11 +241,11 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
void
_obstack_newchunk (struct obstack *h, int length)
{
- struct _obstack_chunk *old_chunk = h->chunk;
- struct _obstack_chunk *new_chunk;
- long new_size;
- long obj_size = h->next_free - h->object_base;
- long i;
+ register struct _obstack_chunk *old_chunk = h->chunk;
+ register struct _obstack_chunk *new_chunk;
+ register long new_size;
+ register long obj_size = h->next_free - h->object_base;
+ register long i;
long already;
char *object_base;
@@ -318,8 +318,8 @@ int _obstack_allocated_p (struct obstack *h, void *obj);
int
_obstack_allocated_p (struct obstack *h, void *obj)
{
- struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
- struct _obstack_chunk *plp; /* point to previous chunk if any */
+ register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
+ register struct _obstack_chunk *plp; /* point to previous chunk if any */
lp = (h)->chunk;
/* We use >= rather than > since the object cannot be exactly at
@@ -341,8 +341,8 @@ _obstack_allocated_p (struct obstack *h, void *obj)
void
__obstack_free (struct obstack *h, void *obj)
{
- struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
- struct _obstack_chunk *plp; /* point to previous chunk if any */
+ register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
+ register struct _obstack_chunk *plp; /* point to previous chunk if any */
lp = h->chunk;
/* We use >= because there cannot be an object at the beginning of a chunk.
@@ -377,8 +377,8 @@ strong_alias (obstack_free, _obstack_free)
int
_obstack_memory_used (struct obstack *h)
{
- struct _obstack_chunk* lp;
- int nbytes = 0;
+ register struct _obstack_chunk* lp;
+ register int nbytes = 0;
for (lp = h->chunk; lp != 0; lp = lp->prev)
{
diff --git a/contrib/tools/m4/lib/obstack.h b/contrib/tools/m4/lib/obstack.h
index 046fc58546..7cf98edbd2 100644
--- a/contrib/tools/m4/lib/obstack.h
+++ b/contrib/tools/m4/lib/obstack.h
@@ -511,8 +511,4 @@ __extension__ \
} /* C++ */
#endif
-#if !defined(obstack_printf)
-int obstack_printf(struct obstack *obs, const char *format, ...);
-#endif
-
#endif /* obstack.h */
diff --git a/contrib/tools/m4/lib/obstack_printf.c b/contrib/tools/m4/lib/obstack_printf.c
deleted file mode 100644
index 291dcd52a4..0000000000
--- a/contrib/tools/m4/lib/obstack_printf.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Formatted output to obstacks.
- 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, 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>
-
-#include "obstack.h"
-#include "vasnprintf.h"
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-int obstack_vprintf(struct obstack *obs, const char *format, va_list args);
-
-/* Grow an obstack with formatted output. Return the number of bytes
- added to OBS. No trailing nul byte is added, and the object should
- be closed with obstack_finish before use.
-
- Upon memory allocation error, call obstack_alloc_failed_handler.
- Upon other error, return -1. */
-int
-obstack_printf (struct obstack *obs, const char *format, ...)
-{
- va_list args;
- int result;
-
- va_start (args, format);
- result = obstack_vprintf (obs, format, args);
- va_end (args);
- return result;
-}
-
-/* Grow an obstack with formatted output. Return the number of bytes
- added to OBS. No trailing nul byte is added, and the object should
- be closed with obstack_finish before use.
-
- Upon memory allocation error, call obstack_alloc_failed_handler.
- Upon other error, return -1. */
-int
-obstack_vprintf (struct obstack *obs, const char *format, va_list args)
-{
- /* If we are close to the end of the current obstack chunk, use a
- stack-allocated buffer and copy, to reduce the likelihood of a
- small-size malloc. Otherwise, print directly into the
- obstack. */
- enum { CUTOFF = 1024 };
- char buf[CUTOFF];
- char *base = obstack_next_free (obs);
- size_t len = obstack_room (obs);
- char *str;
-
- if (len < CUTOFF)
- {
- base = buf;
- len = CUTOFF;
- }
- str = vasnprintf (base, &len, format, args);
- if (!str)
- {
- if (errno == ENOMEM)
- obstack_alloc_failed_handler ();
- return -1;
- }
- if (str == base && str != buf)
- /* The output was already computed in place, but we need to
- account for its size. */
- obstack_blank_fast (obs, len);
- else
- {
- /* The output exceeded available obstack space or we used buf;
- copy the resulting string. */
- obstack_grow (obs, str, len);
- if (str != buf)
- free (str);
- }
- return len;
-}
diff --git a/contrib/tools/m4/lib/tempname.c b/contrib/tools/m4/lib/tempname.c
index 9975449a89..087b79b31f 100644
--- a/contrib/tools/m4/lib/tempname.c
+++ b/contrib/tools/m4/lib/tempname.c
@@ -54,7 +54,7 @@
#include <fcntl.h>
#include <sys/time.h>
#include <stdint.h>
-#include "unistd--.h"
+#include <unistd.h>
#include <sys/stat.h>
diff --git a/contrib/tools/m4/lib/tmpdir.c b/contrib/tools/m4/lib/tmpdir.c
index 1b3fb023a0..97fc3ff888 100644
--- a/contrib/tools/m4/lib/tmpdir.c
+++ b/contrib/tools/m4/lib/tmpdir.c
@@ -23,7 +23,7 @@
#include "tmpdir.h"
#include <stdbool.h>
-#include "stdlib--.h"
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
diff --git a/contrib/tools/m4/lib/unitypes.h b/contrib/tools/m4/lib/unitypes.h
deleted file mode 100644
index 3d7db7510d..0000000000
--- a/contrib/tools/m4/lib/unitypes.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-/* Elementary types and macros for the GNU UniString library.
- Copyright (C) 2002, 2005-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 _UNITYPES_H
-#define _UNITYPES_H
-
-/* Get uint8_t, uint16_t, uint32_t. */
-#include <stdint.h>
-
-/* Type representing a Unicode character. */
-typedef uint32_t ucs4_t;
-
-/* Attribute of a function whose result depends only on the arguments
- (not pointers!) and which has no side effects. */
-#ifndef _UC_ATTRIBUTE_CONST
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
-# define _UC_ATTRIBUTE_CONST __attribute__ ((__const__))
-# else
-# define _UC_ATTRIBUTE_CONST
-# endif
-#endif
-
-/* Attribute of a function whose result depends only on the arguments
- (possibly pointers) and global memory, and which has no side effects. */
-#ifndef _UC_ATTRIBUTE_PURE
-# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-# define _UC_ATTRIBUTE_PURE __attribute__ ((__pure__))
-# else
-# define _UC_ATTRIBUTE_PURE
-# endif
-#endif
-
-#endif /* _UNITYPES_H */
diff --git a/contrib/tools/m4/lib/uniwidth.h b/contrib/tools/m4/lib/uniwidth.h
deleted file mode 100644
index 2ad29275a5..0000000000
--- a/contrib/tools/m4/lib/uniwidth.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-/* Display width functions.
- Copyright (C) 2001-2002, 2005, 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/>. */
-
-#ifndef _UNIWIDTH_H
-#define _UNIWIDTH_H
-
-#include "unitypes.h"
-
-/* Get size_t. */
-#include <stddef.h>
-
-/* Get locale_charset() declaration. */
-#include "localcharset.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Display width. */
-
-/* These functions are locale dependent. The encoding argument identifies
- the encoding (e.g. "ISO-8859-2" for Polish). */
-
-/* Determine number of column positions required for UC. */
-extern int
- uc_width (ucs4_t uc, const char *encoding)
- _UC_ATTRIBUTE_PURE;
-
-/* Determine number of column positions required for first N units
- (or fewer if S ends before this) in S. */
-extern int
- u8_width (const uint8_t *s, size_t n, const char *encoding)
- _UC_ATTRIBUTE_PURE;
-extern int
- u16_width (const uint16_t *s, size_t n, const char *encoding)
- _UC_ATTRIBUTE_PURE;
-extern int
- u32_width (const uint32_t *s, size_t n, const char *encoding)
- _UC_ATTRIBUTE_PURE;
-
-/* Determine number of column positions required for S. */
-extern int
- u8_strwidth (const uint8_t *s, const char *encoding)
- _UC_ATTRIBUTE_PURE;
-extern int
- u16_strwidth (const uint16_t *s, const char *encoding)
- _UC_ATTRIBUTE_PURE;
-extern int
- u32_strwidth (const uint32_t *s, const char *encoding)
- _UC_ATTRIBUTE_PURE;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _UNIWIDTH_H */
diff --git a/contrib/tools/m4/lib/uniwidth/cjk.h b/contrib/tools/m4/lib/uniwidth/cjk.h
deleted file mode 100644
index 11b14dfec5..0000000000
--- a/contrib/tools/m4/lib/uniwidth/cjk.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Test for CJK encoding.
- Copyright (C) 2001-2002, 2005-2007, 2009-2013 Free Software Foundation, Inc.
- Written by Bruno Haible <bruno@clisp.org>, 2002.
-
- 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 "streq.h"
-
-static int
-is_cjk_encoding (const char *encoding)
-{
- if (0
- /* Legacy Japanese encodings */
- || STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)
- /* Legacy Chinese encodings */
- || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
- || STREQ_OPT (encoding, "GBK", 'G', 'B', 'K', 0, 0, 0, 0, 0, 0)
- || STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)
- || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)
- /* Legacy Korean encodings */
- || STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
- || STREQ_OPT (encoding, "CP949", 'C', 'P', '9', '4', '9', 0, 0, 0, 0)
- || STREQ_OPT (encoding, "JOHAB", 'J', 'O', 'H', 'A', 'B', 0, 0, 0, 0))
- return 1;
- return 0;
-}
diff --git a/contrib/tools/m4/lib/uniwidth/width.c b/contrib/tools/m4/lib/uniwidth/width.c
deleted file mode 100644
index 173d0872c7..0000000000
--- a/contrib/tools/m4/lib/uniwidth/width.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/* Determine display width of Unicode character.
- Copyright (C) 2001-2002, 2006-2013 Free Software Foundation, Inc.
- Written by Bruno Haible <bruno@clisp.org>, 2002.
-
- 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 "uniwidth.h"
-
-#include "cjk.h"
-
-/*
- * Non-spacing attribute table.
- * Consists of:
- * - Non-spacing characters; generated from PropList.txt or
- * "grep '^[^;]*;[^;]*;[^;]*;[^;]*;NSM;' UnicodeData.txt"
- * - Format control characters; generated from
- * "grep '^[^;]*;[^;]*;Cf;' UnicodeData.txt"
- * - Zero width characters; generated from
- * "grep '^[^;]*;ZERO WIDTH ' UnicodeData.txt"
- */
-static const unsigned char nonspacing_table_data[27*64] = {
- /* 0x0000-0x01ff */
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, /* 0x0000-0x003f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x0040-0x007f */
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x20, 0x00, 0x00, /* 0x0080-0x00bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00c0-0x00ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0100-0x013f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0140-0x017f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0180-0x01bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x01c0-0x01ff */
- /* 0x0200-0x03ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0200-0x023f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0240-0x027f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0280-0x02bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x02c0-0x02ff */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x0300-0x033f */
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, /* 0x0340-0x037f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0380-0x03bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x03c0-0x03ff */
- /* 0x0400-0x05ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0400-0x043f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0440-0x047f */
- 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0480-0x04bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04c0-0x04ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0500-0x053f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0540-0x057f */
- 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xbf, /* 0x0580-0x05bf */
- 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x05c0-0x05ff */
- /* 0x0600-0x07ff */
- 0x0f, 0x00, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, /* 0x0600-0x063f */
- 0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x01, 0x00, /* 0x0640-0x067f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0680-0x06bf */
- 0x00, 0x00, 0xc0, 0xbf, 0x9f, 0x3d, 0x00, 0x00, /* 0x06c0-0x06ff */
- 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, /* 0x0700-0x073f */
- 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0740-0x077f */
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, 0x00, /* 0x0780-0x07bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x07c0-0x07ff */
- /* 0x0800-0x09ff */
- 0x00, 0x00, 0xc0, 0xfb, 0xef, 0x3e, 0x00, 0x00, /* 0x0800-0x083f */
- 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, /* 0x0840-0x087f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0880-0x08bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08c0-0x08ff */
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, /* 0x0900-0x093f */
- 0xfe, 0x21, 0xfe, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0940-0x097f */
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0980-0x09bf */
- 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x09c0-0x09ff */
- /* 0x0a00-0x0bff */
- 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a00-0x0a3f */
- 0x86, 0x39, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, /* 0x0a40-0x0a7f */
- 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0a80-0x0abf */
- 0xbe, 0x21, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0ac0-0x0aff */
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, /* 0x0b00-0x0b3f */
- 0x1e, 0x20, 0x40, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0b40-0x0b7f */
- 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0b80-0x0bbf */
- 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0bc0-0x0bff */
- /* 0x0c00-0x0dff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, /* 0x0c00-0x0c3f */
- 0xc1, 0x3d, 0x60, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0c40-0x0c7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, /* 0x0c80-0x0cbf */
- 0x00, 0x30, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0cc0-0x0cff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d00-0x0d3f */
- 0x1e, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, /* 0x0d40-0x0d7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0d80-0x0dbf */
- 0x00, 0x04, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0dc0-0x0dff */
- /* 0x0e00-0x0fff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x07, /* 0x0e00-0x0e3f */
- 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0e40-0x0e7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x1b, /* 0x0e80-0x0ebf */
- 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0ec0-0x0eff */
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xa0, 0x02, /* 0x0f00-0x0f3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, /* 0x0f40-0x0f7f */
- 0xdf, 0xe0, 0xff, 0xfe, 0xff, 0xff, 0xff, 0x1f, /* 0x0f80-0x0fbf */
- 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0fc0-0x0fff */
- /* 0x1000-0x11ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfd, 0x66, /* 0x1000-0x103f */
- 0x00, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x1e, 0x00, /* 0x1040-0x107f */
- 0x64, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x1080-0x10bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10c0-0x10ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1100-0x113f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1140-0x117f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1180-0x11bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11c0-0x11ff */
- /* 0x1200-0x13ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1200-0x123f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1240-0x127f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1280-0x12bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x12c0-0x12ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1300-0x133f */
- 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, /* 0x1340-0x137f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1380-0x13bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x13c0-0x13ff */
- /* 0x1600-0x17ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1600-0x163f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1640-0x167f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1680-0x16bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x16c0-0x16ff */
- 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, /* 0x1700-0x173f */
- 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, /* 0x1740-0x177f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x3f, /* 0x1780-0x17bf */
- 0x40, 0xfe, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x00, /* 0x17c0-0x17ff */
- /* 0x1800-0x19ff */
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1800-0x183f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1840-0x187f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x1880-0x18bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18c0-0x18ff */
- 0x00, 0x00, 0x00, 0x00, 0x87, 0x01, 0x04, 0x0e, /* 0x1900-0x193f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1940-0x197f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1980-0x19bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x19c0-0x19ff */
- /* 0x1a00-0x1bff */
- 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, /* 0x1a00-0x1a3f */
- 0x00, 0x00, 0x40, 0x7f, 0xe5, 0x1f, 0xf8, 0x9f, /* 0x1a40-0x1a7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1a80-0x1abf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1ac0-0x1aff */
- 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x17, /* 0x1b00-0x1b3f */
- 0x04, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, /* 0x1b40-0x1b7f */
- 0x03, 0x00, 0x00, 0x00, 0x3c, 0x03, 0x00, 0x00, /* 0x1b80-0x1bbf */
- 0x00, 0x00, 0x00, 0x00, 0x40, 0xa3, 0x03, 0x00, /* 0x1bc0-0x1bff */
- /* 0x1c00-0x1dff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xcf, 0x00, /* 0x1c00-0x1c3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c40-0x1c7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1c80-0x1cbf */
- 0x00, 0x00, 0xf7, 0xff, 0xfd, 0x21, 0x00, 0x00, /* 0x1cc0-0x1cff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d00-0x1d3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d40-0x1d7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d80-0x1dbf */
- 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, /* 0x1dc0-0x1dff */
- /* 0x2000-0x21ff */
- 0x00, 0xf8, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, /* 0x2000-0x203f */
- 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, /* 0x2040-0x207f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2080-0x20bf */
- 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, /* 0x20c0-0x20ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2100-0x213f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2140-0x217f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2180-0x21bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x21c0-0x21ff */
- /* 0x2c00-0x2dff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c00-0x2c3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c40-0x2c7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2c80-0x2cbf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, /* 0x2cc0-0x2cff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d00-0x2d3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0x2d40-0x2d7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2d80-0x2dbf */
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, /* 0x2dc0-0x2dff */
- /* 0x3000-0x31ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, /* 0x3000-0x303f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3040-0x307f */
- 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, /* 0x3080-0x30bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30c0-0x30ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3100-0x313f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3140-0x317f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3180-0x31bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x31c0-0x31ff */
- /* 0xa600-0xa7ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa600-0xa63f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0x30, /* 0xa640-0xa67f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa680-0xa6bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, /* 0xa6c0-0xa6ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa700-0xa73f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa740-0xa77f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa780-0xa7bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa7c0-0xa7ff */
- /* 0xa800-0xa9ff */
- 0x44, 0x08, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* 0xa800-0xa83f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa840-0xa87f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa880-0xa8bf */
- 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, /* 0xa8c0-0xa8ff */
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, /* 0xa900-0xa93f */
- 0x80, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa940-0xa97f */
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x13, /* 0xa980-0xa9bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa9c0-0xa9ff */
- /* 0xaa00-0xabff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x66, 0x00, /* 0xaa00-0xaa3f */
- 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaa40-0xaa7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9d, 0xc1, /* 0xaa80-0xaabf */
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xaac0-0xaaff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab00-0xab3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab40-0xab7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xab80-0xabbf */
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x00, 0x00, /* 0xabc0-0xabff */
- /* 0xfa00-0xfbff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa00-0xfa3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa40-0xfa7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfa80-0xfabf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfac0-0xfaff */
- 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, /* 0xfb00-0xfb3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb40-0xfb7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfb80-0xfbbf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfbc0-0xfbff */
- /* 0xfe00-0xffff */
- 0xff, 0xff, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, /* 0xfe00-0xfe3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe40-0xfe7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xfe80-0xfebf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* 0xfec0-0xfeff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff00-0xff3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff40-0xff7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xff80-0xffbf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, /* 0xffc0-0xffff */
- /* 0x10000-0x101ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10000-0x1003f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10040-0x1007f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10080-0x100bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x100c0-0x100ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10100-0x1013f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10140-0x1017f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10180-0x101bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, /* 0x101c0-0x101ff */
- /* 0x10a00-0x10bff */
- 0x6e, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, /* 0x10a00-0x10a3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a40-0x10a7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10a80-0x10abf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10ac0-0x10aff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b00-0x10b3f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b40-0x10b7f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10b80-0x10bbf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10bc0-0x10bff */
- /* 0x11000-0x111ff */
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* 0x11000-0x1103f */
- 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11040-0x1107f */
- 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x26, /* 0x11080-0x110bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x110c0-0x110ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11100-0x1113f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11140-0x1117f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x11180-0x111bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x111c0-0x111ff */
- /* 0x1d000-0x1d1ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d000-0x1d03f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d040-0x1d07f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d080-0x1d0bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d0c0-0x1d0ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d100-0x1d13f */
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xf8, 0xff, /* 0x1d140-0x1d17f */
- 0xe7, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* 0x1d180-0x1d1bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d1c0-0x1d1ff */
- /* 0x1d200-0x1d3ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d200-0x1d23f */
- 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d240-0x1d27f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d280-0x1d2bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d2c0-0x1d2ff */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d300-0x1d33f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d340-0x1d37f */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1d380-0x1d3bf */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 0x1d3c0-0x1d3ff */
-};
-static const signed char nonspacing_table_ind[240] = {
- 0, 1, 2, 3, 4, 5, 6, 7, /* 0x0000-0x0fff */
- 8, 9, -1, 10, 11, 12, 13, -1, /* 0x1000-0x1fff */
- 14, -1, -1, -1, -1, -1, 15, -1, /* 0x2000-0x2fff */
- 16, -1, -1, -1, -1, -1, -1, -1, /* 0x3000-0x3fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x4000-0x4fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x5000-0x5fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x6000-0x6fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x7000-0x7fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x8000-0x8fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x9000-0x9fff */
- -1, -1, -1, 17, 18, 19, -1, -1, /* 0xa000-0xafff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0xb000-0xbfff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0xc000-0xcfff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0xd000-0xdfff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0xe000-0xefff */
- -1, -1, -1, -1, -1, 20, -1, 21, /* 0xf000-0xffff */
- 22, -1, -1, -1, -1, 23, -1, -1, /* 0x10000-0x10fff */
- 24, -1, -1, -1, -1, -1, -1, -1, /* 0x11000-0x11fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x12000-0x12fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x13000-0x13fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x14000-0x14fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x15000-0x15fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x16000-0x16fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x17000-0x17fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x18000-0x18fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x19000-0x19fff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1a000-0x1afff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1b000-0x1bfff */
- -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1c000-0x1cfff */
- 25, 26, -1, -1, -1, -1, -1, -1 /* 0x1d000-0x1dfff */
-};
-
-/* Determine number of column positions required for UC. */
-int
-uc_width (ucs4_t uc, const char *encoding)
-{
- /* Test for non-spacing or control character. */
- if ((uc >> 9) < 240)
- {
- int ind = nonspacing_table_ind[uc >> 9];
- if (ind >= 0)
- if ((nonspacing_table_data[64*ind + ((uc >> 3) & 63)] >> (uc & 7)) & 1)
- {
- if (uc > 0 && uc < 0xa0)
- return -1;
- else
- return 0;
- }
- }
- else if ((uc >> 9) == (0xe0000 >> 9))
- {
- if (uc >= 0xe0100)
- {
- if (uc <= 0xe01ef)
- return 0;
- }
- else
- {
- if (uc >= 0xe0020 ? uc <= 0xe007f : uc == 0xe0001)
- return 0;
- }
- }
- /* Test for double-width character.
- * Generated from "grep '^[^;]\{4,5\};[WF]' EastAsianWidth.txt"
- * and "grep '^[^;]\{4,5\};[^WF]' EastAsianWidth.txt"
- */
- if (uc >= 0x1100
- && ((uc < 0x1160) /* Hangul Jamo */
- || (uc >= 0x2329 && uc < 0x232b) /* Angle Brackets */
- || (uc >= 0x2e80 && uc < 0xa4d0 /* CJK ... Yi */
- && !(uc == 0x303f) && !(uc >= 0x4dc0 && uc < 0x4e00))
- || (uc >= 0xac00 && uc < 0xd7a4) /* Hangul Syllables */
- || (uc >= 0xf900 && uc < 0xfb00) /* CJK Compatibility Ideographs */
- || (uc >= 0xfe10 && uc < 0xfe20) /* Presentation Forms for Vertical */
- || (uc >= 0xfe30 && uc < 0xfe70) /* CJK Compatibility Forms */
- || (uc >= 0xff00 && uc < 0xff61) /* Fullwidth Forms */
- || (uc >= 0xffe0 && uc < 0xffe7) /* Fullwidth Signs */
- || (uc >= 0x20000 && uc <= 0x2ffff) /* Supplementary Ideographic Plane */
- || (uc >= 0x30000 && uc <= 0x3ffff) /* Tertiary Ideographic Plane */
- ) )
- return 2;
- /* In ancient CJK encodings, Cyrillic and most other characters are
- double-width as well. */
- if (uc >= 0x00A1 && uc < 0xFF61 && uc != 0x20A9
- && is_cjk_encoding (encoding))
- return 2;
- return 1;
-}
diff --git a/contrib/tools/m4/lib/ya.make b/contrib/tools/m4/lib/ya.make
index 4304d890d5..ccb5f20ba0 100644
--- a/contrib/tools/m4/lib/ya.make
+++ b/contrib/tools/m4/lib/ya.make
@@ -46,7 +46,6 @@ SRCS(
basename-lgpl.c
basename.c
binary-io.c
- bitrotate.c
c-ctype.c
c-stack.c
c-strcasecmp.c
@@ -57,7 +56,6 @@ SRCS(
close.c
closein.c
closeout.c
- concat-filename.c
dirname-lgpl.c
dirname.c
dup-safer-flag.c
@@ -86,7 +84,6 @@ SRCS(
gl_oset.c
gl_xlist.c
gl_xoset.c
- hash.c
isnand.c
isnanl.c
isnanf.c
@@ -163,14 +160,12 @@ IF (OS_WINDOWS)
sigaction.c
sigprocmask.c
waitpid.c
- uniwidth/width.c
)
ENDIF()
IF (NOT OS_LINUX OR MUSL)
SRCS(
obstack.c
- obstack_printf.c
)
ENDIF()
diff --git a/contrib/tools/m4/src/cpp.cpp b/contrib/tools/m4/src/cpp.cpp
deleted file mode 100644
index 19c4a90e13..0000000000
--- a/contrib/tools/m4/src/cpp.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// Just include a C++ header to tell stupid MSVC to link in C++ runtime providing wctype().
-
-#include <cassert>
diff --git a/contrib/tools/m4/src/m4.h b/contrib/tools/m4/src/m4.h
index eb2a96784f..96e549eb76 100644
--- a/contrib/tools/m4/src/m4.h
+++ b/contrib/tools/m4/src/m4.h
@@ -28,6 +28,7 @@
#include <ctype.h>
#include <errno.h>
#include <limits.h>
+#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>
diff --git a/contrib/tools/m4/src/symtab.c b/contrib/tools/m4/src/symtab.c
index 7448c272cc..fe37bee694 100644
--- a/contrib/tools/m4/src/symtab.c
+++ b/contrib/tools/m4/src/symtab.c
@@ -123,10 +123,10 @@ symtab_init (void)
static size_t M4_GNUC_PURE
hash (const char *s)
{
- size_t val = 0;
+ register size_t val = 0;
- const char *ptr = s;
- char ch;
+ register const char *ptr = s;
+ register char ch;
while ((ch = *ptr++) != '\0')
val = (val << 7) + (val >> (sizeof (val) * CHAR_BIT - 7)) + ch;
diff --git a/contrib/tools/m4/ya.make b/contrib/tools/m4/ya.make
index cf8d1d977e..881de5781e 100644
--- a/contrib/tools/m4/ya.make
+++ b/contrib/tools/m4/ya.make
@@ -30,7 +30,6 @@ SRCS(
src/output.c
src/path.c
src/symtab.c
- src/cpp.cpp
)
PEERDIR(