commit 2f7885a4b3609dec19e4595c6c24f3a21f33c5d6 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Mon Feb 25 17:44:46 2019 -0800 Fix mod-test build failure Problem reported by Glenn Morris in: https://lists.gnu.org/r/emacs-devel/2019-02/msg00739.html * test/Makefile.in (HYBRID_MALLOC, LIBEGNU_ARCHIVE): New macros, taken from ../src/Makefile.in. (MODULE_CFLAGS): Add -I$(srcdir)/../lib. ($(test_module)): Link $(LIBEGNU_ARCHIVE) too. diff --git a/test/Makefile.in b/test/Makefile.in index 4eddb676d4..ce6ce04b8b 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -254,17 +254,21 @@ else FPIC_CFLAGS = -fPIC endif +HYBRID_MALLOC = @HYBRID_MALLOC@ +LIBEGNU_ARCHIVE = ../lib/lib$(if $(HYBRID_MALLOC),e)gnu.a + # Note: emacs-module.h is generated from emacs-module.h.in, hence we # look in ../src, not $(srcdir)/../src. -MODULE_CFLAGS = -I../src $(FPIC_CFLAGS) $(PROFILING_CFLAGS) \ +MODULE_CFLAGS = -I../src -I$(srcdir)/../lib \ + $(FPIC_CFLAGS) $(PROFILING_CFLAGS) \ $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS) test_module = $(test_module_dir)/mod-test${SO} src/emacs-module-tests.log: $(test_module) -$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h +$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h $(LIBEGNU_ARCHIVE) $(AM_V_at)${MKDIR_P} $(dir $@) $(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \ - -o $@ $< + -o $@ $< $(LIBEGNU_ARCHIVE) endif ## Check that there is no 'automated' subdirectory, which would commit e0668e6871006a4ce8cbd769b67b2603b99336a2 Author: Juri Linkov Date: Mon Feb 25 23:27:47 2019 +0200 * lisp/vc/diff-mode.el (diff-font-lock-keywords): Add more Git headers. * lisp/gnus/mm-view.el (mm-display-inline-fontify): Set mode to the selected major-mode, so diff-mode could be detected afterwards. diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index b0d88d8984..8ce094349f 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el @@ -493,7 +493,8 @@ If MODE is not set, try to find mode automatically." (let ((auto-mode-alist (delq (rassq 'doc-view-mode-maybe auto-mode-alist) (copy-sequence auto-mode-alist)))) - (set-auto-mode))) + (set-auto-mode) + (setq mode major-mode))) ;; The mode function might have already turned on font-lock. ;; Do not fontify if the guess mode is fundamental. (unless (or font-lock-mode diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index bad56391c6..b22a588898 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -436,6 +436,7 @@ and the face `diff-added' for added lines.") ("^\\(?:Index\\|revno\\): \\(.+\\).*\n" (0 'diff-header) (1 'diff-index prepend)) ("^\\(?:index .*\\.\\.\\|diff \\).*\n" . 'diff-header) + ("^\\(?:new\\|deleted\\) file mode .*\n" . 'diff-header) ("^Only in .*\n" . 'diff-nonexistent) ("^Binary files .* differ\n" . 'diff-file-header) ("^\\(#\\)\\(.*\\)" commit 57d2f24005a2e553fa8225eaff8465e5fad06d46 Author: Juri Linkov Date: Mon Feb 25 23:11:34 2019 +0200 * lisp/frame.el (make-frame-on-monitor): New command. (Bug#34516) (make-frame-on-display): Add completion on available display names. diff --git a/etc/NEWS b/etc/NEWS index 587d20cce3..26b0a931d8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1140,6 +1140,10 @@ when given in a string. Previously, '(any "\x80-\xff")' would match characters U+0080...U+00FF. Now the expression matches raw bytes in the 128...255 range, as expected. +** Frames + +*** New command 'make-frame-on-monitor' makes a frame on the specified monitor. + * New Modes and Packages in Emacs 27.1 diff --git a/lisp/frame.el b/lisp/frame.el index dc81302939..8a4a0b6639 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -644,9 +644,43 @@ Return nil if we don't know how to interpret DISPLAY." (defun make-frame-on-display (display &optional parameters) "Make a frame on display DISPLAY. The optional argument PARAMETERS specifies additional frame parameters." - (interactive "sMake frame on display: ") + (interactive (list (completing-read + (format "Make frame on display: ") + (delete-dups + (mapcar (lambda (frame) + (frame-parameter frame 'display)) + (frame-list)))))) (make-frame (cons (cons 'display display) parameters))) +(defun make-frame-on-monitor (monitor &optional display parameters) + "Make a frame on monitor MONITOR. +The optional argument DISPLAY can be a display name, and the optional +argument PARAMETERS specifies additional frame parameters." + (interactive (list (completing-read + (format "Make frame on monitor: ") + (mapcar (lambda (a) + (cdr (assq 'name a))) + (display-monitor-attributes-list))))) + (let* ((monitor-geometry + (car (delq nil (mapcar (lambda (a) + (when (equal (cdr (assq 'name a)) monitor) + (cdr (assq 'workarea a)))) + (display-monitor-attributes-list display))))) + (frame-geometry + (when monitor-geometry + (x-parse-geometry (format "%dx%d+%d+%d" + (nth 2 monitor-geometry) + (nth 3 monitor-geometry) + (nth 0 monitor-geometry) + (nth 1 monitor-geometry))))) + (frame-geometry-in-pixels + (when frame-geometry + `((top . ,(cdr (assq 'top frame-geometry))) + (left . ,(cdr (assq 'left frame-geometry))) + (height . (text-pixels . ,(cdr (assq 'height frame-geometry)))) + (width . (text-pixels . ,(cdr (assq 'width frame-geometry)))))))) + (make-frame (append frame-geometry-in-pixels parameters)))) + (declare-function x-close-connection "xfns.c" (terminal)) (defun close-display-connection (display) commit e73adad8371fd7ea4696908af00cbe1675708322 Author: Tassilo Horn Date: Mon Feb 25 21:07:24 2019 +0100 ; Fixup docs for replace-{buffer,region}-contents diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index ceb2a37120..21c5a73f88 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -4468,18 +4468,18 @@ If the actual costs exceed this limit, heuristics are used to provide a faster but suboptimal solution. The default value is 1000000. @code{replace-buffer-contents} returns t if a non-destructive -replacement could be performed. Otherwise, i.e., if MAX-SECS was -exceeded, it returns nil. +replacement could be performed. Otherwise, i.e., if @code{max-secs} +was exceeded, it returns nil. @end deffn -@deffn Command replace-region-contents beg end replace-fn &optional max-secs max-costs +@defun replace-region-contents beg end replace-fn &optional max-secs max-costs This function replaces the region between @code{beg} and @code{end} using the given @code{replace-fn}. The function @code{replace-fn} is run in the current buffer narrowed to the specified region and it should return either a string or a buffer replacing the region. -The replacement is performed using @code{replace-buffer-contents} -which also describes the @code{max-secs} and @code{max-costs} +The replacement is performed using @code{replace-buffer-contents} (see +above) which also describes the @code{max-secs} and @code{max-costs} arguments and the return value. Note: If the replacement is a string, it will be placed in a temporary @@ -4487,7 +4487,7 @@ buffer so that @code{replace-buffer-contents} can operate on it. Therefore, if you already have the replacement in a buffer, it makes no sense to convert it to a string using @code{buffer-substring} or similar. -@end deffn +@end defun @node Decompression @section Dealing With Compressed Data commit 3ec62eecdf693c9cad588866dd40f7e8b67d6287 Author: Tassilo Horn Date: Mon Feb 25 20:57:25 2019 +0100 ; Delete unused variable replace-buffer-contents-max-secs This variable is a leftover of my now deleted scratch/replace-region-contents branch and has never been used in master. diff --git a/src/editfns.c b/src/editfns.c index b349bd59a2..bffb5db43e 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -4495,12 +4495,6 @@ it to be non-nil. */); binary_as_unsigned = true; #endif - DEFVAR_LISP ("replace-buffer-contents-max-secs", - Vreplace_buffer_contents_max_secs, - doc: /* If differencing the two buffers takes longer than this, -`replace-buffer-contents' falls back to a plain delete and insert. */); - Vreplace_buffer_contents_max_secs = Qnil; - defsubr (&Spropertize); defsubr (&Schar_equal); defsubr (&Sgoto_char); commit e3bb6f90e999a6d71537806573c48b9ceb3fb413 Author: Paul Eggert Date: Mon Feb 25 11:33:51 2019 -0800 format-time-string: document new '+' flag * doc/lispref/os.texi (Time Parsing), etc/NEWS: * src/timefns.c (Fformat_time_string): Document the new behavior, added for compatibility with POSIX.1-2017. diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index cb8f25df0a..59cd5a8fe8 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -1600,7 +1600,9 @@ This is a synonym for @samp{%m/%d/%y}. @item %e This stands for the day of month, blank-padded. @item %F -This stands for the ISO 8601 date format, i.e., @samp{"%Y-%m-%d"}. +This stands for the ISO 8601 date format, which is like +@samp{%+4Y-%m-%d} except that any flags or field width override the +@samp{+} and (after subtracting 6) the @samp{4}. @item %g This stands for the year corresponding to the ISO week within the century. @item %G @@ -1680,7 +1682,9 @@ This stands for a single @samp{%}. @end table One or more flag characters can appear immediately after the @samp{%}. -@samp{0} pads with zeros, @samp{_} pads with blanks, @samp{-} +@samp{0} pads with zeros, @samp{+} pads with zeros and also puts +@samp{+} before nonnegative year numbers with more than four digits, +@samp{_} pads with blanks, @samp{-} suppresses padding, @samp{^} upper-cases letters, and @samp{#} reverses the case of letters. diff --git a/etc/NEWS b/etc/NEWS index 8acbf6d3a7..587d20cce3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1343,6 +1343,12 @@ floating-point operators do. +++ ** New function 'time-equal-p' compares time values for equality. ++++ +** 'format-time-string' supports a new conversion specifier flag '+' +that acts like the '0' flag but also puts a '+' before nonnegative +years containing more than four digits. This is for compatibility +with POSIX.1-2017. + ** 'define-minor-mode' automatically documents the meaning of ARG. +++ diff --git a/src/timefns.c b/src/timefns.c index 7e061228e2..5beeaf57a2 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -1267,7 +1267,7 @@ by text that describes the specified date and time in TIME: %c is the locale's date and time format. %x is the locale's "preferred" date format. %D is like "%m/%d/%y". -%F is the ISO 8601 date format (like "%Y-%m-%d"). +%F is the ISO 8601 date format (like "%+4Y-%m-%d"). %R is like "%H:%M", %T is like "%H:%M:%S", %r is like "%I:%M:%S %p". %X is the locale's "preferred" time format. @@ -1275,17 +1275,23 @@ by text that describes the specified date and time in TIME: Finally, %n is a newline, %t is a tab, %% is a literal %, and unrecognized %-sequences stand for themselves. -Certain flags and modifiers are available with some format controls. -The flags are `_', `-', `^' and `#'. For certain characters X, -%_X is like %X, but padded with blanks; %-X is like %X, -but without padding. %^X is like %X, but with all textual -characters up-cased; %#X is like %X, but with letter-case of -all textual characters reversed. -%NX (where N stands for an integer) is like %X, -but takes up at least N (a number) positions. -The modifiers are `E' and `O'. For certain characters X, -%EX is a locale's alternative version of %X; -%OX is like %X, but uses the locale's number symbols. +A %-sequence can contain optional flags, field width, and a modifier +(in that order) after the `%'. The flags are: + +`-' Do not pad the field. +`_' Pad with spaces. +`0' Pad with zeros. +`+' Pad with zeros and put `+' before nonnegative year numbers with >4 digits. +`^' Use upper case characters if possible. +`#' Use opposite case characters if possible. + +A field width N is an unsigned decimal integer with a leading digit nonzero. +%NX is like %X, but takes up at least N positions. + +The modifiers are: + +`E' Use the locale's alternative version. +`O' Use the locale's number symbols. For example, to produce full ISO 8601 format, use "%FT%T%z". commit 0d49078ad80f54b810180a071e2b6b4bcc024851 Author: Paul Eggert Date: Mon Feb 25 08:26:49 2019 -0800 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. diff --git a/build-aux/config.guess b/build-aux/config.guess index a81aa505ba..8ef92de0e5 100755 --- a/build-aux/config.guess +++ b/build-aux/config.guess @@ -2,7 +2,7 @@ # Attempt to guess a canonical system name. # Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2019-01-15' +timestamp='2019-02-19' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -1113,7 +1113,7 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex index 71667f03ab..929418c760 100644 --- a/doc/misc/texinfo.tex +++ b/doc/misc/texinfo.tex @@ -3,7 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2019-02-01.12} +\def\texinfoversion{2019-02-23.16} % % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc. @@ -5872,7 +5872,9 @@ \divide\doublecolumnhsize by 2 \hsize = \doublecolumnhsize % - % Double the \vsize as well. + % Get the available space for the double columns -- the normal + % (undoubled) page height minus any material left over from the + % previous page. \advance\vsize by -\ht\partialpage \vsize = 2\vsize % @@ -5886,16 +5888,13 @@ \def\doublecolumnout{% % \splittopskip=\topskip \splitmaxdepth=\maxdepth - % Get the available space for the double columns -- the normal - % (undoubled) page height minus any material left over from the - % previous page. \dimen@ = \vsize \divide\dimen@ by 2 % % box0 will be the left-hand column, box2 the right. \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@ \global\advance\vsize by 2\ht\partialpage - \onepageout\pagesofar + \onepageout\pagesofar % empty except for the first time we are called \unvbox\PAGE \penalty\outputpenalty } @@ -5978,13 +5977,14 @@ \def\balancecolumns{% \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120. \dimen@ = \ht0 - \advance\dimen@ by \topskip - \advance\dimen@ by-\baselineskip - \ifdim\dimen@<5\baselineskip + \ifdim\dimen@<7\baselineskip % Don't split a short final column in two. \setbox2=\vbox{}% \global\setbox\balancedcolumns=\vbox{\pagesofar}% \else + % double the leading vertical space + \advance\dimen@ by \topskip + \advance\dimen@ by-\baselineskip \divide\dimen@ by 2 % target to split to \dimen@ii = \dimen@ \splittopskip = \topskip @@ -11191,21 +11191,14 @@ \relax } -% define all Unicode characters we know about, for the sake of @U. +% Define all Unicode characters we know about. This makes UTF-8 the default +% input encoding and allows @U to work. \iftxinativeunicodecapable \nativeunicodechardefsatu \else \utfeightchardefs \fi - -% Make non-ASCII characters printable again for compatibility with -% existing Texinfo documents that may use them, even without declaring a -% document encoding. -% -\setnonasciicharscatcode \other - - \message{formatting,} \newdimen\defaultparindent \defaultparindent = 15pt diff --git a/lib/fstatat.c b/lib/fstatat.c index 515b569399..019d3c6163 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) } #endif +#ifdef __osf__ /* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -#include "sys/stat.h" +# include "sys/stat.h" +#else +# include +#endif #include "stat-time.h" diff --git a/lib/lstat.c b/lib/lstat.c index d57ca105fd..a3e40d826f 100644 --- a/lib/lstat.c +++ b/lib/lstat.c @@ -42,10 +42,14 @@ orig_lstat (const char *filename, struct stat *buf) } /* Specification. */ +# ifdef __osf__ /* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates this include because of the preliminary #include above. */ -# include "sys/stat.h" +# include "sys/stat.h" +# else +# include +# endif # include "stat-time.h" diff --git a/lib/nstrftime.c b/lib/nstrftime.c index 71f778a5fe..bc84da5a0c 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c @@ -180,7 +180,7 @@ extern char *tzname[]; if (digits == 0 && _n < _w) \ { \ size_t _delta = width - _n; \ - if (pad == L_('0')) \ + if (pad == L_('0') || pad == L_('+')) \ memset_zero (p, _delta); \ else \ memset_space (p, _delta); \ @@ -418,7 +418,7 @@ iso_week_days (int yday, int wday) static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t) const CHAR_T *, const struct tm *, - bool, bool * + bool, int, int, bool * extra_args_spec LOCALE_PARAM); /* 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) const struct tm *tp extra_args_spec LOCALE_PARAM) { bool tzset_called = false; - return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, - false, &tzset_called extra_args LOCALE_ARG); + return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false, + 0, -1, &tzset_called extra_args LOCALE_ARG); } #if defined _LIBC && ! FPRINTFTIME libc_hidden_def (my_strftime) @@ -446,7 +446,8 @@ libc_hidden_def (my_strftime) static size_t __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) const CHAR_T *format, - const struct tm *tp, bool upcase, bool *tzset_called + const struct tm *tp, bool upcase, + int yr_spec, int width, bool *tzset_called extra_args_spec LOCALE_PARAM) { #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) if (hour12 == 0) hour12 = 12; - for (f = format; *f != '\0'; ++f) + for (f = format; *f != '\0'; width = -1, f++) { int pad = 0; /* Padding for number ('-', '_', or 0). */ int modifier; /* Field modifier ('E', 'O', or 0). */ @@ -576,12 +577,12 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) + (sizeof (int) < sizeof (time_t) ? INT_STRLEN_BOUND (time_t) : INT_STRLEN_BOUND (int))]; - int width = -1; bool to_lowcase = false; bool to_uppcase = upcase; size_t colons; bool change_case = false; int format_char; + int subwidth; #if DO_MULTIBYTE && !defined COMPILE_WIDE switch (*f) @@ -679,6 +680,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) /* This influences the number formats. */ case L_('_'): case L_('-'): + case L_('+'): case L_('0'): pad = *f; continue; @@ -697,7 +699,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) break; } - /* As a GNU extension we allow the field width to be specified. */ if (ISDIGIT (*f)) { width = 0; @@ -743,12 +744,16 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) } \ while (0) #define DO_SIGNED_NUMBER(d, negative, v) \ + DO_MAYBE_SIGNED_NUMBER (d, negative, v, do_signed_number) +#define DO_YEARISH(d, negative, v) \ + DO_MAYBE_SIGNED_NUMBER (d, negative, v, do_yearish) +#define DO_MAYBE_SIGNED_NUMBER(d, negative, v, label) \ do \ { \ digits = d; \ negative_number = negative; \ u_number_value = v; \ - goto do_signed_number; \ + goto label; \ } \ while (0) @@ -850,7 +855,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) if (modifier == L_('O')) goto bad_format; #ifdef _NL_CURRENT - if (! (modifier == 'E' + if (! (modifier == L_('E') && (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_D_T_FMT))) @@ -861,15 +866,17 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) #endif subformat: + subwidth = -1; + subformat_width: { size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1) - subfmt, - tp, to_uppcase, tzset_called + subfmt, tp, to_uppcase, + pad, subwidth, tzset_called extra_args LOCALE_ARG); add (len, __strftime_internal (p, STRFTIME_ARG (maxsize - i) - subfmt, - tp, to_uppcase, tzset_called + subfmt, tp, to_uppcase, + pad, subwidth, tzset_called extra_args LOCALE_ARG)); } break; @@ -930,7 +937,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) { int century = tp->tm_year / 100 + TM_YEAR_BASE / 100; century -= tp->tm_year % 100 < 0 && 0 < century; - DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century); + DO_YEARISH (2, tp->tm_year < - TM_YEAR_BASE, century); } case L_('x'): @@ -939,7 +946,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) #ifdef _NL_CURRENT if (! (modifier == L_('E') && (*(subfmt = - (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) + (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) != L_('\0')))) subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); goto subformat; @@ -971,9 +978,17 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) always_output_a_sign = true; goto do_number_body; + do_yearish: + if (pad == 0) + pad = yr_spec; + always_output_a_sign + = (pad == L_('+') + && ((digits == 2 ? 99 : 9999) < u_number_value + || digits < width)); + goto do_maybe_signed_number; + do_number_spacepad: - /* Force '_' flag unless overridden by '0' or '-' flag. */ - if (pad != L_('0') && pad != L_('-')) + if (pad == 0) pad = L_('_'); do_number: @@ -983,6 +998,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) do_signed_number: always_output_a_sign = false; + + do_maybe_signed_number: tz_colon_mask = 0; do_number_body: @@ -1087,8 +1104,19 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) case L_('F'): if (modifier != 0) goto bad_format; + if (pad == 0 && width < 0) + { + pad = L_('+'); + subwidth = 4; + } + else + { + subwidth = width - 6; + if (subwidth < 0) + subwidth = 0; + } subfmt = L_("%Y-%m-%d"); - goto subformat; + goto subformat_width; case L_('H'): if (modifier == L_('E')) @@ -1297,17 +1325,18 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) case L_('g'): { int yy = (tp->tm_year % 100 + year_adjust) % 100; - DO_NUMBER (2, (0 <= yy - ? yy - : tp->tm_year < -TM_YEAR_BASE - year_adjust - ? -yy - : yy + 100)); + DO_YEARISH (2, false, + (0 <= yy + ? yy + : tp->tm_year < -TM_YEAR_BASE - year_adjust + ? -yy + : yy + 100)); } case L_('G'): - DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, - (tp->tm_year + (unsigned int) TM_YEAR_BASE - + year_adjust)); + DO_YEARISH (4, tp->tm_year < -TM_YEAR_BASE - year_adjust, + (tp->tm_year + (unsigned int) TM_YEAR_BASE + + year_adjust)); default: DO_NUMBER (2, days / 7 + 1); @@ -1327,7 +1356,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) DO_NUMBER (1, tp->tm_wday); case L_('Y'): - if (modifier == 'E') + if (modifier == L_('E')) { #if HAVE_STRUCT_ERA_ENTRY 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) # else subfmt = era->era_format; # endif + if (pad == 0) + pad = yr_spec; goto subformat; } #else @@ -1347,8 +1378,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) if (modifier == L_('O')) goto bad_format; - DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE, - tp->tm_year + (unsigned int) TM_YEAR_BASE); + DO_YEARISH (4, tp->tm_year < -TM_YEAR_BASE, + tp->tm_year + (unsigned int) TM_YEAR_BASE); case L_('y'): if (modifier == L_('E')) @@ -1358,7 +1389,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) if (era) { int delta = tp->tm_year - era->start_date[0]; - DO_NUMBER (1, (era->offset + if (pad == 0) + pad = yr_spec; + DO_NUMBER (2, (era->offset + delta * era->absolute_direction)); } #else @@ -1370,7 +1403,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) int yy = tp->tm_year % 100; if (yy < 0) yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100; - DO_NUMBER (2, yy); + DO_YEARISH (2, false, yy); } case L_('Z'): diff --git a/lib/vla.h b/lib/vla.h index f6ebba0ede..8f5dea76f6 100644 --- a/lib/vla.h +++ b/lib/vla.h @@ -17,6 +17,20 @@ Written by Paul Eggert. */ +/* The VLA_ELEMS macro does not allocate variable-length arrays (VLAs), + so it does not have the security or performance issues commonly + associated with VLAs. VLA_ELEMS is for exploiting a C11 feature + where a function can start like this: + + double scan_array (int n, double v[static n]) + + to require a caller to pass a vector V with at least N elements; + this allows better static checking and performance in some cases. + In C11 this feature means that V is a VLA, so the feature is + supported only if __STDC_NO_VLA__ is defined, and for compatibility + to platforms that do not support VLAs, VLA_ELEMS (n) expands to + nothing when __STDC_NO_VLA__ is not defined. */ + /* A function's argument must point to an array with at least N elements. Example: 'int main (int argc, char *argv[VLA_ELEMS (argc)]);'. */ @@ -25,3 +39,15 @@ #else # define VLA_ELEMS(n) static n #endif + +/* Although C99 requires support for variable-length arrays (VLAs), + some C compilers never supported VLAs and VLAs are optional in C11. + VLAs are controversial because their allocation may be unintended + or awkward to support, and large VLAs might cause security or + performance problems. GCC can diagnose the use of VLAs via the + -Wvla and -Wvla-larger-than warnings options, and defining the + macro GNULIB_NO_VLA disables the allocation of VLAs in Gnulib code. + + The VLA_ELEMS macro is unaffected by GNULIB_NO_VLA, since it does + not allocate VLAs. Programs that use VLA_ELEMS should be compiled + with 'gcc -Wvla-larger-than' instead of with 'gcc -Wvla'. */ commit cedc3410d4feab7b4beeef3eab474fbabad4035c Author: Michael Albinus Date: Mon Feb 25 11:59:52 2019 +0100 Adapt hooks in Tramp * lisp/net/tramp-archive.el (tramp-archive-cleanup-hash): Remove autoload cookie. (tramp-cleanup-all-connections-hook): Add `tramp-archive-cleanup-hash'. * lisp/net/tramp-cmds.el (tramp-cleanup-connection-hook) (tramp-cleanup-all-connections-hook): New hook variables. (tramp-cleanup-connection): Set `tramp-current-connection' always to nil. (tramp-cleanup-connection): Do not call `tramp-recentf-cleanup'. Run ´tramp-cleanup-connection-hook`. (tramp-cleanup-all-connections): Do not call `tramp-archive-cleanup-hash' and ´tramp-recentf-cleanup'. Run `tramp-cleanup-all-connections-hook'. * lisp/net/tramp-ftp.el (top): Simply call `tramp-disable-ange-ftp'. * lisp/net/tramp-integration.el (tramp-recentf-cleanup-all): New defun. (top): Adapt `tramp-integration-unload-hook', `tramp-cleanup-connection-hook' and `tramp-cleanup-all-connections-hook'. diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index db9aec05c2..dcddb0ec67 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -369,13 +369,13 @@ pass to the OPERATION." (when url-handler-mode (tramp-register-file-name-handlers)) (eval-after-load 'url-handler - (progn - (add-hook 'url-handler-mode-hook 'tramp-register-file-name-handlers) - (add-hook - 'tramp-archive-unload-hook - (lambda () - (remove-hook - 'url-handler-mode-hook 'tramp-register-file-name-handlers))))) + '(progn + (add-hook 'url-handler-mode-hook 'tramp-register-file-name-handlers) + (add-hook + 'tramp-archive-unload-hook + (lambda () + (remove-hook + 'url-handler-mode-hook 'tramp-register-file-name-handlers))))) ;; File name conversions. @@ -467,7 +467,6 @@ name is kept in slot `hop'" (setf (tramp-file-name-localname vec) localname) vec))) -;;;###tramp-autoload (defun tramp-archive-cleanup-hash () "Remove local copies of archives, used by GVFS." (maphash @@ -482,9 +481,12 @@ name is kept in slot `hop'" tramp-archive-hash) (clrhash tramp-archive-hash)) +(add-hook 'tramp-cleanup-all-connections-hook 'tramp-archive-cleanup-hash) (add-hook 'kill-emacs-hook 'tramp-archive-cleanup-hash) (add-hook 'tramp-archive-unload-hook (lambda () + (remove-hook 'tramp-cleanup-all-connections-hook + 'tramp-archive-cleanup-hash) (remove-hook 'kill-emacs-hook 'tramp-archive-cleanup-hash))) diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index 38e440e093..cf4f741747 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -68,6 +68,11 @@ SYNTAX can be one of the symbols `default' (default), (with-current-buffer x (when (tramp-tramp-file-p default-directory) x))) (buffer-list)))) +;;;###tramp-autoload +(defvar tramp-cleanup-connection-hook nil + "List of functions to be called after Tramp connection is cleaned up. +Each function is called with the current vector as argument.") + ;;;###tramp-autoload (defun tramp-cleanup-connection (vec &optional keep-debug keep-password) "Flush all connection related objects. @@ -99,9 +104,8 @@ When called interactively, a Tramp connection has to be selected." (unless keep-password (tramp-clear-passwd vec)) ;; Cleanup `tramp-current-connection'. Otherwise, we would be - ;; suppressed in the test suite. We use `keep-password' as - ;; indicator; it is not worth to add a new argument. - (when keep-password (setq tramp-current-connection nil)) + ;; suppressed. + (setq tramp-current-connection nil) ;; Flush file cache. (tramp-flush-directory-properties vec "") @@ -120,8 +124,8 @@ When called interactively, a Tramp connection has to be selected." (tramp-get-connection-property vec "process-buffer" nil))) (when (bufferp buf) (kill-buffer buf))) - ;; Remove recentf files. - (tramp-recentf-cleanup vec))) + ;; The end. + (run-hook-with-args 'tramp-cleanup-connection-hook vec))) ;;;###tramp-autoload (defun tramp-cleanup-this-connection () @@ -131,6 +135,10 @@ When called interactively, a Tramp connection has to be selected." (tramp-cleanup-connection (tramp-dissect-file-name default-directory 'noexpand)))) +;;;###tramp-autoload +(defvar tramp-cleanup-all-connections-hook nil + "List of functions to be called after all Tramp connections are cleaned up.") + ;;;###tramp-autoload (defun tramp-cleanup-all-connections () "Flush all Tramp internal objects. @@ -146,10 +154,6 @@ This includes password cache, file cache, connection cache, buffers." ;; Flush file and connection cache. (clrhash tramp-cache-data) - ;; Cleanup local copies of archives. - (when (bound-and-true-p tramp-archive-enabled) - (tramp-archive-cleanup-hash)) - ;; Remove ad-hoc proxies. (let ((proxies tramp-default-proxies-alist)) (while proxies @@ -167,9 +171,8 @@ This includes password cache, file cache, connection cache, buffers." (dolist (name (tramp-list-tramp-buffers)) (when (bufferp (get-buffer name)) (kill-buffer name))) - ;; Remove recentf files. - (dolist (v (tramp-list-connections)) - (tramp-recentf-cleanup v))) + ;; The end. + (run-hooks 'tramp-cleanup-all-connections-hook)) ;;;###tramp-autoload (defun tramp-cleanup-all-buffers () diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el index 4807fe0701..8735d13f9d 100644 --- a/lisp/net/tramp-ftp.el +++ b/lisp/net/tramp-ftp.el @@ -54,8 +54,7 @@ present for backward compatibility." (delete a1 (delete a2 file-name-handler-alist))))) (eval-after-load "ange-ftp" - '(when (functionp 'tramp-disable-ange-ftp) - (tramp-disable-ange-ftp))) + '(tramp-disable-ange-ftp)) ;;;###tramp-autoload (defun tramp-ftp-enable-ange-ftp () diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el index f3f95f1b69..e2a0d6b206 100644 --- a/lisp/net/tramp-integration.el +++ b/lisp/net/tramp-integration.el @@ -128,7 +128,7 @@ been set up by `rfn-eshadow-setup-minibuffer'." 'tramp-eshell-directory-change) (add-hook 'eshell-directory-change-hook 'tramp-eshell-directory-change) - (add-hook 'tramp-unload-hook + (add-hook 'tramp-integration-unload-hook (lambda () (remove-hook 'eshell-mode-hook 'tramp-eshell-directory-change) @@ -151,6 +151,25 @@ NAME must be equal to `tramp-current-connection'." (recentf-exclude '(tramp-recentf-exclude-predicate))) (recentf-cleanup)))) +(defun tramp-recentf-cleanup-all () + "Remove all remote file names from recentf." + (when (bound-and-true-p recentf-list) + (let ((recentf-exclude '(file-remote-p))) + (recentf-cleanup)))) + +(eval-after-load "recentf" + '(progn + (add-hook 'tramp-cleanup-connection-hook + 'tramp-recentf-cleanup) + (add-hook 'tramp-cleanup-all-connections-hook + 'tramp-recentf-cleanup-all) + (add-hook 'tramp-integration-unload-hook + (lambda () + (remove-hook 'tramp-cleanup-connection-hook + 'tramp-recentf-cleanup) + (remove-hook 'tramp-cleanup-all-connections-hook + 'tramp-recentf-cleanup-all))))) + (add-hook 'tramp-unload-hook (lambda () (unload-feature 'tramp-integration 'force)))