summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/regexpatch/regexpatch.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-07-15 14:45:37 +0000
committerKarl Berry <karl@freefriends.org>2012-07-15 14:45:37 +0000
commit4253f6c35ba914a69073485658b9ad82389c9faa (patch)
treecd7a73d5898f1e691a0ac1c5da263958e162e43b /Master/texmf-dist/tex/latex/regexpatch/regexpatch.sty
parent3a8d2268677f2d2f3320c4410d9c34f6e98241ac (diff)
regexpatch 0.1a (8jun12)
git-svn-id: svn://tug.org/texlive/trunk@27067 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/regexpatch/regexpatch.sty')
-rw-r--r--Master/texmf-dist/tex/latex/regexpatch/regexpatch.sty103
1 files changed, 48 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/latex/regexpatch/regexpatch.sty b/Master/texmf-dist/tex/latex/regexpatch/regexpatch.sty
index 12cd49e36d6..511e44ddd58 100644
--- a/Master/texmf-dist/tex/latex/regexpatch/regexpatch.sty
+++ b/Master/texmf-dist/tex/latex/regexpatch/regexpatch.sty
@@ -24,7 +24,7 @@
%% The released version of this bundle is available from CTAN.
%%
\RequirePackage{expl3}
-\GetIdInfo$Id: regexpatch.dtx 0.1dev 2012-04-15 12:00:00Z Enrico $
+\GetIdInfo$Id: regexpatch.dtx 0.1a 2012-06-07 12:00:00Z Enrico $
{Extending etoolbox patching commands}
\ProvidesExplPackage
{\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
@@ -39,7 +39,7 @@
}
\tex_endinput:D
}
-\RequirePackage{xparse,l3regex,etoolbox}
+\RequirePackage{xparse,l3regex}
\bool_new:N \l_xpatch_protect_bool
\bool_new:N \l_xpatch_optional_bool
\bool_new:N \l_xpatch_patchable_bool
@@ -50,8 +50,8 @@
\tl_new:N \l_xpatch_arg_tl
\tl_new:N \l_xpatch_replacement_tl
\tl_new:N \l_xpatch_type_tl % for debugging messages
-\cs_generate_variant:Nn \regex_match:nnT {nVT}
-\cs_new:Npn \xpatch_main_check:N #1
+\cs_generate_variant:Nn \regex_match:nnT {nV}
+\cs_new_protected:Npn \xpatch_main_check:N #1
{
\bool_set_false:N \l_xpatch_protect_bool
\bool_set_false:N \l_xpatch_optional_bool
@@ -118,13 +118,13 @@
\l_xpatch_repl_tl
}
}
-\cs_new:Npn \xpatch_main:NNN #1 #2 #3
+\cs_new_protected:Npn \xpatch_main:NNN #1 #2 #3
{
\cs_if_exist:NTF #3
{
\xpatch_main_check:N #3
\bool_if:NT \l_xpatch_tracing_bool
- { \xpatch_message_cstype:n #3 }
+ { \xpatch_message_cstype:N #3 }
\exp_after:wN #1 \cs:w \l_xpatch_name_tl \cs_end:
}
{
@@ -137,31 +137,27 @@
#2
}
}
-\cs_new:Npn \xpatch_get_all:N #1
+\cs_new_protected:Npn \xpatch_get_all:N #1
{
- \exp_args:NNf \tl_set:Nn \l_xpatch_prefix_tl
- {\token_get_prefix_spec:N #1 }
- \exp_args:NNnx \tl_set_rescan:Nnn
- \l_xpatch_prefix_tl { } \l_xpatch_prefix_tl
- \exp_args:NNf \tl_set:Nn \l_xpatch_arg_tl
- {\token_get_arg_spec:N #1 }
- \exp_args:NNnx \tl_set_rescan:Nnn
- \l_xpatch_arg_tl { } \l_xpatch_arg_tl
- \exp_args:NNf \tl_set:Nn \l_xpatch_replacement_tl
- {\token_get_replacement_spec:N #1 }
- \exp_args:NNnx \tl_set_rescan:Nnn
- \l_xpatch_replacement_tl { } \l_xpatch_replacement_tl
+ \tl_set:Nf \l_xpatch_prefix_tl { \token_get_prefix_spec:N #1 }
+ \tl_set_rescan:Nnx \l_xpatch_prefix_tl { } \l_xpatch_prefix_tl
+ \tl_set:Nf \l_xpatch_arg_tl { \token_get_arg_spec:N #1 }
+ \tl_set_rescan:Nnx \l_xpatch_arg_tl { } \l_xpatch_arg_tl
+ \tl_set:Nf \l_xpatch_replacement_tl { \token_get_replacement_spec:N #1 }
+ \tl_set_rescan:Nnx \l_xpatch_replacement_tl { } \l_xpatch_replacement_tl
}
-\cs_new:Npn \xpatch_rebuild:N #1
+\cs_new_protected:Npn \xpatch_rebuild:N #1
{
- \tl_clear:N \l_tmpa_tl
- \tl_put_right:NV \l_tmpa_tl \l_xpatch_prefix_tl
- \tl_put_right:Nn \l_tmpa_tl { \tex_def:D #1 }
- \tl_put_right:NV \l_tmpa_tl \l_xpatch_arg_tl
- \tl_put_right:No \l_tmpa_tl { \exp_after:wN {\l_xpatch_replacement_tl} }
- \tl_use:N \l_tmpa_tl
+ \use:x
+ {
+ \exp_not:V \l_xpatch_prefix_tl
+ \tex_def:D
+ \exp_not:N #1
+ \exp_not:V \l_xpatch_arg_tl
+ { \exp_not:V \l_xpatch_replacement_tl }
+ }
}
-\cs_new:Npn \xpatch_check_patchable:N #1
+\cs_new_protected:Npn \xpatch_check_patchable:N #1
{
\cs_if_exist:NTF #1
{
@@ -192,7 +188,7 @@
}
}
}
-\cs_new:Npn \xpatch_pretocmd:Nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \xpatch_pretocmd:Nnnn #1 #2 #3 #4
{
\xpatch_check_patchable:N #1
\bool_if:NTF \l_xpatch_patchable_bool
@@ -205,7 +201,7 @@
#4
}
}
-\cs_new:Npn \xpatch_apptocmd:Nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \xpatch_apptocmd:Nnnn #1 #2 #3 #4
{
\xpatch_check_patchable:N #1
\bool_if:NTF \l_xpatch_patchable_bool
@@ -218,76 +214,76 @@
#4
}
}
-\cs_new:Npn \xpatch_regexpatchcmd_all:Nnnnn #1 #2 #3 #4 #5
+\cs_new_protected:Npn \xpatch_regexpatchcmd_all:Nnnnn #1 #2 #3 #4 #5
{
\xpatch_check_patchable:N #1
\bool_if:NTF \l_xpatch_patchable_bool
{
- \regex_replace_all:nnN { #2 } { #3 } \l_xpatch_replacement_tl
- \xpatch_rebuild:N #1
- #4
+ \regex_replace_all:nnNTF { #2 } { #3 } \l_xpatch_replacement_tl
+ { \xpatch_rebuild:N #1 #4 }
+ { #5 }
}
{
#5
}
}
-\cs_new:Npn \xpatch_regexpatchcmd_once:Nnnnn #1 #2 #3 #4 #5
+\cs_new_protected:Npn \xpatch_regexpatchcmd_once:Nnnnn #1 #2 #3 #4 #5
{
\xpatch_check_patchable:N #1
\bool_if:NTF \l_xpatch_patchable_bool
{
- \regex_replace_once:nnN { #2 } { #3 } \l_xpatch_replacement_tl
- \xpatch_rebuild:N #1
- #4
+ \regex_replace_once:nnNTF { #2 } { #3 } \l_xpatch_replacement_tl
+ { \xpatch_rebuild:N #1 #4 }
+ { #5 }
}
{
#5
}
}
-\cs_new:Npn \xpatch_patchcmd_once:Nnnnn #1 #2 #3 #4 #5
+\cs_new_protected:Npn \xpatch_patchcmd_once:Nnnnn #1 #2 #3 #4 #5
{
\xpatch_check_patchable:N #1
\bool_if:NTF \l_xpatch_patchable_bool
{
\tl_set:Nn \l_tmpa_tl { #2 }
\tl_set:Nn \l_tmpb_tl { #3 }
- \regex_replace_once:nnN
+ \regex_replace_once:nnNTF
{ \u{l_tmpa_tl} }
{ \u{l_tmpb_tl} }
\l_xpatch_replacement_tl
- \xpatch_rebuild:N #1
- #4
+ { \xpatch_rebuild:N #1 #4 }
+ { #5 }
}
{
#5
}
}
-\cs_new:Npn \xpatch_patchcmd_all:Nnnnn #1 #2 #3 #4 #5
+\cs_new_protected:Npn \xpatch_patchcmd_all:Nnnnn #1 #2 #3 #4 #5
{
\xpatch_check_patchable:N #1
\bool_if:NTF \l_xpatch_patchable_bool
{
\tl_set:Nn \l_tmpa_tl { #2 }
\tl_set:Nn \l_tmpb_tl { #3 }
- \regex_replace_all:nnN
+ \regex_replace_all:nnNTF
{ \u{l_tmpa_tl} }
{ \u{l_tmpb_tl} }
\l_xpatch_replacement_tl
- \xpatch_rebuild:N #1
- #4
+ { \xpatch_rebuild:N #1 #4 }
+ { #5 }
}
{
#5
}
}
-\cs_new:Npn \xpatch_message:n #1
+\cs_new_protected:Npn \xpatch_message:n #1
{
\bool_if:NT \l_xpatch_tracing_bool
{
\msg_term:x { xpatch~message \\ #1 }
}
}
-\cs_new:Npn \xpatch_message_cstype:n #1
+\cs_new:Npn \xpatch_message_cstype:N #1
{
\prg_case_str:onn { \l_xpatch_type_tl }
{
@@ -379,8 +375,8 @@
\NewDocumentCommand{\xpatchcmd}{ s }
{
\IfBooleanTF{#1}
- { \xpatch_main:NNN \xpatch_patchcmd_all:Nnnnn \use_none:nn }
- { \xpatch_main:NNN \xpatch_patchcmd_once:Nnnnn \use_none:nn }
+ { \xpatch_main:NNN \xpatch_patchcmd_all:Nnnnn \use_none:nnn }
+ { \xpatch_main:NNN \xpatch_patchcmd_once:Nnnnn \use_none:nnn }
}
\cs_generate_variant:Nn \xpatch_main:NNN {NNc}
\NewDocumentCommand{\xshowbibmacro} { s m }
@@ -474,13 +470,10 @@
\bool_if:NTF \l_xpatch_optional_bool
{
\tl_set:Nx \l_xpatch_name_tl { \tl_tail:V \l_xpatch_name_tl }
- \exp_args:NNf \tl_set:Nn \l_xpatch_prefix_tl
- {\token_get_prefix_spec:N #1 }
+ \tl_set:Nf \l_xpatch_prefix_tl { \token_get_prefix_spec:N #1 }
\tl_clear:N \l_xpatch_prefix_tl
- \exp_args:NNnx \tl_set_rescan:Nnn
- \l_xpatch_prefix_tl { } \l_xpatch_prefix_tl
- \exp_args:NNV \tl_set_eq:Nc \l_xpatch_replacement_tl
- { \l_xpatch_name_tl }
+ \tl_set_rescan:Nnx \l_xpatch_prefix_tl { } \l_xpatch_prefix_tl
+ \tl_set_eq:Nc \l_xpatch_replacement_tl { \l_xpatch_name_tl }
\tl_set:Nn \l_tmpa_tl { { #2 } }
\regex_replace_once:nnN { \cB. .* \cE. \Z} { \u{l_tmpa_tl} }
\l_xpatch_replacement_tl