Merge remote-tracking branch 'savannah/master' into native-comp

This commit is contained in:
Andrea Corallo 2021-01-24 21:05:33 +01:00
commit b8d3ae78c5
194 changed files with 5165 additions and 2633 deletions

View file

@ -1,5 +1,5 @@
Language: Cpp
BasedOnStyle: LLVM
BasedOnStyle: GNU
AlignEscapedNewlinesLeft: true
AlwaysBreakAfterReturnType: TopLevelDefinitions
BreakBeforeBinaryOperators: All

1
.gitignore vendored
View file

@ -299,4 +299,3 @@ nt/emacs.rc
nt/emacsclient.rc
src/gdb.ini
/var/
src/fingerprint.c

View file

@ -1,4 +1,4 @@
# Copyright (C) 2017-2021 Free Software Foundation, Inc.
# Copyright (C) 2021 Free Software Foundation, Inc.
#
# This file is part of GNU Emacs.
#
@ -194,3 +194,5 @@ test-all:
variables:
target: emacs-inotify
make_params: check-expensive
# Just load from test/infra, to keep build automation files there.
include: '/test/infra/gitlab-ci.yml'

View file

@ -1,8 +1,8 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2020 Free Software Foundation, Inc.
# Copyright 1992-2021 Free Software Foundation, Inc.
timestamp='2020-12-22'
timestamp='2021-01-01'
# 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
@ -50,7 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright 1992-2020 Free Software Foundation, Inc.
Copyright 1992-2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -1087,7 +1087,7 @@ EOF
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-"$LIBC"
exit ;;
riscv32:Linux:*:* | riscv64:Linux:*:*)
riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)

10
build-aux/config.sub vendored
View file

@ -1,8 +1,8 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2020 Free Software Foundation, Inc.
# Copyright 1992-2021 Free Software Foundation, Inc.
timestamp='2020-12-22'
timestamp='2021-01-07'
# 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
@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright 1992-2020 Free Software Foundation, Inc.
Copyright 1992-2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -1230,7 +1230,7 @@ case $cpu-$vendor in
| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
| pru \
| pyramid \
| riscv | riscv32 | riscv64 \
| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
| rl78 | romp | rs6000 | rx \
| s390 | s390x \
| score \
@ -1687,7 +1687,7 @@ case $os in
musl* | newlib* | uclibc*)
;;
# Likewise for "kernel-libc"
eabi | eabihf | gnueabi | gnueabihf)
eabi* | gnueabi*)
;;
# Now accept the basic system types.
# The portable systems comes first.

View file

@ -6011,7 +6011,7 @@ if test $AUTO_DEPEND = yes; then
AS_MKDIR_P([$dir/deps])
done
fi
if $gl_gnulib_enabled_scratch_buffer; then
if $gl_gnulib_enabled_dynarray || $gl_gnulib_enabled_scratch_buffer; then
AS_MKDIR_P([lib/malloc])
if test $AUTO_DEPEND = yes; then
AS_MKDIR_P([lib/deps/malloc])

View file

@ -557,8 +557,9 @@ Likewise, it makes no sense to bind keyword symbols
@item (pred @var{function})
Matches if the predicate @var{function} returns non-@code{nil}
when called on @var{expval}.
the predicate @var{function} can have one of the following forms:
when called on @var{expval}. The test can be negated with the syntax
@code{(pred (not @var{function}))}.
The predicate @var{function} can have one of the following forms:
@table @asis
@item function name (a symbol)

View file

@ -2852,9 +2852,8 @@ Here is how to insert an item called @samp{Work} in the @samp{Signals}
menu of Shell mode, after the item @code{break}:
@example
(define-key-after
(lookup-key shell-mode-map [menu-bar signals])
[work] '("Work" . work-command) 'break)
(define-key-after shell-mode-map [menu-bar signals work]
'("Work" . work-command) 'break)
@end example
@end defun

View file

@ -560,7 +560,9 @@ deactivate the mark. If the value is @w{@code{(only . @var{oldval})}},
then @code{transient-mark-mode} is set to the value @var{oldval} after
any subsequent command that moves point and is not shift-translated
(@pxref{Key Sequence Input, shift-translation}), or after any other
action that would normally deactivate the mark.
action that would normally deactivate the mark. (Marking a region
with the mouse will temporarily enable @code{transient-mark-mode} in
this way.)
@end defopt
@defopt mark-even-if-inactive

View file

@ -729,7 +729,9 @@ coding systems (@pxref{Default Coding Systems}). On the other hand,
it will use @var{query-flag} as its query-on-exit flag (@pxref{Query
Before Exit}). It will be associated with the @var{stderr} buffer
(@pxref{Process Buffers}) and send its output (which is the standard
error of the main process) there.
error of the main process) there. To get the process object for the
standard error process, pass the @var{stderr} buffer to
@code{get-buffer-process}.
If @var{stderr} is a pipe process, Emacs will use it as standard error
process for the new process.
@ -1942,6 +1944,29 @@ code:
(while (accept-process-output stderr-process))
@end example
If you passed a buffer to the @var{stderr} argument of
@code{make-process}, you still have to wait for the standard error
process, like so:
@example
(let* ((stdout (generate-new-buffer "stdout"))
(stderr (generate-new-buffer "stderr"))
(process (make-process :name "test"
:command '("my-program")
:buffer stdout
:stderr stderr))
(stderr-process (get-buffer-process stderr)))
(unless (and process stderr-process)
(error "Process unexpectedly nil"))
(while (accept-process-output process))
(while (accept-process-output stderr-process)))
@end example
@noindent
Only when both @code{accept-process-output} forms return @code{nil},
you can be sure that the process has exited and Emacs has read all its
output.
Reading pending standard error from a process running on a remote host
is not possible this way.

View file

