5 This file is part of groff, the GNU roff type-setting system.
7 Copyright (C) 2005-2018 Free Software Foundation, Inc.
8 written by Joachim Walsdorff <Joachim.Walsdorff@urz.uni-heidelberg.de>.
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
15 groff is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
32 .\" ******************************************************************
33 .\" ** Some macros and default settings needed by hdtbl **
34 .\" ******************************************************************
37 .\" Utility macro: .getarg <key> ...
39 .\" Get macro argument. This macro searches <key> in the
40 .\" remaining arguments and assigns its value to a string
41 .\" register named <key>. The following syntax forms are
44 .\" <key>=<val> Assign <val> to string <key>.
45 .\" <val> must not contain spaces.
46 .\" <key>='<val>' Assign <val> to string <key>.
47 .\" <val> can contain spaces.
48 .\" <key>= Assign '=' to string <key>.
49 .\" <key> Assign 'key' to string <key>.
51 .\" After return, the string 'args' contains the remaining
54 .\" Example: With the definition of string 'foo' as
56 .\" .ds foo aaa=xxx bbb ccc='yyy zzz' ddd= eee
58 .\" a call to 'getarg' with
60 .\" .getarg ccc \*[foo]
62 .\" sets string 'ccc' to value 'yyy zzz'. The string 'args'
63 .\" now contains 'aaa=xxx bbb ddd= eee'. An additional call
66 .\" .getarg ddd \*[args]
68 .\" sets string 'ddd' to value '=', and 'args' contains
69 .\" 'aaa=xxx bbb eee'.
86 . if (\\n[*] > \\n[**]) \{\
87 . as args " "\\*[**]"\" value too short, repeat
90 . substring * 0 (\\n[*] - 1)
91 . \" The surrounding \? escapes emulate string comparison.
92 . ie !"\?\\*[$1]\?"\?\\*[*]\?" \{\
93 . as args " "\\*[**]"\" key not found, repeat
97 . ie "\?\\*[**]\?"\?\\*[$1]\?" \
98 . ds \\*[$1] \\*[$1]\" return key as string
100 . ie "\?\\*[**]\?"\?\\*[$1]=\?" \
101 . ds \\*[$1] =\" return '='
103 . substring ** (\\n[*] + 1) -1
107 . \" check whether value starts with quote
108 . if "\?\\*[*]\?"\?'\?" \{\
113 . \" search final quote
114 . ie "\?\\*[*]\?"\?'\?" \
117 . as \\*[$1] \\*[**] \" not found, append argument
120 . ds ** \\$1\" get next argument
125 . if "\?\\*[*]\?"\?'\?" \{\
127 . break \" break if no final quote
130 . as \\*[$1] \\*[**] \" otherwise append and repeat
134 . as \\*[$1] \\*[**]\"
145 .\" Utility macro: .index <string1> <string2>
147 .\" Check whether <string2> is a substring of <string1> and
148 .\" return its position in number register 't*index', starting
149 .\" with 1. If not found, return 0. If <string2> is empty,
150 .\" set 't*index' to -999.
161 . while (\\n+[*] < \\n[**]) \{\
163 . substring * \\n[*] (\\n[*] + \\n[$2] - 1)
164 . \" The surrounding \? escapes emulate string comparison.
165 . if "\?\\*[*]\?"\?\\$2\?" \
169 . ie (\\n[*] == \\n[**]) \
172 . nr t*index (\\n[*] + 1)
176 .\" ******************************************************************
177 .\" ******** non-accumulating space .t*SP [v] **********
179 .\" ** nl vor erster Seite -1, oben auf Seite 0 resp. tH **
180 .\" ** .k nach .sp oder .br 0, **
181 .\" ** sonst Laenge der angefangenen Zeile **
182 .\" ** Der Merker M# fuer vorangegangenes .t*SP wird in .HM am **
183 .\" ** Seitenanfang zurueckgesetzt. **
184 .\" ** ganz richtig ist .sp + .br = .br + .sp = .sp **
185 .\" ******************************************************************
188 . br \" start very first page
189 . nr * \\n[.p] \" save current page length
192 . pl +1 \" without arg increase page length by 1v
194 . pl +\\$1 \" otherwise use \\$1
196 . nr ** (\\n[.p] - \\n[*]) \" ** now holds arg for .t*SP in base units
197 . pl \\n[*]u \" restore page length
199 . \" we do nothing at start of new page or column
200 . if ((\\n[nl] - \\n[tH]) & (\\n[nl] - \\n[<<]) : \\n[.k]) \{\
201 . ie ((\\n[.d] - \\n[M#]) : \\n[.k]) \{\
202 . sp \\n[**]u \" execute .sp
203 . nr S# \\n[**] \" store ** in S#
206 . if (\\n[**] - \\n[S#]) \{\
207 . sp (\\n[**]u - \\n[S#]u)\" emit difference to previous .t*SP
208 . nr S# \\n[**] \" store ** in S#
211 . nr M# \\n[.d] \" store vertical position .d in M#
216 .\" ******************************************************************
217 .\" ** Perform all arguments once **
218 .\" ** P1 is nestable **
219 .\" ******************************************************************
221 . \" 'while' command is about five times faster than recursion!
229 .\" ******************************************************************
230 .\" ** Hilfsmakro zum Einstellen von Schriftgroesse und **
231 .\" ** Zeilenabstand, bezogen auf Anfangswerte \n[t*s] **
232 .\" ** und \n[t*v] sowie fuer Hyphenation: **
233 .\" ** .t*pv s v hy# hart; macht .br **
234 .\" ** Bei 4. Argument setzen der Register s und v und hy. **
235 .\" ** Fuer angefangene Zeile die vorgefundenen Einstellungen **
237 .\" ** Auxiliary macro to set internal registers for font size **
238 .\" ** and line spacing, relative to initial values \n[t*s] and **
239 .\" ** \n[t*v]. Optionally sets hyphenation. A fourth argument **
240 .\" ** initializes internal registers to global default values. **
241 .\" ******************************************************************
246 . ps (\\n[t*s]u * \\$1z / 1z)
249 . vs (\\n[t*v]u * \\$2p / 1p)
251 . vs (\\n[t*v]u * \\$1p / 1p)
266 .\" ******************************************************************
267 .\" ** Hilfsmakros pop/pops/popr (pop stackelement): **
268 .\" ** pop or popr: pop register **
269 .\" ** pops: pop string **
270 .\" ** .pop[s|r] reg|string stackname **
271 .\" ** reg|string: name of reg/string to get the **
272 .\" ** popped element **
273 .\" ** stack: name of stack **
274 .\" ******************************************************************
277 . ds \\$2 \\$4\" pop first stackelement
281 . ds $3 \\$3\" remember stackname
282 . shift 4 \" shift four args
284 . ds \\*[$3] "\\$@\" fill stack with remaining elements
288 . *pop \\$0 \\$1 \\$2 \\*[\\$2]
295 .\" ******************************************************************
296 .\" ** process diversion **
297 .\" ******************************************************************
300 . nf \" diversion is already formatted - output it unchanged
301 . \\$1 \" output the diversion ...
302 . rm \\$1 \" ... and remove it
304 . fi \" reactivate formatting
307 .\" ******************************************************************
308 .\" ** error checking at end **
309 .\" ******************************************************************
312 . if !"\\*[t*kept]"" \{\
313 . tm1 "hdtbl: Not all tables have been printed.
314 . tm1 " Add '.bp' at the end of your document.
316 . if !"\\*[t*held]"" \{\
317 . tm1 "hdtbl: There are held tables which haven't been printed.
318 . tm1 " Add '.t*free' at the end of your document.
321 . tm hdtbl: Missing '.ETB' macro; last .TBL in \\*[t*FN] at line \\*[t*LN].
325 .\" ====================================================================
327 .\" ====================================================================
333 .\" vim: set filetype=groff textwidth=72: