[latex3-commits] [git/LaTeX3-latex3-latex2e] firstaid: use simple helper after all (423a23bc)
Frank Mittelbach
frank.mittelbach at latex-project.org
Mon Sep 28 13:13:34 CEST 2020
Repository : https://github.com/latex3/latex2e
On branch : firstaid
Link : https://github.com/latex3/latex2e/commit/423a23bca90771c0e5e6f2a0bbfce5705cee2721
>---------------------------------------------------------------
commit 423a23bca90771c0e5e6f2a0bbfce5705cee2721
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Mon Sep 28 13:13:34 2020 +0200
use simple helper after all
>---------------------------------------------------------------
423a23bca90771c0e5e6f2a0bbfce5705cee2721
.../latex2e-first-aid-for-external-files.dtx | 207 +++------------------
.../firstaid/testfiles-TU/firstaid-bidi.luatex.tlg | 2 +-
required/firstaid/testfiles-TU/firstaid-bidi.tlg | 2 +-
required/firstaid/testfiles/firstaid-000.lvt | 3 +-
required/firstaid/testfiles/firstaid-000.tlg | 7 +-
.../testfiles/firstaid-filehook.luatex.tlg | 2 +-
required/firstaid/testfiles/firstaid-filehook.tlg | 2 +-
.../firstaid/testfiles/firstaid-filehook.xetex.tlg | 2 +-
required/firstaid/version-peaking.unused | 194 +++++++++++++++++++
9 files changed, 223 insertions(+), 198 deletions(-)
diff --git a/required/firstaid/latex2e-first-aid-for-external-files.dtx b/required/firstaid/latex2e-first-aid-for-external-files.dtx
index 5f2c0ed7..a4cefca2 100644
--- a/required/firstaid/latex2e-first-aid-for-external-files.dtx
+++ b/required/firstaid/latex2e-first-aid-for-external-files.dtx
@@ -108,195 +108,27 @@
[\LaTeXFirstAidDate\space \LaTeXFirstAidVersion\space
LaTeX kernel fixes to external files and packages]
% \end{macrocode}
-%
-% \subsection{Package version peeking}
-%
+ %
+
+% \begin{macro}{\FirstAidNeededT}
+% This is a very simple help to ensure that we only apply first aid
+% to an unmodified package or class. It only works in the case the
+% file has already been loaded and the csname \cs{ver@\#1.\#2} got
+% defined (holding the current date, version, and short description
+% info). We then compare its content to a frozen string and make
+% the modification \verb=#3= only if both agree. If they differ we
+% assume that the package/class in question got updated by its
+% maintainer.
% \begin{macrocode}
-%<@@=firstaid>
\ExplSyntaxOn
+\cs_new:Npn\FirstAidNeededT#1#2#3{
+ \exp_args:Nc\str_if_eq:onT{ver@#1.#2}{#3}
+}
+\ExplSyntaxOff
% \end{macrocode}
+% \end{macro}
%
-% \begin{macro}{\l_@@_line_tl}
-% \begin{macro}{\g_@@_pkg_ior}
-% \begin{macro}{\l_@@_needs_bool}
-% Some variables needed.
-% \begin{macrocode}
-\tl_new:N \l_@@_line_tl
-\tl_new:N \l_@@_stored_tl
-\tl_new:N \l_@@_target_tl
-\ior_new:N \g_@@_pkg_ior
-\bool_new:N \l_@@_needs_bool
-\scan_new:N \s_@@
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}[TF]{\firstaid_if_needed:nn}
-% \cs{firstaid_if_needed:nn} will check if version |#2| of package
-% |#1| requires first-aid treatment (that is, if the version installed
-% matches |#2|). It returns \meta{true} or \meta{false}, accordingly.
-% \begin{macrocode}
-\prg_new_protected_conditional:Npnn \firstaid_if_needed:nn #1 #2
- { T, F, TF }
- {
- \cs_if_exist:cTF { ver@#1.sty }
- {
-% \end{macrocode}
-%
-% If the file is already loaded, check if the loaded version matches,
-% and return \meta{true} or \meta{false}.
-% \begin{macrocode}
- \str_if_eq:eeTF { \use:c { ver@#1.sty } } {#2}
- { \prg_return_true: }
- { \prg_return_false: }
- }
- {
-% \end{macrocode}
-%
-% If the package is not read yet (\cs[no-index]{ver@\#1} is not
-% defined), then we will silently open the file and peek through its
-% contents with \cs{@@_peek_file:}.
-% \begin{macrocode}
- \tl_set:Nn \l_@@_target_tl { {#1}[#2] }
- \tl_clear:N \l_@@_stored_tl
- \ior_open:Nn \g_@@_pkg_ior { #1.sty }
- \@@_peek_file:
- \ior_close:N \g_@@_pkg_ior
- \bool_if:NTF \l_@@_needs_bool
- { \prg_return_true: }
- { \prg_return_false: }
- }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_peek_file:}
-% If the file isn't loaded yet, we'll read it looking for
-% \cs{ProvidesPackage} and read the argument to that and then check
-% the available version. There are a few limitations of when this
-% will work: the \cs{ProvidesPackage} cannot be within braces, and it
-% must be the first occurrence of the control sequence in the file.
-%
-% The file is read line by line, looking for \cs{ProvidesPackage}.
-% If the end of the file is reached, the boolean \cs{l_@@_needs_bool}
-% is set to false (a package without a \cs{ProvidesPackage} line is
-% set to \emph{not} need first-aid; this could be changed if needed).
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_peek_file:
- {
- \ior_get:NNTF \g_@@_pkg_ior \l_@@_line_tl
- {
- \tl_if_in:NnTF \l_@@_line_tl { \ProvidesPackage }
- { \exp_after:wN \@@_scan_provides_args:w \l_@@_line_tl \s_@@ }
- { \@@_peek_file: }
- }
- { \bool_set_false:N \l_@@_needs_bool }
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{
-% \@@_scan_provides_args:w,
-% \@@_scan_provides_marg:,
-% \@@_marg_check:n,
-% \@@_put_provides_marg:w,
-% }
-% Now extract the tokens after \cs{ProvidesPackage}, and look for the
-% mandatory argument; the package name. Once done, call
-% \cs{@@_put_provides_marg:w} to put the mandatory argument into the
-% storage token list and call \cs{@@_start_opt_check:n} to look for
-% the optional argument.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_scan_provides_args:w
- #1 \ProvidesPackage #2 \s_@@
- { \@@_marg_check:n {#2} }
-\cs_new_protected:Npn \@@_scan_provides_marg:
- {
- \ior_get:NNTF \g_@@_pkg_ior \l_@@_line_tl
- { \exp_args:NV \@@_marg_check:n \l_@@_line_tl }
- { \bool_set_false:N \l_@@_needs_bool }
- }
-\cs_new_protected:Npn \@@_marg_check:n #1
- {
- \tl_if_blank:nTF {#1}
- { \@@_scan_provides_marg: }
- { \@@_put_provides_marg:w #1 \s_@@ }
- }
-\cs_new_protected:Npn \@@_put_provides_marg:w #1 #2 \s_@@
- {
- \tl_put_right:Nn \l_@@_stored_tl { {#1} }
- \@@_start_opt_check:n {#2}
- }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{
-% \@@_start_opt_check:n,
-% \@@_start_provides_opt:,
-% \@@_end_opt_check:n,
-% \@@_scan_provides_opt:,
-% \@@_empty_provides_opt:,
-% }
-% Look for the optional argument by checking that the first non-blank
-% token is a |[|, then grabbing lines one by one looking for an
-% unbraced |]| which ends the optional argument.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_start_opt_check:n #1
- {
- \tl_if_blank:nTF {#1}
- { \@@_start_provides_opt: }
- {
- \str_if_eq:eeTF { \use_i_delimit_by_q_nil:nw #1 \q_nil } { [ }
- { \@@_end_opt_check:n {#1} }
- { \@@_empty_provides_opt: }
- }
- }
-\cs_new_protected:Npn \@@_start_provides_opt:
- {
- \ior_get:NNTF \g_@@_pkg_ior \l_@@_line_tl
- { \exp_args:NV \@@_start_opt_check:n \l_@@_line_tl }
- { \@@_empty_provides_opt: }
- }
-\cs_new_protected:Npn \@@_scan_provides_opt:
- {
- \ior_get:NNTF \g_@@_pkg_ior \l_@@_line_tl
- { \exp_args:NV \@@_end_opt_check:n \l_@@_line_tl }
- { \bool_set_false:N \l_@@_needs_bool }
- }
-\cs_new_protected:Npn \@@_end_opt_check:n #1
- {
- \tl_if_in:nnTF {#1} { ] }
- { \@@_put_opt_arg_end:w #1 \s_@@ }
- {
- \tl_put_right:Nn \l_@@_stored_tl {#1}
- \@@_scan_provides_opt:
- }
- }
-\cs_new_protected:Npn \@@_empty_provides_opt:
- { \use:x { \@@_put_opt_arg_end:w [ \c_novalue_tl ] \s_@@ } }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_put_opt_arg_end:w}
-% When a |]| is found, add everything up to it to the storage token
-% list and compare it with the target token list saved earler.
-% If they are the same, return true, otherwise false.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_put_opt_arg_end:w #1 ] #2 \s_@@
- {
- \tl_put_right:Nn \l_@@_stored_tl { #1] }
- \str_if_eq:NNTF \l_@@_target_tl \l_@@_stored_tl
- { \bool_set_true:N \l_@@_needs_bool }
- { \bool_set_false:N \l_@@_needs_bool }
- }
-% \end{macrocode}
-% \end{macro}
%
-% \begin{macrocode}
-\ExplSyntaxOff
-%<@@=>
-% \end{macrocode}
%
% \subsection{The \pkg{filehook} package first aid}
%
@@ -463,6 +295,9 @@
%
% \begin{macrocode}
\AddToHook{file/after/biditools.sty}[firstaid]{%
+ \FirstAidNeededT{biditools}{sty}%
+ {2020/05/13 v2 Programming tools for bidi package}%
+ {
% \end{macrocode}
% \pkg{bidi} adds some code to the beginning of \cs{document} which
% contains \cs{endgroup} and \cs{begingroup} which is no longer
@@ -483,6 +318,7 @@
\AddToHook{enddocument/info}%
{\let\bidi at AfterEndDocumentCheckLabelsRerun\@firstofone
\bidi at afterenddocumentchecklabelsrerunhook}%
+ }
}
% \end{macrocode}
%
@@ -498,7 +334,8 @@
% Here the fix is simply though.
% \begin{macrocode}
\AddToHook{file/after/dinbrief.cls}[firstaid]{%
- \AddToHook{env/document/begin}{\begingroup}%
+ \FirstAidNeededT{dinbrief}{cls}{2000/03/02 LaTeX2e class}%
+ {\AddToHook{env/document/begin}{\begingroup}}%
}
% \end{macrocode}
%
diff --git a/required/firstaid/testfiles-TU/firstaid-bidi.luatex.tlg b/required/firstaid/testfiles-TU/firstaid-bidi.luatex.tlg
index 5382fde4..db3e66a5 100644
--- a/required/firstaid/testfiles-TU/firstaid-bidi.luatex.tlg
+++ b/required/firstaid/testfiles-TU/firstaid-bidi.luatex.tlg
@@ -2,7 +2,7 @@ This is a generated file for the l3build validation system.
Don't change this file in any respect.
-> The hook 'file/after/biditools.sty':
> Code chunks:
-> firstaid -> \def \firstaid at bidi@document at patch \endgroup ##1\begingroup ##2\firstaid at bidi@document at patch {\unexpanded {##1##2}}\edef \document {\expandafter \firstaid at bidi@document at patch \document \firstaid at bidi@document at patch }\AddToHook {enddocument/info}{\let \bidi at AfterEndDocumentCheckLabelsRerun \@firstofone \bidi at afterenddocumentchecklabelsrerunhook }
+> firstaid -> \FirstAidNeededT {biditools}{sty}{....-..-.. v... Programming tools for bidi package}{ \def \firstaid at bidi@document at patch \endgroup ##1\begingroup ##2\firstaid at bidi@document at patch {\unexpanded {##1##2}}\edef \document {\expandafter \firstaid at bidi@document at patch \document \firstaid at bidi@document at patch }\AddToHook {enddocument/info}{\let \bidi at AfterEndDocumentCheckLabelsRerun \@firstofone \bidi at afterenddocumentchecklabelsrerunhook }}
> Extra code for next invocation:
> ---
> Rules:
diff --git a/required/firstaid/testfiles-TU/firstaid-bidi.tlg b/required/firstaid/testfiles-TU/firstaid-bidi.tlg
index f7dd5544..cd5033a3 100644
--- a/required/firstaid/testfiles-TU/firstaid-bidi.tlg
+++ b/required/firstaid/testfiles-TU/firstaid-bidi.tlg
@@ -2,7 +2,7 @@ This is a generated file for the l3build validation system.
Don't change this file in any respect.
-> The hook 'file/after/biditools.sty':
> Code chunks:
-> firstaid -> \def \firstaid at bidi@document at patch \endgroup ##1\begingroup ##2\firstaid at bidi@document at patch {\unexpanded {##1##2}}\edef \document {\expandafter \firstaid at bidi@document at patch \document \firstaid at bidi@document at patch }\AddToHook {enddocument/info}{\let \bidi at AfterEndDocumentCheckLabelsRerun \@firstofone \bidi at afterenddocumentchecklabelsrerunhook }
+> firstaid -> \FirstAidNeededT {biditools}{sty}{....-..-.. v... Programming tools for bidi package}{ \def \firstaid at bidi@document at patch \endgroup ##1\begingroup ##2\firstaid at bidi@document at patch {\unexpanded {##1##2}}\edef \document {\expandafter \firstaid at bidi@document at patch \document \firstaid at bidi@document at patch }\AddToHook {enddocument/info}{\let \bidi at AfterEndDocumentCheckLabelsRerun \@firstofone \bidi at afterenddocumentchecklabelsrerunhook }}
> Extra code for next invocation:
> ---
> Rules:
diff --git a/required/firstaid/testfiles/firstaid-000.lvt b/required/firstaid/testfiles/firstaid-000.lvt
index 19f830a0..6b1aff42 100644
--- a/required/firstaid/testfiles/firstaid-000.lvt
+++ b/required/firstaid/testfiles/firstaid-000.lvt
@@ -8,7 +8,6 @@
\START
-\show\LaTeXFirstAidDate
-\show\LaTeXFirstAidVersion
+\ifcsname LaTeXFirstAidVersion\endcsname \typeout{File loaded in kernel}\fi
\END
diff --git a/required/firstaid/testfiles/firstaid-000.tlg b/required/firstaid/testfiles/firstaid-000.tlg
index 6adf7dd7..ed2129b9 100644
--- a/required/firstaid/testfiles/firstaid-000.tlg
+++ b/required/firstaid/testfiles/firstaid-000.tlg
@@ -1,8 +1,3 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
-> \LaTeXFirstAidDate=macro:
-->....-..-...
-l. ...\show\LaTeXFirstAidDate
-> \LaTeXFirstAidVersion=macro:
-->v1.0a.
-l. ...\show\LaTeXFirstAidVersion
+File loaded in kernel
diff --git a/required/firstaid/testfiles/firstaid-filehook.luatex.tlg b/required/firstaid/testfiles/firstaid-filehook.luatex.tlg
index 06362be4..354ec247 100644
--- a/required/firstaid/testfiles/firstaid-filehook.luatex.tlg
+++ b/required/firstaid/testfiles/firstaid-filehook.luatex.tlg
@@ -2,7 +2,7 @@ This is a generated file for the l3build validation system.
Don't change this file in any respect.
(filehook-ltx.sty
LaTeX3 Info: Defining command \AtBeginOfPackageFile with sig. 'smm' on line
-(LaTeX3) 65.
+(LaTeX3) 64.
LaTeX3 Info: Defining command \AtEndOfPackageFile with sig. 'smm' on line ...
LaTeX3 Info: Defining command \AtBeginOfClassFile with sig. 'smm' on line ...
LaTeX3 Info: Defining command \AtEndOfClassFile with sig. 'smm' on line ...
diff --git a/required/firstaid/testfiles/firstaid-filehook.tlg b/required/firstaid/testfiles/firstaid-filehook.tlg
index 06362be4..354ec247 100644
--- a/required/firstaid/testfiles/firstaid-filehook.tlg
+++ b/required/firstaid/testfiles/firstaid-filehook.tlg
@@ -2,7 +2,7 @@ This is a generated file for the l3build validation system.
Don't change this file in any respect.
(filehook-ltx.sty
LaTeX3 Info: Defining command \AtBeginOfPackageFile with sig. 'smm' on line
-(LaTeX3) 65.
+(LaTeX3) 64.
LaTeX3 Info: Defining command \AtEndOfPackageFile with sig. 'smm' on line ...
LaTeX3 Info: Defining command \AtBeginOfClassFile with sig. 'smm' on line ...
LaTeX3 Info: Defining command \AtEndOfClassFile with sig. 'smm' on line ...
diff --git a/required/firstaid/testfiles/firstaid-filehook.xetex.tlg b/required/firstaid/testfiles/firstaid-filehook.xetex.tlg
index 06362be4..354ec247 100644
--- a/required/firstaid/testfiles/firstaid-filehook.xetex.tlg
+++ b/required/firstaid/testfiles/firstaid-filehook.xetex.tlg
@@ -2,7 +2,7 @@ This is a generated file for the l3build validation system.
Don't change this file in any respect.
(filehook-ltx.sty
LaTeX3 Info: Defining command \AtBeginOfPackageFile with sig. 'smm' on line
-(LaTeX3) 65.
+(LaTeX3) 64.
LaTeX3 Info: Defining command \AtEndOfPackageFile with sig. 'smm' on line ...
LaTeX3 Info: Defining command \AtBeginOfClassFile with sig. 'smm' on line ...
LaTeX3 Info: Defining command \AtEndOfClassFile with sig. 'smm' on line ...
diff --git a/required/firstaid/version-peaking.unused b/required/firstaid/version-peaking.unused
new file mode 100644
index 00000000..ef9fcceb
--- /dev/null
+++ b/required/firstaid/version-peaking.unused
@@ -0,0 +1,194 @@
+% currently unused code
+
+% \subsection{Package version peeking}
+%
+% \begin{macrocode}
+%<@@=firstaid>
+\ExplSyntaxOn
+% \end{macrocode}
+%
+% \begin{macro}{\l_@@_line_tl}
+% \begin{macro}{\g_@@_pkg_ior}
+% \begin{macro}{\l_@@_needs_bool}
+% Some variables needed.
+% \begin{macrocode}
+\tl_new:N \l_@@_line_tl
+\tl_new:N \l_@@_stored_tl
+\tl_new:N \l_@@_target_tl
+\ior_new:N \g_@@_pkg_ior
+\bool_new:N \l_@@_needs_bool
+\scan_new:N \s_@@
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}[TF]{\firstaid_if_needed:nn}
+% \cs{firstaid_if_needed:nn} will check if version |#2| of package
+% |#1| requires first-aid treatment (that is, if the version installed
+% matches |#2|). It returns \meta{true} or \meta{false}, accordingly.
+% \begin{macrocode}
+\prg_new_protected_conditional:Npnn \firstaid_if_needed:nn #1 #2
+ { T, F, TF }
+ {
+ \cs_if_exist:cTF { ver@#1.sty }
+ {
+% \end{macrocode}
+%
+% If the file is already loaded, check if the loaded version matches,
+% and return \meta{true} or \meta{false}.
+% \begin{macrocode}
+ \str_if_eq:eeTF { \use:c { ver@#1.sty } } {#2}
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+ {
+% \end{macrocode}
+%
+% If the package is not read yet (\cs[no-index]{ver@\#1} is not
+% defined), then we will silently open the file and peek through its
+% contents with \cs{@@_peek_file:}.
+% \begin{macrocode}
+ \tl_set:Nn \l_@@_target_tl { {#1}[#2] }
+ \tl_clear:N \l_@@_stored_tl
+ \ior_open:Nn \g_@@_pkg_ior { #1.sty }
+ \@@_peek_file:
+ \ior_close:N \g_@@_pkg_ior
+ \bool_if:NTF \l_@@_needs_bool
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\FirstAidNeededT \firstaid_if_needed:nnT
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_peek_file:}
+% If the file isn't loaded yet, we'll read it looking for
+% \cs{ProvidesPackage} and read the argument to that and then check
+% the available version. There are a few limitations of when this
+% will work: the \cs{ProvidesPackage} cannot be within braces, and it
+% must be the first occurrence of the control sequence in the file.
+%
+% The file is read line by line, looking for \cs{ProvidesPackage}.
+% If the end of the file is reached, the boolean \cs{l_@@_needs_bool}
+% is set to false (a package without a \cs{ProvidesPackage} line is
+% set to \emph{not} need first-aid; this could be changed if needed).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_peek_file:
+ {
+ \ior_get:NNTF \g_@@_pkg_ior \l_@@_line_tl
+ {
+ \tl_if_in:NnTF \l_@@_line_tl { \ProvidesPackage }
+ { \exp_after:wN \@@_scan_provides_args:w \l_@@_line_tl \s_@@ }
+ { \@@_peek_file: }
+ }
+ { \bool_set_false:N \l_@@_needs_bool }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_scan_provides_args:w,
+% \@@_scan_provides_marg:,
+% \@@_marg_check:n,
+% \@@_put_provides_marg:w,
+% }
+% Now extract the tokens after \cs{ProvidesPackage}, and look for the
+% mandatory argument; the package name. Once done, call
+% \cs{@@_put_provides_marg:w} to put the mandatory argument into the
+% storage token list and call \cs{@@_start_opt_check:n} to look for
+% the optional argument.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_scan_provides_args:w
+ #1 \ProvidesPackage #2 \s_@@
+ { \@@_marg_check:n {#2} }
+\cs_new_protected:Npn \@@_scan_provides_marg:
+ {
+ \ior_get:NNTF \g_@@_pkg_ior \l_@@_line_tl
+ { \exp_args:NV \@@_marg_check:n \l_@@_line_tl }
+ { \bool_set_false:N \l_@@_needs_bool }
+ }
+\cs_new_protected:Npn \@@_marg_check:n #1
+ {
+ \tl_if_blank:nTF {#1}
+ { \@@_scan_provides_marg: }
+ { \@@_put_provides_marg:w #1 \s_@@ }
+ }
+\cs_new_protected:Npn \@@_put_provides_marg:w #1 #2 \s_@@
+ {
+ \tl_put_right:Nn \l_@@_stored_tl { {#1} }
+ \@@_start_opt_check:n {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_start_opt_check:n,
+% \@@_start_provides_opt:,
+% \@@_end_opt_check:n,
+% \@@_scan_provides_opt:,
+% \@@_empty_provides_opt:,
+% }
+% Look for the optional argument by checking that the first non-blank
+% token is a |[|, then grabbing lines one by one looking for an
+% unbraced |]| which ends the optional argument.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_start_opt_check:n #1
+ {
+ \tl_if_blank:nTF {#1}
+ { \@@_start_provides_opt: }
+ {
+ \str_if_eq:eeTF { \use_i_delimit_by_q_nil:nw #1 \q_nil } { [ }
+ { \@@_end_opt_check:n {#1} }
+ { \@@_empty_provides_opt: }
+ }
+ }
+\cs_new_protected:Npn \@@_start_provides_opt:
+ {
+ \ior_get:NNTF \g_@@_pkg_ior \l_@@_line_tl
+ { \exp_args:NV \@@_start_opt_check:n \l_@@_line_tl }
+ { \@@_empty_provides_opt: }
+ }
+\cs_new_protected:Npn \@@_scan_provides_opt:
+ {
+ \ior_get:NNTF \g_@@_pkg_ior \l_@@_line_tl
+ { \exp_args:NV \@@_end_opt_check:n \l_@@_line_tl }
+ { \bool_set_false:N \l_@@_needs_bool }
+ }
+\cs_new_protected:Npn \@@_end_opt_check:n #1
+ {
+ \tl_if_in:nnTF {#1} { ] }
+ { \@@_put_opt_arg_end:w #1 \s_@@ }
+ {
+ \tl_put_right:Nn \l_@@_stored_tl {#1}
+ \@@_scan_provides_opt:
+ }
+ }
+\cs_new_protected:Npn \@@_empty_provides_opt:
+ { \use:x { \@@_put_opt_arg_end:w [ \c_novalue_tl ] \s_@@ } }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_put_opt_arg_end:w}
+% When a |]| is found, add everything up to it to the storage token
+% list and compare it with the target token list saved earler.
+% If they are the same, return true, otherwise false.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_put_opt_arg_end:w #1 ] #2 \s_@@
+ {
+ \tl_put_right:Nn \l_@@_stored_tl { #1] }
+ \str_if_eq:NNTF \l_@@_target_tl \l_@@_stored_tl
+ { \bool_set_true:N \l_@@_needs_bool }
+ { \bool_set_false:N \l_@@_needs_bool }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\ExplSyntaxOff
+%<@@=>
+% \end{macrocode}
More information about the latex3-commits
mailing list.