diff options
| author | Paul Eggert | 2019-02-25 08:26:49 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-02-25 08:27:40 -0800 |
| commit | 0d49078ad80f54b810180a071e2b6b4bcc024851 (patch) | |
| tree | 44be6830a600b9802c4b6a08acbde97480624c50 | |
| parent | cedc3410d4feab7b4beeef3eab474fbabad4035c (diff) | |
| download | emacs-0d49078ad80f54b810180a071e2b6b4bcc024851.tar.gz emacs-0d49078ad80f54b810180a071e2b6b4bcc024851.zip | |
Update from Gnulib
This incorporates:
2019-02-24 nstrftime: support the ‘+’ flag
2019-02-24 stat, lstat: fix conflict with relocatable-prog-wrapper
2019-02-23 nstrftime: tweak arg order
2019-02-21 nstrftime: merge glibc strftime changes
2019-02-02 vla: add commentary about VLA_ELEMS
* build-aux/config.guess, doc/misc/texinfo.tex, lib/fstatat.c:
* lib/lstat.c, lib/nstrftime.c, lib/vla.h:
Copy from Gnulib.
| -rwxr-xr-x | build-aux/config.guess | 4 | ||||
| -rw-r--r-- | doc/misc/texinfo.tex | 29 | ||||
| -rw-r--r-- | lib/fstatat.c | 6 | ||||
| -rw-r--r-- | lib/lstat.c | 6 | ||||
| -rw-r--r-- | lib/nstrftime.c | 97 | ||||
| -rw-r--r-- | lib/vla.h | 26 |
6 files changed, 114 insertions, 54 deletions
diff --git a/build-aux/config.guess b/build-aux/config.guess index a81aa505ba8..8ef92de0e50 100755 --- a/build-aux/config.guess +++ b/build-aux/config.guess | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | # Attempt to guess a canonical system name. | 2 | # Attempt to guess a canonical system name. |
| 3 | # Copyright 1992-2019 Free Software Foundation, Inc. | 3 | # Copyright 1992-2019 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | timestamp='2019-01-15' | 5 | timestamp='2019-02-19' |
| 6 | 6 | ||
| 7 | # This file is free software; you can redistribute it and/or modify it | 7 | # This file is free software; you can redistribute it and/or modify it |
| 8 | # under the terms of the GNU General Public License as published by | 8 | # under the terms of the GNU General Public License as published by |
| @@ -1113,7 +1113,7 @@ EOF | |||
| 1113 | *Pentium) UNAME_MACHINE=i586 ;; | 1113 | *Pentium) UNAME_MACHINE=i586 ;; |
| 1114 | *Pent*|*Celeron) UNAME_MACHINE=i686 ;; | 1114 | *Pent*|*Celeron) UNAME_MACHINE=i686 ;; |
| 1115 | esac | 1115 | esac |
| 1116 | echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" | 1116 | echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" |
| 1117 | exit ;; | 1117 | exit ;; |
| 1118 | i*86:*:3.2:*) | 1118 | i*86:*:3.2:*) |
| 1119 | if test -f /usr/options/cb.name; then | 1119 | if test -f /usr/options/cb.name; then |
diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex index 71667f03ab9..929418c760e 100644 --- a/doc/misc/texinfo.tex +++ b/doc/misc/texinfo.tex | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | % Load plain if necessary, i.e., if running under initex. | 3 | % Load plain if necessary, i.e., if running under initex. |
| 4 | \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi | 4 | \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi |
| 5 | % | 5 | % |
| 6 | \def\texinfoversion{2019-02-01.12} | 6 | \def\texinfoversion{2019-02-23.16} |
| 7 | 7 | ||
| 8 | % | 8 | % |
| 9 | % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc. | 9 | % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc. |
| @@ -5872,7 +5872,9 @@ end | |||
| 5872 | \divide\doublecolumnhsize by 2 | 5872 | \divide\doublecolumnhsize by 2 |
| 5873 | \hsize = \doublecolumnhsize | 5873 | \hsize = \doublecolumnhsize |
| 5874 | % | 5874 | % |
| 5875 | % Double the \vsize as well. | 5875 | % Get the available space for the double columns -- the normal |
| 5876 | % (undoubled) page height minus any material left over from the | ||
| 5877 | % previous page. | ||
| 5876 | \advance\vsize by -\ht\partialpage | 5878 | \advance\vsize by -\ht\partialpage |
| 5877 | \vsize = 2\vsize | 5879 | \vsize = 2\vsize |
| 5878 | % | 5880 | % |
| @@ -5886,16 +5888,13 @@ end | |||
| 5886 | \def\doublecolumnout{% | 5888 | \def\doublecolumnout{% |
| 5887 | % | 5889 | % |
| 5888 | \splittopskip=\topskip \splitmaxdepth=\maxdepth | 5890 | \splittopskip=\topskip \splitmaxdepth=\maxdepth |
| 5889 | % Get the available space for the double columns -- the normal | ||
| 5890 | % (undoubled) page height minus any material left over from the | ||
| 5891 | % previous page. | ||
| 5892 | \dimen@ = \vsize | 5891 | \dimen@ = \vsize |
| 5893 | \divide\dimen@ by 2 | 5892 | \divide\dimen@ by 2 |
| 5894 | % | 5893 | % |
| 5895 | % box0 will be the left-hand column, box2 the right. | 5894 | % box0 will be the left-hand column, box2 the right. |
| 5896 | \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@ | 5895 | \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@ |
| 5897 | \global\advance\vsize by 2\ht\partialpage | 5896 | \global\advance\vsize by 2\ht\partialpage |
| 5898 | \onepageout\pagesofar | 5897 | \onepageout\pagesofar % empty except for the first time we are called |
| 5899 | \unvbox\PAGE | 5898 | \unvbox\PAGE |
| 5900 | \penalty\outputpenalty | 5899 | \penalty\outputpenalty |
| 5901 | } | 5900 | } |
| @@ -5978,13 +5977,14 @@ end | |||
| 5978 | \def\balancecolumns{% | 5977 | \def\balancecolumns{% |
| 5979 | \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120. | 5978 | \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120. |
| 5980 | \dimen@ = \ht0 | 5979 | \dimen@ = \ht0 |
| 5981 | \advance\dimen@ by \topskip | 5980 | \ifdim\dimen@<7\baselineskip |
| 5982 | \advance\dimen@ by-\baselineskip | ||
| 5983 | \ifdim\dimen@<5\baselineskip | ||
| 5984 | % Don't split a short final column in two. | 5981 | % Don't split a short final column in two. |
| 5985 | \setbox2=\vbox{}% | 5982 | \setbox2=\vbox{}% |
| 5986 | \global\setbox\balancedcolumns=\vbox{\pagesofar}% | 5983 | \global\setbox\balancedcolumns=\vbox{\pagesofar}% |
| 5987 | \else | 5984 | \else |
| 5985 | % double the leading vertical space | ||
| 5986 | \advance\dimen@ by \topskip | ||
| 5987 | \advance\dimen@ by-\baselineskip | ||
| 5988 | \divide\dimen@ by 2 % target to split to | 5988 | \divide\dimen@ by 2 % target to split to |
| 5989 | \dimen@ii = \dimen@ | 5989 | \dimen@ii = \dimen@ |
| 5990 | \splittopskip = \topskip | 5990 | \splittopskip = \topskip |
| @@ -11191,21 +11191,14 @@ directory should work if nowhere else does.} | |||
| 11191 | \relax | 11191 | \relax |
| 11192 | } | 11192 | } |
| 11193 | 11193 | ||
| 11194 | % define all Unicode characters we know about, for the sake of @U. | 11194 | % Define all Unicode characters we know about. This makes UTF-8 the default |
| 11195 | % input encoding and allows @U to work. | ||
| 11195 | \iftxinativeunicodecapable | 11196 | \iftxinativeunicodecapable |
| 11196 | \nativeunicodechardefsatu | 11197 | \nativeunicodechardefsatu |
| 11197 | \else | 11198 | \else |
| 11198 | \utfeightchardefs | 11199 | \utfeightchardefs |
| 11199 | \fi | 11200 | \fi |
| 11200 | 11201 | ||
| 11201 | |||
| 11202 | % Make non-ASCII characters printable again for compatibility with | ||
| 11203 | % existing Texinfo documents that may use them, even without declaring a | ||
| 11204 | % document encoding. | ||
| 11205 | % | ||
| 11206 | \setnonasciicharscatcode \other | ||
| 11207 | |||
| 11208 | |||
| 11209 | \message{formatting,} | 11202 | \message{formatting,} |
| 11210 | 11203 | ||
| 11211 | \newdimen\defaultparindent \defaultparindent = 15pt | 11204 | \newdimen\defaultparindent \defaultparindent = 15pt |
diff --git a/lib/fstatat.c b/lib/fstatat.c index 515b5693991..019d3c61638 100644 --- a/lib/fstatat.c +++ b/lib/fstatat.c | |||
| @@ -36,10 +36,14 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) | |||
| 36 | } | 36 | } |
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | #ifdef __osf__ | ||
| 39 | /* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc | 40 | /* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc |
| 40 | eliminates this include because of the preliminary #include <sys/stat.h> | 41 | eliminates this include because of the preliminary #include <sys/stat.h> |
| 41 | above. */ | 42 | above. */ |
| 42 | #include "sys/stat.h" | 43 | # include "sys/stat.h" |
| 44 | #else | ||
| 45 | # include <sys/stat.h> | ||
| 46 | #endif | ||
| 43 | 47 | ||
| 44 | #include "stat-time.h" | 48 | #include "stat-time.h" |
| 45 | 49 | ||
diff --git a/lib/lstat.c b/lib/lstat.c index d57ca105fd3..a3e40d826f0 100644 --- a/lib/lstat.c +++ b/lib/lstat.c | |||
| @@ -42,10 +42,14 @@ orig_lstat (const char *filename, struct stat *buf) | |||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | /* Specification. */ | 44 | /* Specification. */ |
| 45 | # ifdef __osf__ | ||
| 45 | /* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc | 46 | /* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc |
| 46 | eliminates this include because of the preliminary #include <sys/stat.h> | 47 | eliminates this include because of the preliminary #include <sys/stat.h> |
| 47 | above. */ | 48 | above. */ |
| 48 | # include "sys/stat.h" | 49 | # include "sys/stat.h" |
| 50 | # else | ||
| 51 | # include <sys/stat.h> | ||
| 52 | # endif | ||
| 49 | 53 | ||
| 50 | # include "stat-time.h" | 54 | # include "stat-time.h" |
| 51 | 55 | ||
diff --git a/lib/nstrftime.c b/lib/nstrftime.c index 71f778a5fe7..bc84da5a0cb 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c | |||
| @@ -180,7 +180,7 @@ extern char *tzname[]; | |||
| 180 | if (digits == 0 && _n < _w) \ | 180 | if (digits == 0 && _n < _w) \ |
| 181 | { \ | 181 | { \ |
| 182 | size_t _delta = width - _n; \ | 182 | size_t _delta = width - _n; \ |
| 183 | if (pad == L_('0')) \ | 183 | if (pad == L_('0') || pad == L_('+')) \ |
| 184 | memset_zero (p, _delta); \ | 184 | memset_zero (p, _delta); \ |
| 185 | else \ | 185 | else \ |
| 186 | memset_space (p, _delta); \ | 186 | memset_space (p, _delta); \ |
| @@ -418,7 +418,7 @@ iso_week_days (int yday, int wday) | |||
| 418 | 418 | ||
| 419 | static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t) | 419 | static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t) |
| 420 | const CHAR_T *, const struct tm *, | 420 | const CHAR_T *, const struct tm *, |
| 421 | bool, bool * | 421 | bool, int, int, bool * |
| 422 | extra_args_spec LOCALE_PARAM); | 422 | extra_args_spec LOCALE_PARAM); |
| 423 | 423 | ||
| 424 | /* Write information from TP into S according to the format | 424 | /* Write information from TP into S according to the format |
| @@ -433,8 +433,8 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 433 | const struct tm *tp extra_args_spec LOCALE_PARAM) | 433 | const struct tm *tp extra_args_spec LOCALE_PARAM) |
| 434 | { | 434 | { |
| 435 | bool tzset_called = false; | 435 | bool tzset_called = false; |
| 436 | return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, | 436 | return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false, |
| 437 | false, &tzset_called extra_args LOCALE_ARG); | 437 | 0, -1, &tzset_called extra_args LOCALE_ARG); |
| 438 | } | 438 | } |
| 439 | #if defined _LIBC && ! FPRINTFTIME | 439 | #if defined _LIBC && ! FPRINTFTIME |
| 440 | libc_hidden_def (my_strftime) | 440 | libc_hidden_def (my_strftime) |
| @@ -446,7 +446,8 @@ libc_hidden_def (my_strftime) | |||
| 446 | static size_t | 446 | static size_t |
| 447 | __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | 447 | __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) |
| 448 | const CHAR_T *format, | 448 | const CHAR_T *format, |
| 449 | const struct tm *tp, bool upcase, bool *tzset_called | 449 | const struct tm *tp, bool upcase, |
| 450 | int yr_spec, int width, bool *tzset_called | ||
| 450 | extra_args_spec LOCALE_PARAM) | 451 | extra_args_spec LOCALE_PARAM) |
| 451 | { | 452 | { |
| 452 | #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL | 453 | #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL |
| @@ -558,7 +559,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 558 | if (hour12 == 0) | 559 | if (hour12 == 0) |
| 559 | hour12 = 12; | 560 | hour12 = 12; |
| 560 | 561 | ||
| 561 | for (f = format; *f != '\0'; ++f) | 562 | for (f = format; *f != '\0'; width = -1, f++) |
| 562 | { | 563 | { |
| 563 | int pad = 0; /* Padding for number ('-', '_', or 0). */ | 564 | int pad = 0; /* Padding for number ('-', '_', or 0). */ |
| 564 | int modifier; /* Field modifier ('E', 'O', or 0). */ | 565 | int modifier; /* Field modifier ('E', 'O', or 0). */ |
| @@ -576,12 +577,12 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 576 | + (sizeof (int) < sizeof (time_t) | 577 | + (sizeof (int) < sizeof (time_t) |
| 577 | ? INT_STRLEN_BOUND (time_t) | 578 | ? INT_STRLEN_BOUND (time_t) |
| 578 | : INT_STRLEN_BOUND (int))]; | 579 | : INT_STRLEN_BOUND (int))]; |
| 579 | int width = -1; | ||
| 580 | bool to_lowcase = false; | 580 | bool to_lowcase = false; |
| 581 | bool to_uppcase = upcase; | 581 | bool to_uppcase = upcase; |
| 582 | size_t colons; | 582 | size_t colons; |
| 583 | bool change_case = false; | 583 | bool change_case = false; |
| 584 | int format_char; | 584 | int format_char; |
| 585 | int subwidth; | ||
| 585 | 586 | ||
| 586 | #if DO_MULTIBYTE && !defined COMPILE_WIDE | 587 | #if DO_MULTIBYTE && !defined COMPILE_WIDE |
| 587 | switch (*f) | 588 | switch (*f) |
| @@ -679,6 +680,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 679 | /* This influences the number formats. */ | 680 | /* This influences the number formats. */ |
| 680 | case L_('_'): | 681 | case L_('_'): |
| 681 | case L_('-'): | 682 | case L_('-'): |
| 683 | case L_('+'): | ||
| 682 | case L_('0'): | 684 | case L_('0'): |
| 683 | pad = *f; | 685 | pad = *f; |
| 684 | continue; | 686 | continue; |
| @@ -697,7 +699,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 697 | break; | 699 | break; |
| 698 | } | 700 | } |
| 699 | 701 | ||
| 700 | /* As a GNU extension we allow the field width to be specified. */ | ||
| 701 | if (ISDIGIT (*f)) | 702 | if (ISDIGIT (*f)) |
| 702 | { | 703 | { |
| 703 | width = 0; | 704 | width = 0; |
| @@ -743,12 +744,16 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 743 | } \ | 744 | } \ |
| 744 | while (0) | 745 | while (0) |
| 745 | #define DO_SIGNED_NUMBER(d, negative, v) \ | 746 | #define DO_SIGNED_NUMBER(d, negative, v) \ |
| 747 | DO_MAYBE_SIGNED_NUMBER (d, negative, v, do_signed_number) | ||
| 748 | #define DO_YEARISH(d, negative, v) \ | ||
| 749 | DO_MAYBE_SIGNED_NUMBER (d, negative, v, do_yearish) | ||
| 750 | #define DO_MAYBE_SIGNED_NUMBER(d, negative, v, label) \ | ||
| 746 | do \ | 751 | do \ |
| 747 | { \ | 752 | { \ |
| 748 | digits = d; \ | 753 | digits = d; \ |
| 749 | negative_number = negative; \ | 754 | negative_number = negative; \ |
| 750 | u_number_value = v; \ | 755 | u_number_value = v; \ |
| 751 | goto do_signed_number; \ | 756 | goto label; \ |
| 752 | } \ | 757 | } \ |
| 753 | while (0) | 758 | while (0) |
| 754 | 759 | ||
| @@ -850,7 +855,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 850 | if (modifier == L_('O')) | 855 | if (modifier == L_('O')) |
| 851 | goto bad_format; | 856 | goto bad_format; |
| 852 | #ifdef _NL_CURRENT | 857 | #ifdef _NL_CURRENT |
| 853 | if (! (modifier == 'E' | 858 | if (! (modifier == L_('E') |
| 854 | && (*(subfmt = | 859 | && (*(subfmt = |
| 855 | (const CHAR_T *) _NL_CURRENT (LC_TIME, | 860 | (const CHAR_T *) _NL_CURRENT (LC_TIME, |
| 856 | NLW(ERA_D_T_FMT))) | 861 | NLW(ERA_D_T_FMT))) |
| @@ -861,15 +866,17 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 861 | #endif | 866 | #endif |
| 862 | 867 | ||
| 863 | subformat: | 868 | subformat: |
| 869 | subwidth = -1; | ||
| 870 | subformat_width: | ||
| 864 | { | 871 | { |
| 865 | size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1) | 872 | size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1) |
| 866 | subfmt, | 873 | subfmt, tp, to_uppcase, |
| 867 | tp, to_uppcase, tzset_called | 874 | pad, subwidth, tzset_called |
| 868 | extra_args LOCALE_ARG); | 875 | extra_args LOCALE_ARG); |
| 869 | add (len, __strftime_internal (p, | 876 | add (len, __strftime_internal (p, |
| 870 | STRFTIME_ARG (maxsize - i) | 877 | STRFTIME_ARG (maxsize - i) |
| 871 | subfmt, | 878 | subfmt, tp, to_uppcase, |
| 872 | tp, to_uppcase, tzset_called | 879 | pad, subwidth, tzset_called |
| 873 | extra_args LOCALE_ARG)); | 880 | extra_args LOCALE_ARG)); |
| 874 | } | 881 | } |
| 875 | break; | 882 | break; |
| @@ -930,7 +937,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 930 | { | 937 | { |
| 931 | int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; | 938 | int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; |
| 932 | century -= tp->tm_year % 100 < 0 && 0 < century; | 939 | century -= tp->tm_year % 100 < 0 && 0 < century; |
| 933 | DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century); | 940 | DO_YEARISH (2, tp->tm_year < - TM_YEAR_BASE, century); |
| 934 | } | 941 | } |
| 935 | 942 | ||
| 936 | case L_('x'): | 943 | case L_('x'): |
| @@ -939,7 +946,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 939 | #ifdef _NL_CURRENT | 946 | #ifdef _NL_CURRENT |
| 940 | if (! (modifier == L_('E') | 947 | if (! (modifier == L_('E') |
| 941 | && (*(subfmt = | 948 | && (*(subfmt = |
| 942 | (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) | 949 | (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) |
| 943 | != L_('\0')))) | 950 | != L_('\0')))) |
| 944 | subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); | 951 | subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); |
| 945 | goto subformat; | 952 | goto subformat; |
| @@ -971,9 +978,17 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 971 | always_output_a_sign = true; | 978 | always_output_a_sign = true; |
| 972 | goto do_number_body; | 979 | goto do_number_body; |
| 973 | 980 | ||
| 981 | do_yearish: | ||
| 982 | if (pad == 0) | ||
| 983 | pad = yr_spec; | ||
| 984 | always_output_a_sign | ||
| 985 | = (pad == L_('+') | ||
| 986 | && ((digits == 2 ? 99 : 9999) < u_number_value | ||
| 987 | || digits < width)); | ||
| 988 | goto do_maybe_signed_number; | ||
| 989 | |||
| 974 | do_number_spacepad: | 990 | do_number_spacepad: |
| 975 | /* Force '_' flag unless overridden by '0' or '-' flag. */ | 991 | if (pad == 0) |
| 976 | if (pad != L_('0') && pad != L_('-')) | ||
| 977 | pad = L_('_'); | 992 | pad = L_('_'); |
| 978 | 993 | ||
| 979 | do_number: | 994 | do_number: |
| @@ -983,6 +998,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 983 | 998 | ||
| 984 | do_signed_number: | 999 | do_signed_number: |
| 985 | always_output_a_sign = false; | 1000 | always_output_a_sign = false; |
| 1001 | |||
| 1002 | do_maybe_signed_number: | ||
| 986 | tz_colon_mask = 0; | 1003 | tz_colon_mask = 0; |
| 987 | 1004 | ||
| 988 | do_number_body: | 1005 | do_number_body: |
| @@ -1087,8 +1104,19 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1087 | case L_('F'): | 1104 | case L_('F'): |
| 1088 | if (modifier != 0) | 1105 | if (modifier != 0) |
| 1089 | goto bad_format; | 1106 | goto bad_format; |
| 1107 | if (pad == 0 && width < 0) | ||
| 1108 | { | ||
| 1109 | pad = L_('+'); | ||
| 1110 | subwidth = 4; | ||
| 1111 | } | ||
| 1112 | else | ||
| 1113 | { | ||
| 1114 | subwidth = width - 6; | ||
| 1115 | if (subwidth < 0) | ||
| 1116 | subwidth = 0; | ||
| 1117 | } | ||
| 1090 | subfmt = L_("%Y-%m-%d"); | 1118 | subfmt = L_("%Y-%m-%d"); |
| 1091 | goto subformat; | 1119 | goto subformat_width; |
| 1092 | 1120 | ||
| 1093 | case L_('H'): | 1121 | case L_('H'): |
| 1094 | if (modifier == L_('E')) | 1122 | if (modifier == L_('E')) |
| @@ -1297,17 +1325,18 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1297 | case L_('g'): | 1325 | case L_('g'): |
| 1298 | { | 1326 | { |
| 1299 | int yy = (tp->tm_year % 100 + year_adjust) % 100; | 1327 | int yy = (tp->tm_year % 100 + year_adjust) % 100; |
| 1300 | DO_NUMBER (2, (0 <= yy | 1328 | DO_YEARISH (2, false, |
| 1301 | ? yy | 1329 | (0 <= yy |
| 1302 | : tp->tm_year < -TM_YEAR_BASE - year_adjust | 1330 | ? yy |
| 1303 | ? -yy | 1331 | : tp->tm_year < -TM_YEAR_BASE - year_adjust |
| 1304 | : yy + 100)); | 1332 | ? -yy |
| 1333 | : yy + 100)); | ||
| 1305 | } | 1334 | } |
| 1306 | 1335 | ||
| 1307 | case L_('G'): | 1336 | case L_('G'): |
| 1308 | DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, | 1337 | DO_YEARISH (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, |
| 1309 | (tp->tm_year + (unsigned int) TM_YEAR_BASE | 1338 | (tp->tm_year + (unsigned int) TM_YEAR_BASE |
| 1310 | + year_adjust)); | 1339 | + year_adjust)); |
| 1311 | 1340 | ||
| 1312 | default: | 1341 | default: |
| 1313 | DO_NUMBER (2, days / 7 + 1); | 1342 | DO_NUMBER (2, days / 7 + 1); |
| @@ -1327,7 +1356,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1327 | DO_NUMBER (1, tp->tm_wday); | 1356 | DO_NUMBER (1, tp->tm_wday); |
| 1328 | 1357 | ||
| 1329 | case L_('Y'): | 1358 | case L_('Y'): |
| 1330 | if (modifier == 'E') | 1359 | if (modifier == L_('E')) |
| 1331 | { | 1360 | { |
| 1332 | #if HAVE_STRUCT_ERA_ENTRY | 1361 | #if HAVE_STRUCT_ERA_ENTRY |
| 1333 | struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); | 1362 | struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); |
| @@ -1338,6 +1367,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1338 | # else | 1367 | # else |
| 1339 | subfmt = era->era_format; | 1368 | subfmt = era->era_format; |
| 1340 | # endif | 1369 | # endif |
| 1370 | if (pad == 0) | ||
| 1371 | pad = yr_spec; | ||
| 1341 | goto subformat; | 1372 | goto subformat; |
| 1342 | } | 1373 | } |
| 1343 | #else | 1374 | #else |
| @@ -1347,8 +1378,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1347 | if (modifier == L_('O')) | 1378 | if (modifier == L_('O')) |
| 1348 | goto bad_format; | 1379 | goto bad_format; |
| 1349 | 1380 | ||
| 1350 | DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE, | 1381 | DO_YEARISH (4, tp->tm_year < -TM_YEAR_BASE, |
| 1351 | tp->tm_year + (unsigned int) TM_YEAR_BASE); | 1382 | tp->tm_year + (unsigned int) TM_YEAR_BASE); |
| 1352 | 1383 | ||
| 1353 | case L_('y'): | 1384 | case L_('y'): |
| 1354 | if (modifier == L_('E')) | 1385 | if (modifier == L_('E')) |
| @@ -1358,7 +1389,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1358 | if (era) | 1389 | if (era) |
| 1359 | { | 1390 | { |
| 1360 | int delta = tp->tm_year - era->start_date[0]; | 1391 | int delta = tp->tm_year - era->start_date[0]; |
| 1361 | DO_NUMBER (1, (era->offset | 1392 | if (pad == 0) |
| 1393 | pad = yr_spec; | ||
| 1394 | DO_NUMBER (2, (era->offset | ||
| 1362 | + delta * era->absolute_direction)); | 1395 | + delta * era->absolute_direction)); |
| 1363 | } | 1396 | } |
| 1364 | #else | 1397 | #else |
| @@ -1370,7 +1403,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) | |||
| 1370 | int yy = tp->tm_year % 100; | 1403 | int yy = tp->tm_year % 100; |
| 1371 | if (yy < 0) | 1404 | if (yy < 0) |
| 1372 | yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; | 1405 | yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; |
| 1373 | DO_NUMBER (2, yy); | 1406 | DO_YEARISH (2, false, yy); |
| 1374 | } | 1407 | } |
| 1375 | 1408 | ||
| 1376 | case L_('Z'): | 1409 | case L_('Z'): |
| @@ -17,6 +17,20 @@ | |||
| 17 | 17 | ||
| 18 | Written by Paul Eggert. */ | 18 | Written by Paul Eggert. */ |
| 19 | 19 | ||
| 20 | /* The VLA_ELEMS macro does not allocate variable-length arrays (VLAs), | ||
| 21 | so it does not have the security or performance issues commonly | ||
| 22 | associated with VLAs. VLA_ELEMS is for exploiting a C11 feature | ||
| 23 | where a function can start like this: | ||
| 24 | |||
| 25 | double scan_array (int n, double v[static n]) | ||
| 26 | |||
| 27 | to require a caller to pass a vector V with at least N elements; | ||
| 28 | this allows better static checking and performance in some cases. | ||
| 29 | In C11 this feature means that V is a VLA, so the feature is | ||
| 30 | supported only if __STDC_NO_VLA__ is defined, and for compatibility | ||
| 31 | to platforms that do not support VLAs, VLA_ELEMS (n) expands to | ||
| 32 | nothing when __STDC_NO_VLA__ is not defined. */ | ||
| 33 | |||
| 20 | /* A function's argument must point to an array with at least N elements. | 34 | /* A function's argument must point to an array with at least N elements. |
| 21 | Example: 'int main (int argc, char *argv[VLA_ELEMS (argc)]);'. */ | 35 | Example: 'int main (int argc, char *argv[VLA_ELEMS (argc)]);'. */ |
| 22 | 36 | ||
| @@ -25,3 +39,15 @@ | |||
| 25 | #else | 39 | #else |
| 26 | # define VLA_ELEMS(n) static n | 40 | # define VLA_ELEMS(n) static n |
| 27 | #endif | 41 | #endif |
| 42 | |||
| 43 | /* Although C99 requires support for variable-length arrays (VLAs), | ||
| 44 | some C compilers never supported VLAs and VLAs are optional in C11. | ||
| 45 | VLAs are controversial because their allocation may be unintended | ||
| 46 | or awkward to support, and large VLAs might cause security or | ||
| 47 | performance problems. GCC can diagnose the use of VLAs via the | ||
| 48 | -Wvla and -Wvla-larger-than warnings options, and defining the | ||
| 49 | macro GNULIB_NO_VLA disables the allocation of VLAs in Gnulib code. | ||
| 50 | |||
| 51 | The VLA_ELEMS macro is unaffected by GNULIB_NO_VLA, since it does | ||
| 52 | not allocate VLAs. Programs that use VLA_ELEMS should be compiled | ||
| 53 | with 'gcc -Wvla-larger-than' instead of with 'gcc -Wvla'. */ | ||