diff options
| author | Paul Eggert | 2019-10-24 14:32:06 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-10-24 14:35:06 -0700 |
| commit | 4a083b0d36a8b2afe23447dbc357de3641140d4d (patch) | |
| tree | 4a36c261a476fae4d8143e2692789e236e05fa08 /lib/nstrftime.c | |
| parent | 57162dbc065a3b9f9b8dfd555ef628e639061839 (diff) | |
| download | emacs-4a083b0d36a8b2afe23447dbc357de3641140d4d.tar.gz emacs-4a083b0d36a8b2afe23447dbc357de3641140d4d.zip | |
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.
Diffstat (limited to 'lib/nstrftime.c')
| -rw-r--r-- | lib/nstrftime.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/nstrftime.c b/lib/nstrftime.c index bc84da5a0cb..461dadb2929 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c | |||
| @@ -68,6 +68,8 @@ extern char *tzname[]; | |||
| 68 | #include <string.h> | 68 | #include <string.h> |
| 69 | #include <stdbool.h> | 69 | #include <stdbool.h> |
| 70 | 70 | ||
| 71 | #include <intprops.h> | ||
| 72 | |||
| 71 | #ifndef FALLTHROUGH | 73 | #ifndef FALLTHROUGH |
| 72 | # if __GNUC__ < 7 | 74 | # if __GNUC__ < 7 |
| 73 | # define FALLTHROUGH ((void) 0) | 75 | # define FALLTHROUGH ((void) 0) |
| @@ -113,13 +115,6 @@ extern char *tzname[]; | |||
| 113 | ? (a) >> (b) \ | 115 | ? (a) >> (b) \ |
| 114 | : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) | 116 | : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) |
| 115 | 117 | ||
| 116 | /* Bound on length of the string representing an integer type or expression T. | ||
| 117 | Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485; | ||
| 118 | add 1 for integer division truncation; add 1 more for a minus sign | ||
| 119 | if needed. */ | ||
| 120 | #define INT_STRLEN_BOUND(t) \ | ||
| 121 | ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2) | ||
| 122 | |||
| 123 | #define TM_YEAR_BASE 1900 | 118 | #define TM_YEAR_BASE 1900 |
| 124 | 119 | ||
| 125 | #ifndef __isleap | 120 | #ifndef __isleap |
| @@ -704,15 +699,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 704 | width = 0; | 699 | width = 0; |
| 705 | do | 700 | do |
| 706 | { | 701 | { |
| 707 | if (width > INT_MAX / 10 | 702 | if (INT_MULTIPLY_WRAPV (width, 10, &width) |
| 708 | || (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10)) | 703 | || INT_ADD_WRAPV (width, *f - L_('0'), &width)) |
| 709 | /* Avoid overflow. */ | ||
| 710 | width = INT_MAX; | 704 | width = INT_MAX; |
| 711 | else | ||
| 712 | { | ||
| 713 | width *= 10; | ||
| 714 | width += *f - L_('0'); | ||
| 715 | } | ||
| 716 | ++f; | 705 | ++f; |
| 717 | } | 706 | } |
| 718 | while (ISDIGIT (*f)); | 707 | while (ISDIGIT (*f)); |