diff options
| author | Paul Eggert | 2020-01-01 03:11:22 +0000 |
|---|---|---|
| committer | Paul Eggert | 2019-12-31 19:11:56 -0800 |
| commit | 64d1b9fd8a97d355d7fe23025d82bebe52c1af1c (patch) | |
| tree | b3375e41ebc8b83c9d7742a064820a32ef61ab57 /lib/nstrftime.c | |
| parent | c6fb86b40bebf597fccbe4eba58ceea83bd9700f (diff) | |
| download | emacs-64d1b9fd8a97d355d7fe23025d82bebe52c1af1c.tar.gz emacs-64d1b9fd8a97d355d7fe23025d82bebe52c1af1c.zip | |
Update from gnulib
This incorporates:
2019-12-23 mktime, nstrftime: tweak division performance
2019-12-22 count-leading-zeros: assume 'long long'
2019-12-22 count-one-bits: assume 'long long'
2019-12-22 count-trailing-zeros: assume 'long long'
2019-12-12 inttypes-incomplete: assume 'long long'
2019-12-22 malloca: assume 'long long'
2019-12-22 stdint: assume 'long long'
2019-12-22 strtoll, strtoimax, strtoumax: assume 'long long'
2019-12-22 prefer lib_SOURCES to unconditional AC_LIBOBJ
2019-12-19 nstrftime: avoid a shadowing warning
2019-12-18 improve port of AC_C_RESTRICT to Oracle C++
2019-12-12 stdalign: port to xlclang 16.01
2019-12-11 stddef, unistd: fix compilation error in C++ mode on MSVC
2019-12-08 fix compilation errors in C++ mode on Haiku
2019-12-08 fix compilation errors in 32-bit C++ mode on HP-UX 11/ia64
2019-12-08 fix compilation error in C++ mode on OpenBSD
* build-aux/config.guess, doc/misc/texinfo.tex:
* lib/count-leading-zeros.h, lib/count-one-bits.h:
* lib/count-trailing-zeros.h, lib/inttypes.in.h, lib/malloca.h:
* lib/mktime.c, lib/nstrftime.c, lib/signal.in.h, lib/stdalign.in.h:
* lib/stddef.in.h, lib/stdint.in.h, lib/stdio.in.h, lib/stdlib.in.h:
* lib/strtoimax.c, lib/unistd.in.h, m4/gnulib-common.m4:
* m4/inttypes.m4, m4/largefile.m4, m4/malloca.m4, m4/strtoimax.m4:
* m4/strtoll.m4:
Copy from Gnulib. Also, change copyright notices in some other
Gnulib-copied files to exactly match Gnulib, as Gnulib updated
them in a trivially different way.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
Diffstat (limited to 'lib/nstrftime.c')
| -rw-r--r-- | lib/nstrftime.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/nstrftime.c b/lib/nstrftime.c index 667c7ddc56e..fc5052a549c 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c | |||
| @@ -113,7 +113,7 @@ extern char *tzname[]; | |||
| 113 | #define SHR(a, b) \ | 113 | #define SHR(a, b) \ |
| 114 | (-1 >> 1 == -1 \ | 114 | (-1 >> 1 == -1 \ |
| 115 | ? (a) >> (b) \ | 115 | ? (a) >> (b) \ |
| 116 | : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) | 116 | : ((a) + ((a) < 0)) / (1 << (b)) - ((a) < 0)) |
| 117 | 117 | ||
| 118 | #define TM_YEAR_BASE 1900 | 118 | #define TM_YEAR_BASE 1900 |
| 119 | 119 | ||
| @@ -348,8 +348,8 @@ tm_diff (const struct tm *a, const struct tm *b) | |||
| 348 | but it's OK to assume that A and B are close to each other. */ | 348 | but it's OK to assume that A and B are close to each other. */ |
| 349 | int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); | 349 | int a4 = SHR (a->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (a->tm_year & 3); |
| 350 | int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); | 350 | int b4 = SHR (b->tm_year, 2) + SHR (TM_YEAR_BASE, 2) - ! (b->tm_year & 3); |
| 351 | int a100 = a4 / 25 - (a4 % 25 < 0); | 351 | int a100 = (a4 + (a4 < 0)) / 25 - (a4 < 0); |
| 352 | int b100 = b4 / 25 - (b4 % 25 < 0); | 352 | int b100 = (b4 + (b4 < 0)) / 25 - (b4 < 0); |
| 353 | int a400 = SHR (a100, 2); | 353 | int a400 = SHR (a100, 2); |
| 354 | int b400 = SHR (b100, 2); | 354 | int b400 = SHR (b100, 2); |
| 355 | int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); | 355 | int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); |
| @@ -927,9 +927,11 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 927 | } | 927 | } |
| 928 | 928 | ||
| 929 | { | 929 | { |
| 930 | int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; | 930 | bool negative_year = tp->tm_year < - TM_YEAR_BASE; |
| 931 | century -= tp->tm_year % 100 < 0 && 0 < century; | 931 | bool zero_thru_1899 = !negative_year & (tp->tm_year < 0); |
| 932 | DO_YEARISH (2, tp->tm_year < - TM_YEAR_BASE, century); | 932 | int century = ((tp->tm_year - 99 * zero_thru_1899) / 100 |
| 933 | + TM_YEAR_BASE / 100); | ||
| 934 | DO_YEARISH (2, negative_year, century); | ||
| 933 | } | 935 | } |
| 934 | 936 | ||
| 935 | case L_('x'): | 937 | case L_('x'): |
| @@ -1138,8 +1140,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1138 | int ndigs = ns_digits; | 1140 | int ndigs = ns_digits; |
| 1139 | while (width < ndigs || (1 < ndigs && n % 10 == 0)) | 1141 | while (width < ndigs || (1 < ndigs && n % 10 == 0)) |
| 1140 | ndigs--, n /= 10; | 1142 | ndigs--, n /= 10; |
| 1141 | for (int i = ndigs; 0 < i; i--) | 1143 | for (int j = ndigs; 0 < j; j--) |
| 1142 | buf[i - 1] = n % 10 + L_('0'), n /= 10; | 1144 | buf[j - 1] = n % 10 + L_('0'), n /= 10; |
| 1143 | if (!pad) | 1145 | if (!pad) |
| 1144 | pad = L_('0'); | 1146 | pad = L_('0'); |
| 1145 | width_cpy (0, ndigs, buf); | 1147 | width_cpy (0, ndigs, buf); |