summaryrefslogtreecommitdiff
path: root/fonts/malvern/tex/pdcutil.tex
blob: e2133c292888fd6f6fb799a1d932f79599016dcb (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
% pdcutil.tex 1.1.7 1994/07/20 -- various ``utility'' macros
% Copyright 1994 P. Damian Cugley

%%% @TeX-macro-file {
%%%   filename       = "pdcutil.tex",
%%%   version        = "1.1.7",
%%%   date           = "1994/07/20",
%%%   package        = "Malvern 1.1",
%%%   author         = "P. Damian Cugley",
%%%   email          = "damian.cugley@comlab.ox.ac.uk",
%%%   address        = "Oxford University Computing Laboratory,
%%%                     Parks Road, Oxford  OX1 3QD, UK",
%%%   codetable      = "USASCII",
%%%   keywords       = "A few useful macros used by other macro files",
%%%   supported      = "Maybe",
%%%   abstract       = "Character programs for the Malvern
%%%                     font family.",
%%%   dependencies   = "other program files",
%%% }

%{{{ pdcutil.tex
%  Copyright (c) 1991, 1992, 1993 Damian Cugley.

\ifx\utilsversion\UNDEFINED
    \let\next\relax
\else
    \message{Warning: pdcutil.tex \string\input\space more than once.}
    \let\next=\endinput
\fi
\next

\begingroup\catcode`\%=12 \toks0={\endgroup
	\gdef\utilsversion{1.1.7} \gdef\lastedit{pdc 1994/07/20}
}\the\toks0
\message{\utilsversion\space \lastedit}

%{{{  List macros

% TeXbook pp.378-9
%  Note -- parameters in different order!

\toksdef\toksa=0
\toksdef\toksb=1
\toksdef\toksc=2

\long\def\prepend#1#2%  	#1 := <#2> + #1
{%
    \toksa={\\{#2}}\toksb=\expandafter{#1}%
    \edef#1{\the\toksa\the\toksb}%
}

\long\def\gprepend#1#2%  	#1 := <#2> + #1
{%
    \toksa={\\{#2}}\toksb=\expandafter{#1}%
    \xdef#1{\the\toksa\the\toksb}%
}

\long\def\append#1#2%  		#1 := #1 + <#2>
{%
    \toksa={\\{#2}}\toksb=\expandafter{#1}%
    \edef#1{\the\toksb\the\toksa}%
}

\long\def\gappend#1#2%  		#1 := #1 + <#2>
{%
    \toksa={\\{#2}}\toksb=\expandafter{#1}%
    \xdef#1{\the\toksb\the\toksa}%
}

\def\catenate#1#2#3%		#1 := #2 + #3
{%
    \toksa=\expandafter{#2}\toksb=\expandafter{#3}%
    \edef#1{\the\toksa\the\toksb}%
}

\def\gcatenate#1#2#3%		#1 := #2 + #3
{%
    \toksa=\expandafter{#2}\toksb=\expandafter{#3}%
    \xdef#1{\the\toksa\the\toksb}%
}

\def\lop#1#2%			#1, #2 := hd #2, tl #2
{%
    \expandafter\lopoff#2\lopoff#1#2%
}
\long\def\lopoff\\#1#2\lopoff#3#4%    #3, #4 := #1, #2
{%
    \def#3{#1}\def#4{#2}%
}

\def\glop#1#2%
{%
    \expandafter\glopoff#2\glopoff#1#2%
}
\long\def\glopoff\\#1#2\glopoff#3#4%    #3, #4 := #1, #2
{%
    \gdef#3{#1}\gdef#4{#2}%
}

\def\length#1#2%		#1 := length(#2)
{%
    #1=0 \long\def\\##1{\advance#1 1}#2%
}
%}}}
%{{{  Macro expansion

% \expcs\def{foo}... is like \def\foo...
%  #1 a single token
%  #2 a token string
\def\expcs#1#2{\expandafter#1\csname#2\endcsname}

% \noexpcs{foo} -> \noexpand\foo (for in \edefs)
\def\noexpcs{\expcs\noexpand}

% \letcs\tok{foo} is like \let\tok=\fo
%  #1 is a single token
%  #2 is a token string
\def\letcs#1#2{\expandafter\let\expandafter#1\csname#2\endcsname}

% Append to a macro definition
%  #1 is the name of a macro
%  #2 is a token string (it is not expanded)
\def\macappend#1#2%
{%
    \toksa=\expandafter{#1}\toksb={#2}%
    \edef#1{\the\toksa\the\toksb}%
}

%}}}
%{{{  Numbers

%  Convert <dimen> to pure number in TeX's mouth:
%  the following is likely to be used on \fontdimen1
%  to find the slant expressed as a pure number:

% #1 -- <internal dimen>
\def\dimentonumber#1{\expandafter\stripPT\the#1 }
{ \catcode`p=12 \catcode`t=12
    \gdef\\#1pt{#1}
}
\let\stripPT=\\

%  Convert <chardef token> to hexadecimal in TeX's mouth:

\def\chardeftohex#1{\expandafter\stripCHAR\meaning#1}
\def\stripCHAR#1"{}

%}}}  Numbers
%{{{  Arithmetic

\newcount\counta
\newcount\countb
\newcount\countc
\newcount\countd
\newcount\counte

\newcount\tmodulus
\def\modulus#1#2%	#1 := #1 MOD #2
{%
    \tmodulus=#1%
    \divide\tmodulus by#2\relax
    \multiply\tmodulus by#2\relax
    \advance#1-\tmodulus
}
%}}}
%{{{  \begin foo ...\end foo  is like {\foo ... \endfoo}.

\let\END=\end
\outer\def\bye{\par\vfill\supereject\END}

% TeXbook Ex.7.7, Ex.5.7:
\def\begin #1 %
{%
    \expcs\ifx{#1}\relax % is \#1 undefined?
	\errhelp{Give up and type X now, that's my advice to you.
		(I will carry on as if \char`\\#1 was def'd to {}.)}%
	\errmessage{Don't understand #1 environment}%
    \fi
    \def\curenvironment{#1}%
    \begingroup
    \csname#1\endcsname	% if \#1 undefined this does nothing
}

\def\end #1 %
{%
    \csname end#1\endcsname % if \end#1 undefined this does nothing
    \endgroup
    \def\temp{#1}%
    \ifx\temp\curenvironment \else
	\errhelp={Argh.  Why not just type X and get it over with?}%
	\errmessage{Expecting \string\end \curenvironment\space
		but got \string\end #1}%
    \fi
}
%}}}
%{{{  include file iff it exists

\newread\inputifexistsfile

\def\inputifexists#1%
{%
    \openin\inputifexistsfile=#1
    \ifeof\inputifexistsfile
	\message{Note: no file #1.}%
    \else
	\input #1
    \fi
    \closein\inputifexistsfile
}

%}}}  include file iff it exists
%}}} pdcutil.tex

%Local variables:
%fold-folded-p:t
%tex-macros-p: t
%End: