1 .\" -*- mode: nroff -*-
6 This file is part of groff, the GNU roff type-setting system.
8 Copyright (C) 2005-2014 Free Software Foundation, Inc.
9 written by Joachim Walsdorff <Joachim.Walsdorff@urz.uni-heidelberg.de>.
11 groff is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free
13 Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 groff is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
33 .\" ******************************************************************
34 .\" ** Some macros and default settings needed by hdtbl **
35 .\" ******************************************************************
38 .\" Utility macro: .getarg <key> ...
40 .\" Get macro argument. This macro searches <key> in the
41 .\" remaining arguments and assigns its value to a string
42 .\" register named <key>. The following syntax forms are
45 .\" <key>=<val> Assign <val> to string <key>.
46 .\" <val> must not contain spaces.
47 .\" <key>='<val>' Assign <val> to string <key>.
48 .\" <val> can contain spaces.
49 .\" <key>= Assign `=' to string <key>.
50 .\" <key> Assign `key' to string <key>.
52 .\" After return, the string `args' contains the remaining
55 .\" Example: With the definition of string `foo' as
57 .\" .ds foo aaa=xxx bbb ccc='yyy zzz' ddd= eee
59 .\" a call to `getarg' with
61 .\" .getarg ccc \*[foo]
63 .\" sets string `ccc' to value `yyy zzz'. The string `args'
64 .\" now contains `aaa=xxx bbb ddd= eee'. An additional call
67 .\" .getarg ddd \*[args]
69 .\" sets string `ddd' to value `=', and `args' contains
70 .\" `aaa=xxx bbb eee'.
87 . if (\\n[*] > \\n[**]) \{\
88 . as args " "\\*[**]"\" value too short, repeat
91 . substring * 0 (\\n[*] - 1)
92 . \" The surrounding \? escapes emulate string comparison.
93 . ie !"\?\\*[$1]\?"\?\\*[*]\?" \{\
94 . as args " "\\*[**]"\" key not found, repeat
98 . ie "\?\\*[**]\?"\?\\*[$1]\?" \
99 . ds \\*[$1] \\*[$1]\" return key as string
101 . ie "\?\\*[**]\?"\?\\*[$1]=\?" \
102 . ds \\*[$1] =\" return `='
104 . substring ** (\\n[*] + 1) -1
108 . \" check whether value starts with quote
109 . if "\?\\*[*]\?"\?'\?" \{\
114 . \" search final quote
115 . ie "\?\\*[*]\?"\?'\?" \
118 . as \\*[$1] \\*[**] \" not found, append argument
121 . ds ** \\$1\" get next argument
126 . if "\?\\*[*]\?"\?'\?" \{\
128 . break \" break if no final quote
131 . as \\*[$1] \\*[**] \" otherwise append and repeat
135 . as \\*[$1] \\*[**]\"
146 .\" Utility macro: .index <string1> <string2>
148 .\" Check whether <string2> is a substring of <string1> and
149 .\" return its position in number register `t*index', starting
150 .\" with 1. If not found, return 0. If <string2> is empty,
151 .\" set `t*index' to -999.
162 . while (\\n+[*] < \\n[**]) \{\
164 . substring * \\n[*] (\\n[*] + \\n[$2] - 1)
165 . \" The surrounding \? escapes emulate string comparison.
166 . if "\?\\*[*]\?"\?\\$2\?" \
170 . ie (\\n[*] == \\n[**]) \
173 . nr t*index (\\n[*] + 1)
177 .\" ******************************************************************
178 .\" ******** non-accumulating space .t*SP [v] **********
180 .\" ** nl vor erster Seite -1, oben auf Seite 0 resp. tH **
181 .\" ** .k nach .sp oder .br 0, **
182 .\" ** sonst Laenge der angefangenen Zeile **
183 .\" ** Der Merker M# fuer vorangegangenes .t*SP wird in .HM am **
184 .\" ** Seitenanfang zurueckgesetzt. **
185 .\" ** ganz richtig ist .sp + .br = .br + .sp = .sp **
186 .\" ******************************************************************
189 . br \" start very first page
190 . nr * \\n[.p] \" save current page length
193 . pl +1 \" without arg increase page length by 1v
195 . pl +\\$1 \" otherwise use \\$1
197 . nr ** (\\n[.p] - \\n[*]) \" ** now holds arg for .t*SP in base units
198 . pl \\n[*]u \" restore page length
200 . \" we do nothing at start of new page or column
201 . if ((\\n[nl] - \\n[tH]) & (\\n[nl] - \\n[<<]) : \\n[.k]) \{\
202 . ie ((\\n[.d] - \\n[M#]) : \\n[.k]) \{\
203 . sp \\n[**]u \" execute .sp
204 . nr S# \\n[**] \" store ** in S#
207 . if (\\n[**] - \\n[S#]) \{\
208 . sp (\\n[**]u - \\n[S#]u)\" emit difference to previous .t*SP
209 . nr S# \\n[**] \" store ** in S#
212 . nr M# \\n[.d] \" store vertical position .d in M#
217 .\" ******************************************************************
218 .\" ** Perform all arguments once **
219 .\" ** P1 is nestable **
220 .\" ******************************************************************
222 . \" `while' command is about five times faster than recursion!
230 .\" ******************************************************************
231 .\" ** Hilfsmakro zum Einstellen von Schriftgroesse und **
232 .\" ** Zeilenabstand, bezogen auf Anfangswerte \n[t*s] **
233 .\" ** und \n[t*v] sowie fuer Hyphenation: **
234 .\" ** .pv s v hy# hart; macht .br **
235 .\" ** Bei 4. Argument setzen der Register s und v und hy. **
236 .\" ** Fuer angefangene Zeile die vorgefundenen Einstellungen **
238 .\" ** Auxiliary macro to set internal registers for font size **
239 .\" ** and line spacing, relative to initial values \n[t*s] and **
240 .\" ** \n[t*v]. Optionally sets hyphenation. A fourth argument **
241 .\" ** initializes internal registers to global default values. **
242 .\" ******************************************************************
247 . ps (\\n[t*s]u * \\$1z / 1z)
250 . vs (\\n[t*v]u * \\$2p / 1p)
252 . vs (\\n[t*v]u * \\$1p / 1p)
267 .\" ******************************************************************
268 .\" ** Hilfsmakros pop/pops/popr (pop stackelement): **
269 .\" ** pop or popr: pop register **
270 .\" ** pops: pop string **
271 .\" ** .pop[s|r] reg|string stackname **
272 .\" ** reg|string: name of reg/string to get the **
273 .\" ** popped element **
274 .\" ** stack: name of stack **
275 .\" ******************************************************************
278 . ds \\$2 \\$4\" pop first stackelement
282 . ds $3 \\$3\" remember stackname
283 . shift 4 \" shift four args
285 . ds \\*[$3] "\\$@\" fill stack with remaining elements
289 . *pop \\$0 \\$1 \\$2 \\*[\\$2]
296 .\" ******************************************************************
297 .\" ** process diversion **
298 .\" ******************************************************************
301 . nf \" diversion is already formatted - output it unchanged
302 . \\$1 \" output the diversion ...
303 . rm \\$1 \" ... and remove it
305 . fi \" reactivate formatting
308 .\" ******************************************************************
309 .\" ** error checking at end **
310 .\" ******************************************************************
313 . if !"\\*[t*kept]"" \{\
314 . tm1 "hdtbl: Not all tables have been printed.
315 . tm1 " Add `.bp' at the end of your document.
317 . if !"\\*[t*held]"" \{\
318 . tm1 "hdtbl: There are held tables which haven't been printed.
319 . tm1 " Add `.t*free' at the end of your document.
322 . tm hdtbl: Missing `.ETB' macro; last .TBL in \\*[t*FN] at line \\*[t*LN].