Commit 4a083b0d authored by Paul Eggert's avatar Paul Eggert

Update from Gnulib

This incorporates:
2019-10-23 nstrftime: speed up integer overflow checking
2019-10-23 port better to GCC under macOS
2019-10-15 inttypes: use more-robust test for int range
2019-10-14 update-copyright: use en dashes in .texi ranges
* build-aux/update-copyright, lib/intprops.h, lib/inttypes.in.h:
* lib/nstrftime.c, lib/verify.h:
Copy from Gnulib.
parent 57162dbc
Pipeline #3792 passed with stage
in 56 minutes and 9 seconds
......@@ -98,7 +98,7 @@
# 6. Blank lines, even if preceded by the prefix, do not appear
# within the FSF copyright statement.
# 7. Each copyright year is 2 or 4 digits, and years are separated by
# commas or dashes. Whitespace may appear after commas.
# commas, "-", or "--". Whitespace may appear after commas.
#
# Environment variables:
#
......@@ -192,7 +192,7 @@ while (/(^|\n)(.{0,$prefix_max})$copyright_re/g)
$holder_re =~ s/\s/$ws_re/g;
my $stmt_remainder_re =
"(?:$ws_re$circle_c_re)?"
. "$ws_re(?:(?:\\d\\d)?\\d\\d(?:,$ws_re?|-))*"
. "$ws_re(?:(?:\\d\\d)?\\d\\d(?:,$ws_re?|--?))*"
. "((?:\\d\\d)?\\d\\d)$ws_re$holder_re";
if (/\G$stmt_remainder_re/)
{
......@@ -231,26 +231,28 @@ if (defined $stmt_re)
# Make the use of intervals consistent.
if (!$ENV{UPDATE_COPYRIGHT_USE_INTERVALS})
{
$stmt =~ s/(\d{4})-(\d{4})/join(', ', $1..$2)/eg;
$stmt =~ s/(\d{4})--?(\d{4})/join(', ', $1..$2)/eg;
}
else
{
my $ndash = $ARGV =~ /\.tex(i(nfo)?)?$/ ? "--" : "-";
$stmt =~
s/
(\d{4})
(?:
(,\ |-)
(,\ |--?)
((??{
if ($2 eq '-') { '\d{4}'; }
if ($2 ne ', ') { '\d{4}'; }
elsif (!$3) { $1 + 1; }
else { $3 + 1; }
}))
)+
/$1-$3/gx;
/$1$ndash$3/gx;
# When it's 2, emit a single range encompassing all year numbers.
$ENV{UPDATE_COPYRIGHT_USE_INTERVALS} == 2
and $stmt =~ s/\b(\d{4})\b.*\b(\d{4})\b/$1-$2/;
and $stmt =~ s/\b(\d{4})\b.*\b(\d{4})\b/$1$ndash$2/;
}
# Format within margin.
......
......@@ -22,18 +22,6 @@
#include <limits.h>
/* If the compiler lacks __has_builtin, define it well enough for this
source file only. */
#ifndef __has_builtin
# define __has_builtin(x) _GL_HAS_##x
# if 5 <= __GNUC__ && !defined __ICC
# define _GL_HAS___builtin_add_overflow 1
# else
# define _GL_HAS___builtin_add_overflow 0
# endif
# define _GL_TEMPDEF___has_builtin
#endif
/* Return a value with the common real type of E and V and the value of V.
Do not evaluate E. */
#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
......@@ -234,8 +222,10 @@
/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
(A, B, P) work when P is non-null. */
#if __has_builtin (__builtin_add_overflow)
#if 5 <= __GNUC__ && !defined __ICC
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
#else
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
#endif
......@@ -586,10 +576,4 @@
: (tmin) / (a) < (b)) \
: (tmax) / (b) < (a)))
#ifdef _GL_TEMPDEF___has_builtin
# undef __has_builtin
# undef _GL_HAS___builtin_add_overflow
# undef _GL_TEMPDEF___has_builtin
#endif
#endif /* _GL_INTPROPS_H */
......@@ -49,15 +49,15 @@
#ifndef __GLIBC__
# include <stdint.h>
#endif
/* Get CHAR_BIT. */
/* Get CHAR_BIT, INT_MAX, LONG_MAX, etc. */
#include <limits.h>
/* On mingw, __USE_MINGW_ANSI_STDIO only works if <stdio.h> is also included */
#if defined _WIN32 && ! defined __CYGWIN__
# include <stdio.h>
#endif
#if !(INT_MIN == INT32_MIN && INT_MAX == INT32_MAX)
# error "This file assumes that 'int' has exactly 32 bits. Please report your platform and compiler to <bug-gnulib@gnu.org>."
#if !(INT_MAX == 0x7fffffff && INT_MIN + INT_MAX == -1)
# error "This file assumes that 'int' is 32-bit two's complement. Please report your platform and compiler to <bug-gnulib@gnu.org>."
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
......
......@@ -68,6 +68,8 @@ extern char *tzname[];
#include <string.h>
#include <stdbool.h>
#include <intprops.h>
#ifndef FALLTHROUGH
# if __GNUC__ < 7
# define FALLTHROUGH ((void) 0)
......@@ -113,13 +115,6 @@ extern char *tzname[];
? (a) >> (b) \
: (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
/* Bound on length of the string representing an integer type or expression T.
Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485;
add 1 for integer division truncation; add 1 more for a minus sign
if needed. */
#define INT_STRLEN_BOUND(t) \
((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2)
#define TM_YEAR_BASE 1900
#ifndef __isleap
......@@ -704,15 +699,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
width = 0;
do
{
if (width > INT_MAX / 10
|| (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10))
/* Avoid overflow. */
if (INT_MULTIPLY_WRAPV (width, 10, &width)
|| INT_ADD_WRAPV (width, *f - L_('0'), &width))
width = INT_MAX;
else
{
width *= 10;
width += *f - L_('0');
}
++f;
}
while (ISDIGIT (*f));
......
......@@ -56,16 +56,6 @@
# undef _Static_assert
#endif
/* If the compiler lacks __has_builtin, define it well enough for this
source file only. */
#ifndef __has_builtin
# define __has_builtin(x) _GL_HAS_##x
# define _GL_HAS___builtin_unreachable (4 < __GNUC__ + (5 <= __GNUC_MINOR__))
# define _GL_HAS___builtin_trap \
(3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__)))
# define _GL_TEMPDEF___has_builtin
#endif
/* Each of these macros verifies that its argument R is nonzero. To
be portable, R should be an integer constant expression. Unlike
assert (R), there is no run-time overhead.
......@@ -243,6 +233,22 @@ template <int w>
/* @assert.h omit start@ */
#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
# define _GL_HAS_BUILTIN_TRAP 1
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_TRAP __has_builtin (__builtin_trap)
#else
# define _GL_HAS_BUILTIN_TRAP 0
#endif
#if 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
# define _GL_HAS_BUILTIN_UNREACHABLE 1
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
#else
# define _GL_HAS_BUILTIN_UNREACHABLE 0
#endif
/* Each of these macros verifies that its argument R is nonzero. To
be portable, R should be an integer constant expression. Unlike
assert (R), there is no run-time overhead.
......@@ -276,11 +282,11 @@ template <int w>
can suffer if R uses hard-to-optimize features such as function
calls not inlined by the compiler. */
#if __has_builtin (__builtin_unreachable)
#if _GL_HAS_BUILTIN_UNREACHABLE
# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
#elif 1200 <= _MSC_VER
# define assume(R) __assume (R)
#elif (defined GCC_LINT || defined lint) && __has_builtin (__builtin_trap)
#elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP
/* Doing it this way helps various packages when configured with
--enable-gcc-warnings, which compiles with -Dlint. It's nicer
when 'assume' silences warnings even with older GCCs. */
......@@ -290,13 +296,6 @@ template <int w>
# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0)
#endif
#ifdef _GL_TEMPDEF___has_builtin
# undef __has_builtin
# undef _GL_HAS___builtin_unreachable
# undef _GL_HAS___builtin_trap
# undef _GL_TEMPDEF___has_builtin
#endif
/* @assert.h omit end@ */
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment