summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ydoc/ydocstrip.tex
blob: 25ec2c5e63f2fe02e3c00635c7f18d647cd2f5cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
%&pdflatex
\input docstrip

\def\checkOption<#1{%
  \ifcase
    \ifx*#10\else \ifx/#11\else
    \ifx+#12\else \ifx-#13\else
    \ifx<#14\else
    \ifx=#15\else
    \ifx!#16\else
    10\fi\fi\fi\fi\fi\fi\fi\relax
  \expandafter\starOption\or
  \expandafter\slashOption\or
  \expandafter\plusOption\or
  \expandafter\minusOption\or
  \expandafter\verbOption\or
  \expandafter\varOption\or
  \expandafter\valueOption\else
  \expandafter\doOption\fi
  #1}

\def\varOption =#1#2>#3\endLine{{%
    \ifx*#1\relax
        \edef\varStop{\perCent<=/#2>}%
        \global\expandafter\let\csname ydocstrip@var@#2\endcsname\empty%
        \expandafter\def\csname ydocstrip@var@#2\endcsname##1{}%
        \loop
            \ifeof\inFile
                \errmessage{Source file ended while reading a multi-line variable content!}%
            \fi
            \read\inFile to \inLine
        \if 1\ifx\inLine\varStop 0\fi 1% if not inLine==varStop
            \expandafter\xdef\csname ydocstrip@var@#2\endcsname{\csname ydocstrip@var@#2\endcsname^^J\inLine}%
            \maybeMsg{.}%
        \repeat
    \else
    \ifx/#1\relax
        \errmessage{Error in expression: spurious '<=/#2>'}%
    \else
    \ifx+#1\relax
        \expandafter\ifx\csname ydocstrip@var@#2\endcsname\relax
            \expandafter\xdef\csname ydocstrip@var@#2\endcsname{#3}%
        \else
            \expandafter\xdef\csname ydocstrip@var@#2\endcsname{\csname ydocstrip@var@#2\endcsname^^J#3}%
        \fi
    \else
        \expandafter\gdef\csname ydocstrip@var@#1#2\endcsname{#3}%
    \fi
    \fi
    \fi
}}


\def\valueOption !#1>#2\endLine{%
    \begingroup
    \expandafter\let\expandafter\var\csname ydocstrip@var@#1\endcsname
    \ifx\var\relax
        \errmessage{Used variable '#1' was never defined!}%
    \else
    \ifx\var\empty\else
        \def\do##1##2##3{%
            \StreamPut##1{\csname ydocstrip@var@#1\endcsname}%
        }%
        \activefiles
    \fi
    \fi
    \endgroup
}