@ -334,6 +334,25 @@ but there is no peace.
(thing-at-point 'whitespace)
@result{} nil
@end example
@defvar thing-at-point-provider-alist
This variable allows users and modes to tweak how
@code{thing-at-point} works. It's an association list of @var{thing}s
and functions (called with zero parameters) to return that thing.
Entries for @var{thing} will be evaluated in turn until a
non-@code{nil} result is returned.
For instance, a major mode could say:
@lisp
(setq-local thing-at-point-provider-alist
(append thing-at-point-provider-alist
'((url . my-mode--url-at-point))))
@end lisp
If no providers have a non-@code{nil} return, the @var{thing} will be
computed the standard way.
@end defvar
@end defun
@node Comparing Text
@ -5608,6 +5627,11 @@ This function accepts all the changes in the change group specified by
@defun cancel-change-group handle
This function cancels and undoes all the changes in the change group
specified by @var{handle}.
@end defun
@defun undo-amalgamate-change-group
Amalgamate changes in change-group since @var{handle}. I.e., remove
all undo boundaries between the state of @var{handle} and now.
@end defun
Your code should use @code{unwind-protect} to make sure the group is

View file

@ -317,6 +317,12 @@ when forwarding a message.
In non-@code{nil}, only headers that match this regexp will be kept
when forwarding a message. This can also be a list of regexps.
@item message-forward-included-mime-headers
@vindex message-forward-included-mime-headers
In non-@code{nil}, headers that match this regexp will be kept when
forwarding a message as @acronym{MIME}, but @acronym{MML} isn't used.
This can also be a list of regexps.
@item message-make-forward-subject-function
@vindex message-make-forward-subject-function
A list of functions that are called to generate a subject header for

View file

@ -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{2020-10-24.12}
\def\texinfoversion{2020-11-25.18}
%
% Copyright 1985, 1986, 1988, 1990-2020 Free Software Foundation, Inc.
%
@ -572,10 +572,9 @@
\fi
}
% @end foo executes the definition of \Efoo.
% But first, it executes a specialized version of \checkenv
%
\parseargdef\end{%
% @end foo calls \checkenv and executes the definition of \Efoo.
\parseargdef\end{
\if 1\csname iscond.#1\endcsname
\else
% The general wording of \badenverr may not be ideal.
@ -2673,8 +2672,6 @@
\definetextfontsizexi
\message{markup,}
% Check if we are currently using a typewriter font. Since all the
% Computer Modern typewriter fonts have zero interword stretch (and
% shrink), and it is reasonable to expect all typewriter fonts to have
@ -2682,68 +2679,14 @@
%
\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
% define and register \INITMACRO to be called on markup style changes.
% \INITMACRO can check \currentmarkupstyle for the innermost
% style.
\let\currentmarkupstyle\empty
\def\setupmarkupstyle#1{%
\def\currentmarkupstyle{#1}%
\markupstylesetup
}
\let\markupstylesetup\empty
\def\defmarkupstylesetup#1{%
\expandafter\def\expandafter\markupstylesetup
\expandafter{\markupstylesetup #1}%
\def#1%
}
% Markup style setup for left and right quotes.
\defmarkupstylesetup\markupsetuplq{%
\expandafter\let\expandafter \temp
\csname markupsetuplq\currentmarkupstyle\endcsname
\ifx\temp\relax \markupsetuplqdefault \else \temp \fi
}
\defmarkupstylesetup\markupsetuprq{%
\expandafter\let\expandafter \temp
\csname markupsetuprq\currentmarkupstyle\endcsname
\ifx\temp\relax \markupsetuprqdefault \else \temp \fi
}
{
\catcode`\'=\active
\catcode`\`=\active
\gdef\markupsetuplqdefault{\let`\lq}
\gdef\markupsetuprqdefault{\let'\rq}
\gdef\markupsetcodequoteleft{\let`\codequoteleft}
\gdef\markupsetcodequoteright{\let'\codequoteright}
\gdef\setcodequotes{\let`\codequoteleft \let'\codequoteright}
\gdef\setregularquotes{\let`\lq \let'\rq}
}
\let\markupsetuplqcode \markupsetcodequoteleft
\let\markupsetuprqcode \markupsetcodequoteright
%
\let\markupsetuplqexample \markupsetcodequoteleft
\let\markupsetuprqexample \markupsetcodequoteright
%
\let\markupsetuplqkbd \markupsetcodequoteleft
\let\markupsetuprqkbd \markupsetcodequoteright
%
\let\markupsetuplqsamp \markupsetcodequoteleft
\let\markupsetuprqsamp \markupsetcodequoteright
%
\let\markupsetuplqverb \markupsetcodequoteleft
\let\markupsetuprqverb \markupsetcodequoteright
%
\let\markupsetuplqverbatim \markupsetcodequoteleft
\let\markupsetuprqverbatim \markupsetcodequoteright
% Allow an option to not use regular directed right quote/apostrophe
% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
% The undirected quote is ugly, so don't make it the default, but it
@ -2906,7 +2849,7 @@
}
% @samp.
\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
\def\samp#1{{\setcodequotes\lq\tclose{#1}\rq\null}}
% @indicateurl is \samp, that is, with quotes.
\let\indicateurl=\samp
@ -2949,8 +2892,7 @@
\global\let'=\rq \global\let`=\lq % default definitions
%
\global\def\code{\begingroup
\setupmarkupstyle{code}%
% The following should really be moved into \setupmarkupstyle handlers.
\setcodequotes
\catcode\dashChar=\active \catcode\underChar=\active
\ifallowcodebreaks
\let-\codedash
@ -3104,7 +3046,7 @@
\urefcatcodes
%
\global\def\urefcode{\begingroup
\setupmarkupstyle{code}%
\setcodequotes
\urefcatcodes
\let&\urefcodeamp
\let.\urefcodedot
@ -3225,8 +3167,8 @@
\def\kbdsub#1#2#3\par{%
\def\one{#1}\def\three{#3}\def\threex{??}%
\ifx\one\xkey\ifx\threex\three \key{#2}%
\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
\else{\tclose{\kbdfont\setcodequotes\look}}\fi
\else{\tclose{\kbdfont\setcodequotes\look}}\fi
}
% definition of @key that produces a lozenge. Doesn't adjust to text size.
@ -3243,7 +3185,7 @@
% monospace, don't change it; that way, we respect @kbdinputstyle. But
% if it isn't monospace, then use \tt.
%
\def\key#1{{\setupmarkupstyle{key}%
\def\key#1{{\setregularquotes
\nohyphenation
\ifmonospace\else\tt\fi
#1}\null}
@ -3373,16 +3315,20 @@
{\obeylines
\globaldefs=1
\envdef\displaymath{%
\tex
\tex%
\def\thisenv{\displaymath}%
\begingroup\let\end\displaymathend%
$$%
}
\def\Edisplaymath{$$
\def\displaymathend{$$\endgroup\end}%
\def\Edisplaymath{%
\def\thisenv{\tex}%
\end tex
}}
% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
% except specified as a normal braced arg, so no newlines to worry about.
@ -7144,7 +7090,7 @@
% But \@ or @@ will get a plain @ character.
\envdef\tex{%
\setupmarkupstyle{tex}%
\setregularquotes
\catcode `\\=0 \catcode `\{=1 \catcode `\}=2
\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
\catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
@ -7370,7 +7316,7 @@
% If you want all examples etc. small: @set dispenvsize small.
% If you want even small examples the full size: @set dispenvsize nosmall.
% This affects the following displayed environments:
% @example, @display, @format, @lisp
% @example, @display, @format, @lisp, @verbatim
%
\def\smallword{small}
\def\nosmallword{nosmall}
@ -7416,9 +7362,9 @@
%
\maketwodispenvdef{lisp}{example}{%
\nonfillstart
\tt\setupmarkupstyle{example}%
\tt\setcodequotes
\let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
\gobble % eat return
\parsearg\gobble
}
% @display/@smalldisplay: same as @lisp except keep current font.
%
@ -7576,7 +7522,7 @@
\def\setupverb{%
\tt % easiest (and conventionally used) font for verbatim
\def\par{\leavevmode\endgraf}%
\setupmarkupstyle{verb}%
\setcodequotes
\tabeightspaces
% Respect line breaks,
% print special symbols as themselves, and
@ -7617,7 +7563,7 @@
\tt % easiest (and conventionally used) font for verbatim
\def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}%
\tabexpand
\setupmarkupstyle{verbatim}%
\setcodequotes
% Respect line breaks,
% print special symbols as themselves, and
% make each space count.
@ -8036,7 +7982,7 @@
% leave the code in, but it's strange for @var to lead to typewriter.
% Nowadays we recommend @code, since the difference between a ttsl hyphen
% and a tt hyphen is pretty tiny. @code also disables ?` !`.
\def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
\def\var##1{{\setregularquotes\ttslanted{##1}}}%
#1%
\sl\hyphenchar\font=45
}
@ -8145,11 +8091,18 @@
}
\fi
\let\E=\expandafter
% Used at the time of macro expansion.
% Argument is macro body with arguments substituted
\def\scanmacro#1{%
\newlinechar`\^^M
\def\xeatspaces{\eatspaces}%
% expand the expansion of \eatleadingcr twice to maybe remove a leading
% newline (and \else and \fi tokens), then call \eatspaces on the result.
\def\xeatspaces##1{%
\E\E\E\E\E\E\E\eatspaces\E\E\E\E\E\E\E{\eatleadingcr##1%
}}%
\def\xempty##1{}%
%
% Process the macro body under the current catcode regime.
\scantokens{#1@comment}%
@ -8202,6 +8155,11 @@
\unbrace{\gdef\trim@@@ #1 } #2@{#1}
}
{\catcode`\^^M=\other%
\gdef\eatleadingcr#1{\if\noexpand#1\noexpand^^M\else\E#1\fi}}%
% Warning: this won't work for a delimited argument
% or for an empty argument
% Trim a single trailing ^^M off a string.
{\catcode`\^^M=\other \catcode`\Q=3%
\gdef\eatcr #1{\eatcra #1Q^^MQ}%
@ -8368,6 +8326,7 @@
\let\hash\relax
% \hash is redefined to `#' later to get it into definitions
\let\xeatspaces\relax
\let\xempty\relax
\parsemargdefxxx#1,;,%
\ifnum\paramno<10\relax\else
\paramno0\relax
@ -8379,9 +8338,11 @@
\else \let\next=\parsemargdefxxx
\advance\paramno by 1
\expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
{\xeatspaces{\hash\the\paramno}}%
{\xeatspaces{\hash\the\paramno\noexpand\xempty{}}}%
\edef\paramlist{\paramlist\hash\the\paramno,}%
\fi\next}
% the \xempty{} is to give \eatleadingcr an argument in the case of an
% empty macro argument.
% \parsemacbody, \parsermacbody
%
@ -9107,20 +9068,22 @@
% output the `[mynode]' via the macro below so it can be overridden.
\xrefprintnodename\printedrefname
%
% But we always want a comma and a space:
,\space
%
% output the `page 3'.
\turnoffactive \putwordpage\tie\refx{#1-pg}{}%
% Add a , if xref followed by a space
\if\space\noexpand\tokenafterxref ,%
\else\ifx\ \tokenafterxref ,% @TAB
\else\ifx\*\tokenafterxref ,% @*
\else\ifx\ \tokenafterxref ,% @SPACE
\else\ifx\
\tokenafterxref ,% @NL
\else\ifx\tie\tokenafterxref ,% @tie
\fi\fi\fi\fi\fi\fi
\expandafter\ifx\csname SETtxiomitxrefpg\endcsname\relax
% But we always want a comma and a space:
,\space
%
% output the `page 3'.
\turnoffactive \putwordpage\tie\refx{#1-pg}{}%
% Add a , if xref followed by a space
\if\space\noexpand\tokenafterxref ,%
\else\ifx\ \tokenafterxref ,% @TAB
\else\ifx\*\tokenafterxref ,% @*
\else\ifx\ \tokenafterxref ,% @SPACE
\else\ifx\
\tokenafterxref ,% @NL
\else\ifx\tie\tokenafterxref ,% @tie
\fi\fi\fi\fi\fi\fi
\fi
\fi\fi
\fi
\endlink
@ -9550,7 +9513,7 @@
\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
\catcode`\^^M = 5 % in case we're inside an example
\normalturnoffactive % allow _ et al. in names
\def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
\makevalueexpandable
% If the image is by itself, center it.
\ifvmode
\imagevmodetrue
@ -11603,7 +11566,7 @@
\let> = \activegtr
\let~ = \activetilde
\let^ = \activehat
\markupsetuplqdefault \markupsetuprqdefault
\setregularquotes
\let\b = \strong
\let\i = \smartitalic
% in principle, all other definitions in \tex have to be undone too.
@ -11662,8 +11625,7 @@
@let|=@normalverticalbar
@let~=@normaltilde
@let\=@ttbackslash
@markupsetuplqdefault
@markupsetuprqdefault
@setregularquotes
@unsepspaces
}
}
@ -11756,8 +11718,7 @@
@c Do this last of all since we use ` in the previous @catcode assignments.
@catcode`@'=@active
@catcode`@`=@active
@markupsetuplqdefault
@markupsetuprqdefault
@setregularquotes
@c Local variables:
@c eval: (add-hook 'before-save-hook 'time-stamp)

View file

@ -810,9 +810,10 @@ behavior.
@cindex @option{sshx} method
Works like @option{ssh} but without the extra authentication prompts.
@option{sshx} uses @samp{ssh -t -t @var{host} -l @var{user} /bin/sh}
to open a connection with a ``standard'' login shell. It supports
changing the remote login shell @command{/bin/sh}.
@option{sshx} uses @samp{ssh -t -t -l @var{user} -o
RemoteCommand='/bin/sh -i' @var{host}} to open a connection with a
``standard'' login shell. It supports changing the remote login shell
@command{/bin/sh}.
@strong{Note} that @option{sshx} does not bypass authentication
questions. For example, if the host key of the remote host is not
@ -935,9 +936,10 @@ This method supports the @samp{-p} argument.
@cindex @command{ssh} (with @option{scpx} method)
@option{scpx} is useful to avoid login shell questions. It is similar
in performance to @option{scp}. @option{scpx} uses @samp{ssh -t -t
@var{host} -l @var{user} /bin/sh} to open a connection. It supports
changing the remote login shell @command{/bin/sh}.
in performance to @option{scp}. @option{scpx} uses @samp{ssh -t -t -l
@var{user} -o RemoteCommand='/bin/sh -i' @var{host}} to open a
connection. It supports changing the remote login shell
@command{/bin/sh}.
@option{scpx} is useful for MS Windows users when @command{ssh}
triggers an error about allocating a pseudo tty. This happens due to
@ -2220,7 +2222,10 @@ This uses also the settings in @code{tramp-sh-extra-args}.
@vindex RemoteCommand@r{, ssh option}
@strong{Note}: If you use an @option{ssh}-based method for connection,
do @emph{not} set the @option{RemoteCommand} option in your
@command{ssh} configuration, for example to @command{screen}.
@command{ssh} configuration, for example to @command{screen}. On the
other hand, some @option{ssh}-based methods, like @option{sshx} or
@option{scpx}, silently overwrite a @option{RemoteCommand} option of
the configuration file.
@subsection Other remote shell setup hints
@ -2369,8 +2374,7 @@ that can identify such questions using
@lisp
@group
(defconst my-tramp-prompt-regexp
(concat (regexp-opt '("Enter the birth date of your mother:") t)
"\\s-*")
"Enter the birth date of your mother:\\s-*"
"Regular expression matching my login prompt question.")
@end group
@ -2389,6 +2393,11 @@ that can identify such questions using
@end group
@end lisp
The regular expressions used in @code{tramp-actions-before-shell} must
match the end of the connection buffer. Due to performance reasons,
this search starts at the end of the buffer, and it is limited to 256
characters backwards.
@item Conflicting names for users and variables in @file{.profile}
@ -3576,13 +3585,16 @@ Furthermore, this approach has the following limitations:
It works only for connection methods defined in @file{tramp-sh.el} and
@file{tramp-adb.el}.
@vindex ControlMaster@r{, ssh option}
@item
It does not support interactive user authentication. With
@option{ssh}-based methods, this can be avoided by using a password
agent like @command{ssh-agent}, using public key authentication, or
using @option{ControlMaster} options.
@item
It cannot be applied for @option{ssh}-based methods, which use the
@option{RemoteCommand} option.
@item
It cannot be killed via @code{interrupt-process}.
@ -3593,8 +3605,7 @@ It does not report the remote terminal name via @code{process-tty-name}.
It does not set process property @code{remote-pid}.
@item
It does not use @code{tramp-remote-path} and
@code{tramp-remote-process-environment}.
It does not use @code{tramp-remote-path}.
@end itemize
In order to gain even more performance, it is recommended to bind

View file

@ -30,20 +30,16 @@ Bengali (বাংলা) নমস্কার
Braille ⠓⠑⠇⠇⠕
Burmese (မြန်မာ) မင်္ဂလာပါ
C printf ("Hello, world!\n");
Cham (ꨌꩌ) ꨦꨤꩌ ꨦꨁꨰ
Cherokee (ᏣᎳᎩ ᎦᏬᏂᎯᏍᏗ) ᎣᏏᏲ / ᏏᏲ
Comanche /kəˈmæntʃiː/ Haa marʉ́awe
Cree (ᓀᐦᐃᔭᐍᐏᐣ) ᑕᓂᓯ / ᐙᒋᔮ
Czech (čeština) Dobrý den
Danish (dansk) Hej / Goddag / Halløj
Dutch (Nederlands) Hallo / Dag
Efik /ˈɛfɪk/ Mɔkɔm
Egyptian Hieroglyphs (𓂋𓐰𓏤𓈖𓆎𓅓𓏏𓐰𓊖) 𓅓𓊵𓐰𓐷𓏏𓊪𓐸, 𓇍𓇋𓂻𓍘𓇋
Emacs emacs --no-splash -f view-hello-file
Emoji 👋
English /ˈɪŋɡlɪʃ/ Hello
Esperanto Saluton (Eĥoŝanĝo ĉiuĵaŭde)
@ -59,7 +55,6 @@ Hebrew (עִבְרִית) שָׁלוֹם
Hungarian (magyar) Szép jó napot!
Hindi (हिंदी) नमस्ते / नमस्कार ।
Inuktitut (ᐃᓄᒃᑎᑐᑦ) ᐊᐃ
Italian (italiano) Ciao / Buon giorno
Javanese (ꦧꦱꦗꦮꦶ) console.log("ꦲꦭꦺꦴ");
Kannada (ಕನ್ನಡ) ನಮಸ್ಕಾರ
@ -67,7 +62,6 @@ Khmer (ភាសាខ្មែរ) ជំរាបសួរ
Lao (ພາສາລາວ) ສະບາຍດີ / ຂໍໃຫ້ໂຊກດີ
Malayalam (മലയാളം) നമസ്കാരം
Maldivian (ދިވެހި) އައްސަލާމު ޢަލައިކުމް / ކިހިނެހް؟
Maltese (il-Malti) Bonġu / Saħħa
Mathematics ∀ p ∈ world • hello p □
Mongolian (монгол хэл) Сайн байна уу?
@ -83,7 +77,6 @@ Swedish (svenska) Hej / Goddag / Hallå
Tamil (தமிழ்) வணக்கம்
Telugu (తెలుగు) నమస్కారం
TaiViet (ꪁꪫꪱꪣ ꪼꪕ) ꪅꪰꪙꫂ ꪨꪮꫂ ꪁꪫꪱ / ꪅꪽ ꪨꪷ ꪁꪫꪱ
Thai (ภาษาไทย) สวัสดีครับ / สวัสดีค่ะ
Tibetan (བོད་སྐད་) བཀྲ་ཤིས་བདེ་ལེགས༎
Tigrigna (ትግርኛ) ሰላማት
@ -97,7 +90,6 @@ Vietnamese (tiếng Việt) Chào bạn
</x-charset><x-charset><param>chinese-gb2312</param>Chinese (中文,普通话,汉语) 你好
</x-charset><x-charset><param>chinese-big5-1</param>Cantonese (粵語,廣東話) 早晨, 你好
</x-charset><x-charset><param>korean-ksc5601</param>Korean (한글) 안녕하세요 / 안녕하십니까
</x-charset>

View file

@ -326,6 +326,16 @@ the buffer cycles the whole buffer between "only top-level headings",
* Changes in Specialized Modes and Packages in Emacs 28.1
** 'blink-cursor-mode' is now enabled by default regardless of the UI.
It used to be enabled when Emacs is started in GUI mode but not when started
in text mode. The cursor still only actually blinks in GUI frames.
** pcase
+++
*** The `pred` pattern can now take the form (pred (not FUN)).
This is like (pred (lambda (x) (not (FUN x)))) but results
in better code.
+++
** profiler.el
The results displayed by 'profiler-report' now have the usage figures
@ -346,6 +356,12 @@ When emacsclient connects, Emacs will (by default) output a message
about how to exit the client frame. If 'server-client-instructions'
is set to nil, this message is inhibited.
** Perl mode
---
*** New face 'perl-non-scalar-variable'.
This is used to fontify non-scalar variables.
** Python mode
*** 'python-shell-interpreter' now defaults to python3 on systems with python3.
@ -705,9 +721,11 @@ not.
---
*** Respect 'message-forward-ignored-headers' more.
Previously, this variable would not be consulted if
'message-forward-show-mml' was nil. It's now always used, except if
'message-forward-show-mml' is 'best', and we're forwarding an
encrypted/signed message.
'message-forward-show-mml' was nil and forwarding as MIME.
+++
*** New user option 'message-forward-included-mime-headers'.
This is used when forwarding messages as MIME, but not using MML.
+++
*** Message now supports the OpenPGP header.
@ -821,6 +839,10 @@ so e.g. like 'C-x 8 [' inserts a left single quotation mark,
Added a new Mozhi scheme. The inapplicable ITRANS scheme is now
deprecated. Errors in the Inscript method were corrected.
---
*** New input method 'cham'.
There's also a Cham greeting in 'etc/HELLO'.
** Ispell
+++
@ -1538,9 +1560,28 @@ buttons in it.
This function takes a string and returns a string propertized in a way
that makes it a valid button.
** subr-x
+++
*** A number of new string manipulation functions have been added.
'string-clean-whitespace', 'string-fill', 'string-limit',
'string-lines', 'string-pad' and 'string-chop-newline'.
*** New macro `named-let` that provides Scheme's "named let" looping construct
** thingatpt
+++
*** New variable 'thing-at-point-provider-alist'.
This allows mode-specific alterations to how `thing-at-point' works.
** Miscellaneous
---
*** New user option 'remember-diary-regexp'.
---
*** New user option 'remember-text-format-function'.
*** New function 'buffer-line-statistics'.
This function returns some statistics about the line lengths in a buffer.
@ -1571,11 +1612,6 @@ length to a number).
*** New user option 'authinfo-hide-elements'.
This can be set to nil to inhibit hiding passwords in ".authinfo" files.
+++
*** A number of new string manipulation functions have been added.
'string-clean-whitespace', 'string-fill', 'string-limit',
'string-lines', 'string-pad' and 'string-chop-newline'.
+++
*** New variable 'current-minibuffer-command'.
This is like 'this-command', but it is bound recursively when entering

View file

@ -2824,6 +2824,8 @@ the text of the region according to the new value.
the fill-column has been exceeded; the function can determine on its
own whether filling (or justification) is necessary.
**** New helper function 'indent-line-to'
** Processes
*** process-tty-name is a new function that returns the name of the

View file

@ -26,14 +26,16 @@
AIX system header files and several gnulib header files use precisely
this syntax with 'extern'. */
# define _Noreturn [[noreturn]]
# elif ((!defined __cplusplus || defined __clang__) \
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|| 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|| (defined __apple_build_version__ \
? 6000000 <= __apple_build_version__ \
: 3 < __clang_major__ + (5 <= __clang_minor__))))
# elif ((!defined __cplusplus || defined __clang__) \
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|| (!defined __STRICT_ANSI__ \
&& (__4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|| (defined __apple_build_version__ \
? 6000000 <= __apple_build_version__ \
: 3 < __clang_major__ + (5 <= __clang_minor__))))))
/* _Noreturn works as-is. */
# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
|| 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
# define _Noreturn __declspec (noreturn)

View file

@ -85,10 +85,6 @@
# define IF_LINT(Code) /* empty */
#endif
/* True if adding two valid object sizes might overflow idx_t.
As a practical matter, this cannot happen on 64-bit machines. */
enum { NARROW_ADDRESSES = IDX_MAX >> 31 >> 31 == 0 };
#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
# define DOUBLE_SLASH_IS_DISTINCT_ROOT false
#endif
@ -145,11 +141,11 @@ suffix_requires_dir_check (char const *end)
macOS 10.13 <https://bugs.gnu.org/30350>, and should also work on
platforms like AIX 7.2 that need at least "/.". */
#if defined _LIBC || defined LSTAT_FOLLOWS_SLASHED_SYMLINK
# if defined _LIBC || defined LSTAT_FOLLOWS_SLASHED_SYMLINK
static char const dir_suffix[] = "/";
#else
# else
static char const dir_suffix[] = "/./";
#endif
# endif
/* Return true if DIR is a searchable dir, false (setting errno) otherwise.
DIREND points to the NUL byte at the end of the DIR string.
@ -191,13 +187,13 @@ get_path_max (void)
to pacify GCC is known; even an explicit #pragma does not pacify GCC.
When the GCC bug is fixed this workaround should be limited to the
broken GCC versions. */
#if __GNUC_PREREQ (10, 1)
# if defined GCC_LINT || defined lint
# if __GNUC_PREREQ (10, 1)
# if defined GCC_LINT || defined lint
__attribute__ ((__noinline__))
# elif __OPTIMIZE__ && !__NO_INLINE__
# define GCC_BOGUS_WRETURN_LOCAL_ADDR
# elif __OPTIMIZE__ && !__NO_INLINE__
# define GCC_BOGUS_WRETURN_LOCAL_ADDR
# endif
# endif
#endif
static char *
realpath_stk (const char *name, char *resolved,
struct scratch_buffer *rname_buf)
@ -343,7 +339,7 @@ realpath_stk (const char *name, char *resolved,
if (end_in_extra_buffer)
end_idx = end - extra_buf;
size_t len = strlen (end);
if (NARROW_ADDRESSES && INT_ADD_OVERFLOW (len, n))
if (INT_ADD_OVERFLOW (len, n))
{
__set_errno (ENOMEM);
goto error_nomem;
@ -443,7 +439,8 @@ __realpath (const char *name, char *resolved)
}
libc_hidden_def (__realpath)
versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);
#endif /* !FUNC_REALPATH_WORKS || defined _LIBC */
#endif /* defined _LIBC || !FUNC_REALPATH_WORKS */
#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3)

View file

@ -25,7 +25,7 @@
/* The GNU libc does not support any K&R compilers or the traditional mode
of ISO C compilers anymore. Check for some of the combinations not
anymore supported. */
supported anymore. */
#if defined __GNUC__ && !defined __STDC__
# error "You need a ISO C conforming compiler to use the glibc headers"
#endif
@ -34,31 +34,26 @@
#undef __P
#undef __PMT
/* Compilers that are not clang may object to
#if defined __clang__ && __has_attribute(...)
even though they do not need to evaluate the right-hand side of the &&. */
#if defined __clang__ && defined __has_attribute
# define __glibc_clang_has_attribute(name) __has_attribute (name)
/* Compilers that lack __has_attribute may object to
#if defined __has_attribute && __has_attribute (...)
even though they do not need to evaluate the right-hand side of the &&.
Similarly for __has_builtin, etc. */
#if (defined __has_attribute \
&& (!defined __clang_minor__ \
|| 3 < __clang_major__ + (5 <= __clang_minor__)))
# define __glibc_has_attribute(attr) __has_attribute (attr)
#else
# define __glibc_clang_has_attribute(name) 0
# define __glibc_has_attribute(attr) 0
#endif
/* Compilers that are not clang may object to
#if defined __clang__ && __has_builtin(...)
even though they do not need to evaluate the right-hand side of the &&. */
#if defined __clang__ && defined __has_builtin
# define __glibc_clang_has_builtin(name) __has_builtin (name)
#ifdef __has_builtin
# define __glibc_has_builtin(name) __has_builtin (name)
#else
# define __glibc_clang_has_builtin(name) 0
# define __glibc_has_builtin(name) 0
#endif
/* Compilers that are not clang may object to
#if defined __clang__ && __has_extension(...)
even though they do not need to evaluate the right-hand side of the &&. */
#if defined __clang__ && defined __has_extension
# define __glibc_clang_has_extension(ext) __has_extension (ext)
#ifdef __has_extension
# define __glibc_has_extension(ext) __has_extension (ext)
#else
# define __glibc_clang_has_extension(ext) 0
# define __glibc_has_extension(ext) 0
#endif
#if defined __GNUC__ || defined __clang__
@ -74,22 +69,26 @@
# endif
/* GCC can always grok prototypes. For C++ programs we add throw()
to help it optimize the function calls. But this works only with
to help it optimize the function calls. But this only works with
gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions
as non-throwing using a function attribute since programs can use
the -fexceptions options for C code as well. */
# if !defined __cplusplus \
&& (__GNUC_PREREQ (3, 4) || __glibc_clang_has_attribute (__nothrow__))
&& (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
# define __THROW __attribute__ ((__nothrow__ __LEAF))
# define __THROWNL __attribute__ ((__nothrow__))
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
# else
# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
# define __THROW throw ()
# define __THROWNL throw ()
# define __NTH(fct) __LEAF_ATTR fct throw ()
# define __NTHNL(fct) fct throw ()
# if __cplusplus >= 201103L
# define __THROW noexcept (true)
# else
# define __THROW throw ()
# endif
# define __THROWNL __THROW
# define __NTH(fct) __LEAF_ATTR fct __THROW
# define __NTHNL(fct) fct __THROW
# else
# define __THROW
# define __THROWNL
@ -142,24 +141,20 @@
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
#else
# define __glibc_objsize0(__o) __bos0 (__o)
# define __glibc_objsize(__o) __bos (__o)
#endif
#if __GNUC_PREREQ (4,3)
# define __warndecl(name, msg) \
extern void name (void) __attribute__((__warning__ (msg)))
# define __warnattr(msg) __attribute__((__warning__ (msg)))
# define __errordecl(name, msg) \
extern void name (void) __attribute__((__error__ (msg)))
#elif __glibc_clang_has_attribute (__diagnose_if__) && 0
/* These definitions are not enabled, because they produce bogus warnings
in the glibc Fortify functions. These functions are written in a style
that works with GCC. In order to work with clang, these functions would
need to be modified. */
# define __warndecl(name, msg) \
extern void name (void) __attribute__((__diagnose_if__ (1, msg, "warning")))
# define __warnattr(msg) __attribute__((__diagnose_if__ (1, msg, "warning")))
# define __errordecl(name, msg) \
extern void name (void) __attribute__((__diagnose_if__ (1, msg, "error")))
#else
# define __warndecl(name, msg) extern void name (void)
# define __warnattr(msg)
# define __errordecl(name, msg) extern void name (void)
#endif
@ -233,7 +228,7 @@
/* At some point during the gcc 2.96 development the `malloc' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
#if __GNUC_PREREQ (2,96) || __glibc_clang_has_attribute (__malloc__)
#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
# define __attribute_malloc__ __attribute__ ((__malloc__))
#else
# define __attribute_malloc__ /* Ignore */
@ -251,23 +246,31 @@
/* At some point during the gcc 2.96 development the `pure' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
#if __GNUC_PREREQ (2,96) || __glibc_clang_has_attribute (__pure__)
#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
# define __attribute_pure__ __attribute__ ((__pure__))
#else
# define __attribute_pure__ /* Ignore */
#endif
/* This declaration tells the compiler that the value is constant. */
#if __GNUC_PREREQ (2,5) || __glibc_clang_has_attribute (__const__)
#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
# define __attribute_const__ __attribute__ ((__const__))
#else
# define __attribute_const__ /* Ignore */
#endif
#if defined __STDC_VERSION__ && 201710L < __STDC_VERSION__
# define __attribute_maybe_unused__ [[__maybe_unused__]]
#elif __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
# define __attribute_maybe_unused__ __attribute__ ((__unused__))
#else
# define __attribute_maybe_unused__ /* Ignore */
#endif
/* At some point during the gcc 3.1 development the `used' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
#if __GNUC_PREREQ (3,1) || __glibc_clang_has_attribute (__used__)
#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
# define __attribute_used__ __attribute__ ((__used__))
# define __attribute_noinline__ __attribute__ ((__noinline__))
#else
@ -276,7 +279,7 @@
#endif
/* Since version 3.2, gcc allows marking deprecated functions. */
#if __GNUC_PREREQ (3,2) || __glibc_clang_has_attribute (__deprecated__)
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
#else
# define __attribute_deprecated__ /* Ignore */
@ -285,8 +288,8 @@
/* Since version 4.5, gcc also allows one to specify the message printed
when a deprecated function is used. clang claims to be gcc 4.2, but
may also support this feature. */
#if __GNUC_PREREQ (4,5) || \
__glibc_clang_has_extension (__attribute_deprecated_with_message__)
#if __GNUC_PREREQ (4,5) \
|| __glibc_has_extension (__attribute_deprecated_with_message__)
# define __attribute_deprecated_msg__(msg) \
__attribute__ ((__deprecated__ (msg)))
#else
@ -299,7 +302,7 @@
If several `format_arg' attributes are given for the same function, in
gcc-3.0 and older, all but the last one are ignored. In newer gccs,
all designated arguments are considered. */
#if __GNUC_PREREQ (2,8) || __glibc_clang_has_attribute (__format_arg__)
#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
#else
# define __attribute_format_arg__(x) /* Ignore */
@ -309,7 +312,7 @@
attribute for functions was introduced. We don't want to use it
unconditionally (although this would be possible) since it
generates warnings. */
#if __GNUC_PREREQ (2,97) || __glibc_clang_has_attribute (__format__)
#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
# define __attribute_format_strfmon__(a,b) \
__attribute__ ((__format__ (__strfmon__, a, b)))
#else
@ -317,19 +320,21 @@
#endif
/* The nonnull function attribute marks pointer parameters that
must not be NULL. Do not define __nonnull if it is already defined,
for portability when this file is used in Gnulib. */
must not be NULL. */
#ifndef __nonnull
# if __GNUC_PREREQ (3,3) || __glibc_clang_has_attribute (__nonnull__)
# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
# define __nonnull(params) __attribute__ ((__nonnull__ params))
# else
# define __nonnull(params)
# endif
#elif !defined __GLIBC__
# undef __nonnull
# define __nonnull(params) _GL_ATTRIBUTE_NONNULL (params)
#endif
/* If fortification mode, we warn about unused results of certain
function calls which can lead to problems. */
#if __GNUC_PREREQ (3,4) || __glibc_clang_has_attribute (__warn_unused_result__)
#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
# define __attribute_warn_unused_result__ \
__attribute__ ((__warn_unused_result__))
# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
@ -343,7 +348,7 @@
#endif
/* Forces a function to be always inlined. */
#if __GNUC_PREREQ (3,2) || __glibc_clang_has_attribute (__always_inline__)
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
it conflicts with this definition. Therefore undefine it first to
allow either header to be included first. */
@ -356,7 +361,7 @@
/* Associate error messages with the source location of the call site rather
than with the source location inside the function. */
#if __GNUC_PREREQ (4,3) || __glibc_clang_has_attribute (__artificial__)
#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
# define __attribute_artificial__ __attribute__ ((__artificial__))
#else
# define __attribute_artificial__ /* Ignore */
@ -433,7 +438,7 @@
# endif
#endif
#if (__GNUC__ >= 3) || __glibc_clang_has_builtin (__builtin_expect)
#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
# define __glibc_likely(cond) __builtin_expect ((cond), 1)
#else
@ -441,12 +446,6 @@
# define __glibc_likely(cond) (cond)
#endif
#ifdef __has_attribute
# define __glibc_has_attribute(attr) __has_attribute (attr)
#else
# define __glibc_has_attribute(attr) 0
#endif
#if (!defined _Noreturn \
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
&& !(__GNUC_PREREQ (4,7) \
@ -467,6 +466,16 @@
# define __attribute_nonstring__
#endif
/* Undefine (also defined in libc-symbols.h). */
#undef __attribute_copy__
#if __GNUC_PREREQ (9, 0)
/* Copies attributes from the declaration or type referenced by
the argument. */
# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
#else
# define __attribute_copy__(arg)
#endif
#if (!defined _Static_assert && !defined __cplusplus \
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
&& (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
@ -483,7 +492,37 @@
# include <bits/long-double.h>
#endif
#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
# ifdef __REDIRECT
/* Alias name defined automatically. */
# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
# define __LDBL_REDIR_DECL(name) \
extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
/* Alias name defined automatically, with leading underscores. */
# define __LDBL_REDIR2_DECL(name) \
extern __typeof (__##name) __##name \
__asm (__ASMNAME ("__" #name "ieee128"));
/* Alias name defined manually. */
# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
# define __LDBL_REDIR1_DECL(name, alias) \
extern __typeof (name) name __asm (__ASMNAME (#alias));
# define __LDBL_REDIR1_NTH(name, proto, alias) \
__REDIRECT_NTH (name, proto, alias)
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
__LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
/* Unused. */
# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
# else
_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
# endif
#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
# define __LDBL_COMPAT 1
# ifdef __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
@ -492,6 +531,8 @@
# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
# define __LDBL_REDIR_NTH(name, proto) \
__LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
# define __LDBL_REDIR2_DECL(name) \
extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
# define __LDBL_REDIR1_DECL(name, alias) \
extern __typeof (name) name __asm (__ASMNAME (#alias));
# define __LDBL_REDIR_DECL(name) \
@ -502,11 +543,13 @@
__LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
# endif
#endif
#if !defined __LDBL_COMPAT || !defined __REDIRECT
#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
|| !defined __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) name proto
# define __LDBL_REDIR(name, proto) name proto
# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
# define __LDBL_REDIR2_DECL(name)
# define __LDBL_REDIR_DECL(name)
# ifdef __REDIRECT
# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
@ -537,7 +580,7 @@
check is required to enable the use of generic selection. */
#if !defined __cplusplus \
&& (__GNUC_PREREQ (4, 9) \
|| __glibc_clang_has_extension (c_generic_selections) \
|| __glibc_has_extension (c_generic_selections) \
|| (!defined __GNUC__ && defined __STDC_VERSION__ \
&& __STDC_VERSION__ >= 201112L))
# define __HAVE_GENERIC_SELECTION 1
@ -545,4 +588,23 @@
# define __HAVE_GENERIC_SELECTION 0
#endif
#if __GNUC_PREREQ (10, 0)
/* Designates a 1-based positional argument ref-index of pointer type
that can be used to access size-index elements of the pointed-to
array according to access mode, or at least one element when
size-index is not provided:
access (access-mode, <ref-index> [, <size-index>]) */
#define __attr_access(x) __attribute__ ((__access__ x))
#else
# define __attr_access(x)
#endif
/* Specify that a function such as setjmp or vfork may return
twice. */
#if __GNUC_PREREQ (4, 1)
# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
#else
# define __attribute_returns_twice__ /* Ignore. */
#endif
#endif /* sys/cdefs.h */

View file

@ -154,7 +154,8 @@ _GL_WARN_ON_USE (closedir, "closedir is not portable - "
/* Return the file descriptor associated with the given directory stream,
or -1 if none exists. */
# if @REPLACE_DIRFD@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
/* On kLIBC, dirfd() is a macro that does not work. Undefine it. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) || defined dirfd
# undef dirfd
# define dirfd rpl_dirfd
# endif

31
lib/dynarray.h Normal file
View file

@ -0,0 +1,31 @@
/* Type-safe arrays which grow dynamically.
Copyright 2021 Free Software Foundation, Inc.
This program 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,
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 <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert, 2021. */
#ifndef _GL_DYNARRAY_H
#define _GL_DYNARRAY_H
#include <libc-config.h>
#define __libc_dynarray_at_failure gl_dynarray_at_failure
#define __libc_dynarray_emplace_enlarge gl_dynarray_emplace_enlarge
#define __libc_dynarray_finalize gl_dynarray_finalize
#define __libc_dynarray_resize_clear gl_dynarray_resize_clear
#define __libc_dynarray_resize gl_dynarray_resize
#include <malloc/dynarray.h>
#endif /* _GL_DYNARRAY_H */

View file

@ -54,11 +54,21 @@ explicit_bzero (void *s, size_t len)
explicit_memset (s, '\0', len);
#elif HAVE_MEMSET_S
(void) memset_s (s, len, '\0', len);
#else
#elif defined __GNUC__ && !defined __clang__
memset (s, '\0', len);
# if defined __GNUC__ && !defined __clang__
/* Compiler barrier. */
asm volatile ("" ::: "memory");
# endif
#elif defined __clang__
memset (s, '\0', len);
/* Compiler barrier. */
/* With asm ("" ::: "memory") LLVM analyzes uses of 's' and finds that the
whole thing is dead and eliminates it. Use 'g' to work around this
problem. See <https://bugs.llvm.org/show_bug.cgi?id=15495#c11>. */
__asm__ volatile ("" : : "g"(s) : "memory");
#else
/* Invoke memset through a volatile function pointer. This defeats compiler
optimizations. */
void * (* const volatile volatile_memset) (void *, int, size_t) = memset;
(void) volatile_memset (s, '\0', len);
#endif
}

View file

@ -38,6 +38,7 @@ orig_fchmodat (int dir, char const *file, mode_t mode, int flags)
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __osf__
@ -63,6 +64,22 @@ orig_fchmodat (int dir, char const *file, mode_t mode, int flags)
int
fchmodat (int dir, char const *file, mode_t mode, int flags)
{
# if HAVE_NEARLY_WORKING_FCHMODAT
/* Correct the trailing slash handling. */
size_t len = strlen (file);
if (len && file[len - 1] == '/')
{
struct stat st;
if (fstatat (dir, file, &st, flags & AT_SYMLINK_NOFOLLOW) < 0)
return -1;
if (!S_ISDIR (st.st_mode))
{
errno = ENOTDIR;
return -1;
}
}
# endif
# if NEED_FCHMODAT_NONSYMLINK_FIX
if (flags == AT_SYMLINK_NOFOLLOW)
{

View file

@ -27,7 +27,21 @@ void
rpl_free (void *p)
#undef free
{
#if defined __GNUC__ && !defined __clang__
/* An invalid GCC optimization
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396>
would optimize away the assignments in the code below, when link-time
optimization (LTO) is enabled. Make the code more complicated, so that
GCC does not grok how to optimize it. */
int err[2];
err[0] = errno;
err[1] = errno;
errno = 0;
free (p);
errno = err[errno == 0];
#else
int err = errno;
free (p);
errno = err;
#endif
}

View file

@ -516,6 +516,7 @@ GNULIB_SYMLINK = @GNULIB_SYMLINK@
GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@
GNULIB_TIMEGM = @GNULIB_TIMEGM@
GNULIB_TIMESPEC_GET = @GNULIB_TIMESPEC_GET@
GNULIB_TIME_R = @GNULIB_TIME_R@
GNULIB_TIME_RZ = @GNULIB_TIME_RZ@
GNULIB_TMPFILE = @GNULIB_TMPFILE@
@ -746,6 +747,7 @@ HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@
HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@
HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
HAVE_TIMEGM = @HAVE_TIMEGM@
HAVE_TIMESPEC_GET = @HAVE_TIMESPEC_GET@
HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@
HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
HAVE_UNISTD_H = @HAVE_UNISTD_H@
@ -949,6 +951,7 @@ REPLACE_FCNTL = @REPLACE_FCNTL@
REPLACE_FDOPEN = @REPLACE_FDOPEN@
REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@
REPLACE_FFLUSH = @REPLACE_FFLUSH@
REPLACE_FFSLL = @REPLACE_FFSLL@
REPLACE_FOPEN = @REPLACE_FOPEN@
REPLACE_FPRINTF = @REPLACE_FPRINTF@
REPLACE_FPURGE = @REPLACE_FPURGE@
@ -989,7 +992,9 @@ REPLACE_MEMCHR = @REPLACE_MEMCHR@
REPLACE_MEMMEM = @REPLACE_MEMMEM@
REPLACE_MKDIR = @REPLACE_MKDIR@
REPLACE_MKFIFO = @REPLACE_MKFIFO@
REPLACE_MKFIFOAT = @REPLACE_MKFIFOAT@
REPLACE_MKNOD = @REPLACE_MKNOD@
REPLACE_MKNODAT = @REPLACE_MKNODAT@
REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
REPLACE_MKTIME = @REPLACE_MKTIME@
REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@
@ -1087,6 +1092,7 @@ SYSTEM_TYPE = @SYSTEM_TYPE@
SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
TERMCAP_OBJ = @TERMCAP_OBJ@
TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
TIME_H_DEFINES_TIME_UTC = @TIME_H_DEFINES_TIME_UTC@
TOOLKIT_LIBW = @TOOLKIT_LIBW@
UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@
UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@
@ -1171,6 +1177,7 @@ gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1 = @gl_GNULIB_ENABLED_a9786850
gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36 = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36@
gl_GNULIB_ENABLED_cloexec = @gl_GNULIB_ENABLED_cloexec@
gl_GNULIB_ENABLED_dirfd = @gl_GNULIB_ENABLED_dirfd@
gl_GNULIB_ENABLED_dynarray = @gl_GNULIB_ENABLED_dynarray@
gl_GNULIB_ENABLED_euidaccess = @gl_GNULIB_ENABLED_euidaccess@
gl_GNULIB_ENABLED_getdtablesize = @gl_GNULIB_ENABLED_getdtablesize@
gl_GNULIB_ENABLED_getgroups = @gl_GNULIB_ENABLED_getgroups@
@ -1584,6 +1591,20 @@ EXTRA_libgnu_a_SOURCES += dup2.c
endif
## end gnulib module dup2
## begin gnulib module dynarray
ifeq (,$(OMIT_GNULIB_MODULE_dynarray))
ifneq (,$(gl_GNULIB_ENABLED_dynarray))
libgnu_a_SOURCES += malloc/dynarray_at_failure.c malloc/dynarray_emplace_enlarge.c malloc/dynarray_finalize.c malloc/dynarray_resize.c malloc/dynarray_resize_clear.c
endif
EXTRA_DIST += dynarray.h malloc/dynarray-skeleton.c malloc/dynarray.h
EXTRA_libgnu_a_SOURCES += malloc/dynarray-skeleton.c
endif
## end gnulib module dynarray
## begin gnulib module eloop-threshold
ifeq (,$(OMIT_GNULIB_MODULE_eloop-threshold))
@ -3036,6 +3057,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
-e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
-e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
@ -3237,7 +3259,9 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
-e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
-e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
-e 's|@''REPLACE_MKFIFOAT''@|$(REPLACE_MKFIFOAT)|g' \
-e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
-e 's|@''REPLACE_MKNODAT''@|$(REPLACE_MKNODAT)|g' \
-e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
-e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@ -3350,6 +3374,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_STRFTIME''@/$(GNULIB_STRFTIME)/g' \
-e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
-e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
-e 's/@''GNULIB_TIMESPEC_GET''@/$(GNULIB_TIMESPEC_GET)/g' \
-e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
-e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \
-e 's/@''GNULIB_TZSET''@/$(GNULIB_TZSET)/g' \
@ -3358,6 +3383,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
-e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
-e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
-e 's|@''HAVE_TIMESPEC_GET''@|$(HAVE_TIMESPEC_GET)|g' \
-e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
-e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
-e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
@ -3372,6 +3398,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''TIME_H_DEFINES_TIME_UTC''@|$(TIME_H_DEFINES_TIME_UTC)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \

View file

@ -71,107 +71,112 @@
# endif
#endif
/* Prepare to include <cdefs.h>, which is our copy of glibc
<sys/cdefs.h>. */
#ifndef __attribute_maybe_unused__
/* <sys/cdefs.h> either does not exist, or is too old for Gnulib.
Prepare to include <cdefs.h>, which is Gnulib's version of a
more-recent glibc <sys/cdefs.h>. */
/* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
#ifndef _FEATURES_H
# define _FEATURES_H 1
#endif
# ifndef _FEATURES_H
# define _FEATURES_H 1
# endif
/* Define __WORDSIZE so that <cdefs.h> does not attempt to include
nonexistent files. Make it a syntax error, since Gnulib does not
use __WORDSIZE now, and if Gnulib uses it later the syntax error
will let us know that __WORDSIZE needs configuring. */
#ifndef __WORDSIZE
# define __WORDSIZE %%%
#endif
# ifndef __WORDSIZE
# define __WORDSIZE %%%
# endif
/* Undef the macros unconditionally defined by our copy of glibc
<sys/cdefs.h>, so that they do not clash with any system-defined
versions. */
#undef _SYS_CDEFS_H
#undef __ASMNAME
#undef __ASMNAME2
#undef __BEGIN_DECLS
#undef __CONCAT
#undef __END_DECLS
#undef __HAVE_GENERIC_SELECTION
#undef __LDBL_COMPAT
#undef __LDBL_REDIR
#undef __LDBL_REDIR1
#undef __LDBL_REDIR1_DECL
#undef __LDBL_REDIR1_NTH
#undef __LDBL_REDIR_DECL
#undef __LDBL_REDIR_NTH
#undef __LEAF
#undef __LEAF_ATTR
#undef __NTH
#undef __NTHNL
#undef __P
#undef __PMT
#undef __REDIRECT
#undef __REDIRECT_LDBL
#undef __REDIRECT_NTH
#undef __REDIRECT_NTHNL
#undef __REDIRECT_NTH_LDBL
#undef __STRING
#undef __THROW
#undef __THROWNL
#undef __always_inline
#undef __attribute__
#undef __attribute_alloc_size__
#undef __attribute_artificial__
#undef __attribute_const__
#undef __attribute_deprecated__
#undef __attribute_deprecated_msg__
#undef __attribute_format_arg__
#undef __attribute_format_strfmon__
#undef __attribute_malloc__
#undef __attribute_noinline__
#undef __attribute_nonstring__
#undef __attribute_pure__
#undef __attribute_used__
#undef __attribute_warn_unused_result__
#undef __bos
#undef __bos0
#undef __errordecl
#undef __extension__
#undef __extern_always_inline
#undef __extern_inline
#undef __flexarr
#undef __fortify_function
#undef __glibc_c99_flexarr_available
#undef __glibc_clang_has_extension
#undef __glibc_likely
#undef __glibc_macro_warning
#undef __glibc_macro_warning1
#undef __glibc_unlikely
#undef __inline
#undef __ptr_t
#undef __restrict
#undef __restrict_arr
#undef __va_arg_pack
#undef __va_arg_pack_len
#undef __warnattr
#undef __warndecl
# undef _SYS_CDEFS_H
# undef __ASMNAME
# undef __ASMNAME2
# undef __BEGIN_DECLS
# undef __CONCAT
# undef __END_DECLS
# undef __HAVE_GENERIC_SELECTION
# undef __LDBL_COMPAT
# undef __LDBL_REDIR
# undef __LDBL_REDIR1
# undef __LDBL_REDIR1_DECL
# undef __LDBL_REDIR1_NTH
# undef __LDBL_REDIR2_DECL
# undef __LDBL_REDIR_DECL
# undef __LDBL_REDIR_NTH
# undef __LEAF
# undef __LEAF_ATTR
# undef __NTH
# undef __NTHNL
# undef __REDIRECT
# undef __REDIRECT_LDBL
# undef __REDIRECT_NTH
# undef __REDIRECT_NTHNL
# undef __REDIRECT_NTH_LDBL
# undef __STRING
# undef __THROW
# undef __THROWNL
# undef __attr_access
# undef __attribute__
# undef __attribute_alloc_size__
# undef __attribute_artificial__
# undef __attribute_const__
# undef __attribute_deprecated__
# undef __attribute_deprecated_msg__
# undef __attribute_format_arg__
# undef __attribute_format_strfmon__
# undef __attribute_malloc__
# undef __attribute_noinline__
# undef __attribute_nonstring__
# undef __attribute_pure__
# undef __attribute_returns_twice__
# undef __attribute_used__
# undef __attribute_warn_unused_result__
# undef __bos
# undef __bos0
# undef __errordecl
# undef __extension__
# undef __extern_always_inline
# undef __extern_inline
# undef __flexarr
# undef __fortify_function
# undef __glibc_c99_flexarr_available
# undef __glibc_has_attribute
# undef __glibc_has_builtin
# undef __glibc_has_extension
# undef __glibc_macro_warning
# undef __glibc_macro_warning1
# undef __glibc_objsize
# undef __glibc_objsize0
# undef __glibc_unlikely
# undef __inline
# undef __ptr_t
# undef __restrict
# undef __restrict_arr
# undef __va_arg_pack
# undef __va_arg_pack_len
# undef __warnattr
/* Include our copy of glibc <sys/cdefs.h>. */
#include <cdefs.h>
# include <cdefs.h>
/* <cdefs.h> __inline is too pessimistic for non-GCC. */
#undef __inline
#ifndef HAVE___INLINE
# if 199901 <= __STDC_VERSION__ || defined inline
# define __inline inline
# else
# define __inline
# undef __inline
# ifndef HAVE___INLINE
# if 199901 <= __STDC_VERSION__ || defined inline
# define __inline inline
# else
# define __inline
# endif
# endif
#endif
#endif /* defined __glibc_likely */
/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
#define attribute_hidden
#define libc_hidden_proto(name, ...)
#define libc_hidden_proto(name)
#define libc_hidden_def(name)
#define libc_hidden_weak(name)
#define libc_hidden_ver(local, name)

View file

@ -0,0 +1,525 @@
/* Type-safe arrays which grow dynamically.
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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.
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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* Pre-processor macros which act as parameters:
DYNARRAY_STRUCT
The struct tag of dynamic array to be defined.
DYNARRAY_ELEMENT
The type name of the element type. Elements are copied
as if by memcpy, and can change address as the dynamic
array grows.
DYNARRAY_PREFIX
The prefix of the functions which are defined.
The following parameters are optional:
DYNARRAY_ELEMENT_FREE
DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
contents of elements. E is of type DYNARRAY_ELEMENT *.
DYNARRAY_ELEMENT_INIT
DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
element. E is of type DYNARRAY_ELEMENT *.
If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
defined, new elements are automatically zero-initialized.
Otherwise, new elements have undefined contents.
DYNARRAY_INITIAL_SIZE
The size of the statically allocated array (default:
at least 2, more elements if they fit into 128 bytes).
Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
there is no statically allocated array at, and all non-empty
arrays are heap-allocated.
DYNARRAY_FINAL_TYPE
The name of the type which holds the final array. If not
defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
must be a struct type, with members of type DYNARRAY_ELEMENT and
size_t at the start (in this order).
These macros are undefined after this header file has been
included.
The following types are provided (their members are private to the
dynarray implementation):
struct DYNARRAY_STRUCT
The following functions are provided:
void DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *);
bool DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *);
size_t DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *, size_t);
void DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *, DYNARRAY_ELEMENT);
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *);
bool DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *, size_t);
void DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *);
void DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *);
The following functions are provided are provided if the
prerequisites are met:
bool DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
DYNARRAY_FINAL_TYPE *);
(if DYNARRAY_FINAL_TYPE is defined)
DYNARRAY_ELEMENT *DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
size_t *);
(if DYNARRAY_FINAL_TYPE is not defined)
*/
#include <malloc/dynarray.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#ifndef DYNARRAY_STRUCT
# error "DYNARRAY_STRUCT must be defined"
#endif
#ifndef DYNARRAY_ELEMENT
# error "DYNARRAY_ELEMENT must be defined"
#endif
#ifndef DYNARRAY_PREFIX
# error "DYNARRAY_PREFIX must be defined"
#endif
#ifdef DYNARRAY_INITIAL_SIZE
# if DYNARRAY_INITIAL_SIZE < 0
# error "DYNARRAY_INITIAL_SIZE must be non-negative"
# endif
# if DYNARRAY_INITIAL_SIZE > 0
# define DYNARRAY_HAVE_SCRATCH 1
# else
# define DYNARRAY_HAVE_SCRATCH 0
# endif
#else
/* Provide a reasonable default which limits the size of
DYNARRAY_STRUCT. */
# define DYNARRAY_INITIAL_SIZE \
(sizeof (DYNARRAY_ELEMENT) > 64 ? 2 : 128 / sizeof (DYNARRAY_ELEMENT))
# define DYNARRAY_HAVE_SCRATCH 1
#endif
/* Public type definitions. */
/* All fields of this struct are private to the implementation. */
struct DYNARRAY_STRUCT
{
union
{
struct dynarray_header dynarray_abstract;
struct
{
/* These fields must match struct dynarray_header. */
size_t used;
size_t allocated;
DYNARRAY_ELEMENT *array;
} dynarray_header;
} u;
#if DYNARRAY_HAVE_SCRATCH
/* Initial inline allocation. */
DYNARRAY_ELEMENT scratch[DYNARRAY_INITIAL_SIZE];
#endif
};
/* Internal use only: Helper macros. */
/* Ensure macro-expansion of DYNARRAY_PREFIX. */
#define DYNARRAY_CONCAT0(prefix, name) prefix##name
#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name)
#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name)
/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free),
so that Gnulib does not change 'free' to 'rpl_free'. */
#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree)
/* Address of the scratch buffer if any. */
#if DYNARRAY_HAVE_SCRATCH
# define DYNARRAY_SCRATCH(list) (list)->scratch
#else
# define DYNARRAY_SCRATCH(list) NULL
#endif
/* Internal use only: Helper functions. */
/* Internal function. Call DYNARRAY_ELEMENT_FREE with the array
elements. Name mangling needed due to the DYNARRAY_ELEMENT_FREE
macro expansion. */
static inline void
DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array,
size_t __dynarray_used)
{
#ifdef DYNARRAY_ELEMENT_FREE
for (size_t __dynarray_i = 0; __dynarray_i < __dynarray_used; ++__dynarray_i)
DYNARRAY_ELEMENT_FREE (&__dynarray_array[__dynarray_i]);
#endif /* DYNARRAY_ELEMENT_FREE */
}
/* Internal function. Free the non-scratch array allocation. */
static inline void
DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list)
{
#if DYNARRAY_HAVE_SCRATCH
if (list->u.dynarray_header.array != list->scratch)
free (list->u.dynarray_header.array);
#else
free (list->u.dynarray_header.array);
#endif
}
/* Public functions. */
/* Initialize a dynamic array object. This must be called before any
use of the object. */
__nonnull ((1))
static void
DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
{
list->u.dynarray_header.used = 0;
list->u.dynarray_header.allocated = DYNARRAY_INITIAL_SIZE;
list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
}
/* Deallocate the dynamic array and its elements. */
__attribute_maybe_unused__ __nonnull ((1))
static void
DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
DYNARRAY_NAME (free__array__) (list);
DYNARRAY_NAME (init) (list);
}
/* Return true if the dynamic array is in an error state. */
__nonnull ((1))
static inline bool
DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.allocated == __dynarray_error_marker ();
}
/* Mark the dynamic array as failed. All elements are deallocated as
a side effect. */
__nonnull ((1))
static void
DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
DYNARRAY_NAME (free__array__) (list);
list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
list->u.dynarray_header.used = 0;
list->u.dynarray_header.allocated = __dynarray_error_marker ();
}
/* Return the number of elements which have been added to the dynamic
array. */
__nonnull ((1))
static inline size_t
DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.used;
}
/* Return a pointer to the array element at INDEX. Terminate the
process if INDEX is out of bounds. */
__nonnull ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
{
if (__glibc_unlikely (index >= DYNARRAY_NAME (size) (list)))
__libc_dynarray_at_failure (DYNARRAY_NAME (size) (list), index);
return list->u.dynarray_header.array + index;
}
/* Return a pointer to the first array element, if any. For a
zero-length array, the pointer can be NULL even though the dynamic
array has not entered the failure state. */
__nonnull ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.array;
}
/* Return a pointer one element past the last array element. For a
zero-length array, the pointer can be NULL even though the dynamic
array has not entered the failure state. */
__nonnull ((1))
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list)
{
return list->u.dynarray_header.array + list->u.dynarray_header.used;
}
/* Internal function. Slow path for the add function below. */
static void
DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
{
if (__glibc_unlikely
(!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT))))
{
DYNARRAY_NAME (mark_failed) (list);
return;
}
/* Copy the new element and increase the array length. */
list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
}
/* Add ITEM at the end of the array, enlarging it by one element.
Mark *LIST as failed if the dynamic array allocation size cannot be
increased. */
__nonnull ((1))
static inline void
DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
{
/* Do nothing in case of previous error. */
if (DYNARRAY_NAME (has_failed) (list))
return;
/* Enlarge the array if necessary. */
if (__glibc_unlikely (list->u.dynarray_header.used
== list->u.dynarray_header.allocated))
{
DYNARRAY_NAME (add__) (list, item);
return;
}
/* Copy the new element and increase the array length. */
list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
}
/* Internal function. Building block for the emplace functions below.
Assumes space for one more element in *LIST. */
static inline DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace__tail__) (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_ELEMENT *result
= &list->u.dynarray_header.array[list->u.dynarray_header.used];
++list->u.dynarray_header.used;
#if defined (DYNARRAY_ELEMENT_INIT)
DYNARRAY_ELEMENT_INIT (result);
#elif defined (DYNARRAY_ELEMENT_FREE)
memset (result, 0, sizeof (*result));
#endif
return result;
}
/* Internal function. Slow path for the emplace function below. */
static DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list)
{
if (__glibc_unlikely
(!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT))))
{
DYNARRAY_NAME (mark_failed) (list);
return NULL;
}
return DYNARRAY_NAME (emplace__tail__) (list);
}
/* Allocate a place for a new element in *LIST and return a pointer to
it. The pointer can be NULL if the dynamic array cannot be
enlarged due to a memory allocation failure. */
__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1))
static
/* Avoid inlining with the larger initialization code. */
#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE))
inline
#endif
DYNARRAY_ELEMENT *
DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list)
{
/* Do nothing in case of previous error. */
if (DYNARRAY_NAME (has_failed) (list))
return NULL;
/* Enlarge the array if necessary. */
if (__glibc_unlikely (list->u.dynarray_header.used
== list->u.dynarray_header.allocated))
return (DYNARRAY_NAME (emplace__) (list));
return DYNARRAY_NAME (emplace__tail__) (list);
}
/* Change the size of *LIST to SIZE. If SIZE is larger than the
existing size, new elements are added (which can be initialized).
Otherwise, the list is truncated, and elements are freed. Return
false on memory allocation failure (and mark *LIST as failed). */
__attribute_maybe_unused__ __nonnull ((1))
static bool
DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
{
if (size > list->u.dynarray_header.used)
{
bool ok;
#if defined (DYNARRAY_ELEMENT_INIT)
/* The new elements have to be initialized. */
size_t old_size = list->u.dynarray_header.used;
ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
size, DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT));
if (ok)
for (size_t i = old_size; i < size; ++i)
{
DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
}
#elif defined (DYNARRAY_ELEMENT_FREE)
/* Zero initialization is needed so that the elements can be
safely freed. */
ok = __libc_dynarray_resize_clear
(&list->u.dynarray_abstract, size,
DYNARRAY_SCRATCH (list), sizeof (DYNARRAY_ELEMENT));
#else
ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
size, DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT));
#endif
if (__glibc_unlikely (!ok))
DYNARRAY_NAME (mark_failed) (list);
return ok;
}
else
{
/* The list has shrunk in size. Free the removed elements. */
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array + size,
list->u.dynarray_header.used - size);
list->u.dynarray_header.used = size;
return true;
}
}
/* Remove the last element of LIST if it is present. */
__attribute_maybe_unused__ __nonnull ((1))
static void
DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
{
/* used > 0 implies that the array is the non-failed state. */
if (list->u.dynarray_header.used > 0)
{
size_t new_length = list->u.dynarray_header.used - 1;
#ifdef DYNARRAY_ELEMENT_FREE
DYNARRAY_ELEMENT_FREE (&list->u.dynarray_header.array[new_length]);
#endif
list->u.dynarray_header.used = new_length;
}
}
/* Remove all elements from the list. The elements are freed, but the
list itself is not. */
__attribute_maybe_unused__ __nonnull ((1))
static void
DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
{
/* free__elements__ does nothing if the list is in the failed
state. */
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
list->u.dynarray_header.used = 0;
}
#ifdef DYNARRAY_FINAL_TYPE
/* Transfer the dynamic array to a permanent location at *RESULT.
Returns true on success on false on allocation failure. In either
case, *LIST is re-initialized and can be reused. A NULL pointer is
stored in *RESULT if LIST refers to an empty list. On success, the
pointer in *RESULT is heap-allocated and must be deallocated using
free. */
__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1, 2))
static bool
DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
DYNARRAY_FINAL_TYPE *result)
{
struct dynarray_finalize_result res;
if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT), &res))
{
/* On success, the result owns all the data. */
DYNARRAY_NAME (init) (list);
*result = (DYNARRAY_FINAL_TYPE) { res.array, res.length };
return true;
}
else
{
/* On error, we need to free all data. */
DYNARRAY_FREE (list);
errno = ENOMEM;
return false;
}
}
#else /* !DYNARRAY_FINAL_TYPE */
/* Transfer the dynamic array to a heap-allocated array and return a
pointer to it. The pointer is NULL if memory allocation fails, or
if the array is empty, so this function should be used only for
arrays which are known not be empty (usually because they always
have a sentinel at the end). If LENGTHP is not NULL, the array
length is written to *LENGTHP. *LIST is re-initialized and can be
reused. */
__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1))
static DYNARRAY_ELEMENT *
DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
{
struct dynarray_finalize_result res;
if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
DYNARRAY_SCRATCH (list),
sizeof (DYNARRAY_ELEMENT), &res))
{
/* On success, the result owns all the data. */
DYNARRAY_NAME (init) (list);
if (lengthp != NULL)
*lengthp = res.length;
return res.array;
}
else
{
/* On error, we need to free all data. */
DYNARRAY_FREE (list);
errno = ENOMEM;
return NULL;
}
}
#endif /* !DYNARRAY_FINAL_TYPE */
/* Undo macro definitions. */
#undef DYNARRAY_CONCAT0
#undef DYNARRAY_CONCAT1
#undef DYNARRAY_NAME
#undef DYNARRAY_SCRATCH
#undef DYNARRAY_HAVE_SCRATCH
#undef DYNARRAY_STRUCT
#undef DYNARRAY_ELEMENT
#undef DYNARRAY_PREFIX
#undef DYNARRAY_ELEMENT_FREE
#undef DYNARRAY_ELEMENT_INIT
#undef DYNARRAY_INITIAL_SIZE
#undef DYNARRAY_FINAL_TYPE

178
lib/malloc/dynarray.h Normal file
View file

@ -0,0 +1,178 @@
/* Type-safe arrays which grow dynamically. Shared definitions.
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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.
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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/* To use the dynarray facility, you need to include
<malloc/dynarray-skeleton.c> and define the parameter macros
documented in that file.
A minimal example which provides a growing list of integers can be
defined like this:
struct int_array
{
// Pointer to result array followed by its length,
// as required by DYNARRAY_FINAL_TYPE.
int *array;
size_t length;
};
#define DYNARRAY_STRUCT dynarray_int
#define DYNARRAY_ELEMENT int
#define DYNARRAY_PREFIX dynarray_int_
#define DYNARRAY_FINAL_TYPE struct int_array
#include <malloc/dynarray-skeleton.c>
To create a three-element array with elements 1, 2, 3, use this
code:
struct dynarray_int dyn;
dynarray_int_init (&dyn);
for (int i = 1; i <= 3; ++i)
{
int *place = dynarray_int_emplace (&dyn);
assert (place != NULL);
*place = i;
}
struct int_array result;
bool ok = dynarray_int_finalize (&dyn, &result);
assert (ok);
assert (result.length == 3);
assert (result.array[0] == 1);
assert (result.array[1] == 2);
assert (result.array[2] == 3);
free (result.array);
If the elements contain resources which must be freed, define
DYNARRAY_ELEMENT_FREE appropriately, like this:
struct str_array
{
char **array;
size_t length;
};
#define DYNARRAY_STRUCT dynarray_str
#define DYNARRAY_ELEMENT char *
#define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
#define DYNARRAY_PREFIX dynarray_str_
#define DYNARRAY_FINAL_TYPE struct str_array
#include <malloc/dynarray-skeleton.c>
Compared to scratch buffers, dynamic arrays have the following
features:
- They have an element type, and are not just an untyped buffer of
bytes.
- When growing, previously stored elements are preserved. (It is
expected that scratch_buffer_grow_preserve and
scratch_buffer_set_array_size eventually go away because all
current users are moved to dynamic arrays.)
- Scratch buffers have a more aggressive growth policy because
growing them typically means a retry of an operation (across an
NSS service module boundary), which is expensive.
- For the same reason, scratch buffers have a much larger initial
stack allocation. */
#ifndef _DYNARRAY_H
#define _DYNARRAY_H
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
struct dynarray_header
{
size_t used;
size_t allocated;
void *array;
};
/* Marker used in the allocated member to indicate that an error was
encountered. */
static inline size_t
__dynarray_error_marker (void)
{
return -1;
}
/* Internal function. See the has_failed function in
dynarray-skeleton.c. */
static inline bool
__dynarray_error (struct dynarray_header *list)
{
return list->allocated == __dynarray_error_marker ();
}
/* Internal function. Enlarge the dynamically allocated area of the
array to make room for one more element. SCRATCH is a pointer to
the scratch area (which is not heap-allocated and must not be
freed). ELEMENT_SIZE is the size, in bytes, of one element.
Return false on failure, true on success. */
bool __libc_dynarray_emplace_enlarge (struct dynarray_header *,
void *scratch, size_t element_size);
/* Internal function. Enlarge the dynamically allocated area of the
array to make room for at least SIZE elements (which must be larger
than the existing used part of the dynamic array). SCRATCH is a
pointer to the scratch area (which is not heap-allocated and must
not be freed). ELEMENT_SIZE is the size, in bytes, of one element.
Return false on failure, true on success. */
bool __libc_dynarray_resize (struct dynarray_header *, size_t size,
void *scratch, size_t element_size);
/* Internal function. Like __libc_dynarray_resize, but clear the new
part of the dynamic array. */
bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size,
void *scratch, size_t element_size);
/* Internal type. */
struct dynarray_finalize_result
{
void *array;
size_t length;
};
/* Internal function. Copy the dynamically-allocated area to an
explicitly-sized heap allocation. SCRATCH is a pointer to the
embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the
element type. On success, true is returned, and pointer and length
are written to *RESULT. On failure, false is returned. The caller
has to take care of some of the memory management; this function is
expected to be called from dynarray-skeleton.c. */
bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch,
size_t element_size,
struct dynarray_finalize_result *result);
/* Internal function. Terminate the process after an index error.
SIZE is the number of elements of the dynamic array. INDEX is the
lookup index which triggered the failure. */
_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index);
#ifndef _ISOMAC
libc_hidden_proto (__libc_dynarray_emplace_enlarge)
libc_hidden_proto (__libc_dynarray_resize)
libc_hidden_proto (__libc_dynarray_resize_clear)
libc_hidden_proto (__libc_dynarray_finalize)
libc_hidden_proto (__libc_dynarray_at_failure)
#endif
#endif /* _DYNARRAY_H */

View file

@ -0,0 +1,35 @@
/* Report an dynamic array index out of bounds condition.
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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.
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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <dynarray.h>
#include <stdio.h>
#include <stdlib.h>
void
__libc_dynarray_at_failure (size_t size, size_t index)
{
#ifdef _LIBC
char buf[200];
__snprintf (buf, sizeof (buf), "Fatal glibc error: "
"array index %zu not less than array length %zu\n",
index, size);
#else
abort ();
#endif
}
libc_hidden_def (__libc_dynarray_at_failure)

View file

@ -0,0 +1,73 @@
/* Increase the size of a dynamic array in preparation of an emplace operation.
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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.
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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <dynarray.h>
#include <errno.h>
#include <intprops.h>
#include <stdlib.h>
#include <string.h>
bool
__libc_dynarray_emplace_enlarge (struct dynarray_header *list,
void *scratch, size_t element_size)
{
size_t new_allocated;
if (list->allocated == 0)
{
/* No scratch buffer provided. Choose a reasonable default
size. */
if (element_size < 4)
new_allocated = 16;
else if (element_size < 8)
new_allocated = 8;
else
new_allocated = 4;
}
else
/* Increase the allocated size, using an exponential growth
policy. */
{
new_allocated = list->allocated + list->allocated / 2 + 1;
if (new_allocated <= list->allocated)
{
/* Overflow. */
__set_errno (ENOMEM);
return false;
}
}
size_t new_size;
if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size))
return false;
void *new_array;
if (list->array == scratch)
{
/* The previous array was not heap-allocated. */
new_array = malloc (new_size);
if (new_array != NULL && list->array != NULL)
memcpy (new_array, list->array, list->used * element_size);
}
else
new_array = realloc (list->array, new_size);
if (new_array == NULL)
return false;
list->array = new_array;
list->allocated = new_allocated;
return true;
}
libc_hidden_def (__libc_dynarray_emplace_enlarge)

View file

@ -0,0 +1,62 @@
/* Copy the dynamically-allocated area to an explicitly-sized heap allocation.
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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.
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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <dynarray.h>
#include <stdlib.h>
#include <string.h>
bool
__libc_dynarray_finalize (struct dynarray_header *list,
void *scratch, size_t element_size,
struct dynarray_finalize_result *result)
{
if (__dynarray_error (list))
/* The caller will reported the deferred error. */
return false;
size_t used = list->used;
/* Empty list. */
if (used == 0)
{
/* An empty list could still be backed by a heap-allocated
array. Free it if necessary. */
if (list->array != scratch)
free (list->array);
*result = (struct dynarray_finalize_result) { NULL, 0 };
return true;
}
size_t allocation_size = used * element_size;
void *heap_array = malloc (allocation_size);
if (heap_array != NULL)
{
/* The new array takes ownership of the strings. */
if (list->array != NULL)
memcpy (heap_array, list->array, allocation_size);
if (list->array != scratch)
free (list->array);
*result = (struct dynarray_finalize_result)
{ .array = heap_array, .length = used };
return true;
}
else
/* The caller will perform the freeing operation. */
return false;
}
libc_hidden_def (__libc_dynarray_finalize)

View file

@ -0,0 +1,64 @@
/* Increase the size of a dynamic array.
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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.
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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <dynarray.h>
#include <errno.h>
#include <intprops.h>
#include <stdlib.h>
#include <string.h>
bool
__libc_dynarray_resize (struct dynarray_header *list, size_t size,
void *scratch, size_t element_size)
{
/* The existing allocation provides sufficient room. */
if (size <= list->allocated)
{
list->used = size;
return true;
}
/* Otherwise, use size as the new allocation size. The caller is
expected to provide the final size of the array, so there is no
over-allocation here. */
size_t new_size_bytes;
if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes))
{
/* Overflow. */
__set_errno (ENOMEM);
return false;
}
void *new_array;
if (list->array == scratch)
{
/* The previous array was not heap-allocated. */
new_array = malloc (new_size_bytes);
if (new_array != NULL && list->array != NULL)
memcpy (new_array, list->array, list->used * element_size);
}
else
new_array = realloc (list->array, new_size_bytes);
if (new_array == NULL)
return false;
list->array = new_array;
list->allocated = size;
list->used = size;
return true;
}
libc_hidden_def (__libc_dynarray_resize)

View file

@ -0,0 +1,35 @@
/* Increase the size of a dynamic array and clear the new part.
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
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.
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 the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <dynarray.h>
#include <string.h>
bool
__libc_dynarray_resize_clear (struct dynarray_header *list, size_t size,
void *scratch, size_t element_size)
{
size_t old_size = list->used;
if (!__libc_dynarray_resize (list, size, scratch, element_size))
return false;
/* __libc_dynarray_resize already checked for overflow. */
char *array = list->array;
memset (array + (old_size * element_size), 0,
(size - old_size) * element_size);
return true;
}
libc_hidden_def (__libc_dynarray_resize_clear)

View file

@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
Copyright (C) 2015-2020 Free Software Foundation, Inc.
Copyright (C) 2015-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or

View file

@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
Copyright (C) 2015-2020 Free Software Foundation, Inc.
Copyright (C) 2015-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or

View file

@ -1,5 +1,5 @@
/* Variable-sized buffer with on-stack default allocation.
Copyright (C) 2015-2020 Free Software Foundation, Inc.
Copyright (C) 2015-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or

View file

@ -4521,7 +4521,7 @@ mpz_export (void *r, size_t *countp, int order, size_t size, int endian,
mp_size_t un;
if (nails != 0)
gmp_die ("mpz_import: Nails not supported.");
gmp_die ("mpz_export: Nails not supported.");
assert (order == 1 || order == -1);
assert (endian >= -1 && endian <= 1);

View file

@ -1,5 +1,5 @@
/* Internals of mktime and related functions
Copyright 2016-2020 Free Software Foundation, Inc.
Copyright 2016-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert <eggert@cs.ucla.edu>.

View file

@ -19,7 +19,7 @@
# define USE_IN_EXTENDED_LOCALE_MODEL 1
# define HAVE_STRUCT_ERA_ENTRY 1
# define HAVE_TM_GMTOFF 1
# define HAVE_TM_ZONE 1
# define HAVE_STRUCT_TM_TM_ZONE 1
# define HAVE_TZNAME 1
# include "../locale/localeinfo.h"
#else
@ -499,7 +499,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
#endif
zone = NULL;
#if HAVE_TM_ZONE
#if HAVE_STRUCT_TM_TM_ZONE
/* The POSIX test suite assumes that setting
the environment variable TZ to a new value before calling strftime()
will influence the result (the %Z format) even if the information in
@ -516,7 +516,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
}
else
{
# if !HAVE_TM_ZONE
# if !HAVE_STRUCT_TM_TM_ZONE
/* Infer the zone name from *TZ instead of from TZNAME. */
tzname_vec = tz->tzname_copy;
# endif

View file

@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
Copyright (C) 2002-2020 Free Software Foundation, Inc.
Copyright (C) 2002-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.

View file

@ -32,6 +32,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <dynarray.h>
#include <intprops.h>
#include <verify.h>
@ -444,25 +445,6 @@ typedef struct re_dfa_t re_dfa_t;
#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
#if defined _LIBC || HAVE_ALLOCA
# include <alloca.h>
#endif
#ifndef _LIBC
# if HAVE_ALLOCA
/* The OS usually guarantees only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
allocate anything larger than 4096 bytes. Also care for the possibility
of a few compiler-allocated temporary stack slots. */
# define __libc_use_alloca(n) ((n) < 4032)
# else
/* alloca is implemented with malloc, so just use malloc. */
# define __libc_use_alloca(n) 0
# undef alloca
# define alloca(n) malloc (n)
# endif
#endif
#ifdef _LIBC
# define MALLOC_0_IS_NONNULL 1
#elif !defined MALLOC_0_IS_NONNULL
@ -848,12 +830,14 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
}
#endif /* RE_ENABLE_I18N */
#ifndef FALLTHROUGH
# if (__GNUC__ >= 7) || (__clang_major__ >= 10)
#ifdef _LIBC
# if __GNUC__ >= 7
# define FALLTHROUGH __attribute__ ((__fallthrough__))
# else
# define FALLTHROUGH ((void) 0)
# endif
#else
# include "attribute.h"
#endif
#endif /* _REGEX_INTERNAL_H */

View file

@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
Copyright (C) 2002-2020 Free Software Foundation, Inc.
Copyright (C) 2002-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@ -1355,6 +1355,12 @@ pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
return fs->stack[num].node;
}
#define DYNARRAY_STRUCT regmatch_list
#define DYNARRAY_ELEMENT regmatch_t
#define DYNARRAY_PREFIX regmatch_list_
#include <malloc/dynarray-skeleton.c>
/* Set the positions where the subexpressions are starts/ends to registers
PMATCH.
Note: We assume that pmatch[0] is already set, and
@ -1370,8 +1376,8 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
re_node_set eps_via_nodes;
struct re_fail_stack_t *fs;
struct re_fail_stack_t fs_body = { 0, 2, NULL };
regmatch_t *prev_idx_match;
bool prev_idx_match_malloced = false;
struct regmatch_list prev_match;
regmatch_list_init (&prev_match);
DEBUG_ASSERT (nmatch > 1);
DEBUG_ASSERT (mctx->state_log != NULL);
@ -1388,18 +1394,13 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
cur_node = dfa->init_node;
re_node_set_init_empty (&eps_via_nodes);
if (__libc_use_alloca (nmatch * sizeof (regmatch_t)))
prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t));
else
if (!regmatch_list_resize (&prev_match, nmatch))
{
prev_idx_match = re_malloc (regmatch_t, nmatch);
if (prev_idx_match == NULL)
{
free_fail_stack_return (fs);
return REG_ESPACE;
}
prev_idx_match_malloced = true;
regmatch_list_free (&prev_match);
free_fail_stack_return (fs);
return REG_ESPACE;
}
regmatch_t *prev_idx_match = regmatch_list_begin (&prev_match);
memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
@ -1417,8 +1418,7 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
if (reg_idx == nmatch)
{
re_node_set_free (&eps_via_nodes);
if (prev_idx_match_malloced)
re_free (prev_idx_match);
regmatch_list_free (&prev_match);
return free_fail_stack_return (fs);
}
cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
@ -1427,8 +1427,7 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
else
{
re_node_set_free (&eps_via_nodes);
if (prev_idx_match_malloced)
re_free (prev_idx_match);
regmatch_list_free (&prev_match);
return REG_NOERROR;
}
}
@ -1442,8 +1441,7 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
if (__glibc_unlikely (cur_node == -2))
{
re_node_set_free (&eps_via_nodes);
if (prev_idx_match_malloced)
re_free (prev_idx_match);
regmatch_list_free (&prev_match);
free_fail_stack_return (fs);
return REG_ESPACE;
}
@ -1453,15 +1451,13 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
else
{
re_node_set_free (&eps_via_nodes);
if (prev_idx_match_malloced)
re_free (prev_idx_match);
regmatch_list_free (&prev_match);
return REG_NOMATCH;
}
}
}
re_node_set_free (&eps_via_nodes);
if (prev_idx_match_malloced)
re_free (prev_idx_match);
regmatch_list_free (&prev_match);
return free_fail_stack_return (fs);
}
@ -3251,7 +3247,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
/* Build transition table for the state.
Return true if successful. */
static bool
static bool __attribute_noinline__
build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
{
reg_errcode_t err;
@ -3259,36 +3255,20 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
int ch;
bool need_word_trtable = false;
bitset_word_t elem, mask;
bool dests_node_malloced = false;
bool dest_states_malloced = false;
Idx ndests; /* Number of the destination states from 'state'. */
re_dfastate_t **trtable;
re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl;
re_node_set follows, *dests_node;
bitset_t *dests_ch;
re_dfastate_t *dest_states[SBC_MAX];
re_dfastate_t *dest_states_word[SBC_MAX];
re_dfastate_t *dest_states_nl[SBC_MAX];
re_node_set follows;
bitset_t acceptable;
struct dests_alloc
{
re_node_set dests_node[SBC_MAX];
bitset_t dests_ch[SBC_MAX];
} *dests_alloc;
/* We build DFA states which corresponds to the destination nodes
from 'state'. 'dests_node[i]' represents the nodes which i-th
destination state contains, and 'dests_ch[i]' represents the
characters which i-th destination state accepts. */
if (__libc_use_alloca (sizeof (struct dests_alloc)))
dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc));
else
{
dests_alloc = re_malloc (struct dests_alloc, 1);
if (__glibc_unlikely (dests_alloc == NULL))
return false;
dests_node_malloced = true;
}
dests_node = dests_alloc->dests_node;
dests_ch = dests_alloc->dests_ch;
re_node_set dests_node[SBC_MAX];
bitset_t dests_ch[SBC_MAX];
/* Initialize transition table. */
state->word_trtable = state->trtable = NULL;
@ -3298,8 +3278,6 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
if (__glibc_unlikely (ndests <= 0))
{
if (dests_node_malloced)
re_free (dests_alloc);
/* Return false in case of an error, true otherwise. */
if (ndests == 0)
{
@ -3314,38 +3292,14 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
err = re_node_set_alloc (&follows, ndests + 1);
if (__glibc_unlikely (err != REG_NOERROR))
goto out_free;
/* Avoid arithmetic overflow in size calculation. */
size_t ndests_max
= ((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
/ (3 * sizeof (re_dfastate_t *)));
if (__glibc_unlikely (ndests_max < ndests))
goto out_free;
if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
+ ndests * 3 * sizeof (re_dfastate_t *)))
dest_states = (re_dfastate_t **)
alloca (ndests * 3 * sizeof (re_dfastate_t *));
else
{
dest_states = re_malloc (re_dfastate_t *, ndests * 3);
if (__glibc_unlikely (dest_states == NULL))
{
out_free:
if (dest_states_malloced)
re_free (dest_states);
re_node_set_free (&follows);
for (i = 0; i < ndests; ++i)
re_node_set_free (dests_node + i);
if (dests_node_malloced)
re_free (dests_alloc);
return false;
}
dest_states_malloced = true;
out_free:
re_node_set_free (&follows);
for (i = 0; i < ndests; ++i)
re_node_set_free (dests_node + i);
return false;
}
dest_states_word = dest_states + ndests;
dest_states_nl = dest_states_word + ndests;
bitset_empty (acceptable);
/* Then build the states for all destinations. */
@ -3470,16 +3424,9 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
}
}
if (dest_states_malloced)
re_free (dest_states);
re_node_set_free (&follows);
for (i = 0; i < ndests; ++i)
re_node_set_free (dests_node + i);
if (dests_node_malloced)
re_free (dests_alloc);
return true;
}

View file

@ -21,6 +21,7 @@
#include <libc-config.h>
#define __libc_scratch_buffer_dupfree gl_scratch_buffer_dupfree
#define __libc_scratch_buffer_grow gl_scratch_buffer_grow
#define __libc_scratch_buffer_grow_preserve gl_scratch_buffer_grow_preserve
#define __libc_scratch_buffer_set_array_size gl_scratch_buffer_set_array_size

View file

@ -49,6 +49,23 @@
# ifndef _@GUARD_PREFIX@_STDDEF_H
/* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a
type with alignment 4, but 'long' has alignment 8. */
# if defined _AIX && defined _ARCH_PPC64
# if !GNULIB_defined_max_align_t
# ifdef _MAX_ALIGN_T
/* /usr/include/stddef.h has already defined max_align_t. Override it. */
typedef long rpl_max_align_t;
# define max_align_t rpl_max_align_t
# else
/* Prevent /usr/include/stddef.h from defining max_align_t. */
typedef long max_align_t;
# define _MAX_ALIGN_T
# endif
# define GNULIB_defined_max_align_t 1
# endif
# endif
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
@ -86,8 +103,10 @@
we are currently compiling with gcc.
On MSVC, max_align_t is defined only in C++ mode, after <cstddef> was
included. Its definition is good since it has an alignment of 8 (on x86
and x86_64). */
#if defined _MSC_VER && defined __cplusplus
and x86_64).
Similarly on OS/2 kLIBC. */
#if (defined _MSC_VER || (defined __KLIBC__ && !defined __LIBCN__)) \
&& defined __cplusplus
# include <cstddef>
#else
# if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T)

View file

@ -69,6 +69,14 @@
# include <unistd.h>
#endif
/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */
/* But in any case avoid namespace pollution on glibc systems. */
#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
&& defined _AIX) \
&& ! defined __GLIBC__
# include <strings.h>
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
@ -110,10 +118,18 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
/* Find the index of the least-significant set bit. */
#if @GNULIB_FFSLL@
# if !@HAVE_FFSLL@
# if @REPLACE_FFSLL@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define ffsll rpl_ffsll
# endif
_GL_FUNCDECL_RPL (ffsll, int, (long long int i));
_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
# else
# if !@HAVE_FFSLL@
_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
# endif
# endif
_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
# endif
_GL_CXXALIASWARN (ffsll);
#elif defined GNULIB_POSIXCHECK
# undef ffsll

View file

@ -713,11 +713,21 @@ _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
#if @GNULIB_MKFIFOAT@
# if !@HAVE_MKFIFOAT@
# if @REPLACE_MKFIFOAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef mkfifoat
# define mkfifoat rpl_mkfifoat
# endif
_GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode));
# else
# if !@HAVE_MKFIFOAT@
_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
_GL_ARG_NONNULL ((2)));
# endif
# endif
_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
# endif
_GL_CXXALIASWARN (mkfifoat);
#elif defined GNULIB_POSIXCHECK
# undef mkfifoat
@ -756,13 +766,25 @@ _GL_WARN_ON_USE (mknod, "mknod is not portable - "
#if @GNULIB_MKNODAT@
# if !@HAVE_MKNODAT@
# if @REPLACE_MKNODAT@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef mknodat
# define mknodat rpl_mknodat
# endif
_GL_FUNCDECL_RPL (mknodat, int,
(int fd, char const *file, mode_t mode, dev_t dev)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (mknodat, int,
(int fd, char const *file, mode_t mode, dev_t dev));
# else
# if !@HAVE_MKNODAT@
_GL_FUNCDECL_SYS (mknodat, int,
(int fd, char const *file, mode_t mode, dev_t dev)
_GL_ARG_NONNULL ((2)));
# endif
# endif
_GL_CXXALIAS_SYS (mknodat, int,
(int fd, char const *file, mode_t mode, dev_t dev));
# endif
_GL_CXXALIASWARN (mknodat);
#elif defined GNULIB_POSIXCHECK
# undef mknodat

View file

@ -22,6 +22,7 @@
#include <sys/types.h>
#include <assert.h>
#include <stdbool.h>
#include <errno.h>
@ -61,7 +62,8 @@
# define __gen_tempname gen_tempname
# define __mkdir mkdir
# define __open open
# define __lxstat64(version, file, buf) lstat (file, buf)
# define __lstat64(file, buf) lstat (file, buf)
# define __stat64(file, buf) stat (file, buf)
# define __getrandom getrandom
# define __clock_gettime64 clock_gettime
# define __timespec64 timespec
@ -76,13 +78,14 @@ typedef uint_fast64_t random_value;
#define BASE_62_POWER (62LL * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62)
static random_value
random_bits (random_value var)
random_bits (random_value var, bool use_getrandom)
{
random_value r;
if (__getrandom (&r, sizeof r, 0) == sizeof r)
/* Without GRND_NONBLOCK it can be blocked for minutes on some systems. */
if (use_getrandom && __getrandom (&r, sizeof r, GRND_NONBLOCK) == sizeof r)
return r;
#if _LIBC || (defined CLOCK_MONOTONIC && HAVE_CLOCK_GETTIME)
/* Add entropy if getrandom is not supported. */
/* Add entropy if getrandom did not work. */
struct __timespec64 tv;
__clock_gettime64 (CLOCK_MONOTONIC, &tv);
var ^= tv.tv_nsec;
@ -96,7 +99,7 @@ static int
direxists (const char *dir)
{
struct_stat64 buf;
return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
return __stat64 (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
}
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
@ -188,7 +191,7 @@ try_nocreate (char *tmpl, void *flags _GL_UNUSED)
{
struct_stat64 st;
if (__lxstat64 (_STAT_VER, tmpl, &st) == 0 || errno == EOVERFLOW)
if (__lstat64 (tmpl, &st) == 0 || errno == EOVERFLOW)
__set_errno (EEXIST);
return errno == ENOENT ? 0 : -1;
}
@ -267,6 +270,13 @@ try_tempname_len (char *tmpl, int suffixlen, void *args,
/* How many random base-62 digits can currently be extracted from V. */
int vdigits = 0;
/* Whether to consume entropy when acquiring random bits. On the
first try it's worth the entropy cost with __GT_NOCREATE, which
is inherently insecure and can use the entropy to make it a bit
less secure. On the (rare) second and later attempts it might
help against DoS attacks. */
bool use_getrandom = tryfunc == try_nocreate;
/* Least unfair value for V. If V is less than this, V can generate
BASE_62_DIGITS digits fairly. Otherwise it might be biased. */
random_value const unfair_min
@ -290,7 +300,10 @@ try_tempname_len (char *tmpl, int suffixlen, void *args,
if (vdigits == 0)
{
do
v = random_bits (v);
{
v = random_bits (v, use_getrandom);
use_getrandom = true;
}
while (unfair_min <= v);
vdigits = BASE_62_DIGITS;

View file

@ -24,7 +24,7 @@ struct tm_zone
members are zero. */
struct tm_zone *next;
#if HAVE_TZNAME && !HAVE_TM_ZONE
#if HAVE_TZNAME && !HAVE_STRUCT_TM_TM_ZONE
/* Copies of recent strings taken from tzname[0] and tzname[1].
The copies are in ABBRS, so that they survive tzset. Null if unknown. */
char *tzname_copy[2];

View file

@ -101,6 +101,25 @@ struct __time_t_must_be_integral {
# define GNULIB_defined_struct_time_t_must_be_integral 1
# endif
/* Define TIME_UTC, a positive integer constant used for timespec_get(). */
# if ! @TIME_H_DEFINES_TIME_UTC@
# if !GNULIB_defined_TIME_UTC
# define TIME_UTC 1
# define GNULIB_defined_TIME_UTC 1
# endif
# endif
/* Set *TS to the current time, and return BASE.
Upon failure, return 0. */
# if @GNULIB_TIMESPEC_GET@
# if ! @HAVE_TIMESPEC_GET@
_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
_GL_CXXALIASWARN (timespec_get);
# endif
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
return -1 and store the remaining time into RMTP. See
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */

View file

@ -71,7 +71,7 @@ tzalloc (char const *name)
if (tz)
{
tz->next = NULL;
#if HAVE_TZNAME && !HAVE_TM_ZONE
#if HAVE_TZNAME && !HAVE_STRUCT_TM_TM_ZONE
tz->tzname_copy[0] = tz->tzname_copy[1] = NULL;
#endif
tz->tz_is_set = !!name;
@ -83,13 +83,13 @@ tzalloc (char const *name)
}
/* Save into TZ any nontrivial time zone abbreviation used by TM, and
update *TM (if HAVE_TM_ZONE) or *TZ (if !HAVE_TM_ZONE &&
HAVE_TZNAME) if they use the abbreviation. Return true if
successful, false (setting errno) otherwise. */
update *TM (if HAVE_STRUCT_TM_TM_ZONE) or *TZ (if
!HAVE_STRUCT_TM_TM_ZONE && HAVE_TZNAME) if they use the abbreviation.
Return true if successful, false (setting errno) otherwise. */
static bool
save_abbr (timezone_t tz, struct tm *tm)
{
#if HAVE_TM_ZONE || HAVE_TZNAME
#if HAVE_STRUCT_TM_TM_ZONE || HAVE_TZNAME
char const *zone = NULL;
char *zone_copy = (char *) "";
@ -97,7 +97,7 @@ save_abbr (timezone_t tz, struct tm *tm)
int tzname_index = -1;
# endif
# if HAVE_TM_ZONE
# if HAVE_STRUCT_TM_TM_ZONE
zone = tm->tm_zone;
# endif
@ -145,7 +145,7 @@ save_abbr (timezone_t tz, struct tm *tm)
}
/* Replace the zone name so that its lifetime matches that of TZ. */
# if HAVE_TM_ZONE
# if HAVE_STRUCT_TM_TM_ZONE
tm->tm_zone = zone_copy;
# else
if (0 <= tzname_index)
@ -303,7 +303,7 @@ mktime_z (timezone_t tz, struct tm *tm)
tm_1.tm_isdst = tm->tm_isdst;
time_t t = mktime (&tm_1);
bool ok = 0 <= tm_1.tm_yday;
#if HAVE_TM_ZONE || HAVE_TZNAME
#if HAVE_STRUCT_TM_TM_ZONE || HAVE_TZNAME
ok = ok && save_abbr (tz, &tm_1);
#endif
if (revert_tz (old_tz) && ok)

View file

@ -1,6 +1,6 @@
/* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
Copyright (C) 1994-2020 Free Software Foundation, Inc.
Copyright (C) 1994-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or

View file

@ -27,6 +27,7 @@
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
@ -52,7 +53,9 @@
/* Avoid recursion with rpl_futimens or rpl_utimensat. */
#undef futimens
#undef utimensat
#if !HAVE_NEARLY_WORKING_UTIMENSAT
# undef utimensat
#endif
/* Solaris 9 mistakenly succeeds when given a non-directory with a
trailing slash. Force the use of rpl_stat for a fix. */
@ -246,6 +249,20 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
# if HAVE_UTIMENSAT
if (fd < 0)
{
# if defined __APPLE__ && defined __MACH__
size_t len = strlen (file);
if (len > 0 && file[len - 1] == '/')
{
struct stat statbuf;
if (stat (file, &statbuf) < 0)
return -1;
if (!S_ISDIR (statbuf.st_mode))
{
errno = ENOTDIR;
return -1;
}
}
# endif
result = utimensat (AT_FDCWD, file, ts, 0);
# ifdef __linux__
/* Work around a kernel bug:

View file

@ -24,14 +24,40 @@
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "stat-time.h"
#include "timespec.h"
#include "utimens.h"
#if HAVE_UTIMENSAT
#if HAVE_NEARLY_WORKING_UTIMENSAT
/* Use the original utimensat(), but correct the trailing slash handling. */
int
rpl_utimensat (int fd, char const *file, struct timespec const times[2],
int flag)
# undef utimensat
{
size_t len = strlen (file);
if (len && file[len - 1] == '/')
{
struct stat st;
if (fstatat (fd, file, &st, flag & AT_SYMLINK_NOFOLLOW) < 0)
return -1;
if (!S_ISDIR (st.st_mode))
{
errno = ENOTDIR;
return -1;
}
}
return utimensat (fd, file, times, flag);
}
#else
# if HAVE_UTIMENSAT
/* If we have a native utimensat, but are compiling this file, then
utimensat was defined to rpl_utimensat by our replacement
@ -42,24 +68,25 @@
local_utimensat provides the fallback manipulation. */
static int local_utimensat (int, char const *, struct timespec const[2], int);
# define AT_FUNC_NAME local_utimensat
# define AT_FUNC_NAME local_utimensat
/* Like utimensat, but work around native bugs. */
int
rpl_utimensat (int fd, char const *file, struct timespec const times[2],
int flag)
# undef utimensat
{
# if defined __linux__ || defined __sun
# if defined __linux__ || defined __sun
struct timespec ts[2];
# endif
# endif
/* See comments in utimens.c for details. */
static int utimensat_works_really; /* 0 = unknown, 1 = yes, -1 = no. */
if (0 <= utimensat_works_really)
{
int result;
# if defined __linux__ || defined __sun
# if defined __linux__ || defined __sun
struct stat st;
/* As recently as Linux kernel 2.6.32 (Dec 2009), several file
systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
@ -90,7 +117,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
ts[1] = times[1];
times = ts;
}
# ifdef __hppa__
# ifdef __hppa__
/* Linux kernel 2.6.22.19 on hppa does not reject invalid tv_nsec
values. */
else if (times
@ -104,8 +131,36 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
errno = EINVAL;
return -1;
}
# endif
# endif
# if defined __APPLE__ && defined __MACH__
/* macOS 10.13 does not reject invalid tv_nsec values either. */
if (times
&& ((times[0].tv_nsec != UTIME_OMIT
&& times[0].tv_nsec != UTIME_NOW
&& ! (0 <= times[0].tv_nsec
&& times[0].tv_nsec < TIMESPEC_HZ))
|| (times[1].tv_nsec != UTIME_OMIT
&& times[1].tv_nsec != UTIME_NOW
&& ! (0 <= times[1].tv_nsec
&& times[1].tv_nsec < TIMESPEC_HZ))))
{
errno = EINVAL;
return -1;
}
size_t len = strlen (file);
if (len > 0 && file[len - 1] == '/')
{
struct stat statbuf;
if (fstatat (fd, file, &statbuf, 0) < 0)
return -1;
if (!S_ISDIR (statbuf.st_mode))
{
errno = ENOTDIR;
return -1;
}
}
# endif
# endif
result = utimensat (fd, file, times, flag);
/* Linux kernel 2.6.25 has a bug where it returns EINVAL for
UTIME_NOW or UTIME_OMIT with non-zero tv_sec, which
@ -129,11 +184,11 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
return local_utimensat (fd, file, times, flag);
}
#else /* !HAVE_UTIMENSAT */
# else /* !HAVE_UTIMENSAT */
# define AT_FUNC_NAME utimensat
# define AT_FUNC_NAME utimensat
#endif /* !HAVE_UTIMENSAT */
# endif /* !HAVE_UTIMENSAT */
/* Set the access and modification timestamps of FILE to be
TIMESPEC[0] and TIMESPEC[1], respectively; relative to directory
@ -146,15 +201,17 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2],
Return 0 on success, -1 (setting errno) on failure. */
/* AT_FUNC_NAME is now utimensat or local_utimensat. */
#define AT_FUNC_F1 lutimens
#define AT_FUNC_F2 utimens
#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW
#define AT_FUNC_POST_FILE_PARAM_DECLS , struct timespec const ts[2], int flag
#define AT_FUNC_POST_FILE_ARGS , ts
#include "at-func.c"
#undef AT_FUNC_NAME
#undef AT_FUNC_F1
#undef AT_FUNC_F2
#undef AT_FUNC_USE_F1_COND
#undef AT_FUNC_POST_FILE_PARAM_DECLS
#undef AT_FUNC_POST_FILE_ARGS
# define AT_FUNC_F1 lutimens
# define AT_FUNC_F2 utimens
# define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW
# define AT_FUNC_POST_FILE_PARAM_DECLS , struct timespec const ts[2], int flag
# define AT_FUNC_POST_FILE_ARGS , ts
# include "at-func.c"
# undef AT_FUNC_NAME
# undef AT_FUNC_F1
# undef AT_FUNC_F2
# undef AT_FUNC_USE_F1_COND
# undef AT_FUNC_POST_FILE_PARAM_DECLS
# undef AT_FUNC_POST_FILE_ARGS
#endif /* !HAVE_NEARLY_WORKING_UTIMENSAT */

View file

@ -22,16 +22,10 @@
/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC)
works as per C11. This is supported by GCC 4.6.0 and later, in C
mode, and by clang (also in C++ mode).
works as per C11. This is supported by GCC 4.6.0+ and by clang 4+.
Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
per C2X. This is supported by GCC 9.1 and later, and by clang in
C++1z mode.
Define _GL_HAVE_STATIC_ASSERT1 if static_assert (R) works as per
C++17. This is supported by GCC 9.1 and later, and by clang in
C++1z mode.
per C2X. This is supported by GCC 9.1+.
Support compilers claiming conformance to the relevant standard,
and also support GCC when not pedantic. If we were willing to slow
@ -47,18 +41,6 @@
|| (!defined __STRICT_ANSI__ && 9 <= __GNUC__))
# define _GL_HAVE__STATIC_ASSERT1 1
# endif
#else
# if 4 <= __clang_major__
# define _GL_HAVE__STATIC_ASSERT 1
# endif
# if 4 <= __clang_major__ && 201411 <= __cpp_static_assert
# define _GL_HAVE__STATIC_ASSERT1 1
# endif
# if 201703L <= __cplusplus \
|| 9 <= __GNUC__ \
|| (4 <= __clang_major__ && 201411 <= __cpp_static_assert)
# define _GL_HAVE_STATIC_ASSERT1 1
# endif
#endif
/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
@ -225,7 +207,9 @@ template <int w>
Unfortunately, unlike C11, this implementation must appear as an
ordinary declaration, and cannot appear inside struct { ... }. */
#if defined _GL_HAVE__STATIC_ASSERT
#if 200410 <= __cpp_static_assert
# define _GL_VERIFY(R, DIAGNOSTIC, ...) static_assert (R, DIAGNOSTIC)
#elif defined _GL_HAVE__STATIC_ASSERT
# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
#else
# define _GL_VERIFY(R, DIAGNOSTIC, ...) \
@ -239,7 +223,7 @@ template <int w>
# define _Static_assert(...) \
_GL_VERIFY (__VA_ARGS__, "static assertion failed", -)
# endif
# if !defined _GL_HAVE_STATIC_ASSERT1 && !defined static_assert
# if __cpp_static_assert < 201411 && !defined static_assert
# define static_assert _Static_assert /* C11 requires this #define. */
# endif
#endif

View file

@ -651,6 +651,8 @@ The command \\[yank] can retrieve it from there."
(defvar calc-embed-prev-modes)
(defun calc-embedded-set-modes (gmodes modes local-modes &optional temp)
(defvar the-language)
(defvar the-display-just)
(let ((the-language (calc-embedded-language))
(the-display-just (calc-embedded-justify))
(v gmodes)

View file

@ -2181,7 +2181,7 @@ order to Calc's."
v math-read-big-baseline))
;; Small radical sign.
((and (= other-char ?V)
((and (memq other-char '(?V ?√))
(= (math-read-big-char (1+ math-rb-h1) (1- v)) ?\_))
(setq h (1+ math-rb-h1))
(math-read-big-emptyp math-rb-h1 math-rb-v1 h (1- v) nil t)

View file

@ -2144,7 +2144,7 @@ the United States."
(let ((w (split-window nil (/ (* (window-width) 2) 3) t)))
(set-window-buffer w calc-trail-buffer)
(and calc-make-windows-dedicated
(set-window-dedicated-p nil t))))
(set-window-dedicated-p w t))))
(calc-wrapper
(setq overlay-arrow-string calc-trail-overlay
overlay-arrow-position calc-trail-pointer)

View file

@ -138,19 +138,19 @@
(math-format-number (nth 2 aa))))))
(if (= calc-number-radix 10)
c
(list 'horiz "(" c
(list 'subscr ")"
(int-to-string calc-number-radix)))))
(list 'subscr (math--comp-round-bracket c)
(int-to-string calc-number-radix))))
(math-format-number a)))
(if (not (eq calc-language 'big))
(math-format-number a prec)
(if (memq (car-safe a) '(cplx polar))
(if (math-zerop (nth 2 a))
(math-compose-expr (nth 1 a) prec)
(list 'horiz "("
(math-compose-expr (nth 1 a) 0)
(if (eq (car a) 'cplx) ", " "; ")
(math-compose-expr (nth 2 a) 0) ")"))
(math--comp-round-bracket
(list 'horiz
(math-compose-expr (nth 1 a) 0)
(if (eq (car a) 'cplx) ", " "; ")
(math-compose-expr (nth 2 a) 0))))
(if (or (= calc-number-radix 10)
(not (Math-realp a))
(and calc-group-digits
@ -340,12 +340,13 @@
(funcall spfn a prec)
(math-compose-var a)))))
((eq (car a) 'intv)
(list 'horiz
(if (memq (nth 1 a) '(0 1)) "(" "[")
(math-compose-expr (nth 2 a) 0)
" .. "
(math-compose-expr (nth 3 a) 0)
(if (memq (nth 1 a) '(0 2)) ")" "]")))
(math--comp-bracket
(if (memq (nth 1 a) '(0 1)) ?\( ?\[)
(if (memq (nth 1 a) '(0 2)) ?\) ?\])
(list 'horiz
(math-compose-expr (nth 2 a) 0)
" .. "
(math-compose-expr (nth 3 a) 0))))
((eq (car a) 'date)
(if (eq (car calc-date-format) 'X)
(math-format-date a)
@ -377,7 +378,7 @@
(and (eq (car-safe (nth 1 a)) 'cplx)
(math-negp (nth 1 (nth 1 a)))
(eq (nth 2 (nth 1 a)) 0)))
(list 'horiz "(" (math-compose-expr (nth 1 a) 0) ")")
(math--comp-round-bracket (math-compose-expr (nth 1 a) 0))
(math-compose-expr (nth 1 a) 201))
(let ((calc-language 'flat)
(calc-number-radix 10)
@ -444,7 +445,7 @@
(if (> prec (nth 2 a))
(if (setq spfn (get calc-language 'math-big-parens))
(list 'horiz (car spfn) c (cdr spfn))
(list 'horiz "(" c ")"))
(math--comp-round-bracket c))
c)))
((and (eq (car a) 'calcFunc-choriz)
(not (eq calc-language 'unform))
@ -612,7 +613,7 @@
(list 'horiz "{left ( "
(math-compose-expr a -1)
" right )}")))
(list 'horiz "(" (math-compose-expr a 0) ")"))))
(math--comp-round-bracket (math-compose-expr a 0)))))
((and (memq calc-language '(tex latex))
(memq (car a) '(/ calcFunc-choose calcFunc-evalto))
(>= prec 0))
@ -638,7 +639,7 @@
(rhs (math-compose-expr (nth 2 a) (nth 3 op) (eq (nth 1 op) '/))))
(and (equal (car op) "^")
(eq (math-comp-first-char lhs) ?-)
(setq lhs (list 'horiz "(" lhs ")")))
(setq lhs (math--comp-round-bracket lhs)))
(and (memq calc-language '(tex latex))
(or (equal (car op) "^") (equal (car op) "_"))
(not (and (stringp rhs) (= (length rhs) 1)))
@ -721,7 +722,7 @@
(list 'horiz "{left ( "
(math-compose-expr a -1)
" right )}")))
(list 'horiz "(" (math-compose-expr a 0) ")"))))
(math--comp-round-bracket (math-compose-expr a 0)))))
(t
(let ((lhs (math-compose-expr (nth 1 a) (nth 2 op))))
(list 'horiz
@ -759,7 +760,7 @@
(list 'horiz "{left ( "
(math-compose-expr a -1)
" right )}")))
(list 'horiz "(" (math-compose-expr a 0) ")"))))
(math--comp-round-bracket (math-compose-expr a 0)))))
(t
(let ((rhs (math-compose-expr (nth 1 a) (nth 3 op))))
(list 'horiz
@ -821,9 +822,16 @@
(if (setq spfn (get calc-language 'math-func-formatter))
(funcall spfn func a)
(list 'horiz func calc-function-open
(math-compose-vector (cdr a) ", " 0)
calc-function-close))))))))))
(let ((args (math-compose-vector (cdr a) ", " 0)))
(if (and (member calc-function-open '("(" "[" "{"))
(member calc-function-close '(")" "]" "}")))
(list 'horiz func
(math--comp-bracket
(string-to-char calc-function-open)
(string-to-char calc-function-close)
args))
(list 'horiz func calc-function-open
args calc-function-close))))))))))))
(defun math-prod-first-term (x)
@ -966,6 +974,69 @@
(and (memq (car a) '(^ calcFunc-subscr))
(math-tex-expr-is-flat (nth 1 a)))))
;; FIXME: maybe try box drawing chars if big bracket chars are unavailable,
;; like ┌ ┐n
;; │a + b│ ┌ a + b ┐n
;; │-----│ or │ ----- │ ?
;; │ c │ └ c ┘
;; └ ┘
;; They are more common than the chars below, but look a bit square.
;; Rounded corners exist but are less commonly available.
(defconst math--big-bracket-alist
'((?\( . (?⎛ ?⎝ ?⎜))
(?\) . (?⎞ ?⎠ ?⎟))
(?\[ . (?⎡ ?⎣ ?⎢))
(?\] . (?⎤ ?⎦ ?⎥))
(?\{ . (?⎧ ?⎩ ?⎪ ?⎨))
(?\} . (?⎫ ?⎭ ?⎪ ?⎬)))
"Alist mapping bracket chars to (UPPER LOWER EXTENSION MIDPIECE).
Not all brackets have midpieces.")
(defun math--big-bracket (bracket-char height baseline)
"Composition for BRACKET-CHAR of HEIGHT with BASELINE."
(if (<= height 1)
(char-to-string bracket-char)
(let ((pieces (cdr (assq bracket-char math--big-bracket-alist))))
(if (memq nil (mapcar #'char-displayable-p pieces))
(char-to-string bracket-char)
(let* ((upper (nth 0 pieces))
(lower (nth 1 pieces))
(extension (nth 2 pieces))
(midpiece (nth 3 pieces)))
(cons 'vleft ; alignment doesn't matter; width is 1 char
(cons baseline
(mapcar
#'char-to-string
(append
(list upper)
(if midpiece
(let ((lower-ext (/ (- height 3) 2)))
(append
(make-list (- height 3 lower-ext) extension)
(list midpiece)
(make-list lower-ext extension)))
(make-list (- height 2) extension))
(list lower))))))))))
(defun math--comp-bracket (left-bracket right-bracket comp)
"Put the composition COMP inside LEFT-BRACKET and RIGHT-BRACKET."
(if (eq calc-language 'big)
(let ((height (math-comp-height comp))
(baseline (1- (math-comp-ascent comp))))
(list 'horiz
(math--big-bracket left-bracket height baseline)
comp
(math--big-bracket right-bracket height baseline)))
(list 'horiz
(char-to-string left-bracket)
comp
(char-to-string right-bracket))))
(defun math--comp-round-bracket (comp)
"Put the composition COMP inside plain brackets."
(math--comp-bracket ?\( ?\) comp))
(put 'calcFunc-log 'math-compose-big #'math-compose-log)
(defun math-compose-log (a _prec)
(and (= (length a) 3)
@ -973,18 +1044,14 @@
(list 'subscr "log"
(let ((calc-language 'flat))
(math-compose-expr (nth 2 a) 1000)))
"("
(math-compose-expr (nth 1 a) 1000)
")")))
(math--comp-round-bracket (math-compose-expr (nth 1 a) 1000)))))
(put 'calcFunc-log10 'math-compose-big #'math-compose-log10)
(defun math-compose-log10 (a _prec)
(and (= (length a) 2)
(list 'horiz
(list 'subscr "log" "10")
"("
(math-compose-expr (nth 1 a) 1000)
")")))
(list 'subscr "log" "10")
(math--comp-round-bracket (math-compose-expr (nth 1 a) 1000)))))
(put 'calcFunc-deriv 'math-compose-big #'math-compose-deriv)
(put 'calcFunc-tderiv 'math-compose-big #'math-compose-deriv)
@ -1027,12 +1094,9 @@
(defun math-compose-choose (a _prec)
(let ((a1 (math-compose-expr (nth 1 a) 0))
(a2 (math-compose-expr (nth 2 a) 0)))
(list 'horiz
"("
(list 'vcent
(math-comp-height a1)
a1 " " a2)
")")))
(math--comp-round-bracket (list 'vcent
(+ (math-comp-height a1))
a1 " " a2))))
(put 'calcFunc-integ 'math-compose-big #'math-compose-integ)
(defun math-compose-integ (a prec)
@ -1052,9 +1116,12 @@
"d%s"
(nth 1 (nth 2 a)))))
(nth 1 a)) 185))
(calc-language 'flat)
(low (and (nth 3 a) (math-compose-expr (nth 3 a) 0)))
(high (and (nth 4 a) (math-compose-expr (nth 4 a) 0)))
(low (and (nth 3 a)
(let ((calc-language 'flat))
(math-compose-expr (nth 3 a) 0))))
(high (and (nth 4 a)
(let ((calc-language 'flat))
(math-compose-expr (nth 4 a) 0))))
;; Check if we have Unicode integral top/bottom parts.
(fancy (and (char-displayable-p ?⌠)
(char-displayable-p ?⌡)))
@ -1066,40 +1133,47 @@
((char-displayable-p ?│) "")
;; U+007C VERTICAL LINE
(t "| "))))
(list 'horiz
(if parens "(" "")
(append (list 'vcent (if fancy
(if high 2 1)
(if high 3 2)))
(and high (list (if fancy
(list 'horiz high " ")
(list 'horiz " " high))))
(if fancy
(list "" fancy-stem "")
'(" /"
" | "
" | "
" | "
"/ "))
(and low (list (if fancy
(list 'horiz low " ")
(list 'horiz low " ")))))
expr
(if over
""
(list 'horiz " d" var))
(if parens ")" "")))))
(let ((comp
(list 'horiz
(append (list 'vcent (if fancy
(if high 2 1)
(if high 3 2)))
(and high (list (if fancy
(list 'horiz high " ")
(list 'horiz " " high))))
(if fancy
(list "" fancy-stem "")
'(" /"
" | "
" | "
" | "
"/ "))
(and low (list (if fancy
(list 'horiz low " ")
(list 'horiz low " ")))))
expr
(if over
""
(list 'horiz " d" var)))))
(if parens
(math--comp-round-bracket comp)
comp)))))
(put 'calcFunc-sum 'math-compose-big #'math-compose-sum)
(defun math-compose-sum (a prec)
(and (memq (length a) '(3 5 6))
(let* ((expr (math-compose-expr (nth 1 a) 185))
(calc-language 'flat)
(var (math-compose-expr (nth 2 a) 0))
(low (and (nth 3 a) (math-compose-expr (nth 3 a) 0)))
(high (and (nth 4 a) (math-compose-vector (nthcdr 4 a) ", " 0))))
(list 'horiz
(if (memq prec '(180 201)) "(" "")
(var
(let ((calc-language 'flat))
(math-compose-expr (nth 2 a) 0)))
(low (and (nth 3 a)
(let ((calc-language 'flat))
(math-compose-expr (nth 3 a) 0))))
(high (and (nth 4 a)
(let ((calc-language 'flat))
(math-compose-vector (nthcdr 4 a) ", " 0))))
(comp
(list 'horiz
(append (list 'vcent (if high 3 2))
(and high (list high))
'("---- "
@ -1112,32 +1186,42 @@
(list var)))
(if (memq (car-safe (nth 1 a)) '(calcFunc-sum calcFunc-prod))
" " "")
expr
(if (memq prec '(180 201)) ")" "")))))
expr)))
(if (memq prec '(180 201))
(math--comp-round-bracket comp)
comp))))
(put 'calcFunc-prod 'math-compose-big #'math-compose-prod)
(defun math-compose-prod (a prec)
(and (memq (length a) '(3 5 6))
(let* ((expr (math-compose-expr (nth 1 a) 198))
(calc-language 'flat)
(var (math-compose-expr (nth 2 a) 0))
(low (and (nth 3 a) (math-compose-expr (nth 3 a) 0)))
(high (and (nth 4 a) (math-compose-vector (nthcdr 4 a) ", " 0))))
(list 'horiz
(if (memq prec '(196 201)) "(" "")
(append (list 'vcent (if high 3 2))
(and high (list high))
'("----- "
" | | "
" | | "
" | | ")
(if low
(list (list 'horiz var " = " low))
(list var)))
(if (memq (car-safe (nth 1 a)) '(calcFunc-sum calcFunc-prod))
" " "")
expr
(if (memq prec '(196 201)) ")" "")))))
(var
(let ((calc-language 'flat))
(math-compose-expr (nth 2 a) 0)))
(low (and (nth 3 a)
(let ((calc-language 'flat))
(math-compose-expr (nth 3 a) 0))))
(high (and (nth 4 a)
(let ((calc-language 'flat))
(math-compose-vector (nthcdr 4 a) ", " 0))))
(comp
(list 'horiz
(append (list 'vcent (if high 3 2))
(and high (list high))
'("----- "
" | | "
" | | "
" | | ")
(if low
(list (list 'horiz var " = " low))
(list var)))
(if (memq (car-safe (nth 1 a))
'(calcFunc-sum calcFunc-prod))
" " "")
expr)))
(if (memq prec '(196 201))
(math--comp-round-bracket comp)
comp))))
;; The variables math-svo-c, math-svo-wid and math-svo-off are local
;; to math-stack-value-offset in calc.el, but are used by

View file

@ -1,4 +1,4 @@
;;; cal-bahai.el --- calendar functions for the Baháí calendar.
;;; cal-bahai.el --- calendar functions for the Baháí calendar. -*- lexical-binding: t; -*-
;; Copyright (C) 2001-2021 Free Software Foundation, Inc.
@ -124,9 +124,10 @@ Defaults to today's date if DATE is not given."
(y (calendar-extract-year bahai-date)))
(if (< y 1)
"" ; pre-Bahai
(let* ((m (calendar-extract-month bahai-date))
(d (calendar-extract-day bahai-date))
(monthname (if (and (= m 19)
(let ((m (calendar-extract-month bahai-date))
(d (calendar-extract-day bahai-date)))
(calendar-dlet*
((monthname (if (and (= m 19)
(<= d 0))
"Ayyám-i-Há"
(aref calendar-bahai-month-name-array (1- m))))
@ -137,8 +138,8 @@ Defaults to today's date if DATE is not given."
(year (number-to-string y))
(month (number-to-string m))
dayname)
;; Can't call calendar-date-string because of monthname oddity.
(mapconcat 'eval calendar-date-display-form "")))))
;; Can't call calendar-date-string because of monthname oddity.
(mapconcat #'eval calendar-date-display-form ""))))))
;;;###cal-autoload
(defun calendar-bahai-print-date ()
@ -153,13 +154,12 @@ Defaults to today's date if DATE is not given."
"Interactively read the arguments for a Baháí date command.
Reads a year, month and day."
(let* ((today (calendar-current-date))
(year (calendar-read
"Baháí calendar year (not 0): "
(year (calendar-read-sexp
"Baháí calendar year (not 0)"
(lambda (x) (not (zerop x)))
(number-to-string
(calendar-extract-year
(calendar-bahai-from-absolute
(calendar-absolute-from-gregorian today))))))
(calendar-extract-year
(calendar-bahai-from-absolute
(calendar-absolute-from-gregorian today)))))
(completion-ignore-case t)
(month (cdr (assoc
(completing-read
@ -169,8 +169,8 @@ Reads a year, month and day."
nil t)
(calendar-make-alist calendar-bahai-month-name-array
1))))
(day (calendar-read "Baháí calendar day (1-19): "
(lambda (x) (and (< 0 x) (<= x 19))))))
(day (calendar-read-sexp "Baháí calendar day (1-19)"
(lambda (x) (and (< 0 x) (<= x 19))))))
(list (list month day year))))
;;;###cal-autoload

View file

@ -1,4 +1,4 @@
;;; cal-china.el --- calendar functions for the Chinese calendar
;;; cal-china.el --- calendar functions for the Chinese calendar -*- lexical-binding: t; -*-
;; Copyright (C) 1995, 1997, 2001-2021 Free Software Foundation, Inc.
@ -185,7 +185,9 @@ N congruent to 1 gives the first name, N congruent to 2 gives the second name,
(defun calendar-chinese-zodiac-sign-on-or-after (d)
"Absolute date of first new Zodiac sign on or after absolute date D.
The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees."
(let* ((year (calendar-extract-year (calendar-gregorian-from-absolute d)))
(with-suppressed-warnings ((lexical year))
(defvar year))
(let* ((year (calendar-extract-year (calendar-gregorian-from-absolute d)))
(calendar-time-zone (eval calendar-chinese-time-zone)) ; uses year
(calendar-daylight-time-offset
calendar-chinese-daylight-time-offset)
@ -207,6 +209,8 @@ The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees."
(defun calendar-chinese-new-moon-on-or-after (d)
"Absolute date of first new moon on or after absolute date D."
(with-suppressed-warnings ((lexical year))
(defvar year))
(let* ((year (calendar-extract-year (calendar-gregorian-from-absolute d)))
(calendar-time-zone (eval calendar-chinese-time-zone))
(calendar-daylight-time-offset
@ -602,14 +606,14 @@ Echo Chinese date unless NOECHO is non-nil."
(interactive
(let* ((c (calendar-chinese-from-absolute
(calendar-absolute-from-gregorian (calendar-current-date))))
(cycle (calendar-read
"Chinese calendar cycle number (>44): "
(cycle (calendar-read-sexp
"Chinese calendar cycle number (>44)"
(lambda (x) (> x 44))
(number-to-string (car c))))
(year (calendar-read
"Year in Chinese cycle (1..60): "
(car c)))
(year (calendar-read-sexp
"Year in Chinese cycle (1..60)"
(lambda (x) (and (<= 1 x) (<= x 60)))
(number-to-string (cadr c))))
(cadr c)))
(month-list (calendar-chinese-months-to-alist
(calendar-chinese-months cycle year)))
(month (cdr (assoc
@ -624,9 +628,11 @@ Echo Chinese date unless NOECHO is non-nil."
(list cycle year month 1))))))
30
29))
(day (calendar-read
(format "Chinese calendar day (1-%d): " last)
(lambda (x) (and (<= 1 x) (<= x last))))))
(day (calendar-read-sexp
"Chinese calendar day (1-%d)"
(lambda (x) (and (<= 1 x) (<= x last)))
nil
last)))
(list (list cycle year month day))))
(calendar-goto-date (calendar-gregorian-from-absolute
(calendar-chinese-to-absolute date)))
@ -663,17 +669,17 @@ Echo Chinese date unless NOECHO is non-nil."
["正月" "二月" "三月" "四月" "五月" "六月"
"七月" "八月" "九月" "十月" "冬月" "臘月"])
;;; NOTE: In the diary the cycle and year of a Chinese date is
;;; combined using this formula: (+ (* cycle 100) year).
;; NOTE: In the diary the cycle and year of a Chinese date is
;; combined using this formula: (+ (* cycle 100) year).
;;;
;;; These two functions convert to and back from this representation.
(defun calendar-chinese-from-absolute-for-diary (date)
(pcase-let ((`(,c ,y ,m ,d) (calendar-chinese-from-absolute date)))
;; These two functions convert to and back from this representation.
(defun calendar-chinese-from-absolute-for-diary (thedate)
(pcase-let ((`(,c ,y ,m ,d) (calendar-chinese-from-absolute thedate)))
;; Note: For leap months M is a float.
(list (floor m) d (+ (* c 100) y))))
(defun calendar-chinese-to-absolute-for-diary (date &optional prefer-leap)
(pcase-let* ((`(,m ,d ,y) date)
(defun calendar-chinese-to-absolute-for-diary (thedate &optional prefer-leap)
(pcase-let* ((`(,m ,d ,y) thedate)
(cycle (floor y 100))
(year (mod y 100))
(months (calendar-chinese-months cycle year))
@ -691,7 +697,8 @@ Echo Chinese date unless NOECHO is non-nil."
(unless (zerop month)
(calendar-mark-1 month day year
#'calendar-chinese-from-absolute-for-diary
(lambda (date) (calendar-chinese-to-absolute-for-diary date t))
(lambda (thedate)
(calendar-chinese-to-absolute-for-diary thedate t))
color)))
;;;###cal-autoload

View file

@ -1,4 +1,4 @@
;;; cal-coptic.el --- calendar functions for the Coptic/Ethiopic calendars
;;; cal-coptic.el --- calendar functions for the Coptic/Ethiopic calendars -*- lexical-binding: t; -*-
;; Copyright (C) 1995, 1997, 2001-2021 Free Software Foundation, Inc.
@ -116,12 +116,13 @@ Defaults to today's date if DATE is not given."
(m (calendar-extract-month coptic-date)))
(if (< y 1)
""
(let ((monthname (aref calendar-coptic-month-name-array (1- m)))
(day (number-to-string (calendar-extract-day coptic-date)))
(dayname nil)
(month (number-to-string m))
(year (number-to-string y)))
(mapconcat 'eval calendar-date-display-form "")))))
(calendar-dlet*
((monthname (aref calendar-coptic-month-name-array (1- m)))
(day (number-to-string (calendar-extract-day coptic-date)))
(dayname nil)
(month (number-to-string m))
(year (number-to-string y)))
(mapconcat #'eval calendar-date-display-form "")))))
;;;###cal-autoload
(defun calendar-coptic-print-date ()
@ -136,13 +137,13 @@ Defaults to today's date if DATE is not given."
"Interactively read the arguments for a Coptic date command.
Reads a year, month, and day."
(let* ((today (calendar-current-date))
(year (calendar-read
(format "%s calendar year (>0): " calendar-coptic-name)
(year (calendar-read-sexp
"%s calendar year (>0)"
(lambda (x) (> x 0))
(number-to-string
(calendar-extract-year
(calendar-coptic-from-absolute
(calendar-absolute-from-gregorian today))))))
(calendar-extract-year
(calendar-coptic-from-absolute
(calendar-absolute-from-gregorian today)))
calendar-coptic-name))
(completion-ignore-case t)
(month (cdr (assoc-string
(completing-read
@ -151,11 +152,14 @@ Reads a year, month, and day."
(append calendar-coptic-month-name-array nil))
nil t)
(calendar-make-alist calendar-coptic-month-name-array
1) t)))
1)
t)))
(last (calendar-coptic-last-day-of-month month year))
(day (calendar-read
(format "%s calendar day (1-%d): " calendar-coptic-name last)
(lambda (x) (and (< 0 x) (<= x last))))))
(day (calendar-read-sexp
"%s calendar day (1-%d)"
(lambda (x) (and (< 0 x) (<= x last)))
nil
calendar-coptic-name last)))
(list (list month day year))))
;;;###cal-autoload
@ -194,30 +198,30 @@ Echo Coptic date unless NOECHO is t."
(defconst calendar-ethiopic-name "Ethiopic"
"Used in some message strings.")
(defun calendar-ethiopic-to-absolute (date)
(defun calendar-ethiopic-to-absolute (thedate)
"Compute absolute date from Ethiopic date DATE.
The absolute date is the number of days elapsed since the (imaginary)
Gregorian date Sunday, December 31, 1 BC."
(let ((calendar-coptic-epoch calendar-ethiopic-epoch))
(calendar-coptic-to-absolute date)))
(calendar-coptic-to-absolute thedate)))
(defun calendar-ethiopic-from-absolute (date)
(defun calendar-ethiopic-from-absolute (thedate)
"Compute the Ethiopic equivalent for absolute date DATE.
The result is a list of the form (MONTH DAY YEAR).
The absolute date is the number of days elapsed since the imaginary
Gregorian date Sunday, December 31, 1 BC."
(let ((calendar-coptic-epoch calendar-ethiopic-epoch))
(calendar-coptic-from-absolute date)))
(calendar-coptic-from-absolute thedate)))
;;;###cal-autoload
(defun calendar-ethiopic-date-string (&optional date)
(defun calendar-ethiopic-date-string (&optional thedate)
"String of Ethiopic date of Gregorian DATE.
Returns the empty string if DATE is pre-Ethiopic calendar.
Defaults to today's date if DATE is not given."
(let ((calendar-coptic-epoch calendar-ethiopic-epoch)
(calendar-coptic-name calendar-ethiopic-name)
(calendar-coptic-month-name-array calendar-ethiopic-month-name-array))
(calendar-coptic-date-string date)))
(calendar-coptic-date-string thedate)))
;;;###cal-autoload
(defun calendar-ethiopic-print-date ()
@ -229,8 +233,8 @@ Defaults to today's date if DATE is not given."
(call-interactively 'calendar-coptic-print-date)))
;;;###cal-autoload
(defun calendar-ethiopic-goto-date (date &optional noecho)
"Move cursor to Ethiopic date DATE.
(defun calendar-ethiopic-goto-date (thedate &optional noecho)
"Move cursor to Ethiopic date THEDATE.
Echo Ethiopic date unless NOECHO is t."
(interactive
(let ((calendar-coptic-epoch calendar-ethiopic-epoch)
@ -238,7 +242,7 @@ Echo Ethiopic date unless NOECHO is t."
(calendar-coptic-month-name-array calendar-ethiopic-month-name-array))
(calendar-coptic-read-date)))
(calendar-goto-date (calendar-gregorian-from-absolute
(calendar-ethiopic-to-absolute date)))
(calendar-ethiopic-to-absolute thedate)))
(or noecho (calendar-ethiopic-print-date)))
;; To be called from diary-list-sexp-entries, where DATE is bound.

View file

@ -1,4 +1,4 @@
;;; cal-french.el --- calendar functions for the French Revolutionary calendar
;;; cal-french.el --- calendar functions for the French Revolutionary calendar -*- lexical-binding: t; -*-
;; Copyright (C) 1988-1989, 1992, 1994-1995, 1997, 2001-2021 Free
;; Software Foundation, Inc.
@ -35,54 +35,45 @@
(defconst calendar-french-epoch (calendar-absolute-from-gregorian '(9 22 1792))
"Absolute date of start of French Revolutionary calendar = Sept 22, 1792.")
(defconst calendar-french-month-name-array
["Vende'miaire" "Brumaire" "Frimaire" "Nivo^se" "Pluvio^se" "Vento^se"
"Germinal" "Flore'al" "Prairial" "Messidor" "Thermidor" "Fructidor"]
"Array of month names in the French calendar.")
(define-obsolete-variable-alias 'calendar-french-multibyte-month-name-array
'calendar-french-month-name-array "28.1")
(defconst calendar-french-multibyte-month-name-array
(defconst calendar-french-month-name-array
["Vendémiaire" "Brumaire" "Frimaire" "Nivôse" "Pluviôse" "Ventôse"
"Germinal" "Floréal" "Prairial" "Messidor" "Thermidor" "Fructidor"]
"Array of multibyte month names in the French calendar.")
"Array of month names in the French calendar.")
(defconst calendar-french-day-name-array
["Primidi" "Duodi" "Tridi" "Quartidi" "Quintidi" "Sextidi" "Septidi"
"Octidi" "Nonidi" "Decadi"]
"Array of day names in the French calendar.")
(defconst calendar-french-special-days-array
["de la Vertu" "du Ge'nie" "du Travail" "de la Raison" "des Re'compenses"
"de la Re'volution"]
"Array of special day names in the French calendar.")
(define-obsolete-variable-alias 'calendar-french-multibyte-special-days-array
'calendar-french-special-days-array "28.1")
(defconst calendar-french-multibyte-special-days-array
(defconst calendar-french-special-days-array
["de la Vertu" "du Génie" "du Travail" "de la Raison" "des Récompenses"
"de la Révolution"]
"Array of multibyte special day names in the French calendar.")
"Array of special day names in the French calendar.")
(defun calendar-french-accents-p ()
"Return non-nil if diacritical marks are available."
(and (or window-system
(terminal-coding-system))
(or enable-multibyte-characters
(and (char-table-p standard-display-table)
(equal (aref standard-display-table 161) [161])))))
(declare (obsolete nil "28.1"))
t)
(defun calendar-french-month-name-array ()
"Return the array of month names, depending on whether accents are available."
(if (calendar-french-accents-p)
calendar-french-multibyte-month-name-array
calendar-french-month-name-array))
(declare (obsolete "use the variable of the same name instead" "28.1"))
calendar-french-month-name-array)
(defun calendar-french-day-name-array ()
"Return the array of day names."
(declare (obsolete "use the variable of the same name instead" "28.1"))
calendar-french-day-name-array)
(defun calendar-french-special-days-array ()
"Return the special day names, depending on whether accents are available."
(if (calendar-french-accents-p)
calendar-french-multibyte-special-days-array
calendar-french-special-days-array))
(declare (obsolete "use the variable of the same name instead" "28.1"))
calendar-french-special-days-array)
(defun calendar-french-leap-year-p (year)
"True if YEAR is a leap year on the French Revolutionary calendar.
@ -171,17 +162,13 @@ Defaults to today's date if DATE is not given."
(d (calendar-extract-day french-date)))
(cond
((< y 1) "")
((= m 13) (format (if (calendar-french-accents-p)
"Jour %s de l'Année %d de la Révolution"
"Jour %s de l'Anne'e %d de la Re'volution")
(aref (calendar-french-special-days-array) (1- d))
((= m 13) (format "Jour %s de l'Année %d de la Révolution"
(aref calendar-french-special-days-array (1- d))
y))
(t (format
(if (calendar-french-accents-p)
"%d %s an %d de la Révolution"
"%d %s an %d de la Re'volution")
"%d %s an %d de la Révolution"
d
(aref (calendar-french-month-name-array) (1- m))
(aref calendar-french-month-name-array (1- m))
y)))))
;;;###cal-autoload
@ -198,19 +185,16 @@ Defaults to today's date if DATE is not given."
"Move cursor to French Revolutionary date DATE.
Echo French Revolutionary date unless NOECHO is non-nil."
(interactive
(let* ((months (calendar-french-month-name-array))
(special-days (calendar-french-special-days-array))
(let* ((months calendar-french-month-name-array)
(special-days calendar-french-special-days-array)
(year (progn
(calendar-read
(if (calendar-french-accents-p)
"Année de la Révolution (>0): "
"Anne'e de la Re'volution (>0): ")
(calendar-read-sexp
"Année de la Révolution (>0)"
(lambda (x) (> x 0))
(number-to-string
(calendar-extract-year
(calendar-french-from-absolute
(calendar-absolute-from-gregorian
(calendar-current-date))))))))
(calendar-extract-year
(calendar-french-from-absolute
(calendar-absolute-from-gregorian
(calendar-current-date)))))))
(month-list
(mapcar 'list
(append months
@ -234,8 +218,8 @@ Echo French Revolutionary date unless NOECHO is non-nil."
(calendar-make-alist month-list 1 'car) t)))
(day (if (> month 12)
(- month 12)
(calendar-read
"Jour (1-30): "
(calendar-read-sexp
"Jour (1-30)"
(lambda (x) (and (<= 1 x) (<= x 30))))))
(month (if (> month 12) 13 month)))
(list (list month day year))))

View file

@ -1,4 +1,4 @@
;;; cal-hebrew.el --- calendar functions for the Hebrew calendar
;;; cal-hebrew.el --- calendar functions for the Hebrew calendar -*- lexical-binding: t; -*-
;; Copyright (C) 1995, 1997, 2001-2021 Free Software Foundation, Inc.
@ -225,13 +225,12 @@ Driven by the variable `calendar-date-display-form'."
"Interactively read the arguments for a Hebrew date command.
Reads a year, month, and day."
(let* ((today (calendar-current-date))
(year (calendar-read
"Hebrew calendar year (>3760): "
(year (calendar-read-sexp
"Hebrew calendar year (>3760)"
(lambda (x) (> x 3760))
(number-to-string
(calendar-extract-year
(calendar-hebrew-from-absolute
(calendar-absolute-from-gregorian today))))))
(calendar-extract-year
(calendar-hebrew-from-absolute
(calendar-absolute-from-gregorian today)))))
(month-array (if (calendar-hebrew-leap-year-p year)
calendar-hebrew-month-name-array-leap-year
calendar-hebrew-month-name-array-common-year))
@ -258,10 +257,11 @@ Reads a year, month, and day."
(last (calendar-hebrew-last-day-of-month month year))
(first (if (and (= year 3761) (= month 10))
18 1))
(day (calendar-read
(format "Hebrew calendar day (%d-%d): "
first last)
(lambda (x) (and (<= first x) (<= x last))))))
(day (calendar-read-sexp
"Hebrew calendar day (%d-%d)"
(lambda (x) (and (<= first x) (<= x last)))
nil
first last)))
(list (list month day year))))
;;;###cal-autoload
@ -399,19 +399,20 @@ is non-nil."
(list m (calendar-last-day-of-month m y) y))))))
(abs-h (calendar-hebrew-to-absolute (list 9 25 h-y)))
(ord ["first" "second" "third" "fourth" "fifth" "sixth"
"seventh" "eighth"])
han)
"seventh" "eighth"]))
(holiday-filter-visible-calendar
(if (or all calendar-hebrew-all-holidays-flag)
(append
(list
(list (calendar-gregorian-from-absolute (1- abs-h))
"Erev Hanukkah"))
(dotimes (i 8 (nreverse han))
(push (list
(calendar-gregorian-from-absolute (+ abs-h i))
(format "Hanukkah (%s day)" (aref ord i)))
han)))
(let (han)
(dotimes (i 8)
(push (list
(calendar-gregorian-from-absolute (+ abs-h i))
(format "Hanukkah (%s day)" (aref ord i)))
han))
(nreverse han)))
(list (list (calendar-gregorian-from-absolute abs-h) "Hanukkah")))))))
;;;###holiday-autoload
@ -681,10 +682,10 @@ from the cursor position."
(if (equal (current-buffer) (get-buffer calendar-buffer))
(calendar-cursor-to-date t)
(let* ((today (calendar-current-date))
(year (calendar-read
"Year of death (>0): "
(year (calendar-read-sexp
"Year of death (>0)"
(lambda (x) (> x 0))
(number-to-string (calendar-extract-year today))))
(calendar-extract-year today)))
(month-array calendar-month-name-array)
(completion-ignore-case t)
(month (cdr (assoc-string
@ -694,20 +695,23 @@ from the cursor position."
nil t)
(calendar-make-alist month-array 1) t)))
(last (calendar-last-day-of-month month year))
(day (calendar-read
(format "Day of death (1-%d): " last)
(lambda (x) (and (< 0 x) (<= x last))))))
(day (calendar-read-sexp
"Day of death (1-%d)"
(lambda (x) (and (< 0 x) (<= x last)))
nil
last)))
(list month day year))))
(death-year (calendar-extract-year death-date))
(start-year (calendar-read
(format "Starting year of Yahrzeit table (>%d): "
death-year)
(start-year (calendar-read-sexp
"Starting year of Yahrzeit table (>%d)"
(lambda (x) (> x death-year))
(number-to-string (1+ death-year))))
(end-year (calendar-read
(format "Ending year of Yahrzeit table (>=%d): "
start-year)
(lambda (x) (>= x start-year)))))
(1+ death-year)
death-year))
(end-year (calendar-read-sexp
"Ending year of Yahrzeit table (>=%d)"
(lambda (x) (>= x start-year))
nil
start-year)))
(list death-date start-year end-year)))
(message "Computing Yahrzeits...")
(let* ((h-date (calendar-hebrew-from-absolute

View file

@ -1,4 +1,4 @@
;;; cal-html.el --- functions for printing HTML calendars
;;; cal-html.el --- functions for printing HTML calendars -*- lexical-binding: t; -*-
;; Copyright (C) 2002-2021 Free Software Foundation, Inc.
@ -250,7 +250,7 @@ Contains links to previous and next month and year, and current minical."
calendar-week-start-day))
7))
(monthpage-name (cal-html-monthpage-name month year))
date)
) ;; date
;; Start writing table.
(insert (cal-html-comment "MINICAL")
(cal-html-b-table "class=minical border=1 align=center"))
@ -276,7 +276,7 @@ Contains links to previous and next month and year, and current minical."
(insert cal-html-e-tablerow-string
cal-html-b-tablerow-string)))
;; End empty slots (for some browsers like konqueror).
(dotimes (i end-blank-days)
(dotimes (_ end-blank-days)
(insert
cal-html-b-tabledata-string
cal-html-e-tabledata-string)))
@ -431,12 +431,11 @@ holidays in HOLIDAY-LIST."
;;; User commands.
;;;###cal-autoload
(defun cal-html-cursor-month (month year dir &optional event)
(defun cal-html-cursor-month (month year dir &optional _event)
"Write an HTML calendar file for numeric MONTH of four-digit YEAR.
The output directory DIR is created if necessary. Interactively,
MONTH and YEAR are taken from the calendar cursor position, or from
the position specified by EVENT. Note that any existing output files
are overwritten."
MONTH and YEAR are taken from the calendar cursor position.
Note that any existing output files are overwritten."
(interactive (let* ((event last-nonmenu-event)
(date (calendar-cursor-to-date t event))
(month (calendar-extract-month date))
@ -446,11 +445,11 @@ are overwritten."
(cal-html-one-month month year dir))
;;;###cal-autoload
(defun cal-html-cursor-year (year dir &optional event)
(defun cal-html-cursor-year (year dir &optional _event)
"Write HTML calendar files (index and monthly pages) for four-digit YEAR.
The output directory DIR is created if necessary. Interactively,
YEAR is taken from the calendar cursor position, or from the position
specified by EVENT. Note that any existing output files are overwritten."
YEAR is taken from the calendar cursor position.
Note that any existing output files are overwritten."
(interactive (let* ((event last-nonmenu-event)
(year (calendar-extract-year
(calendar-cursor-to-date t event))))

View file

@ -1,4 +1,4 @@
;;; cal-islam.el --- calendar functions for the Islamic calendar
;;; cal-islam.el --- calendar functions for the Islamic calendar -*- lexical-binding: t; -*-
;; Copyright (C) 1995, 1997, 2001-2021 Free Software Foundation, Inc.
@ -67,8 +67,8 @@
"Absolute date of Islamic DATE.
The absolute date is the number of days elapsed since the (imaginary)
Gregorian date Sunday, December 31, 1 BC."
(let* ((month (calendar-extract-month date))
(day (calendar-extract-day date))
(let* (;;(month (calendar-extract-month date))
;;(day (calendar-extract-day date))
(year (calendar-extract-year date))
(y (% year 30))
(leap-years-in-cycle (cond ((< y 3) 0)
@ -143,13 +143,12 @@ Driven by the variable `calendar-date-display-form'."
"Interactively read the arguments for an Islamic date command.
Reads a year, month, and day."
(let* ((today (calendar-current-date))
(year (calendar-read
"Islamic calendar year (>0): "
(year (calendar-read-sexp
"Islamic calendar year (>0)"
(lambda (x) (> x 0))
(number-to-string
(calendar-extract-year
(calendar-islamic-from-absolute
(calendar-absolute-from-gregorian today))))))
(calendar-extract-year
(calendar-islamic-from-absolute
(calendar-absolute-from-gregorian today)))))
(month-array calendar-islamic-month-name-array)
(completion-ignore-case t)
(month (cdr (assoc-string
@ -159,9 +158,11 @@ Reads a year, month, and day."
nil t)
(calendar-make-alist month-array 1) t)))
(last (calendar-islamic-last-day-of-month month year))
(day (calendar-read
(format "Islamic calendar day (1-%d): " last)
(lambda (x) (and (< 0 x) (<= x last))))))
(day (calendar-read-sexp
"Islamic calendar day (1-%d)"
(lambda (x) (and (< 0 x) (<= x last)))
nil
last)))
(list (list month day year))))
;;;###cal-autoload

View file

@ -1,4 +1,4 @@
;;; cal-iso.el --- calendar functions for the ISO calendar
;;; cal-iso.el --- calendar functions for the ISO calendar -*- lexical-binding: t; -*-
;; Copyright (C) 1995, 1997, 2001-2021 Free Software Foundation, Inc.
@ -92,22 +92,23 @@ date Sunday, December 31, 1 BC."
"Interactively read the arguments for an ISO date command.
Reads a year and week, and if DAYFLAG is non-nil a day (otherwise
taken to be 1)."
(let* ((year (calendar-read
"ISO calendar year (>0): "
(let* ((year (calendar-read-sexp
"ISO calendar year (>0)"
(lambda (x) (> x 0))
(number-to-string (calendar-extract-year
(calendar-current-date)))))
(calendar-extract-year (calendar-current-date))))
(no-weeks (calendar-extract-month
(calendar-iso-from-absolute
(1-
(calendar-dayname-on-or-before
1 (calendar-absolute-from-gregorian
(list 1 4 (1+ year))))))))
(week (calendar-read
(format "ISO calendar week (1-%d): " no-weeks)
(lambda (x) (and (> x 0) (<= x no-weeks)))))
(day (if dayflag (calendar-read
"ISO day (1-7): "
(week (calendar-read-sexp
"ISO calendar week (1-%d)"
(lambda (x) (and (> x 0) (<= x no-weeks)))
nil
no-weeks))
(day (if dayflag (calendar-read-sexp
"ISO day (1-7)"
(lambda (x) (and (<= 1 x) (<= x 7))))
1)))
(list (list week day year))))

View file

@ -95,14 +95,13 @@ Driven by the variable `calendar-date-display-form'."
"Move cursor to Julian DATE; echo Julian date unless NOECHO is non-nil."
(interactive
(let* ((today (calendar-current-date))
(year (calendar-read
"Julian calendar year (>0): "
(year (calendar-read-sexp
"Julian calendar year (>0)"
(lambda (x) (> x 0))
(number-to-string
(calendar-extract-year
(calendar-julian-from-absolute
(calendar-absolute-from-gregorian
today))))))
(calendar-extract-year
(calendar-julian-from-absolute
(calendar-absolute-from-gregorian
today)))))
(month-array calendar-month-name-array)
(completion-ignore-case t)
(month (cdr (assoc-string
@ -115,12 +114,13 @@ Driven by the variable `calendar-date-display-form'."
(if (and (zerop (% year 4)) (= month 2))
29
(aref [31 28 31 30 31 30 31 31 30 31 30 31] (1- month))))
(day (calendar-read
(format "Julian calendar day (%d-%d): "
(if (and (= year 1) (= month 1)) 3 1) last)
(day (calendar-read-sexp
"Julian calendar day (%d-%d)"
(lambda (x)
(and (< (if (and (= year 1) (= month 1)) 2 0) x)
(<= x last))))))
(<= x last)))
nil
(if (and (= year 1) (= month 1)) 3 1) last)))
(list (list month day year))))
(calendar-goto-date (calendar-gregorian-from-absolute
(calendar-julian-to-absolute date)))
@ -173,8 +173,8 @@ Defaults to today's date if DATE is not given."
(defun calendar-astro-goto-day-number (daynumber &optional noecho)
"Move cursor to astronomical (Julian) DAYNUMBER.
Echo astronomical (Julian) day number unless NOECHO is non-nil."
(interactive (list (calendar-read
"Astronomical (Julian) day number (>1721425): "
(interactive (list (calendar-read-sexp
"Astronomical (Julian) day number (>1721425)"
(lambda (x) (> x 1721425)))))
(calendar-goto-date
(calendar-gregorian-from-absolute

View file

@ -1,4 +1,4 @@
;;; cal-mayan.el --- calendar functions for the Mayan calendars
;;; cal-mayan.el --- calendar functions for the Mayan calendars -*- lexical-binding: t; -*-
;; Copyright (C) 1992-1993, 1995, 1997, 2001-2021 Free Software
;; Foundation, Inc.
@ -135,8 +135,8 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using
(defun calendar-mayan-read-haab-date ()
"Prompt for a Mayan haab date."
(let* ((completion-ignore-case t)
(haab-day (calendar-read
"Haab kin (0-19): "
(haab-day (calendar-read-sexp
"Haab kin (0-19)"
(lambda (x) (and (>= x 0) (< x 20)))))
(haab-month-list (append calendar-mayan-haab-month-name-array
(and (< haab-day 5) '("Uayeb"))))
@ -151,8 +151,8 @@ but some use 1137140. Using 1232041 gives you Spinden's correlation; using
(defun calendar-mayan-read-tzolkin-date ()
"Prompt for a Mayan tzolkin date."
(let* ((completion-ignore-case t)
(tzolkin-count (calendar-read
"Tzolkin kin (1-13): "
(tzolkin-count (calendar-read-sexp
"Tzolkin kin (1-13)"
(lambda (x) (and (> x 0) (< x 14)))))
(tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil))
(tzolkin-name (cdr

View file

@ -1,4 +1,4 @@
;;; cal-menu.el --- calendar functions for menu bar and popup menu support
;;; cal-menu.el --- calendar functions for menu bar and popup menu support -*- lexical-binding: t; -*-
;; Copyright (C) 1994-1995, 2001-2021 Free Software Foundation, Inc.
@ -183,6 +183,8 @@ Signals an error if popups are unavailable."
;; Autoloaded in diary-lib.
(declare-function calendar-check-holidays "holidays" (date))
(defvar diary-list-include-blanks)
(defun calendar-mouse-view-diary-entries (&optional date diary event)
"Pop up menu of diary entries for mouse-selected date.
Use optional DATE and alternative file DIARY. EVENT is the event

View file

@ -1,4 +1,4 @@
;;; cal-move.el --- calendar functions for movement in the calendar
;;; cal-move.el --- calendar functions for movement in the calendar -*- lexical-binding: t; -*-
;; Copyright (C) 1995, 2001-2021 Free Software Foundation, Inc.
@ -386,15 +386,16 @@ Moves forward if ARG is negative."
"Move cursor to YEAR, DAY number; echo DAY/YEAR unless NOECHO is non-nil.
Negative DAY counts backward from end of year."
(interactive
(let* ((year (calendar-read
"Year (>0): "
(let* ((year (calendar-read-sexp
"Year (>0)"
(lambda (x) (> x 0))
(number-to-string (calendar-extract-year
(calendar-current-date)))))
(calendar-extract-year (calendar-current-date))))
(last (if (calendar-leap-year-p year) 366 365))
(day (calendar-read
(format "Day number (+/- 1-%d): " last)
(lambda (x) (and (<= 1 (abs x)) (<= (abs x) last))))))
(day (calendar-read-sexp
"Day number (+/- 1-%d)"
(lambda (x) (and (<= 1 (abs x)) (<= (abs x) last)))
nil
last)))
(list year day)))
(calendar-goto-date
(calendar-gregorian-from-absolute

View file

@ -1,4 +1,4 @@
;;; cal-persia.el --- calendar functions for the Persian calendar
;;; cal-persia.el --- calendar functions for the Persian calendar -*- lexical-binding: t; -*-
;; Copyright (C) 1996-1997, 2001-2021 Free Software Foundation, Inc.
@ -139,13 +139,14 @@ Gregorian date Sunday, December 31, 1 BC."
(calendar-absolute-from-gregorian
(or date (calendar-current-date)))))
(y (calendar-extract-year persian-date))
(m (calendar-extract-month persian-date))
(monthname (aref calendar-persian-month-name-array (1- m)))
(m (calendar-extract-month persian-date)))
(calendar-dlet*
((monthname (aref calendar-persian-month-name-array (1- m)))
(day (number-to-string (calendar-extract-day persian-date)))
(year (number-to-string y))
(month (number-to-string m))
dayname)
(mapconcat 'eval calendar-date-display-form "")))
(mapconcat #'eval calendar-date-display-form ""))))
;;;###cal-autoload
(defun calendar-persian-print-date ()
@ -157,14 +158,13 @@ Gregorian date Sunday, December 31, 1 BC."
(defun calendar-persian-read-date ()
"Interactively read the arguments for a Persian date command.
Reads a year, month, and day."
(let* ((year (calendar-read
"Persian calendar year (not 0): "
(let* ((year (calendar-read-sexp
"Persian calendar year (not 0)"
(lambda (x) (not (zerop x)))
(number-to-string
(calendar-extract-year
(calendar-persian-from-absolute
(calendar-absolute-from-gregorian
(calendar-current-date)))))))
(calendar-extract-year
(calendar-persian-from-absolute
(calendar-absolute-from-gregorian
(calendar-current-date))))))
(completion-ignore-case t)
(month (cdr (assoc
(completing-read
@ -175,9 +175,11 @@ Reads a year, month, and day."
(calendar-make-alist calendar-persian-month-name-array
1))))
(last (calendar-persian-last-day-of-month month year))
(day (calendar-read
(format "Persian calendar day (1-%d): " last)
(lambda (x) (and (< 0 x) (<= x last))))))
(day (calendar-read-sexp
"Persian calendar day (1-%d)"
(lambda (x) (and (< 0 x) (<= x last)))
nil
last)))
(list (list month day year))))
;;;###cal-autoload

View file

@ -1,4 +1,4 @@
;;; cal-tex.el --- calendar functions for printing calendars with LaTeX
;;; cal-tex.el --- calendar functions for printing calendars with LaTeX -*- lexical-binding: t; -*-
;; Copyright (C) 1995, 2001-2021 Free Software Foundation, Inc.
@ -248,6 +248,8 @@ This definition is the heart of the calendar!")
(autoload 'diary-list-entries "diary-lib")
(defvar diary-list-include-blanks)
(defun cal-tex-list-diary-entries (d1 d2)
"Generate a list of all diary-entries from absolute date D1 to D2."
(let (diary-list-include-blanks)
@ -591,6 +593,8 @@ indicates a buffer position to use instead of point."
LaTeX commands are inserted for the days of the MONTH in YEAR.
Diary entries on DIARY-LIST are included. Holidays on HOLIDAYS
are included. Each day is formatted using format DAY-FORMAT."
(with-suppressed-warnings ((lexical date))
(defvar date)) ;For `cal-tex-daily-string'.
(let ((blank-days ; at start of month
(mod
(- (calendar-day-of-week (list month 1 year))
@ -605,7 +609,7 @@ are included. Each day is formatted using format DAY-FORMAT."
(insert (format day-format (cal-tex-month-name month) j))
(cal-tex-arg (cal-tex-latexify-list diary-list date))
(cal-tex-arg (cal-tex-latexify-list holidays date))
(cal-tex-arg (eval cal-tex-daily-string))
(cal-tex-arg (eval cal-tex-daily-string t))
(cal-tex-arg)
(cal-tex-comment))
(when (and (zerop (mod (+ j blank-days) 7))
@ -885,13 +889,15 @@ argument EVENT specifies a different buffer position."
(interactive (list (prefix-numeric-value current-prefix-arg)
last-nonmenu-event))
(or n (setq n 1))
(with-suppressed-warnings ((lexical date))
(defvar date)) ;For `cal-tex-daily-string'.
(let* ((date (calendar-gregorian-from-absolute
(calendar-dayname-on-or-before
1
(calendar-absolute-from-gregorian
(calendar-cursor-to-date t event)))))
(month (calendar-extract-month date))
(year (calendar-extract-year date))
;; (year (calendar-extract-year date))
(day (calendar-extract-day date))
(d1 (calendar-absolute-from-gregorian date))
(d2 (+ (* 7 n) d1))
@ -932,7 +938,7 @@ argument EVENT specifies a different buffer position."
(insert ": ")
(cal-tex-large-bf s))
(cal-tex-hfill)
(insert " " (eval cal-tex-daily-string))
(insert " " (eval cal-tex-daily-string t))
(cal-tex-e-parbox)
(cal-tex-nl)
(cal-tex-noindent)
@ -951,7 +957,8 @@ argument EVENT specifies a different buffer position."
(cal-tex-e-parbox "2cm")
(cal-tex-nl)
(setq month (calendar-extract-month date)
year (calendar-extract-year date)))
;; year (calendar-extract-year date)
))
(cal-tex-e-parbox)
(unless (= i (1- n))
(run-hooks 'cal-tex-week-hook)
@ -961,13 +968,16 @@ argument EVENT specifies a different buffer position."
;; TODO respect cal-tex-daily-start,end?
;; Using different numbers of hours will probably break some layouts.
(defun cal-tex-week-hours (date holidays height)
"Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT.
(defun cal-tex-week-hours (thedate holidays height)
"Insert hourly entries for THEDATE with HOLIDAYS, with line height HEIGHT.
Uses the 24-hour clock if `cal-tex-24' is non-nil. Note that the hours
shown are hard-coded to 8-12, 13-17."
(let ((month (calendar-extract-month date))
(with-suppressed-warnings ((lexical date))
(defvar date)) ;For `cal-tex-daily-string'.
(let ((date thedate)
(month (calendar-extract-month date))
(day (calendar-extract-day date))
(year (calendar-extract-year date))
;; (year (calendar-extract-year date))
morning afternoon s)
(cal-tex-comment "begin cal-tex-week-hours")
(cal-tex-cmd "\\ \\\\[-.2cm]")
@ -983,7 +993,7 @@ shown are hard-coded to 8-12, 13-17."
(insert ": ")
(cal-tex-large-bf s))
(cal-tex-hfill)
(insert " " (eval cal-tex-daily-string))
(insert " " (eval cal-tex-daily-string t))
(cal-tex-e-parbox)
(cal-tex-nl "-.3cm")
(cal-tex-rule "0pt" "6.8in" ".2mm")
@ -1088,14 +1098,16 @@ shown are hard-coded to 8-12, 13-17."
(defun cal-tex-weekly-common (n event &optional filofax)
"Common code for weekly calendars."
(or n (setq n 1))
(with-suppressed-warnings ((lexical date))
(defvar date)) ;For `cal-tex-daily-string'.
(let* ((date (calendar-gregorian-from-absolute
(calendar-dayname-on-or-before
1
(calendar-absolute-from-gregorian
(calendar-cursor-to-date t event)))))
(month (calendar-extract-month date))
(year (calendar-extract-year date))
(day (calendar-extract-day date))
;; (month (calendar-extract-month date))
;; (year (calendar-extract-year date))
;; (day (calendar-extract-day date))
(d1 (calendar-absolute-from-gregorian date))
(d2 (+ (* 7 n) d1))
(holidays (if cal-tex-holidays
@ -1161,7 +1173,7 @@ shown are hard-coded to 8-12, 13-17."
(cal-tex-arg (number-to-string (calendar-extract-day date)))
(cal-tex-arg (cal-tex-latexify-list diary-list date))
(cal-tex-arg (cal-tex-latexify-list holidays date))
(cal-tex-arg (eval cal-tex-daily-string))
(cal-tex-arg (eval cal-tex-daily-string t))
(insert "%\n")
(setq date (cal-tex-incr-date date)))
(insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n")
@ -1258,14 +1270,16 @@ Optional EVENT indicates a buffer position to use instead of point."
(interactive (list (prefix-numeric-value current-prefix-arg)
last-nonmenu-event))
(or n (setq n 1))
(with-suppressed-warnings ((lexical date))
(defvar date)) ;For `cal-tex-daily-string'.
(let* ((date (calendar-gregorian-from-absolute
(calendar-dayname-on-or-before
calendar-week-start-day
(calendar-absolute-from-gregorian
(calendar-cursor-to-date t event)))))
(month (calendar-extract-month date))
(year (calendar-extract-year date))
(day (calendar-extract-day date))
;; (month (calendar-extract-month date))
;; (year (calendar-extract-year date))
;; (day (calendar-extract-day date))
(d1 (calendar-absolute-from-gregorian date))
(d2 (+ (* 7 n) d1))
(holidays (if cal-tex-holidays
@ -1311,7 +1325,7 @@ Optional EVENT indicates a buffer position to use instead of point."
(cal-tex-arg (number-to-string (calendar-extract-day date)))
(cal-tex-arg (cal-tex-latexify-list diary-list date))
(cal-tex-arg (cal-tex-latexify-list holidays date))
(cal-tex-arg (eval cal-tex-daily-string))
(cal-tex-arg (eval cal-tex-daily-string t))
(insert "%\n")
(setq date (cal-tex-incr-date date)))
(unless (= i (1- n))
@ -1342,14 +1356,16 @@ Optional EVENT indicates a buffer position to use instead of point."
(interactive (list (prefix-numeric-value current-prefix-arg)
last-nonmenu-event))
(or n (setq n 1))
(with-suppressed-warnings ((lexical date))
(defvar date)) ;For `cal-tex-daily-string'.
(let* ((date (calendar-gregorian-from-absolute
(calendar-dayname-on-or-before
1
(calendar-absolute-from-gregorian
(calendar-cursor-to-date t event)))))
(month (calendar-extract-month date))
(year (calendar-extract-year date))
(day (calendar-extract-day date))
;; (month (calendar-extract-month date))
;; (year (calendar-extract-year date))
;; (day (calendar-extract-day date))
(d1 (calendar-absolute-from-gregorian date))
(d2 (+ (* 7 n) d1))
(holidays (if cal-tex-holidays
@ -1383,11 +1399,11 @@ Optional EVENT indicates a buffer position to use instead of point."
"\\leftday")))
(cal-tex-arg (cal-tex-latexify-list diary-list date))
(cal-tex-arg (cal-tex-latexify-list holidays date "\\\\" t))
(cal-tex-arg (eval cal-tex-daily-string))
(cal-tex-arg (eval cal-tex-daily-string t))
(insert "%\n")
(if cal-tex-rules
(insert "\\linesfill\n")
(insert "\\vfill\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n"))
(insert (if cal-tex-rules
"\\linesfill\n"
"\\vfill\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n"))
(cal-tex-newpage)
(setq date (cal-tex-incr-date date)))
(insert "%\n")
@ -1397,11 +1413,11 @@ Optional EVENT indicates a buffer position to use instead of point."
(insert "\\weekend")
(cal-tex-arg (cal-tex-latexify-list diary-list date))
(cal-tex-arg (cal-tex-latexify-list holidays date "\\\\" t))
(cal-tex-arg (eval cal-tex-daily-string))
(cal-tex-arg (eval cal-tex-daily-string t))
(insert "%\n")
(if cal-tex-rules
(insert "\\linesfill\n")
(insert "\\vfill"))
(insert (if cal-tex-rules
"\\linesfill\n"
"\\vfill"))
(setq date (cal-tex-incr-date date)))
(or cal-tex-rules
(insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n"))
@ -1442,12 +1458,15 @@ a buffer position to use instead of point."
(cal-tex-end-document)
(run-hooks 'cal-tex-hook)))
(defun cal-tex-daily-page (date)
"Make a calendar page for Gregorian DATE on 8.5 by 11 paper.
(defun cal-tex-daily-page (thedate)
"Make a calendar page for Gregorian THEDATE on 8.5 by 11 paper.
Uses the 24-hour clock if `cal-tex-24' is non-nil. Produces
hourly sections for the period specified by `cal-tex-daily-start'
and `cal-tex-daily-end'."
(let ((month-name (cal-tex-month-name (calendar-extract-month date)))
(with-suppressed-warnings ((lexical date))
(defvar date)) ;For `cal-tex-daily-string'.
(let ((date thedate)
(month-name (cal-tex-month-name (calendar-extract-month date)))
(i (1- cal-tex-daily-start))
hour)
(cal-tex-banner "cal-tex-daily-page")
@ -1459,7 +1478,7 @@ and `cal-tex-daily-end'."
(cal-tex-bf month-name )
(cal-tex-e-parbox)
(cal-tex-hspace "1cm")
(cal-tex-scriptsize (eval cal-tex-daily-string))
(cal-tex-scriptsize (eval cal-tex-daily-string t))
(cal-tex-hspace "3.5cm")
(cal-tex-e-makebox)
(cal-tex-hfill)

View file

@ -1,4 +1,4 @@
;;; cal-x.el --- calendar windows in dedicated frames
;;; cal-x.el --- calendar windows in dedicated frames -*- lexical-binding: t; -*-
;; Copyright (C) 1994-1995, 2001-2021 Free Software Foundation, Inc.

View file

@ -112,6 +112,8 @@
;;; Code:
(eval-when-compile (require 'subr-x))
(load "cal-loaddefs" nil t)
;; Calendar has historically relied heavily on dynamic scoping.
@ -1459,7 +1461,7 @@ Optional integers MON and YR are used instead of today's date."
Inserts STRING so that it ends at INDENT. STRING is either a
literal string, or a sexp to evaluate to return such. Truncates
STRING to length TRUNCATE, and ensures a trailing space."
(if (not (ignore-errors (stringp (setq string (eval string)))))
(if (not (ignore-errors (stringp (setq string (eval string t)))))
(calendar-move-to-column indent)
(if (> (string-width string) truncate)
(setq string (truncate-string-to-width string truncate)))
@ -1526,7 +1528,7 @@ first INDENT characters on the line."
(format (format "%%%dd" calendar-day-digit-width) day)
'mouse-face 'highlight
'help-echo (calendar-dlet* ((day day) (month month) (year year))
(eval calendar-date-echo-text))
(eval calendar-date-echo-text t))
;; 'date property prevents intermonth text confusing re-searches.
;; (Tried intangible, it did not really work.)
'date t)
@ -2054,23 +2056,40 @@ With argument ARG, jump to mark, pop it, and put point at end of ring."
(error "%s not available in the calendar"
(global-key-binding (this-command-keys))))
(defun calendar-read-sexp (prompt predicate &optional default &rest args)
"Return an object read from the minibuffer.
Passes PROMPT, DEFAULT, and ARGS to `format-prompt' to build
the actual prompt. PREDICATE is called with a single value (the object
the user entered) and it should return non-nil if that value is a valid choice.
DEFAULT is the default value to use."
(unless (stringp default) (setq default (format "%S" default)))
(named-let query ()
;; The call to `read-from-minibuffer' is copied from `read-minibuffer',
;; except it's changed to use the DEFAULT arg instead of INITIAL-CONTENTS.
(let ((value (read-from-minibuffer
(apply #'format-prompt prompt default args)
nil minibuffer-local-map t 'minibuffer-history default)))
(if (funcall predicate value)
value
(query)))))
(defun calendar-read (prompt acceptable &optional initial-contents)
"Return an object read from the minibuffer.
Prompt with the string PROMPT and use the function ACCEPTABLE to decide
if entered item is acceptable. If non-nil, optional third arg
INITIAL-CONTENTS is a string to insert in the minibuffer before reading."
(declare (obsolete calendar-read-sexp "28.1"))
(let ((value (read-minibuffer prompt initial-contents)))
(while (not (funcall acceptable value))
(setq value (read-minibuffer prompt initial-contents)))
value))
(defun calendar-customized-p (symbol)
"Return non-nil if SYMBOL has been customized."
(and (default-boundp symbol)
(let ((standard (get symbol 'standard-value)))
(and standard
(not (equal (eval (car standard)) (default-value symbol)))))))
(not (equal (eval (car standard) t) (default-value symbol)))))))
(defun calendar-abbrev-construct (full &optional maxlen)
"From sequence FULL, return a vector of abbreviations.
@ -2284,32 +2303,38 @@ arguments SEQUENCES."
(append (list sequence) sequences))
(reverse alist)))
(defun calendar-read-date (&optional noday)
(defun calendar-read-date (&optional noday default-date)
"Prompt for Gregorian date. Return a list (month day year).
If optional NODAY is t, does not ask for day, but just returns
\(month 1 year); if NODAY is any other non-nil value the value
returned is (month year)."
(let* ((year (calendar-read
"Year (>0): "
(lambda (x) (> x 0))
(number-to-string (calendar-extract-year
(calendar-current-date)))))
(unless default-date (setq default-date (calendar-current-date)))
(let* ((defyear (calendar-extract-year default-date))
(year (calendar-read-sexp "Year (>0)"
(lambda (x) (> x 0))
defyear))
(month-array calendar-month-name-array)
(defmon (aref month-array (1- (calendar-extract-month default-date))))
(completion-ignore-case t)
(month (cdr (assoc-string
(completing-read
"Month name: "
(mapcar #'list (append month-array nil))
nil t)
(completing-read
(format-prompt "Month name" defmon)
(append month-array nil)
nil t nil nil defmon)
(calendar-make-alist month-array 1) t)))
(defday (calendar-extract-day default-date))
(last (calendar-last-day-of-month month year)))
(if noday
(if (eq noday t)
(list month 1 year)
(list month year))
(list month
(calendar-read (format "Day (1-%d): " last)
(lambda (x) (and (< 0 x) (<= x last))))
(calendar-read-sexp "Day (1-%d)"
(lambda (x) (and (< 0 x) (<= x last)))
;; Don't offer today's day as default
;; if it's not valid for the chosen
;; month/year.
(if (<= defday last) defday) last)
year))))
(defun calendar-interval (mon1 yr1 mon2 yr2)

View file

@ -2221,8 +2221,8 @@ Prefix argument ARG makes the entry nonmarking."
(diary-make-entry
(format "%s(diary-cyclic %d %s)"
diary-sexp-entry-symbol
(calendar-read "Repeat every how many days: "
(lambda (x) (> x 0)))
(calendar-read-sexp "Repeat every how many days"
(lambda (x) (> x 0)))
(calendar-date-string (calendar-cursor-to-date t) nil t))
arg)))

View file

@ -423,16 +423,15 @@ of a holiday list.
The optional LABEL is used to label the buffer created."
(interactive
(let* ((start-year (calendar-read
"Starting year of holidays (>0): "
(let* ((start-year (calendar-read-sexp
"Starting year of holidays (>0)"
(lambda (x) (> x 0))
(number-to-string (calendar-extract-year
(calendar-current-date)))))
(end-year (calendar-read
(format "Ending year (inclusive) of holidays (>=%s): "
start-year)
(calendar-extract-year (calendar-current-date))))
(end-year (calendar-read-sexp
"Ending year (inclusive) of holidays (>=%s)"
(lambda (x) (>= x start-year))
(number-to-string start-year)))
start-year
start-year))
(completion-ignore-case t)
(lists
(list

View file

@ -160,16 +160,13 @@ and querying them will cause the actual project to get loaded.")
;; Projects can also affect how EDE works, by changing what appears in
;; the EDE menu, or how some keys are bound.
;;
(unless (fboundp 'ede-target-list-p)
(cl-deftype ede-target-list () '(list-of ede-target)))
(defclass ede-project (ede-project-placeholder)
((subproj :initform nil
:type list
:documentation "Sub projects controlled by this project.
For Automake based projects, each directory is treated as a project.")
(targets :initarg :targets
:type ede-target-list
:type (list-of ede-target)
:custom (repeat (object :objectcreatefcn ede-new-target-custom))
:label "Local Targets"
:group (targets)

View file

@ -184,7 +184,7 @@ Target variables are always renamed such as foo_CFLAGS, then included into
commands where the variable would usually appear.")
(rules :initarg :rules
:initform nil
:type list
:type (list-of ede-makefile-rule)
:custom (repeat (object :objecttype ede-makefile-rule))
:label "Additional Rules"
:group (make)

View file

@ -3863,7 +3863,11 @@ REGEXP-GROUP is the regular expression group in REGEXP to use."
(push (buffer-substring-no-properties
(match-beginning regexp-group)
(match-end regexp-group))
results))
results)
(when (zerop (length (match-string 0)))
;; If the regexp can be empty (for instance, "^.*$"), we
;; don't advance, so ensure forward progress.
(forward-line 1)))
(nreverse results))))
;; Converting process modes to use comint mode

View file

@ -880,7 +880,7 @@ since it could result in memory overflow and make Emacs crash."
;; Don't re-add to custom-delayed-init-variables post-startup.
(unless after-init-time
;; Note this is the _only_ initialize property we handle.
(if (eq (cadr (memq :initialize rest)) 'custom-initialize-delay)
(if (eq (cadr (memq :initialize rest)) #'custom-initialize-delay)
;; These vars are defined early and should hence be initialized
;; early, even if this file happens to be loaded late. so add them
;; to the end of custom-delayed-init-variables. Otherwise,

View file

@ -125,17 +125,7 @@ This is used in files that are preloaded (or for autoloaded
variables), so that the initialization is done in the run-time
context rather than the build-time context. This also has the
side-effect that the (delayed) initialization is performed with
the :set function.
For variables in preloaded files, you can simply use this
function for the :initialize property. For autoloaded variables,
you will also need to add an autoload stanza calling this
function, and another one setting the standard-value property.
Or you can wrap the defcustom in a progn, to force the autoloader
to include all of it." ; see eg vc-sccs-search-project-dir
;; No longer true:
;; "See `send-mail-function' in sendmail.el for an example."
the :set function."
;; Defvar it so as to mark it special, etc (bug#25770).
(internal--define-uninitialized-variable symbol)

View file

@ -1168,7 +1168,10 @@ ARGS are command switches passed to PROGRAM.")
("\\.tar\\.bz2\\'" . "tar -cf - %i | bzip2 -c9 > %o")
("\\.tar\\.xz\\'" . "tar -cf - %i | xz -c9 > %o")
("\\.tar\\.zst\\'" . "tar -cf - %i | zstd -19 -o %o")
("\\.zip\\'" . "zip %o -r --filesync %i"))
("\\.tar\\.lz\\'" . "tar -cf - %i | lzip -c9 > %o")
("\\.tar\\.lzo\\'" . "tar -cf - %i | lzop -c9 > %o")
("\\.zip\\'" . "zip %o -r --filesync %i")
("\\.pax\\'" . "pax -wf %o %i"))
"Control the compression shell command for `dired-do-compress-to'.
Each element is (REGEXP . CMD), where REGEXP is the name of the

View file

@ -1483,7 +1483,7 @@ a prefix argument, when it offers the filename near point as a default."
;;; Internal functions.
;; Fixme: This should probably use `thing-at-point'. -- fx
(define-obsolete-function-alias 'dired-file-name-at-point
(define-obsolete-function-alias 'dired-filename-at-point
#'dired-x-guess-file-name-at-point "28.1")
(defun dired-x-guess-file-name-at-point ()
"Return the filename closest to point, expanded.

File diff suppressed because it is too large Load diff

View file

@ -238,8 +238,11 @@ The return value is undefined.
#'(lambda (x)
(let ((f (cdr (assq (car x) macro-declarations-alist))))
(if f (apply (car f) name arglist (cdr x))
(message "Warning: Unknown macro property %S in %S"
(car x) name))))
(macroexp--warn-and-return
(format-message
"Unknown macro property %S in %S"
(car x) name)
nil))))
decls)))
;; Refresh font-lock if this is a new macro, or it is an
;; existing macro whose 'no-font-lock-keyword declaration
@ -307,9 +310,12 @@ The return value is undefined.
(cdr body)
body)))
nil)
(t (message "Warning: Unknown defun property `%S' in %S"
(car x) name)))))
decls))
(t
(macroexp--warn-and-return
(format-message "Unknown defun property `%S' in %S"
(car x) name)
nil)))))
decls))
(def (list 'defalias
(list 'quote name)
(list 'function

View file

@ -2577,7 +2577,8 @@ list that represents a doc string reference.
(when (memq sym byte-compile-lexical-variables)
(setq byte-compile-lexical-variables
(delq sym byte-compile-lexical-variables))
(byte-compile-warn "Variable `%S' declared after its first use" sym))
(when (byte-compile-warning-enabled-p 'lexical sym)
(byte-compile-warn "Variable `%S' declared after its first use" sym)))
(push sym byte-compile-bound-variables)
(push sym byte-compile--seen-defvars))

View file

@ -241,7 +241,12 @@ system. Possible values are:
defun - Spell-check when style checking a single defun.
buffer - Spell-check when style checking the whole buffer.
interactive - Spell-check during any interactive check.
t - Always spell-check."
t - Always spell-check.
There is a list of Lisp-specific words which checkdoc will
install into Ispell on the fly, but only if Ispell is not already
running. Use `ispell-kill-ispell' to make checkdoc restart it
with these words enabled."
:type '(choice (const nil)
(const defun)
(const buffer)

View file

@ -487,7 +487,7 @@ Errors during evaluation are caught and handled like nil."
Returns nil if they are."
(if (not (eq (type-of a) (type-of b)))
`(different-types ,a ,b)
(pcase-exhaustive a
(pcase a
((pred consp)
(let ((a-length (proper-list-p a))
(b-length (proper-list-p b)))
@ -538,7 +538,7 @@ Returns nil if they are."
for xi = (ert--explain-equal-rec ai bi)
do (when xi (cl-return `(array-elt ,i ,xi)))
finally (cl-assert (equal a b) t))))
((pred atom)
(_
(if (not (equal a b))
(if (and (symbolp a) (symbolp b) (string= a b))
`(different-symbols-with-the-same-name ,a ,b)

View file

@ -127,7 +127,7 @@ and also to avoid outputting the warning during normal execution."
(cond
((null msg) form)
((macroexp--compiling-p)
(if (gethash form macroexp--warned)
(if (and (consp form) (gethash form macroexp--warned))
;; Already wrapped this exp with a warning: avoid inf-looping
;; where we keep adding the same warning onto `form' because
;; macroexpand-all gets right back to macroexpanding `form'.
@ -138,9 +138,10 @@ and also to avoid outputting the warning during normal execution."
,form)))
(t
(unless compile-only
(message "%s%s" (if (stringp load-file-name)
(concat (file-relative-name load-file-name) ": ")
"")
(message "%sWarning: %s"
(if (stringp load-file-name)
(concat (file-relative-name load-file-name) ": ")
"")
msg))
form))))
@ -180,8 +181,9 @@ and also to avoid outputting the warning during normal execution."
(defun macroexp-macroexpand (form env)
"Like `macroexpand' but checking obsolescence."
(let ((new-form
(macroexpand form env)))
(let* ((macroexpand-all-environment env)
(new-form
(macroexpand form env)))
(if (and (not (eq form new-form)) ;It was a macro call.
(car-safe form)
(symbolp (car form))

View file

@ -3288,9 +3288,9 @@ To unhide a package, type
`\\[customize-variable] RET package-hidden-regexps'.
Type \\[package-menu-toggle-hiding] to toggle package hiding."
(declare (interactive-only "change `package-hidden-regexps' instead."))
(interactive)
(package--ensure-package-menu-mode)
(declare (interactive-only "change `package-hidden-regexps' instead."))
(let* ((name (when (derived-mode-p 'package-menu-mode)
(concat "\\`" (regexp-quote (symbol-name (package-desc-name
(tabulated-list-get-id))))

View file

@ -39,10 +39,10 @@
;; - along these lines, provide patterns to match CL structs.
;; - provide something like (setq VAR) so a var can be set rather than
;; let-bound.
;; - provide a way to fallthrough to subsequent cases (not sure what I meant by
;; this :-()
;; - provide a way to fallthrough to subsequent cases
;; (e.g. Like Racket's (=> ID).
;; - try and be more clever to reduce the size of the decision tree, and
;; to reduce the number of leaves that need to be turned into function:
;; to reduce the number of leaves that need to be turned into functions:
;; - first, do the tests shared by all remaining branches (it will have
;; to be performed anyway, so better do it first so it's shared).
;; - then choose the test that discriminates more (?).
@ -97,11 +97,15 @@
(declare-function get-edebug-spec "edebug" (symbol))
(declare-function edebug-match "edebug" (cursor specs))
(defun pcase--get-macroexpander (s)
"Return the macroexpander for pcase pattern head S, or nil"
(get s 'pcase-macroexpander))
(defun pcase--edebug-match-macro (cursor)
(let (specs)
(mapatoms
(lambda (s)
(let ((m (get s 'pcase-macroexpander)))
(let ((m (pcase--get-macroexpander s)))
(when (and m (get-edebug-spec m))
(push (cons (symbol-name s) (get-edebug-spec m))
specs)))))
@ -128,6 +132,7 @@ PATTERN matches. PATTERN can take one of the forms:
If a SYMBOL is used twice in the same pattern
the second occurrence becomes an `eq'uality test.
(pred FUN) matches if FUN called on EXPVAL returns non-nil.
(pred (not FUN)) matches if FUN called on EXPVAL returns nil.
(app FUN PAT) matches if FUN called on EXPVAL matches PAT.
(guard BOOLEXP) matches if BOOLEXP evaluates to non-nil.
(let PAT EXPR) matches if EXPR matches PAT.
@ -193,7 +198,7 @@ Emacs Lisp manual for more information and examples."
(let (more)
;; Collect all the extensions.
(mapatoms (lambda (symbol)
(let ((me (get symbol 'pcase-macroexpander)))
(let ((me (pcase--get-macroexpander symbol)))
(when me
(push (cons symbol me)
more)))))
@ -424,7 +429,7 @@ of the elements of LIST is performed as if by `pcase-let'.
((eq head 'let) `(let ,(pcase--macroexpand (cadr pat)) ,@(cddr pat)))
((eq head 'app) `(app ,(nth 1 pat) ,(pcase--macroexpand (nth 2 pat))))
(t
(let* ((expander (get head 'pcase-macroexpander))
(let* ((expander (pcase--get-macroexpander head))
(npat (if expander (apply expander (cdr pat)))))
(if (null npat)
(error (if expander
@ -658,6 +663,14 @@ MATCH is the pattern that needs to be matched, of the form:
'(:pcase--succeed . nil))))
(defun pcase--split-pred (vars upat pat)
"Indicate the overlap or mutual-exclusion between UPAT and PAT.
More specifically retuns a pair (A . B) where A indicates whether PAT
can match when UPAT has matched, and B does the same for the case
where UPAT failed to match.
A and B can be one of:
- nil if we don't know
- `:pcase--fail' if UPAT match's result implies that PAT can't match
- `:pcase--succeed' if UPAT match's result implies that PAT matches"
(let (test)
(cond
((and (equal upat pat)
@ -670,6 +683,19 @@ MATCH is the pattern that needs to be matched, of the form:
;; and catch at least the easy cases such as (bug#14773).
(not (macroexp--fgrep (mapcar #'car vars) (cadr upat)))))
'(:pcase--succeed . :pcase--fail))
;; In case UPAT is of the form (pred (not PRED))
((and (eq 'pred (car upat)) (eq 'not (car-safe (cadr upat))))
(let* ((test (cadr (cadr upat)))
(res (pcase--split-pred vars `(pred ,test) pat)))
(cons (cdr res) (car res))))
;; In case PAT is of the form (pred (not PRED))
((and (eq 'pred (car-safe pat)) (eq 'not (car-safe (cadr pat))))
(let* ((test (cadr (cadr pat)))
(res (pcase--split-pred vars upat `(pred ,test)))
(reverse (lambda (x) (cond ((eq x :pcase--succeed) :pcase--fail)
((eq x :pcase--fail) :pcase--succeed)))))
(cons (funcall reverse (car res))
(funcall reverse (cdr res)))))
((and (eq 'pred (car upat))
(let ((otherpred
(cond ((eq 'pred (car-safe pat)) (cadr pat))
@ -728,8 +754,10 @@ MATCH is the pattern that needs to be matched, of the form:
(defun pcase--funcall (fun arg vars)
"Build a function call to FUN with arg ARG."
(if (symbolp fun)
`(,fun ,arg)
(cond
((symbolp fun) `(,fun ,arg))
((eq 'not (car-safe fun)) `(not ,(pcase--funcall (cadr fun) arg vars)))
(t
(let* (;; `env' is an upper bound on the bindings we need.
(env (mapcar (lambda (x) (list (car x) (cdr x)))
(macroexp--fgrep vars fun)))
@ -747,7 +775,7 @@ MATCH is the pattern that needs to be matched, of the form:
;; Let's not replace `vars' in `fun' since it's
;; too difficult to do it right, instead just
;; let-bind `vars' around `fun'.
`(let* ,env ,call)))))
`(let* ,env ,call))))))
(defun pcase--eval (exp vars)
"Build an expression that will evaluate EXP."

View file

@ -198,9 +198,10 @@ If not found, return nil."
(pcase-defmacro radix-tree-leaf (vpat)
"Pattern which matches a radix-tree leaf.
The pattern VPAT is matched against the leaf's carried value."
;; FIXME: We'd like to use a negative pattern (not consp), but pcase
;; doesn't support it. Using `atom' works but generates sub-optimal code.
`(or `(t . ,,vpat) (and (pred atom) ,vpat))))
;; We used to use `(pred atom)', but `pcase' doesn't understand that
;; `atom' is equivalent to the negation of `consp' and hence generates
;; suboptimal code.
`(or `(t . ,,vpat) (and (pred (not consp)) ,vpat))))
(defun radix-tree-iter-subtrees (tree fun)
"Apply FUN to every immediate subtree of radix TREE.

View file

@ -389,6 +389,28 @@ it makes no sense to convert it to a string using
(set-buffer source-buffer)
(replace-buffer-contents tmp-buffer max-secs max-costs)))))))))
(defmacro named-let (name bindings &rest body)
"Looping construct taken from Scheme.
Like `let', bind variables in BINDINGS and then evaluate BODY,
but with the twist that BODY can evaluate itself recursively by
calling NAME, where the arguments passed to NAME are used
as the new values of the bound variables in the recursive invocation."
(declare (indent 2) (debug (symbolp (&rest (symbolp form)) body)))
(require 'cl-lib)
(let ((fargs (mapcar (lambda (b) (if (consp b) (car b) b)) bindings))
(aargs (mapcar (lambda (b) (if (consp b) (cadr b))) bindings)))
;; According to the Scheme semantics of named let, `name' is not in scope
;; while evaluating the expressions in `bindings', and for this reason, the
;; "initial" function call below needs to be outside of the `cl-labels'.
;; When the "self-tco" eliminates all recursive calls, the `cl-labels'
;; expands to a lambda which the byte-compiler then combines with the
;; funcall to make a `let' so we end up with a plain `while' loop and no
;; remaining `lambda' at all.
`(funcall
(cl-labels ((,name ,fargs . ,body)) #',name)
. ,aargs)))
(provide 'subr-x)
;;; subr-x.el ends here

View file

@ -87,9 +87,11 @@
(defun cua-toggle-global-mark (stay)
"Set or cancel the global marker.
When the global marker is set, CUA cut and copy commands will automatically
insert the deleted or copied text before the global marker, even when the
global marker is in another buffer.
When the global marker is set, CUA cut and copy commands will
automatically insert the inserted, deleted or copied text before
the global marker, even when the global marker is in another
buffer.
If the global marker isn't set, set the global marker at point in the current
buffer. Otherwise jump to the global marker position and cancel it.
With prefix argument, don't jump to global mark when canceling it."

View file

@ -359,8 +359,8 @@ DOC is documentation text to insert at the start."
;; Find the end of the documentation text at the start.
;; Set POINT to where it ends, or nil if ends at eob.
(unless (get-text-property point 'epa-list-keys)
(setq point (next-single-property-change point 'epa-list-keys)))
(unless (get-text-property point 'epa-key)
(setq point (next-single-property-change point 'epa-key)))
;; If caller specified documentation text for that, replace the old
;; documentation text (if any) with what was specified.

View file

@ -606,9 +606,14 @@ color. The function should accept a single argument, the color name."
(defun list-colors-print (list &optional callback)
(let ((callback-fn
(if callback
`(lambda (button)
(funcall ,callback (button-get button 'color-name))))))
;; Expect CALLBACK to be a function, but allow it to be a form that
;; evaluates to a function, for backward-compatibility. (Bug#45831)
(cond ((functionp callback)
(lambda (button)
(funcall callback (button-get button 'color-name))))
(callback
`(lambda (button)
(funcall ,callback (button-get button 'color-name)))))))
(dolist (color list)
(if (consp color)
(if (cdr color)

View file

@ -2199,7 +2199,7 @@ the above example."
(not (funcall pred type)))
;; Strip off last hyphen and what follows, then try again
(setq type
(if (setq hyphend (string-match-p "[-_][^-_]+$" type))
(if (setq hyphend (string-match-p "[-_.][^-_.]+$" type))
(substring type 0 hyphend)
nil))))
type)

View file

@ -4067,7 +4067,7 @@ Return the new variables list."
(subdirs (assq 'subdirs alist)))
(if (or (not subdirs)
(progn
(setq alist (delq subdirs alist))
(setq alist (remq subdirs alist))
(cdr-safe subdirs))
;; TODO someone might want to extend this to allow
;; integer values for subdir, where N means

View file

@ -1104,8 +1104,8 @@ Called with two arguments BEG and END.")
"Reinitialize the font-lock machinery and (re-)fontify the buffer.
This functions is a convenience functions when developing font
locking for a mode, and is not meant to be called from lisp functions."
(interactive)
(declare (interactive-only t))
(interactive)
;; Make font-lock recalculate all the mode-specific data.
(setq font-lock-major-mode nil)
;; Make the syntax machinery discard all information.

Some files were not shown because too many files have changed in this diff Show more