%%
%% This is file `xpatch.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xpatch.dtx  (with options: `package')
%% 
%% Do not distribute this file without also distributing the
%% source files specified above.
%% 
%% File: xpatch.dtx (C) Copyright 2012-2020 Enrico Gregorio
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "xpatch bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
\RequirePackage{expl3}
\GetIdInfo$Id: xpatch.dtx 0.3a 2020-03-25 12:00:00Z Enrico $
          {Extending etoolbox patching commands}
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\@ifpackagelater { expl3 } { 2011/10/09 }
  { }
  {
    \PackageError { xpatch } { Support~package~l3kernel~too~old. }
      {
        Please~install~an~up~to~date~version~of~l3kernel~
        using~your~TeX~package~manager~or~from~CTAN.\\ \\
        Loading~xpatch~will~abort!
      }
    \tex_endinput:D
  }
\RequirePackage{xparse,etoolbox}
\cs_generate_variant:Nn \tl_if_in:NnT { Nx }
\bool_new:N \l__xpatch_protect_bool
\cs_if_exist:NF \c_backslash_str
  { \tl_const:Nx \c_backslash_str { \cs_to_str:N \\ } }
\tl_const:Nx \c__xpatch_bizarre_tl
  { \tl_to_str:n { **)-(**/**]-[** } }
\tl_new:N \l__xpatch_name_tl
\tl_new:N \l__xpatch_repl_tl
\cs_new:Npn \xpatch_main:NN #1 #2
  {
    \bool_set_false:N \l__xpatch_protect_bool
   \tl_set:Nx \l__xpatch_name_tl { \cs_to_str:N #2  }
   \tl_set:Nx \l__xpatch_repl_tl
     { \c__xpatch_bizarre_tl \cs_replacement_spec:N #2 }
   \tl_if_in:NxT \l__xpatch_repl_tl
     {
      \c__xpatch_bizarre_tl
      \token_to_str:N \protect \c_space_tl
      \c_backslash_str \l__xpatch_name_tl \c_space_tl \c_space_tl
     }
     {
      \bool_set_true:N \l__xpatch_protect_bool
      \tl_put_right:Nn \l__xpatch_name_tl { \c_space_tl }
     }
   \tl_if_in:NxT \l__xpatch_repl_tl
     {
      \c__xpatch_bizarre_tl
      \token_to_str:N \x@protect \c_space_tl
        \c_backslash_str \l__xpatch_name_tl \c_backslash_str
     }
     {
      \bool_set_true:N \l__xpatch_protect_bool
      \tl_put_right:Nn \l__xpatch_name_tl { \c_space_tl }
     }
   \tl_if_in:NxT \l__xpatch_repl_tl
     {
      \c__xpatch_bizarre_tl
      \token_to_str:N \@protected@testopt \c_space_tl
        \c_backslash_str \l__xpatch_name_tl
        \c_space_tl \c_backslash_str \c_backslash_str
     }
     {
      \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str }
     }
   \tl_if_in:NxT \l__xpatch_repl_tl
     {
      \c__xpatch_bizarre_tl
      \token_to_str:N \@protected@testopt \c_space_tl
        \c_backslash_str \l__xpatch_name_tl
        \c_backslash_str \c_backslash_str
     }
     {
      \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str }
     }
   \tl_if_in:NxT \l__xpatch_repl_tl
     {
      \c__xpatch_bizarre_tl
      \token_to_str:N \@testopt \c_space_tl
        \c_backslash_str \c_backslash_str \l__xpatch_name_tl
     }
     {
      \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str }
     }
   \bool_if:NT \l__xpatch_protect_bool
     {
      \tl_set:Nx \l__xpatch_repl_tl
        { \c__xpatch_bizarre_tl
          \exp_after:wN \cs_replacement_spec:N
            \cs:w \l__xpatch_name_tl \cs_end: }
      \tl_if_in:NxT \l__xpatch_repl_tl
        {
         \c__xpatch_bizarre_tl
         \token_to_str:N \@protected@testopt \c_space_tl
           \c_backslash_str \l__xpatch_name_tl
           \c_space_tl \c_backslash_str \c_backslash_str
        }
        {
         \tl_put_left:Nn \l__xpatch_name_tl { \c_backslash_str }
        }
     }
   \exp_after:wN #1 \cs:w \l__xpatch_name_tl \cs_end:
  }
\NewDocumentCommand{\xpatchcmd}{}{ \xpatch_main:NN \patchcmd }
\NewDocumentCommand{\xpretocmd}{}{ \xpatch_main:NN \pretocmd }
\NewDocumentCommand{\xapptocmd}{}{ \xpatch_main:NN \apptocmd }
\NewDocumentCommand{\xshowcmd} {}{ \xpatch_main:NN \show     }
\cs_generate_variant:Nn \xpatch_main:NN { Nc }
\NewDocumentCommand{\xpatchbibmacro} { m }
  { \xpatch_main:Nc \patchcmd { abx@macro@ \tl_to_str:n {#1} } }
\NewDocumentCommand{\xpretobibmacro} { m }
  { \xpatch_main:Nc \pretocmd { abx@macro@ \tl_to_str:n {#1} } }
\NewDocumentCommand{\xapptobibmacro} { m }
  { \xpatch_main:Nc \apptocmd { abx@macro@ \tl_to_str:n {#1} } }
\NewDocumentCommand{\xshowbibmacro} { m }
  { \xpatch_main:Nc \show { abx@macro@ \tl_to_str:n {#1} } }
\NewDocumentCommand{\xpatchfieldformat} { O{*} m }
  { \xpatch_main:Nc \patchcmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpretofieldformat} { O{*} m }
  { \xpatch_main:Nc \pretocmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xapptofieldformat} { O{*} m }
  { \xpatch_main:Nc \apptocmd { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xshowfieldformat} { O{*} m }
  { \xpatch_main:Nc \show { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpatchnameformat} { O{*} m }
  { \xpatch_main:Nc \patchcmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpretonameformat} { O{*} m }
  { \xpatch_main:Nc \pretocmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xapptonameformat} { O{*} m }
  { \xpatch_main:Nc \apptocmd { abx@nfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xshownameformat} { O{*} m }
  { \xpatch_main:Nc \show { abx@ffd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpatchlistformat} { O{*} m }
  { \xpatch_main:Nc \patchcmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpretolistformat} { O{*} m }
  { \xpatch_main:Nc \pretocmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xapptolistformat} { O{*} m }
  { \xpatch_main:Nc \apptocmd { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xshowlistformat} { O{*} m }
  { \xpatch_main:Nc \show { abx@lfd@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpatchindexfieldformat} { O{*} m }
  { \xpatch_main:Nc \patchcmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpretoindexfieldformat} { O{*} m }
  { \xpatch_main:Nc \pretocmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xapptoindexfieldformat} { O{*} m }
  { \xpatch_main:Nc \apptocmd { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xshowindexfieldformat} { O{*} m }
  { \xpatch_main:Nc \show { abx@fid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpatchindexnameformat} { O{*} m }
  { \xpatch_main:Nc \patchcmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpretoindexnameformat} { O{*} m }
  { \xpatch_main:Nc \pretocmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xapptoindexnameformat} { O{*} m }
  { \xpatch_main:Nc \apptocmd { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xshowindexnameformat} { O{*} m }
  { \xpatch_main:Nc \show { abx@nid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpatchindexlistformat} { O{*} m }
  { \xpatch_main:Nc \patchcmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpretoindexlistformat} { O{*} m }
  { \xpatch_main:Nc \pretocmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xappindextolistformat} { O{*} m }
  { \xpatch_main:Nc \apptocmd { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xshowindexlistformat} { O{*} m }
  { \xpatch_main:Nc \show { abx@lid@ \tl_to_str:n {#1} @ \tl_to_str:n {#2} } }
\NewDocumentCommand{\xpatchbibdriver} { m }
  { \exp_args:Nc \patchcmd {blx@bbx@#1} }
\NewDocumentCommand{\xpretobibdriver} { m }
  { \exp_args:Nc \pretocmd {blx@bbx@#1} }
\NewDocumentCommand{\xapptobibdriver} { m }
  { \exp_args:Nc \apptocmd {blx@bbx@#1} }
\NewDocumentCommand{\xshowbibdriver} { m }
  { \exp_args:Nc \show {blx@bbx@#1} }
%% 
%%
%% End of file `xpatch.sty'.
