Debian Codegraph @

texmf-dist/tex/plain/zztex/zzmisc.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % Module: ZzTeX Miscellaneous Facilities
4 %
5 % Synopsis: This module contains miscellaneous facilities that do not
6 % seem to belong in any other file.
7 %
8 % Author: Paul C. Anagnostopoulos
9 % Created: 26 August 1989
10 %
11 % Copyright 1989--2020 by Paul C. Anagnostopoulos
12 % under The MIT License (opensource.org/licenses/MIT)
13 %
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15
16 % Character Categories
17 % --------- ----------
18
19
20 % The following list contains characters with category codes other
21 % than endofline, ignored, space, letter, other, and invalid:
22
23 \setlist \zcatlist = {}
24
25
26 \def \establishcatcode #1#2{% {`\c}{\catname}
27 \zdelcat{#1}%
28 \catcode #1 = #2%
29 {\setflag \znext = \true
30 \if \eqlp{#2}{\catendofline}\setflag \znext = \false \fi
31 \if \eqlp{#2}{\catignored}\setflag \znext = \false \fi
32 \if \eqlp{#2}{\catspace}\setflag \znext = \false \fi
33 \if \eqlp{#2}{\catletter}\setflag \znext = \false \fi
34 \if \eqlp{#2}{\catother}\setflag \znext = \false \fi
35 \if \eqlp{#2}{\catinvalid}\setflag \znext = \false \fi
36 \if \znext \append{#1}{\zcatlist}\fi}}
37
38 \def \zdelcat #1{%
39 {\setlist \znewcatlist = {}%
40 \maplist{\def \zcata {##1}\def \zcatb{#1}%
41 \if \notp{\tokeqlp{\zcata}{\zcatb}}\append{##1}{\znewcatlist}\fi}%
42 {\zcatlist}%
43 \setlist \zcatlist = \znewcatlist}}
44
45 % Initialize the character list:
46
47 \establishcatcode{`\^^L}{\catactive}
48 \establishcatcode{`\#}{\catparameter}
49 \establishcatcode{`\$}{\catmath}
50 \establishcatcode{`\&}{\catalign}
51 \establishcatcode{`\%}{\catcomment}
52 \establishcatcode{`\@}{\catactive}
53 \establishcatcode{`\\}{\catescape}
54 \establishcatcode{`\^}{\catsuperscript}
55 \establishcatcode{`\_}{\catsubscript}
56 \establishcatcode{`\{}{\catbegin}
57 \establishcatcode{`\}}{\catend}
58 \establishcatcode{`\~}{\catactive}
59
60 \def \uncatcode #1#2#3{% {allow-commands}{allow-at-commands}{allow-math}
61 \maplist{\catcode##1=\catother}{\zcatlist}%
62 \if #1%
63 \catcode`\\ = \catescape
64 \catcode`\{ = \catbegin
65 \catcode`\} = \catend
66 \fi
67 \if #2%
68 \catcode`\@ = \catactive
69 \fi
70 \if #3%
71 \catcode`\$ = \catmath
72 \catcode`\^ = \catsuperscript
73 \catcode`\_ = \catsubscript
74 \fi}
75
76 \def \catcodemath {%
77 \catcode `\ = \catspace
78 \catcode `\$ = \catmath
79 \catcode `\^ = \catsuperscript
80 \catcode `\_ = \catsubscript}
81
82 \def \catcoderange #1#2#3{% {first}{last}{\catname}
83 \tcounta = #1\relax
84 \tcountb = #2\relax \increment \tcountb
85 \loop
86 \ifnum \tcounta < \tcountb
87 \catcode \tcounta = #3%
88 \increment \tcounta
89 \repeat}
90
91 % Make the upper half of the ASCII characters invalid.
92
93 \catcoderange{"80}{"FF}{\catinvalid}
94
95 % Conditional Text
96 % ----------- ----
97
98
99 \let \setif = \if
100 \let \endsetif = \fi
101
102 \def \ignore {%
103 \if \notp{\zemptyblockstackp}\todo{$\ignore command.}\fi
104 \setif \false}
105
106 \let \endignore = \endsetif
107
108 % Date & Time
109 % ---- - ----
110
111
112 % \year, \month, and \day are TeX parameters.
113
114 \definecount{\weekday}{0}
115
116 % \time is a TeX parameter, the number of minutes since midnight.
117
118 \definecount{\hour}{0}
119 \definecount{\minute}{0}
120
121
122 \def \zdtinit {%
123 \zwdinit
124 \hour = \time
125 \divide \hour by 60
126 \minute = \time
127 \divide \minute by 60
128 \multiply \minute by -60
129 \advance \minute by \time}
130
131 \def \zwdinit {%
132 \tcounta = \year
133 \if \lssp{\month}{3}\advance \tcounta by -1 \fi
134 \tcountb = \tcounta
135 \divide \tcountb by 100
136 \tcountc = \tcountb
137 \multiply \tcountc by -100
138 \advance \tcountc by \tcounta
139 \tcounta = \month
140 \if \lssp{\month}{3}\advance \tcounta by 9 \else \advance \tcounta by -3 \fi
141 \multiply \tcountb by 146097
142 \divide \tcountb by 4
143 \multiply \tcountc by 1461
144 \divide \tcountc by 4
145 \advance \tcountb by \tcountc
146 \multiply \tcounta by 153
147 \advance \tcounta by 2
148 \divide \tcounta by 5
149 \advance \tcountb by \tcounta
150 \advance \tcountb by \day
151 \advance \tcountb by -693902
152 \weekday = \tcountb
153 \divide \weekday by 7
154 \multiply \weekday by -7
155 \advance \weekday by \tcountb}
156
157
158 \def \formattime {%
159 \number\hour:%
160 \if \lssp{\minute}{10}0\fi
161 \number\minute}
162
163 % Fancy Names
164 % ----- -----
165
166
167 \def \AMSTeX {AMS\TeX}
168
169 \def \BibTeX {Bib\TeX}
170
171 \def \LaTeX {L\kern-.3em \raise .4ex \hbox{a}\kern-.05em \TeX}
172
173 % Hiding Writes
174 % ------ ------
175
176
177 % These macros help to hide the \write's that are performed by commands
178 % like \tag and \xpage.
179
180 \definedimen{\zhidewriteskip}{0pt}
181
182 \def \zbeginhidewrite {%
183 \zhidewriteskip = \lastskip
184 \begingroup
185 \if \hmodep \edef \zsf {\spacefactor=\the\spacefactor}\fi}
186
187 \def \zendhidewrite {%
188 \if \hmodep \zsf \fi
189 \endgroup
190 \if \andp{\hmodep}{\dimposp{\zhidewriteskip}}\ignorespaces \fi}
191
192 % Initialization File
193 % -------------- ----
194
195
196 \def \zloadinifile {%
197 \gdef \inicompositor {???}%
198 \gdef \iniinitials {???}%
199 \gdef \ininame {???}
200 \gdef \iniorganization {(none)}%
201 \checkfile{\zini}{zztex.ini}%
202 \if \zini
203 \writelog{(loading ini file)}%
204 \zloadinifilea
205 \else
206 \writelog{(no ini file)}%
207 \fi}
208
209 \def \zloadinifilea {%
210 \begingroup
211 \catcode \endlinechar = \catcomment
212 \catcode `\; = \catcomment
213 \openin \zreada zztex.ini\relax
214 \setflag \zinireg = \false
215 \loop
216 \read \zreada to \zline
217 \if \notp{\emptydefp{\zline}}\expandafter\zloadinifileb \zline\zmark \fi
218 \if \notp{\eofp{\zreada}}\repeat
219 \closein \zreada
220 \endgroup}
221
222 \def \zloadinifileb #1#2\zmark {%
223 \if \codeeqlp{#1}{[}%
224 \zloadinifilec #2\zmark
225 \else\if \zinireg
226 \zloadinifiled #1#2\zmark
227 \fi\fi}
228
229 \def \zloadinifilec #1]#2\zmark {%
230 \stringeql{\zinireg}{#1}{registration}}
231
232 \def \zloadinifiled #1=#2\zmark {%
233 \withname\gdef {\ini#1}{#2}}
234
235 % Penalties
236 % ---------
237
238
239 % The following symbolic penalties should be used everywhere so they
240 % can be adjusted without any recoding. The trailing spaces are
241 % like \relax but don't screw up \ifnum.
242
243 \def \breaknever {10000 } %~ Never break here. %^penalty
244 \def \breakworst {500 } %~ Worst place to break. %^penalty
245 \def \breakworse {300 } %~ Worse place to break. %^penalty
246 \def \breakbad {100 } %~ Bad place to break. %^penalty
247 \def \breakallowed {0 } %~ Break allowed here. %^penalty
248 \def \breakgood {-100 } %~ Good place to break. %^penalty
249 \def \breakbetter {-300 } %~ Better place to break. %^penalty
250 \def \breakbest {-500 } %~ Best place to break. %^penalty
251 \def \breakalways {-10000 } %~ Always break here. %^penalty
252
253
254 \def \allowbreak {\penalty \breakallowed} %~ Allow page break here.
255 \def \break {\penalty \breakalways} %~ Force page break here.
256 \def \nobreak {\penalty \breaknever} %~ Disallow page break here.
257 \let \unbreakable = \nobreak
258
259 % Versions
260 % --------
261
262
263 % I have no idea what my intention was here.
264
265
266 \def \defineversion #1#2{% {\name}{status}
267 \if #2%
268 \let \znext = \zletiftrue
269 \else
270 \let \znext = \zletiffalse
271 \fi
272 \withname\let {\end \expandafter\discardtok\string#1} = \fi
273 \znext{#1}}
274
275 \def \zletiftrue #1{%
276 \let #1 = \iftrue}
277
278 \def \zletiffalse #1{%
279 \let #1 = \iffalse}
280
281
282 \defineversion{\ignore}{\false}
283
284 % Translator Flags
285 % ---------- -----
286
287
288 \def \XTran<#1>{%
289 \error{xtran}{XTran flag: #1}}
290
291 \def \ZzTran[#1]{%
292 \error{zztran}{ZzTran flag: #1}}