commit 7dafbe3ab91e838803a84ab388bca03ff985e312 (HEAD, refs/remotes/origin/master) Author: Basil L. Contovounesios Date: Wed May 1 00:39:54 2019 +0100 Minor region-noncontiguous-p simplification * lisp/simple.el (region-noncontiguous-p): Don't needlessly traverse region-bounds. diff --git a/lisp/simple.el b/lisp/simple.el index 5660f6574f..acea1f9ddc 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5612,7 +5612,7 @@ see `region-noncontiguous-p' and `extract-rectangle-bounds'." "Return non-nil if the region contains several pieces. An example is a rectangular region handled as a list of separate contiguous regions for each line." - (> (length (region-bounds)) 1)) + (cdr (region-bounds))) (defvar redisplay-unhighlight-region-function (lambda (rol) (when (overlayp rol) (delete-overlay rol)))) commit 910d170771ac74ab76d6dcb2dda3f3167e01b705 Author: Stefan Monnier Date: Tue Apr 30 14:56:29 2019 -0400 * lisp/progmodes/cc-engine.el: Silence minor compiler warnings (c-restricted-<>-arglists, c-parse-and-markup-<>-arglists): Move declaration before first use. (c-after-change-unmark-raw-strings): Remove unused var `found-end`. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 5d1b4bbed6..a0459b9f2a 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -1812,7 +1812,7 @@ comment at the start of cc-engine.el for more info." (setcar c-sws-lit-limits (match-beginning 1)) (setq c-sws-lit-limits (cons (match-beginning 1) (match-end 1))))))) -(defun c-invalidate-sws-region-after-del (beg end old-len) +(defun c-invalidate-sws-region-after-del (beg end _old-len) ;; Text has been deleted, OLD-LEN characters of it starting from position ;; BEG. END is typically eq to BEG. Should there have been a comment or ;; CPP construct open at END before the deletion, check whether this @@ -5475,6 +5475,9 @@ comment at the start of cc-engine.el for more info." (setq c-bs-cache-limit (min c-bs-cache-limit pos))) +(defvar c-restricted-<>-arglists) ;FIXME: Move definition here? +(defvar c-parse-and-markup-<>-arglists) ;FIXME: Move definition here? + (defun c-update-brace-stack (stack from to) ;; Given a brace-stack which has the value STACK at position FROM, update it ;; to its value at position TO, where TO is after (or equal to) FROM. @@ -6488,9 +6491,6 @@ comment at the start of cc-engine.el for more info." (c-clear-<>-pair-props) (forward-char))))))) -(defvar c-restricted-<>-arglists) ;FIXME: Move definition here? -(defvar c-parse-and-markup-<>-arglists) ;FIXME: Move definition here? - (defun c-restore-<>-properties (_beg _end _old-len) ;; This function is called as an after-change function. It restores the ;; category/syntax-table properties on template/generic <..> pairs between @@ -6927,7 +6927,7 @@ comment at the start of cc-engine.el for more info." ;; This functions is called as an after-change function by virtue of its ;; membership of the C++ value of `c-before-font-lock-functions'. ;; (when (< beg end) - (c-save-buffer-state (found eoll state id found-beg found-end) + (c-save-buffer-state (found eoll state id found-beg) ;; Has an inserted " swallowed up a R"(, turning it into "...R"(? (goto-char end) (setq eoll (c-point 'eoll)) commit 325f51c84d9ad4d9776784bd324b347ffe4fe51b Author: Paul Eggert Date: Tue Apr 30 10:45:48 2019 -0700 Fix decode-time/encode-time roundtrip on macOS * src/timefns.c (Fencode_time): Ignore DST flag when the zone is numeric or is a cons, as the doc string says it’s ignored in that case, and not ignoring it causes encode-time to not invert decode-time on some platforms (Bug#35502). * test/src/timefns-tests.el (encode-time-dst-numeric-zone): New test. diff --git a/src/timefns.c b/src/timefns.c index 5005c73b7f..7b5af6a5d2 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -1488,10 +1488,11 @@ usage: (encode-time &optional TIME FORM &rest OBSOLESCENT-ARGUMENTS) */) tm.tm_mon = check_tm_member (XCAR (a), 1); a = XCDR (a); tm.tm_year = check_tm_member (XCAR (a), TM_YEAR_BASE); a = XCDR (a); a = XCDR (a); - if (SYMBOLP (XCAR (a))) - tm.tm_isdst = !NILP (XCAR (a)); + Lisp_Object dstflag = XCAR (a); a = XCDR (a); zone = XCAR (a); + if (SYMBOLP (dstflag) && !FIXNUMP (zone) && !CONSP (zone)) + tm.tm_isdst = !NILP (dstflag); } else if (nargs < 6) xsignal2 (Qwrong_number_of_arguments, Qencode_time, make_fixnum (nargs)); diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el index 5c858ef3bd..2c90af757f 100644 --- a/test/src/timefns-tests.el +++ b/test/src/timefns-tests.el @@ -142,3 +142,9 @@ (< 0.99 (/ x y) 1.01) (< 0.99 (/ (- (float-time a)) (float-time b)) 1.01)))))))) + +(ert-deftest encode-time-dst-numeric-zone () + "Check for Bug#35502." + (should (time-equal-p + (encode-time '(29 31 17 30 4 2019 2 t 7200)) + '(23752 27217)))) commit 35ef33dd234707d611e2a307a3500b4dbcf46cf6 Author: Stefan Monnier Date: Tue Apr 30 13:42:44 2019 -0400 * lisp/progmodes/cc-fonts.el: Silence some compiler warnings (c-font-lock-declarators): Mark `id_end` and `not-top` as unused. diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index c7c9aa5564..5f09be60a6 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -1042,7 +1042,7 @@ casts and declarations are fontified. Used on level 2 and higher." (c-do-declarators limit list not-top (if types 'c-decl-type-start 'c-decl-id-start) - (lambda (id-start id-end end-pos not-top is-function init-char) + (lambda (id-start _id-end end-pos _not-top is-function init-char) (if types ;; Register and fontify the identifier as a type. (let ((c-promote-possible-types t)) commit 46b434a62cea06bdcb3c8d9ee18284ab59e9b012 Author: Paul Eggert Date: Tue Apr 30 09:44:38 2019 -0700 Update from Gnulib * build-aux/config.guess, doc/misc/texinfo.tex: * lib/mktime-internal.h, lib/mktime.c, lib/timegm.c: Copy from Gnulib. * lib/gnulib.mk.in: Regenerate. diff --git a/build-aux/config.guess b/build-aux/config.guess index 79d1317f52..4cd9454b35 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-03-04' +timestamp='2019-04-28' # 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 @@ -1468,6 +1468,14 @@ cat > "$dummy.c" < #include #endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif main () { #if defined (sony) @@ -1554,19 +1562,24 @@ main () #else printf ("vax-dec-bsd\n"); exit (0); #endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif +#endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) -#include -#if defined(_SIZE_T_) /* >= ULTRIX4 */ - printf ("mips-dec-ultrix4\n"); exit (0); +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); #else -#if defined(ULTRIX3) || defined(ultrix3) || defined(SIGLOST) - printf ("mips-dec-ultrix3\n"); exit (0); -#endif + printf ("mips-dec-ultrix\n"); exit (0); #endif #endif #endif diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex index 192284cccc..ccd112941a 100644 --- a/doc/misc/texinfo.tex +++ b/doc/misc/texinfo.tex @@ -3,8 +3,7 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2019-03-03.15} - +\def\texinfoversion{2019-04-12.13} % % Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc. % @@ -387,14 +386,8 @@ % take effect in \write's, yet the group defined by the \vbox ends % before the \shipout runs. % - \indexdummies % don't expand commands in the output. - \normalturnoffactive % \ in index entries must not stay \, e.g., if - % the page break happens to be in the middle of an example. - % We don't want .vr (or whatever) entries like this: - % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}} - % "\acronym" won't work when it's read back in; - % it needs to be - % {\code {{\backslashcurfont }acronym} + \atdummies % don't expand commands in the output. + \turnoffactive \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi @@ -455,11 +448,10 @@ }% } -% First remove any @comment, then any @c comment. Also remove a @texinfoc -% comment (see \scanmacro for details). Pass the result on to \argcheckspaces. +% First remove any @comment, then any @c comment. Pass the result on to +% \argcheckspaces. \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} -\def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm} -\def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} +\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} % Each occurrence of `\^^M' or `\^^M' is replaced by a single space. % @@ -1131,6 +1123,16 @@ \fi \fi +\newif\ifpdforxetex +\pdforxetexfalse +\ifpdf + \pdforxetextrue +\fi +\ifx\XeTeXrevision\thisisundefined\else + \pdforxetextrue +\fi + + % PDF uses PostScript string constants for the names of xref targets, % for display in the outlines, and in other places. Thus, we have to % double any backslashes. Otherwise, a name like "\node" will be @@ -2173,7 +2175,7 @@ % A few fonts for @defun names and args. \setfont\defbf\bfshape{10}{\magstep1}{OT1} \setfont\deftt\ttshape{10}{\magstep1}{OT1TT} -\setfont\defsl\slshape{10}{\magstep1}{OT1TT} +\setfont\defsl\slshape{10}{\magstep1}{OT1} \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} \def\df{\let\ttfont=\deftt \let\bffont = \defbf \let\ttslfont=\defttsl \let\slfont=\defsl \bf} @@ -2321,7 +2323,7 @@ % A few fonts for @defun names and args. \setfont\defbf\bfshape{10}{\magstephalf}{OT1} \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} -\setfont\defsl\slshape{10}{\magstephalf}{OT1TT} +\setfont\defsl\slshape{10}{\magstephalf}{OT1} \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} \def\df{\let\ttfont=\deftt \let\bffont = \defbf \let\slfont=\defsl \let\ttslfont=\defttsl \bf} @@ -2844,7 +2846,7 @@ % @t, explicit typewriter. \def\t#1{% - {\tt \rawbackslash \plainfrenchspacing #1}% + {\tt \plainfrenchspacing #1}% \null } @@ -2871,7 +2873,6 @@ % Turn off hyphenation. \nohyphenation % - \rawbackslash \plainfrenchspacing #1% }% @@ -3097,9 +3098,9 @@ % Allow a ragged right output to aid breaking long URL's. Putting stretch in % between characters of the URL doesn't look good. \def\urefallowbreak{% - \hskip 0pt plus 1fil\relax + \hskip 0pt plus 4 em\relax \allowbreak - \hskip 0pt plus -1fil\relax + \hskip 0pt plus -4 em\relax } \urefbreakstyle after @@ -3112,7 +3113,7 @@ % So now @email is just like @uref, unless we are pdf. % %\def\email#1{\angleleft{\tt #1}\angleright} -\ifpdf +\ifpdforxetex \def\email#1{\doemail#1,,\finish} \def\doemail#1,#2,#3\finish{\begingroup \unsepspaces @@ -3122,18 +3123,7 @@ \endlink \endgroup} \else - \ifx\XeTeXrevision\thisisundefined - \let\email=\uref - \else - \def\email#1{\doemail#1,,\finish} - \def\doemail#1,#2,#3\finish{\begingroup - \unsepspaces - \pdfurl{mailto:#1}% - \setbox0 = \hbox{\ignorespaces #2}% - \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi - \endlink - \endgroup} - \fi + \let\email=\uref \fi % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), @@ -4667,19 +4657,6 @@ } } -% We have this subroutine so that we can handle at least some @value's -% properly in indexes (we call \makevalueexpandable in \indexdummies). -% The command has to be fully expandable (if the variable is set), since -% the result winds up in the index file. This means that if the -% variable's value contains other Texinfo commands, it's almost certain -% it will fail (although perhaps we could fix that with sufficient work -% to do a one-level expansion on the result, instead of complete). -% -% Unfortunately, this has the consequence that when _ is in the *value* -% of an @set, it does not print properly in the roman fonts (get the cmr -% dot accent at position 126 instead). No fix comes to mind, and it's -% been this way since 2003 or earlier, so just ignore it. -% \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']}% @@ -4708,7 +4685,7 @@ % if possible, otherwise sort late. \def\indexnofontsvalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax - ZZZZZZZ + ZZZZZZZ% \else \csname SET#1\endcsname \fi @@ -4858,23 +4835,8 @@ \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}} -% Used when writing an index entry out to an index file to prevent -% expansion of Texinfo commands that can appear in an index entry. -% -\def\indexdummies{% - \escapechar = `\\ % use backslash in output files. - \definedummyletter\@% - \definedummyletter\ % - % - % For texindex which always views { and } as separators. - \def\{{\lbracechar{}}% - \def\}{\rbracechar{}}% - % - % Do the redefinitions. - \definedummies -} - -% Used for the aux and toc files, where @ is the escape character. +% Used for the aux, toc and index files to prevent expansion of Texinfo +% commands. % \def\atdummies{% \definedummyletter\@% @@ -4904,8 +4866,7 @@ \def\definedummyletter#1{\def#1{\string#1}}% \let\definedummyaccent\definedummyletter -% Called from \indexdummies and \atdummies, to effectively prevent -% the expansion of commands. +% Called from \atdummies to prevent the expansion of commands. % \def\definedummies{% % @@ -4954,6 +4915,7 @@ % Assorted special characters. \definedummyword\atchar \definedummyword\arrow + \definedummyword\backslashchar \definedummyword\bullet \definedummyword\comma \definedummyword\copyright @@ -5070,11 +5032,10 @@ \commondummyword\xref } -% This does nothing, but for a time it was recommended to use -% \usebracesinindexestrue to be able to use braces in index entries. - \let\indexlbrace\relax \let\indexrbrace\relax +\let\indexatchar\relax +\let\indexbackslash\relax {\catcode`\@=0 \catcode`\\=13 @@ -5108,10 +5069,8 @@ } \gdef\indexnonalnumreappear{% - \useindexbackslash \let-\normaldash \let<\normalless - \def\@{@}% } } @@ -5222,8 +5181,6 @@ -\let\SETmarginindex=\relax % put index entries in margin (undocumented)? - % #1 is the index name, #2 is the entry text. \def\doind#1#2{% \iflinks @@ -5255,13 +5212,6 @@ \fi} \def\indexisfl{fl} -% Output \ as {\indexbackslash}, because \ is an escape character in -% the index files. -\let\indexbackslash=\relax -{\catcode`\@=0 \catcode`\\=\active - @gdef@useindexbackslash{@def\{{@indexbackslash}}} -} - % Definition for writing index entry sort key. { \catcode`\-=13 @@ -5273,14 +5223,31 @@ \xdef\indexsortkey{#1}\endgroup} } +\def\indexwriteseealso#1{ + \gdef\pagenumbertext{@seealso{#1}}% +} +\def\indexwriteseeentry#1{ + \gdef\pagenumbertext{@seeentry{#1}}% +} + +% The default definitions +\def\sortas#1{}% +\def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only +\def\putwordSeeAlso{See also} +\def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only + + % Given index entry text like "aaa @subentry bbb @sortas{ZZZ}": % * Set \bracedtext to "{aaa}{bbb}" % * Set \fullindexsortkey to "aaa @subentry ZZZ" +% * If @seealso occurs, set \pagenumbertext % \def\splitindexentry#1{% \gdef\fullindexsortkey{}% \xdef\bracedtext{}% \def\sep{}% + \def\seealso##1{}% + \def\seeentry##1{}% \expandafter\doindexsegment#1\subentry\finish\subentry } @@ -5292,7 +5259,6 @@ % % Fully expand the segment, throwing away any @sortas directives, and % trim spaces. - \def\sortas##1{}% \edef\trimmed{\segment}% \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}% % @@ -5302,16 +5268,23 @@ % font commands turned off. \bgroup \let\sortas\indexwritesortas + \let\seealso\indexwriteseealso + \let\seeentry\indexwriteseeentry \indexnofonts % The braces around the commands are recognized by texindex. - \def\lbracechar{{\indexlbrace}}% - \def\rbracechar{{\indexrbrace}}% + \def\lbracechar{{\string\indexlbrace}}% + \def\rbracechar{{\string\indexrbrace}}% \let\{=\lbracechar \let\}=\rbracechar + \def\@{{\string\indexatchar}}% + \def\atchar##1{\@}% + \def\backslashchar{{\string\indexbackslash}}% + \uccode`\~=`\\ \uppercase{\let~\backslashchar}% % \let\indexsortkey\empty + \global\let\pagenumbertext\empty % Execute the segment and throw away the typeset output. This executes - % any @sortas commands in this segment. + % any @sortas or @seealso commands in this segment. \setbox\dummybox = \hbox{\segment}% \ifx\indexsortkey\empty{% \indexnonalnumdisappear @@ -5332,21 +5305,31 @@ \fi } \def\isfinish{\finish}% +\newbox\dummybox % used above \let\subentry\relax -% Write the entry in \toks0 to the index file. +% Use \ instead of @ in index files. To support old texi2dvi and texindex. +% This works without changing the escape character used in the toc or aux +% files because the index entries are fully expanded here, and \string uses +% the current value of \escapechar. +\def\escapeisbackslash{\escapechar=`\\} + +% Write the entry in \indextext to the index file. % \def\doindwrite{% - % Put the index entry in the margin if desired. - \ifx\SETmarginindex\relax\else - \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% + \maybemarginindex + % + \atdummies + % + \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else + \escapeisbackslash \fi % - % Remember, we are within a group. - \indexdummies % Must do this here, since \bf, etc expand at this stage - \useindexbackslash % \indexbackslash isn't defined now so it will be output - % as is; and it will print as backslash. + % For texindex which always views { and } as separators. + \def\{{\lbracechar{}}% + \def\}{\rbracechar{}}% + \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}% % % Split the entry into primary entry and any subentries, and get the index % sort key. @@ -5360,11 +5343,21 @@ % \edef\temp{% \write\writeto{% - \string\entry{\fullindexsortkey}{\noexpand\folio}\bracedtext}% + \string\entry{\fullindexsortkey}% + {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}% + \bracedtext}% }% \temp } -\newbox\dummybox % used above + +% Put the index entry in the margin if desired (undocumented). +\def\maybemarginindex{% + \ifx\SETmarginindex\relax\else + \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}% + \fi +} +\let\SETmarginindex=\relax + % Take care of unwanted page breaks/skips around a whatsit: % @@ -5452,9 +5445,14 @@ % \entry {topic}{pagelist} % for a topic that is used without subtopics % \primary {topic} +% \entry {topic}{} % for the beginning of a topic that is used with subtopics % \secondary {subtopic}{pagelist} % for each subtopic. +% \secondary {subtopic}{} +% for a subtopic with sub-subtopics +% \tertiary {subtopic}{subsubtopic}{pagelist} +% for each sub-subtopic. % Define the user-accessible indexing commands % @findex, @vindex, @kindex, @cindex. @@ -5479,14 +5477,10 @@ \plainfrenchspacing \everypar = {}% don't want the \kern\-parindent from indentation suppression. % - % See if the index file exists and is nonempty. - % Change catcode of @ here so that if the index file contains - % \initial {@} - % as its first line, TeX doesn't complain about mismatched braces - % (because it thinks @} is a control sequence). - \catcode`\@ = 12 % See comment in \requireopenindexfile. \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi + % + % See if the index file exists and is nonempty. \openin 1 \jobname.\indexname s \ifeof 1 % \enddoublecolumns gets confused if there is no text in the index, @@ -5496,8 +5490,6 @@ \putwordIndexNonexistent \typeout{No file \jobname.\indexname s.}% \else - \catcode`\\ = 0 - % % If the index file exists but is empty, then \openin leaves \ifeof % false. We have to make TeX try to read something from the file, so % it can discover if there is anything in it. @@ -5505,47 +5497,52 @@ \ifeof 1 \putwordIndexIsEmpty \else - % Index files are almost Texinfo source, but we use \ as the escape - % character. It would be better to use @, but that's too big a change - % to make right now. - \def\indexbackslash{\ttbackslash}% - \let\indexlbrace\{ % Likewise, set these sequences for braces - \let\indexrbrace\} % used in the sort key. - \begindoublecolumns - \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty - % - % Read input from the index file line by line. - \loopdo - \ifeof1 \else - \read 1 to \nextline - \fi - % - \indexinputprocessing - \thisline - % - \ifeof1\else - \let\thisline\nextline - \repeat - %% - \enddoublecolumns + \expandafter\printindexzz\thisline\relax\relax\finish% \fi \fi \closein 1 \endgroup} -\def\loopdo#1\repeat{\def\body{#1}\loopdoxxx} -\def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next} -\def\indexinputprocessing{% - \ifeof1 - \let\firsttoken\relax +% If the index file starts with a backslash, forgo reading the index +% file altogether. If somebody upgrades texinfo.tex they may still have +% old index files using \ as the escape character. Reading this would +% at best lead to typesetting garbage, at worst a TeX syntax error. +\def\printindexzz#1#2\finish{% + \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax + \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1 + \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax +\errmessage{% +ERROR: A sorted index file in an obsolete format was skipped. +To fix this problem, please upgrade your version of 'texi2dvi' +or 'texi2pdf' to that at . +If you are using an old version of 'texindex' (part of the Texinfo +distribution), you may also need to upgrade to a newer version (at least 6.0). +You may be able to typeset the index if you run +'texindex \jobname.\indexname' yourself. +You could also try setting the 'txiindexescapeisbackslash' flag by +running a command like +'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'. If you do +this, Texinfo will try to use index files in the old format. +If you continue to have problems, deleting the index files and starting again +might help (with 'rm \jobname.?? \jobname.??s')% +}% + \else + (Skipped sorted index file in obsolete format) + \fi + \else + \begindoublecolumns + \input \jobname.\indexname s + \enddoublecolumns + \fi \else - \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}% - \act + \message{trying to print index \indexname}% + \begindoublecolumns + \catcode`\\=0\relax + \catcode`\@=12\relax + \input \jobname.\indexname s + \enddoublecolumns \fi } -\def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken} -\long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1} - % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. @@ -5554,12 +5551,19 @@ \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13 \catcode`\$=3 \gdef\initialglyphs{% + % special control sequences used in the index sort key + \let\indexlbrace\{% + \let\indexrbrace\}% + \let\indexatchar\@% + \def\indexbackslash{\math{\backslash}}% + % % Some changes for non-alphabetic characters. Using the glyphs from the % math fonts looks more consistent than the typewriter font used elsewhere % for these characters. - \def\indexbackslash{\math{\backslash}}% - \let\\=\indexbackslash + \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}} % + % In case @\ is used for backslash + \uppercase{\let\\=~} % Can't get bold backslash so don't use bold forward slash \catcode`\/=13 \def/{{\secrmnotbold \normalslash}}% @@ -5618,12 +5622,6 @@ % \def\entry{% \begingroup - % - % For pdfTeX and XeTeX. - % The redefinition of \domark stops marks being added in \pdflink to - % preserve coloured links across page boundaries. Otherwise the marks - % would get in the way of \lastbox in \insertentrybox. - \let\domark\relax % % Start a new paragraph if necessary, so our assignments below can't % affect previous text. @@ -5657,35 +5655,31 @@ \gdef\finishentry#1{% \egroup % end box A \dimen@ = \wd\boxA % Length of text of entry - \global\setbox\boxA=\hbox\bgroup\unhbox\boxA - % #1 is the page number. - % - % Get the width of the page numbers, and only use - % leaders if they are present. - \global\setbox\boxB = \hbox{#1}% - \ifdim\wd\boxB = 0pt - \null\nobreak\hfill\ % - \else - % - \null\nobreak\indexdotfill % Have leaders before the page number. + \global\setbox\boxA=\hbox\bgroup + \unhbox\boxA + % #1 is the page number. % - \ifpdf - \pdfgettoks#1.% - \hskip\skip\thinshrinkable\the\toksA + % Get the width of the page numbers, and only use + % leaders if they are present. + \global\setbox\boxB = \hbox{#1}% + \ifdim\wd\boxB = 0pt + \null\nobreak\hfill\ % \else - \ifx\XeTeXrevision\thisisundefined - \hskip\skip\thinshrinkable #1% - \else + % + \null\nobreak\indexdotfill % Have leaders before the page number. + % + \ifpdforxetex \pdfgettoks#1.% \hskip\skip\thinshrinkable\the\toksA + \else + \hskip\skip\thinshrinkable #1% \fi \fi - \fi \egroup % end \boxA \ifdim\wd\boxB = 0pt - \global\setbox\entrybox=\vbox{\unhbox\boxA}% - \else - \global\setbox\entrybox=\vbox\bgroup + \noindent\unhbox\boxA\par + \nobreak + \else\bgroup % We want the text of the entries to be aligned to the left, and the % page numbers to be aligned to the right. % @@ -5751,55 +5745,11 @@ \egroup % The \vbox \fi \endgroup - \dotheinsertentrybox }} \newskip\thinshrinkable \skip\thinshrinkable=.15em minus .15em -\newbox\entrybox -\def\insertentrybox{% - \ourunvbox\entrybox -} - -% default definition -\let\dotheinsertentrybox\insertentrybox - -% Use \lastbox to take apart vbox box by box, and add each sub-box -% to the current vertical list. -\def\ourunvbox#1{% -\bgroup % for local binding of \delayedbox - % Remove the last box from box #1 - \global\setbox#1=\vbox{% - \unvbox#1% - \unskip % remove any glue - \unpenalty - \global\setbox\interbox=\lastbox - }% - \setbox\delayedbox=\box\interbox - \ifdim\ht#1=0pt\else - \ourunvbox#1 % Repeat on what's left of the box - \nobreak - \fi - \box\delayedbox -\egroup -} -\newbox\delayedbox -\newbox\interbox - -% Used from \printindex. \firsttoken should be the first token -% after the \entry. If it's not another \entry, we are at the last -% line of a group of index entries, so insert a penalty to discourage -% widowed index entries. -\def\dotheinsertentryboxwithpenalty{% - \ifx\firsttoken\isentry - \else - \penalty 9000 - \fi - \insertentrybox -} -\def\isentry{\entry}% - % Like plain.tex's \dotfill, except uses up at least 1 em. % The filll stretch here overpowers both the fil and fill stretch to push % the page number to the right. @@ -5809,24 +5759,15 @@ \def\primary #1{\line{#1\hfil}} -\newskip\secondaryindent \secondaryindent=0.5cm -\def\secondary#1#2{{% - \parfillskip=0in - \parskip=0in - \hangindent=1in - \hangafter=1 - \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill - \ifpdf - \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. - \else - \ifx\XeTeXrevision\thisisundefined - #2 - \else - \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. - \fi - \fi - \par -}} +\def\secondary{\indententry{0.5cm}} +\def\tertiary{\indententry{1cm}} + +\def\indententry#1#2#3{% + \bgroup + \leftskip=#1 + \entry{#2}{#3}% + \egroup +} % Define two-column mode, which we use to typeset indexes. % Adapted from the TeXbook, page 416, which is to say, @@ -5844,17 +5785,6 @@ \output = {% \savetopmark % - % Here is a possibility not foreseen in manmac: if we accumulate a - % whole lot of material, we might end up calling this \output - % routine twice in a row (see the doublecol-lose test, which is - % essentially a couple of indexes with @setchapternewpage off). In - % that case we just ship out what is in \partialpage with the normal - % output routine. Generally, \partialpage will be empty when this - % runs and this will be a no-op. See the indexspread.tex test case. - \ifvoid\partialpage \else - \onepageout{\pagecontents\partialpage}% - \fi - % \global\setbox\partialpage = \vbox{% % Unvbox the main output page. \unvbox\PAGE @@ -6134,11 +6064,9 @@ % @raisesections: treat @section as chapter, @subsection as section, etc. \def\raisesections{\global\advance\secbase by -1} -\let\up=\raisesections % original BFox name % @lowersections: treat @chapter as section, @section as subsection, etc. \def\lowersections{\global\advance\secbase by 1} -\let\down=\lowersections % original BFox name % we only have subsub. \chardef\maxseclevel = 3 @@ -6790,13 +6718,8 @@ % 1 and 2 (the page numbers aren't printed), and so are the first % two pages of the document. Thus, we'd have two destinations named % `1', and two named `2'. - \ifpdf + \ifpdforxetex \global\pdfmakepagedesttrue - \else - \ifx\XeTeXrevision\thisisundefined - \else - \global\pdfmakepagedesttrue - \fi \fi } @@ -7159,11 +7082,7 @@ % @cartouche ... @end cartouche: draw rectangle w/rounded corners around % environment contents. -\font\circle=lcircle10 -\newdimen\circthick -\newdimen\cartouter\newdimen\cartinner -\newskip\normbskip\newskip\normpskip\newskip\normlskip -\circthick=\fontdimen8\circle + % \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth \def\ctr{{\hskip 6pt\circle\char'010}} @@ -7178,7 +7097,18 @@ % \newskip\lskip\newskip\rskip +% only require the font if @cartouche is actually used +\def\cartouchefontdefs{% + \font\circle=lcircle10\relax + \circthick=\fontdimen8\circle +} +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip + + \envdef\cartouche{% + \cartouchefontdefs \ifhmode\par\fi % can't be in the midst of a paragraph. \startsavinginserts \lskip=\leftskip \rskip=\rightskip @@ -8050,36 +7980,18 @@ } \fi -% alias because \c means cedilla in @tex or @math -\let\texinfoc=\c - -\newcount\savedcatcodeone -\newcount\savedcatcodetwo - % Used at the time of macro expansion. % Argument is macro body with arguments substituted \def\scanmacro#1{% \newlinechar`\^^M \def\xeatspaces{\eatspaces}% % - % Temporarily undo catcode changes of \printindex. Set catcode of @ to - % 0 so that @-commands in macro expansions aren't printed literally when - % formatting an index file, where \ is used as the escape character. - \savedcatcodeone=\catcode`\@ - \savedcatcodetwo=\catcode`\\ - \catcode`\@=0 - \catcode`\\=\active - % % Process the macro body under the current catcode regime. - \scantokens{#1@texinfoc}% - % - \catcode`\@=\savedcatcodeone - \catcode`\\=\savedcatcodetwo + \scantokens{#1@comment}% % - % The \texinfoc is to remove the \newlinechar added by \scantokens, and - % can be noticed by \parsearg. - % We avoid surrounding the call to \scantokens with \bgroup and \egroup - % to allow macros to open or close groups themselves. + % The \comment is to remove the \newlinechar added by \scantokens, and + % can be noticed by \parsearg. Note \c isn't used because this means cedilla + % in math mode. } % Used for copying and captions @@ -8180,12 +8092,14 @@ \def\macroargctxt{% \scanctxt \catcode`\ =\active + \catcode`\@=\other \catcode`\^^M=\other \catcode`\\=\active } \def\macrolineargctxt{% used for whole-line arguments without braces \scanctxt + \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other } @@ -8749,9 +8663,29 @@ % also remove a trailing comma, in case of something like this: % @node Help-Cross, , , Cross-refs \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} -\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} +\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode} + +% Used so that the @top node doesn't have to be wrapped in an @ifnottex +% conditional. +% \doignore goes to more effort to skip nested conditionals but we don't need +% that here. +\def\omittopnode{% + \ifx\lastnode\wordTop + \expandafter\ignorenode\fi +} +\def\wordTop{Top} + +% Until the next @node or @bye command, divert output to a box that is not +% output. +\def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}% +\ignorenodebye +} + +{\let\bye\relax +\gdef\ignorenodebye{\let\bye\ignorenodebyedef} +\gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}} +% The redefinition of \bye here is because it is declared \outer -\let\nwnode=\node \let\lastnode=\empty % Write a cross-reference definition for the current node. #1 is the @@ -9226,19 +9160,6 @@ \catcode`\^^]=\other \catcode`\^^^=\other \catcode`\^^_=\other - % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. - % in xref tags, i.e., node names. But since ^^e4 notation isn't - % supported in the main text, it doesn't seem desirable. Furthermore, - % that is not enough: for node names that actually contain a ^ - % character, we would end up writing a line like this: 'xrdef {'hat - % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first - % argument, and \hat is not an expandable control sequence. It could - % all be worked out, but why? Either we support ^^ or we don't. - % - % The other change necessary for this was to define \auxhat: - % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter - % and then to call \auxhat in \setq. - % \catcode`\^=\other % % Special characters. Should be turned off anyway, but... @@ -9256,14 +9177,7 @@ \catcode`\%=\other \catcode`+=\other % avoid \+ for paranoia even though we've turned it off % - % This is to support \ in node names and titles, since the \ - % characters end up in a \csname. It's easier than - % leaving it active and making its active definition an actual \ - % character. What I don't understand is why it works in the *value* - % of the xrdef. Seems like it should be a catcode12 \, and that - % should not typeset properly. But it works, so I'm moving on for - % now. --karl, 15jan04. - \catcode`\\=\other + \catcode`\\=\active % % @ is our escape character in .aux files, and we need braces. \catcode`\{=1 @@ -11534,11 +11448,9 @@ % \backslashcurfont outputs one backslash character in current font, % as in \char`\\. \global\chardef\backslashcurfont=`\\ -\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work -% \realbackslash is an actual character `\' with catcode other, and -% \doublebackslash is two of them (for the pdf outlines). -{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} +% \realbackslash is an actual character `\' with catcode other. +{\catcode`\\=\other @gdef@realbackslash{\}} % In Texinfo, backslash is an active character; it prints the backslash % in fixed width font. @@ -11556,10 +11468,8 @@ @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents. -% \rawbackslash defines an active \ to do \backslashcurfont. % \otherbackslash defines an active \ to be a literal `\' character with -% catcode other. We switch back and forth between these. -@gdef@rawbackslash{@let\=@backslashcurfont} +% catcode other. @gdef@otherbackslash{@let\=@realbackslash} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of @@ -11631,7 +11541,7 @@ @ifx\@eatinput @let\ = @ttbackslash @fi @catcode13=5 % regular end of line @enableemergencynewline - @let@c=@texinfoc + @let@c=@comment @let@parsearg@originalparsearg % Also turn back on active characters that might appear in the input % file name, in case not using a pre-dumped format. diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index ade4ff8ebd..1cbbff212b 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -1046,6 +1046,7 @@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ +emacs_major_version = @emacs_major_version@ etcdir = @etcdir@ etcdocdir = @etcdocdir@ exec_prefix = @exec_prefix@ diff --git a/lib/mktime-internal.h b/lib/mktime-internal.h index d13d89cfae..52ab781442 100644 --- a/lib/mktime-internal.h +++ b/lib/mktime-internal.h @@ -1,40 +1,56 @@ -/* mktime variant that also uses an offset guess - +/* Internals of mktime and related functions Copyright 2016-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Paul Eggert . - This program is free software; you can redistribute it and/or + The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public - License along with this program; if not, see + License along with the GNU C Library; if not, see . */ -#include +#ifndef _LIBC +# include +#endif /* mktime_offset_t is a signed type wide enough to hold a UTC offset in seconds, and used as part of the type of the offset-guess - argument to mktime_internal. Use time_t on platforms where time_t + argument to mktime_internal. In Glibc, it is always long int. + When in Gnulib, use time_t on platforms where time_t is signed, to be compatible with platforms like BeOS that export this implementation detail of mktime. On platforms where time_t is unsigned, GNU and POSIX code can assume 'int' is at least 32 bits which is wide enough for a UTC offset. */ - -#if TIME_T_IS_SIGNED +#ifdef _LIBC +typedef long int mktime_offset_t; +#elif defined TIME_T_IS_SIGNED typedef time_t mktime_offset_t; #else typedef int mktime_offset_t; #endif -time_t mktime_internal (struct tm *, - struct tm * (*) (time_t const *, struct tm *), - mktime_offset_t *); +/* The source code uses identifiers like __time64_t for glibc + timestamps that can contain 64-bit values even when time_t is only + 32 bits. These are just macros for the ordinary identifiers unless + compiling within glibc when time_t is 32 bits. */ +#if ! (defined _LIBC && __TIMESIZE != 64) +# undef __time64_t +# define __time64_t time_t +# define __gmtime64_r __gmtime_r +# define __localtime64_r __localtime_r +# define __mktime64 mktime +# define __timegm64 timegm +#endif + +#ifndef _LIBC /* Although glibc source code uses leading underscores, Gnulib wants ordinary names. @@ -45,9 +61,19 @@ time_t mktime_internal (struct tm *, Similarly for gmtime_r. See the gnulib time_r module for one way to implement this. */ -#undef __gmtime_r -#undef __localtime_r -#define __gmtime_r gmtime_r -#define __localtime_r localtime_r +# undef __gmtime_r +# undef __localtime_r +# define __gmtime_r gmtime_r +# define __localtime_r localtime_r + +# define __mktime_internal mktime_internal + +#endif -#define __mktime_internal mktime_internal +/* Subroutine of mktime. Return the time_t representation of TP and + normalize TP, given that a struct tm * maps to a time_t as performed + by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */ +extern __time64_t __mktime_internal (struct tm *tp, + struct tm *(*func) (__time64_t const *, + struct tm *), + mktime_offset_t *offset) attribute_hidden; diff --git a/lib/mktime.c b/lib/mktime.c index e3783d7a95..b00af96c8c 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -112,11 +112,11 @@ my_tzset (void) added to them, and then with another timestamp added, without worrying about overflow. - Much of the code uses long_int to represent time_t values, to - lessen the hassle of dealing with platforms where time_t is + Much of the code uses long_int to represent __time64_t values, to + lessen the hassle of dealing with platforms where __time64_t is unsigned, and because long_int should suffice to represent all - time_t values that mktime can generate even on platforms where - time_t is excessively wide. */ + __time64_t values that mktime can generate even on platforms where + __time64_t is wider than the int components of struct tm. */ #if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60 typedef long int long_int; @@ -144,16 +144,15 @@ shr (long_int a, int b) : a / (one << b) - (a % (one << b) < 0)); } -/* Bounds for the intersection of time_t and long_int. */ +/* Bounds for the intersection of __time64_t and long_int. */ static long_int const mktime_min - = ((TYPE_SIGNED (time_t) && TYPE_MINIMUM (time_t) < TYPE_MINIMUM (long_int)) - ? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (time_t)); + = ((TYPE_SIGNED (__time64_t) + && TYPE_MINIMUM (__time64_t) < TYPE_MINIMUM (long_int)) + ? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (__time64_t)); static long_int const mktime_max - = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (time_t) - ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (time_t)); - -verify (TYPE_IS_INTEGER (time_t)); + = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (__time64_t) + ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (__time64_t)); #define EPOCH_YEAR 1970 #define TM_YEAR_BASE 1900 @@ -252,23 +251,23 @@ tm_diff (long_int year, long_int yday, int hour, int min, int sec, } /* Use CONVERT to convert T to a struct tm value in *TM. T must be in - range for time_t. Return TM if successful, NULL (setting errno) on + range for __time64_t. Return TM if successful, NULL (setting errno) on failure. */ static struct tm * -convert_time (struct tm *(*convert) (const time_t *, struct tm *), +convert_time (struct tm *(*convert) (const __time64_t *, struct tm *), long_int t, struct tm *tm) { - time_t x = t; + __time64_t x = t; return convert (&x, tm); } /* Use CONVERT to convert *T to a broken down time in *TP. If *T is out of range for conversion, adjust it so that it is the nearest in-range value and then convert that. - A value is in range if it fits in both time_t and long_int. + A value is in range if it fits in both __time64_t and long_int. Return TP on success, NULL (setting errno) on failure. */ static struct tm * -ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), +ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *), long_int *t, struct tm *tp) { long_int t1 = (*t < mktime_min ? mktime_min @@ -310,7 +309,7 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), } -/* Convert *TP to a time_t value, inverting +/* Convert *TP to a __time64_t value, inverting the monotonic and mostly-unit-linear conversion function CONVERT. Use *OFFSET to keep track of a guess at the offset of the result, compared to what the result would be for UTC without leap seconds. @@ -318,9 +317,9 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), If successful, set *TP to the canonicalized struct tm; otherwise leave *TP alone, return ((time_t) -1) and set errno. This function is external because it is used also by timegm.c. */ -time_t +__time64_t __mktime_internal (struct tm *tp, - struct tm *(*convert) (const time_t *, struct tm *), + struct tm *(*convert) (const __time64_t *, struct tm *), mktime_offset_t *offset) { struct tm tm; @@ -520,9 +519,9 @@ __mktime_internal (struct tm *tp, #if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS -/* Convert *TP to a time_t value. */ -time_t -mktime (struct tm *tp) +/* Convert *TP to a __time64_t value. */ +__time64_t +__mktime64 (struct tm *tp) { /* POSIX.1 8.1.1 requires that whenever mktime() is called, the time zone names contained in the external variable 'tzname' shall @@ -531,7 +530,7 @@ mktime (struct tm *tp) # if defined _LIBC || NEED_MKTIME_WORKING static mktime_offset_t localtime_offset; - return __mktime_internal (tp, __localtime_r, &localtime_offset); + return __mktime_internal (tp, __localtime64_r, &localtime_offset); # else # undef mktime return mktime (tp); @@ -539,11 +538,29 @@ mktime (struct tm *tp) } #endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */ -#ifdef weak_alias -weak_alias (mktime, timelocal) +#if defined _LIBC && __TIMESIZE != 64 + +libc_hidden_def (__mktime64) + +time_t +mktime (struct tm *tp) +{ + struct tm tm = *tp; + __time64_t t = __mktime64 (&tm); + if (in_time_t_range (t)) + { + *tp = tm; + return t; + } + else + { + __set_errno (EOVERFLOW); + return -1; + } +} + #endif -#ifdef _LIBC +weak_alias (mktime, timelocal) libc_hidden_def (mktime) libc_hidden_weak (timelocal) -#endif diff --git a/lib/timegm.c b/lib/timegm.c index 2ca57444d4..c440480cb2 100644 --- a/lib/timegm.c +++ b/lib/timegm.c @@ -18,17 +18,41 @@ . */ #ifndef _LIBC -# include +# include #endif #include +#include #include "mktime-internal.h" -time_t -timegm (struct tm *tmp) +__time64_t +__timegm64 (struct tm *tmp) { static mktime_offset_t gmtime_offset; tmp->tm_isdst = 0; - return __mktime_internal (tmp, __gmtime_r, &gmtime_offset); + return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset); } + +#if defined _LIBC && __TIMESIZE != 64 + +libc_hidden_def (__timegm64) + +time_t +timegm (struct tm *tmp) +{ + struct tm tm = *tmp; + __time64_t t = __timegm64 (&tm); + if (in_time_t_range (t)) + { + *tmp = tm; + return t; + } + else + { + __set_errno (EOVERFLOW); + return -1; + } +} + +#endif commit 826f1e260121edc5185e0ed3fa20a781fbddc9a2 Author: Mattias Engdegård Date: Tue Apr 30 15:53:56 2019 +0200 * lisp/autorevert.el (auto-revert-avoid-polling): Fix :set form. diff --git a/lisp/autorevert.el b/lisp/autorevert.el index 6f5ca75ddf..cdd8223fff 100644 --- a/lisp/autorevert.el +++ b/lisp/autorevert.el @@ -322,7 +322,8 @@ the value of this variable." :type 'boolean :set (lambda (variable value) (set-default variable value) - (auto-revert-set-timer)) + (when (fboundp 'auto-revert-set-timer) + (auto-revert-set-timer))) :version "27.1") ;; Internal variables: commit 28853721681436a4e0adecce1df428feec4f3211 Author: Alan Mackenzie Date: Tue Apr 30 13:20:22 2019 +0000 CC Mode: in certain font lock loops, check point is not beyond limit. * /lisp/progmodes/cc-fonts.el (c-font-lock-enum-body) (autodoc-font-lock-line-markup): As part of the `while' condition, check that the previous iteration of the loop hasn't moved point past `limit', thus obviating "wrong side of point" errors in re-search-forward, etc. diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 831fa30886..c7c9aa5564 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -1549,7 +1549,8 @@ casts and declarations are fontified. Used on level 2 and higher." ;; font-lock-keyword-face. It always returns NIL to inhibit this and ;; prevent a repeat invocation. See elisp/lispref page "Search-based ;; Fontification". - (while (search-forward-regexp c-enum-clause-introduction-re limit t) + (while (and (< (point) limit) + (search-forward-regexp c-enum-clause-introduction-re limit t)) (when (save-excursion (backward-char) (c-backward-over-enum-header)) @@ -2850,7 +2851,8 @@ need for `pike-font-lock-extra-types'.") "\\)\\)\\s *\\)@[A-Za-z_-]+\\(\\s \\|$\\)")) (markup-faces (list c-doc-markup-face-name c-doc-face-name))) - (while (re-search-forward line-re limit t) + (while (and (< (point) limit) + (re-search-forward line-re limit t)) (goto-char (match-end 1)) (if (looking-at autodoc-decl-keywords) commit c61bbb4c8e7e2f2068c1cfac9a001806a1969202 Author: Mattias Engdegård Date: Wed Apr 24 18:39:05 2019 +0200 Don't poll auto-revert files that use notification (bug#35418) It is a waste to periodically poll files that use change notification in auto-revert mode; stop doing that. If no files need polling, turn off the periodic execution entirely to further avoid wasting power. Use a timer to inhibit immediate reversion for some time after a notification, for throttling. This change does not apply to files in global-auto-revert-mode, where polling is still necessary. It is disabled by default, and enabled by setting `auto-revert-avoid-polling' to non-nil. * lisp/autorevert.el (toplevel): Require cl-lib. (auto-revert-avoid-polling, auto-revert--polled-buffers) (auto-revert--need-polling-p, auto-revert--lockout-interval) (auto-revert--lockout-timer, auto-revert--end-lockout): New. (global-auto-revert-mode): Keep notifiers for buffers in auto-revert mode. (auto-revert-set-timer): Use auto-revert--need-polling-p. (auto-revert-notify-handler): Restart polling if notification stopped. Use new lockout timer. (auto-revert-buffers): Use auto-revert--polled-buffers and auto-revert--need-polling-p. (auto-revert-buffers-counter, auto-revert-buffers-counter-lockedout): Remove. * etc/NEWS (Changes in Specialized Modes and Packages): Describe the new auto-revert-avoid-polling variable. * doc/emacs/files.texi (Reverting): Add paragraph describing auto-revert-avoid-polling. diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index a57428230c..990b8f1679 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -988,6 +988,20 @@ the polling interval through the variable @code{auto-revert-interval}. supported, @code{auto-revert-use-notify} will be @code{nil} by default. +@vindex auto-revert-avoid-polling +@vindex auto-revert-notify-exclude-dir-regexp + By default, Auto-Revert mode will poll files for changes +periodically even when file notifications are used. Such polling is +usually unnecessary, and turning it off may save power by relying on +notifications only. To do so, set the variable +@code{auto-revert-avoid-polling} to non-@code{nil}. However, +notification is ineffective on certain file systems; mainly network +file system on Unix-like machines, where files can be altered from +other machines. To force polling when +@code{auto-revert-avoid-polling} is non-@code{nil}, set +@code{auto-revert-notify-exclude-dir-regexp} to match files that +should be excluded from using notification. + One use of Auto-Revert mode is to ``tail'' a file such as a system log, so that changes made to that file by other programs are continuously displayed. To do this, just move the point to the end of diff --git a/etc/NEWS b/etc/NEWS index 9b32d720b6..f6676e0e0b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1389,6 +1389,16 @@ Packages deriving from 'js-mode' with 'define-derived-mode' should call this function to add enabled syntax extensions to their mode name, too. +** Autorevert + +*** New variable 'auto-revert-avoid-polling' for saving power. +When set to a non-nil value, buffers in Auto-Revert mode are no longer +polled for changes periodically. This reduces the power consumption +of an idle Emacs, but may fail on some network file systems; set +'auto-revert-notify-exclude-dir-regexp' to match files where +notification is not supported. The new variable currently has no +effect in 'global-auto-revert-mode'. The default value is nil. + * New Modes and Packages in Emacs 27.1 diff --git a/lisp/autorevert.el b/lisp/autorevert.el index 1d20896c83..6f5ca75ddf 100644 --- a/lisp/autorevert.el +++ b/lisp/autorevert.el @@ -107,7 +107,7 @@ ;; Dependencies: -(eval-when-compile (require 'cl-lib)) +(require 'cl-lib) (require 'timer) (require 'filenotify) @@ -302,6 +302,29 @@ You should set this variable through Custom." :type 'regexp :version "24.4") +(defcustom auto-revert-avoid-polling nil + "Non-nil to avoid polling files when notification is available. + +Set this variable to a non-nil value to save power by avoiding +polling when possible. Files on file-systems that do not support +change notifications must match `auto-revert-notify-exclude-dir-regexp' +for Auto-Revert to work properly in this case. This typically +includes files on network file systems on Unix-like machines, +when those files are modified from another computer. + +When nil, buffers in Auto-Revert Mode will always be polled for +changes to their files on disk every `auto-revert-interval' +seconds, in addition to using notification for those files. + +In Global Auto-Revert Mode, polling is always done regardless of +the value of this variable." + :group 'auto-revert + :type 'boolean + :set (lambda (variable value) + (set-default variable value) + (auto-revert-set-timer)) + :version "27.1") + ;; Internal variables: (defvar auto-revert-buffer-list () @@ -479,9 +502,32 @@ specifies in the mode line." (auto-revert-buffers) (dolist (buf (buffer-list)) (with-current-buffer buf - (when auto-revert-notify-watch-descriptor + (when (and auto-revert-notify-watch-descriptor + (not (memq buf auto-revert-buffer-list))) (auto-revert-notify-rm-watch)))))) +(defun auto-revert--polled-buffers () + "List of buffers that need to be polled." + (cond (global-auto-revert-mode (buffer-list)) + (auto-revert-avoid-polling + (mapcan (lambda (buffer) + (and (not (buffer-local-value + 'auto-revert-notify-watch-descriptor buffer)) + (list buffer))) + auto-revert-buffer-list)) + (t auto-revert-buffer-list))) + +;; Same as above in a boolean context, but cheaper. +(defun auto-revert--need-polling-p () + "Whether periodic polling is required." + (or global-auto-revert-mode + (if auto-revert-avoid-polling + (not (cl-every (lambda (buffer) + (buffer-local-value + 'auto-revert-notify-watch-descriptor buffer)) + auto-revert-buffer-list)) + auto-revert-buffer-list))) + (defun auto-revert-set-timer () "Restart or cancel the timer used by Auto-Revert Mode. If such a timer is active, cancel it. Start a new timer if @@ -492,10 +538,10 @@ will use an up-to-date value of `auto-revert-interval'" (if (timerp auto-revert-timer) (cancel-timer auto-revert-timer)) (setq auto-revert-timer - (if (or global-auto-revert-mode auto-revert-buffer-list) - (run-with-timer auto-revert-interval - auto-revert-interval - 'auto-revert-buffers)))) + (and (auto-revert--need-polling-p) + (run-with-timer auto-revert-interval + auto-revert-interval + 'auto-revert-buffers)))) (defun auto-revert-notify-rm-watch () "Disable file notification for current buffer's associated file." @@ -558,24 +604,20 @@ will use an up-to-date value of `auto-revert-interval'" ;; often, we want to skip some revert operations so that we don't spend all our ;; time reverting the buffer. ;; -;; We do this by reverting immediately in response to the first in a flurry of -;; notifications. We suppress subsequent notifications until the next time -;; `auto-revert-buffers' is called (this happens on a timer with a period set by -;; `auto-revert-interval'). -(defvar auto-revert-buffers-counter 1 - "Incremented each time `auto-revert-buffers' is called") -(defvar-local auto-revert-buffers-counter-lockedout 0 - "Buffer-local value to indicate whether we should immediately -update the buffer on a notification event or not. If - - (= auto-revert-buffers-counter-lockedout - auto-revert-buffers-counter) - -then the updates are locked out, and we wait until the next call -of `auto-revert-buffers' to revert the buffer. If no lockout is -present, then we revert immediately and set the lockout, so that -no more reverts are possible until the next call of -`auto-revert-buffers'") +;; We do this by reverting immediately in response to the first in a +;; flurry of notifications. Any notifications during the following +;; `auto-revert-lockout-interval' seconds are noted but not acted upon +;; until the end of that interval. + +(defconst auto-revert--lockout-interval 2.5 + "Duration, in seconds, of the Auto-Revert Mode notification lockout. +This is the quiescence after each notification of a file being +changed during which no automatic reverting takes place, to +prevent many updates in rapid succession from overwhelming the +system.") + +(defvar-local auto-revert--lockout-timer nil + "Timer awaiting the end of the notification lockout interval, or nil.") (defun auto-revert-notify-handler (event) "Handle an EVENT returned from file notification." @@ -604,7 +646,11 @@ no more reverts are possible until the next call of (file-name-nondirectory buffer-file-name))) ;; A buffer w/o a file, like dired. (null buffer-file-name)) - (auto-revert-notify-rm-watch)))) + (auto-revert-notify-rm-watch) + ;; Restart the timer if it wasn't running. + (when (and (memq buffer auto-revert-buffer-list) + (not auto-revert-timer)) + (auto-revert-set-timer))))) ;; Loop over all buffers, in order to find the intended one. (cl-dolist (buffer buffers) @@ -630,11 +676,21 @@ no more reverts are possible until the next call of (setq auto-revert-notify-modified-p t) ;; Revert the buffer now if we're not locked out. - (when (/= auto-revert-buffers-counter-lockedout - auto-revert-buffers-counter) + (unless auto-revert--lockout-timer (auto-revert-handler) - (setq auto-revert-buffers-counter-lockedout - auto-revert-buffers-counter)))))))))) + (setq auto-revert--lockout-timer + (run-with-timer + auto-revert--lockout-interval nil + #'auto-revert--end-lockout buffer))))))))))) + +(defun auto-revert--end-lockout (buffer) + "End the lockout period after a notification. +If the buffer needs to be reverted, do it now." + (when (buffer-live-p buffer) + (with-current-buffer buffer + (setq auto-revert--lockout-timer nil) + (when auto-revert-notify-modified-p + (auto-revert-handler))))) (defun auto-revert-active-p () "Check if auto-revert is active (in current buffer or globally)." @@ -755,13 +811,8 @@ This function is also responsible for removing buffers no longer in Auto-Revert Mode from `auto-revert-buffer-list', and for canceling the timer when no buffers need to be checked." - (setq auto-revert-buffers-counter - (1+ auto-revert-buffers-counter)) - (save-match-data - (let ((bufs (if global-auto-revert-mode - (buffer-list) - auto-revert-buffer-list)) + (let ((bufs (auto-revert--polled-buffers)) remaining new) ;; Buffers with remote contents shall be reverted only if the ;; connection is established already. @@ -810,8 +861,7 @@ the timer when no buffers need to be checked." (setq bufs (cdr bufs))) (setq auto-revert-remaining-buffers bufs) ;; Check if we should cancel the timer. - (when (and (not global-auto-revert-mode) - (null auto-revert-buffer-list)) + (unless (auto-revert--need-polling-p) (if (timerp auto-revert-timer) (cancel-timer auto-revert-timer)) (setq auto-revert-timer nil)))))