summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cprotect/cprotect.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/cprotect/cprotect.sty')
-rw-r--r--Master/texmf-dist/tex/latex/cprotect/cprotect.sty152
1 files changed, 152 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/cprotect/cprotect.sty b/Master/texmf-dist/tex/latex/cprotect/cprotect.sty
new file mode 100644
index 00000000000..d340995fb55
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/cprotect/cprotect.sty
@@ -0,0 +1,152 @@
+%%
+%% This is file `cprotect.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% cprotect.dtx (with options: `package')
+%% ----------------------------------------------------------------
+%% cprotect --- verbatim in macro arguments
+%% E-mail: bruno@le-floch.fr
+%% Released under the LaTeX Project Public License v1.3c or later
+%% See http://www.latex-project.org/lppl.txt
+%% ----------------------------------------------------------------
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{cprotect}[2010/12/30 v1.0 (Bruno Le Floch)]
+\RequirePackage{ifthen}
+\RequirePackage{suffix}
+\newwrite\CPT@WriteOut
+\newcounter{CPT@WriteCount}
+\newcommand{\CPT@Write}[1]{%
+ \stepcounter{CPT@WriteCount}%
+ \immediate\openout\CPT@WriteOut=\jobname-%
+ \arabic{CPT@WriteCount}.cpt%
+ \newlinechar`\^^M%
+ \immediate\write\CPT@WriteOut{#1}%
+ \immediate\closeout\CPT@WriteOut%
+ \aftergroup\CPT@setLastFileName%
+}
+\newcommand{\CPT@setLastFileName}{%
+ \def\CPT@lastFileName{\jobname-\arabic{CPT@WriteCount}.cpt}}
+\newcommand{\CPT@input@last}{%
+ \expandafter\protect\expandafter\input
+ \expandafter{\CPT@lastFileName}}
+\newcommand{\makeallletters}{%
+ \count0=0\relax %
+ \loop %
+ \catcode\count0=11\relax %
+ \advance\count0 by 1\relax %
+ \ifnum\count0<256 %
+ \repeat %
+}
+\newcommand\ReadVerbatimUntil[2][]{%
+ \def\CPT@commandatend{#2}%
+ \begingroup #1%
+ \makeallletters%
+ \CPT@setup}
+\WithSuffix\newcommand\ReadVerbatimUntil*[2][]{%
+ \def\CPT@commandatend{#2}%
+ \begingroup #1%
+ \makeallletters%
+ \CPT@starsetup}
+\newcommand{\CPT@def}[2]{\expandafter\def\expandafter#1%
+ \expandafter##\expandafter1#2}
+\newcommand{\CPT@setup}[1]{%
+ \def\CPT@delimiter{#1}%
+ \CPT@def\CPT@readPreText\CPT@delimiter{%
+ \def\CPT@preText{##1}\CPT@readPostText}%
+ \CPT@def\CPT@readPostText\CPT@delimiter{%
+ \def\CPT@postText{##1}\CPT@readBegin}%
+ \CPT@def\CPT@readBegin\CPT@delimiter{%
+ \def\CPT@begin{##1}\CPT@readEnd}%
+ \CPT@def\CPT@readEnd\CPT@delimiter{%
+ \def\CPT@end{##1}\CPT@readContent}%
+ \CPT@readPreText%
+}
+\newcommand{\CPT@starsetup}[1]{\CPT@setup#1#1#1}
+\def\CPT@qend{\CPT@qend}
+\newcounter{CPT@numB}
+\newcommand{\CPT@store}[1]{\edef\CPT@storage{\CPT@storage#1}}
+\newcommand{\CPT@readContent}{%
+ \CPT@def\CPT@gobbleOneB\CPT@begin##2{%
+ \ifx\CPT@qend##2\CPT@store{##1}\addtocounter{CPT@numB}{-1}%
+ \else\CPT@store{##1\CPT@begin}\stepcounter{CPT@numB}%
+ \expandafter\CPT@gobbleOneB\expandafter##2\fi}%
+ %
+ \CPT@def\CPT@gobbleUntilE\CPT@end{%
+ \edef\CPT@tempi{##1\CPT@begin}%
+ \expandafter\CPT@gobbleOneB\CPT@tempi\CPT@qend%
+ \ifthenelse{\value{CPT@numB}<0}{%
+ \CPT@store{\CPT@postText}%
+ \CPT@Write{\CPT@storage}\endgroup%
+ \CPT@commandatend%
+ }{%
+ \CPT@store{\CPT@end}\CPT@gobbleUntilE%
+ }%
+ }%
+ \setcounter{CPT@numB}{0}%
+ \def\CPT@storage{\CPT@preText}%
+ \CPT@gobbleUntilE%
+}
+\newcommand{\cprotect}[1]{\def\CPT@cs{#1}%
+ \afterassignment\CPT@A\let\CPT@next}
+\begingroup
+ \catcode`\{=11 \catcode`\}=11 \catcode`\+=11
+ \catcode`\(=1 \catcode`\)=2
+ \gdef\CPT@A(%
+ \ifx\CPT@next\bgroup%
+ \expandafter\CPT@n{%
+ \else%
+ \expandafter\CPT@N%
+ \fi)
+ \gdef\CPT@n{(\ReadVerbatimUntil*(%
+ \CPT@cs(\CPT@input@last))+{+}+)%
+ \gdef\CPT@N(\expandafter\CPT@n{\CPT@next })%
+\endgroup
+\newcommand{\cMakeRobust}[1]{%
+ \def\CPT@cs@name{\expandafter\@gobble\string#1}%
+ \expandafter\let\csname CPT@old@\CPT@cs@name\endcsname #1%
+ \expandafter\def\csname\CPT@cs@name\endcsname{%
+ \expandafter\cprotect\csname CPT@old@\CPT@cs@name\endcsname}%
+}
+\newcommand{\CPTbegin}[1]{%
+ \def\CPT@commandatend{\begin{#1}\CPT@input@last\end{#1}}%
+ \begingroup%
+ \CPT@env@setup{#1}%
+ \makeallletters%
+ \CPT@readContent%
+}
+\begingroup\catcode`\/=0
+/begingroup/catcode`/\=11
+ /catcode`/{=11 /catcode`/}=11 /catcode`/-=11
+ /catcode`/(=1 /catcode`/)=2
+ /gdef/CPT@env@setup#1(%
+ /def/CPT@preText(\relax )%
+ /def/CPT@postText(\relax )%
+ /def/CPT@begin(\begin{#1})%
+ /def/CPT@end(\end{#1})%
+ )
+/endgroup
+\endgroup
+\def\cprotEnv\begin{\CPTbegin}
+%%
+%% Copyright (C) 2010 by Bruno Le Floch <bruno@le-floch.fr>
+%%
+%% This work 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 work is "maintained" (as per LPPL maintenance status) by
+%% Bruno Le Floch.
+%%
+%% This work consists of the file cprotect.dtx
+%% and the derived files cprotect.ins,
+%% cprotect.pdf and
+%% cprotect.sty.
+%%
+%%
+%% End of file `cprotect.sty'.