summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/qstest/makematch.sty
blob: c57a8a66b226fb2b21766259990b365757d516ec (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
%%
%% This is file `makematch.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% makematch.dtx  (with options: `package,etex')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from makematch.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file makematch.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%%
%% Copyright (C) 2006, 2007 QuinScape GmbH
%% http://www.quinscape.de
\NeedsTeXFormat{LaTeX2e}
\def\next$#1: #2.dtx #3 #4-#5-#6 #7${%
  \ProvidesPackage{#2}[#4/#5/#6 1.#3 Pattern matching with
  wildcards]
}
\next
$Id: makematch.dtx 7925 2007-02-23 14:22:19Z dkastrup $
\newcommand\MakeMatcher[3][\relax]{%
 \edef#2{\detokenize{#3}}%
  \def\qst@mmtmp##1##2#1{\qst@parseonecase{##1}{##2}}%
  \let\qst@comma= #1\relax
  \edef#2##1{\noexpand\qst@setup##1%
    \expandafter\qst@parsestart\expandafter\@firstoftwo
    #2#1{#1\m@ne}\noexpand\qst@finish}}
\long\def\qst@matchalways#1#2#3{#2}
\long\def\qst@matchnever#1#2#3{#3}
\def\qst@setup{\let\MatchedTarget\@undefined
  \let\qst@finish\@secondoftwo
  \futurelet\qst@matchlist\qst@setupii}
\def\qst@setupii{\ifcase
    \ifcat\noexpand\qst@matchlist\bgroup\@ne\fi
    \ifx\qst@matchlist[\tw@\fi %]
    \m@ne
  \or
    \expandafter\MakeMatchTarget\expandafter\qst@matchlist
  \or
    \expandafter\qst@setupiii
  \else \expandafter\@gobble
  \fi}
\def\qst@setupiii[#1]{\MakeMatchTarget[{#1}]\qst@matchlist}
\def\qst@parsestart#1#2{%
  \ifcase
    \ifx\qst@comma#2\@ne\fi
    \ifx\qst@comma\relax
      \else\ifx!#2#1\tw@\@ne\fi
    \fi
    \thr@@
  \or
    \expandafter\qst@parsestart
    \expandafter\@firstoftwo
  \or
    \expandafter\qst@parsestart
    \expandafter\@secondoftwo
  \or
    \expandafter\qst@mmtmp
    \expandafter#1%
    \expandafter#2%
  \fi
}
\def\qst@afterfi#1#2\fi{\fi#1}
\def\qst@parseonecase#1#2{%
  \noexpand\qst@checkname {\qst@parsewild#2*\,23456789*}%
  \noexpand#1\qst@parsestart\@firstoftwo}
\def\qst@parsewild#1*#2\,#3#4*{%
  #1%
  \ifx\,#2\,%
  \else
    #####3%
    \qst@afterfi{\qst@skipwild#2\,#4*}%
  \fi}
\def\qst@skipwild#1*#2\,{%
  #1%
  \ifcase
    \ifx *#1*\ifx\,#2\,\else \@ne \fi \fi
    \tw@
  \or
    \expandafter\qst@skipwild
  \or
    \expandafter\qst@parsewild\expandafter*%
  \fi#2\,}
\def\qst@checkname#1{%
  \def\qst@mmtmp##1\,#1\,{#1\,\@nil}%
  \expandafter\expandafter\expandafter\qst@checknameii
  \expandafter\qst@mmtmp
  \expandafter\,\qst@matchlist\,#1\,\@nil}
\def\qst@checknameii#1\,#2\@nil#3{%
  \ifcase
    \ifx\@nil#3\@ne\fi
    \ifx\@nil#2\@nil \tw@\fi
    \m@ne
  \or
    \expandafter\qst@checknamenomatch
  \or
    \expandafter\qst@checknamematch
  \fi \expandafter\qst@checknameii\qst@mmtmp#1\,#2#3}
\def\qst@checknamenomatch#1\@nil#2{}
\def\qst@checknamematch#1\qst@mmtmp#2\,#3\@nil{%
  \def\MatchedTarget{#2}%
  \let\qst@finish}
\def\RemoveMatched#1{\ifx#1\MatchedTarget
    \let#1\@empty
  \else
    \expandafter\def\expandafter\qst@mmtmp
    \expandafter##\expandafter1\expandafter\,\MatchedTarget\,{##1\,}%
    \expandafter\def\expandafter#1\expandafter{%
      \romannumeral\expandafter\expandafter\expandafter\z@
      \expandafter\qst@remmat
      \romannumeral\expandafter\expandafter\expandafter\z@
      \expandafter\qst@mmtmp\expandafter\,#1\,\@nil}%
  \fi}
\def\qst@remmat\,#1\,\@nil{#1}
\newcommand\MakeMatchTarget[3][\relax]{%
  \def\qst@mmtmp##1#1##2{##1\noexpand\,\qst@mmtmp##2}%
  \edef#2{\expandafter\qst@mmtmp\expandafter
    \@gobbletwo\expandafter#1\detokenize{#3}\iffalse#1\fi}%
}
\endinput
%%
%% End of file `makematch.sty'.