summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2003-09-07 12:34:54 +1000
committerDarren Tucker <dtucker@zip.com.au>2003-09-07 12:34:54 +1000
commit167bd9cfef47736fdda2cc428802303d32cce9dc (patch)
tree245f7d07c57708af0cfd099415903fddb54c34ff
parent7c600f24a4d6e2f4a9eae27ec4acebbc0943ae56 (diff)
- (dtucker) [CREDITS Makefile.in configure.ac mdoc2man.awk mdoc2man.pl]
Replace mdoc2man.pl with mdoc2man.awk, provided by Peter Stuge.
-rw-r--r--CREDITS3
-rw-r--r--ChangeLog4
-rw-r--r--Makefile.in5
-rw-r--r--configure.ac3
-rw-r--r--mdoc2man.awk340
-rw-r--r--mdoc2man.pl592
6 files changed, 350 insertions, 597 deletions
diff --git a/CREDITS b/CREDITS
index 6bd52bfa2..092229cf7 100644
--- a/CREDITS
+++ b/CREDITS
@@ -70,6 +70,7 @@ Pavel Kankovsky <peak@argo.troja.mff.cuni.cz> - Security fixes
70Pavel Troller <patrol@omni.sinus.cz> - Bugfixes 70Pavel Troller <patrol@omni.sinus.cz> - Bugfixes
71Pekka Savola <pekkas@netcore.fi> - Bugfixes 71Pekka Savola <pekkas@netcore.fi> - Bugfixes
72Peter Kocks <peter.kocks@baygate.com> - Makefile fixes 72Peter Kocks <peter.kocks@baygate.com> - Makefile fixes
73Peter Stuge <stuge@cdy.org> - mdoc2man.awk script
73Phil Hands <phil@hands.com> - Debian scripts, assorted patches 74Phil Hands <phil@hands.com> - Debian scripts, assorted patches
74Phil Karn <karn@ka9q.ampr.org> - Autoconf fixes 75Phil Karn <karn@ka9q.ampr.org> - Autoconf fixes
75Philippe WILLEM <Philippe.WILLEM@urssaf.fr> - Bugfixes 76Philippe WILLEM <Philippe.WILLEM@urssaf.fr> - Bugfixes
@@ -93,5 +94,5 @@ Apologies to anyone I have missed.
93 94
94Damien Miller <djm@mindrot.org> 95Damien Miller <djm@mindrot.org>
95 96
96$Id: CREDITS,v 1.73 2003/08/11 13:03:53 dtucker Exp $ 97$Id: CREDITS,v 1.74 2003/09/07 02:34:54 dtucker Exp $
97 98
diff --git a/ChangeLog b/ChangeLog
index 3a7ab4147..3c87cb229 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@
8 - (dtucker) [regress/sftp-cmds.sh] Skip quoted file test on Cygwin. 8 - (dtucker) [regress/sftp-cmds.sh] Skip quoted file test on Cygwin.
9 - (dtucker) [openbsd-compat/xcrypt.c] #elsif -> #elif 9 - (dtucker) [openbsd-compat/xcrypt.c] #elsif -> #elif
10 - (dtucker) [acconfig.h] Typo. 10 - (dtucker) [acconfig.h] Typo.
11 - (dtucker) [CREDITS Makefile.in configure.ac mdoc2man.awk mdoc2man.pl]
12 Replace mdoc2man.pl with mdoc2man.awk, provided by Peter Stuge.
11 13
1220030906 1420030906
13 - (dtucker) [acconfig.h configure.ac uidswap.c] Prefer setuid/setgid on AIX. 15 - (dtucker) [acconfig.h configure.ac uidswap.c] Prefer setuid/setgid on AIX.
@@ -1035,4 +1037,4 @@
1035 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. 1037 - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
1036 Report from murple@murple.net, diagnosis from dtucker@zip.com.au 1038 Report from murple@murple.net, diagnosis from dtucker@zip.com.au
1037 1039
1038$Id: ChangeLog,v 1.2968 2003/09/07 01:37:27 dtucker Exp $ 1040$Id: ChangeLog,v 1.2969 2003/09/07 02:34:54 dtucker Exp $
diff --git a/Makefile.in b/Makefile.in
index 59ebeea59..5d72ee999 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
1# $Id: Makefile.in,v 1.246 2003/09/05 01:35:52 dtucker Exp $ 1# $Id: Makefile.in,v 1.247 2003/09/07 02:34:54 dtucker Exp $
2 2
3# uncomment if you run a non bourne compatable shell. Ie. csh 3# uncomment if you run a non bourne compatable shell. Ie. csh
4#SHELL = @SH@ 4#SHELL = @SH@
@@ -46,6 +46,7 @@ LIBS=@LIBS@
46LIBPAM=@LIBPAM@ 46LIBPAM=@LIBPAM@
47LIBWRAP=@LIBWRAP@ 47LIBWRAP=@LIBWRAP@
48AR=@AR@ 48AR=@AR@
49AWK=@AWK@
49RANLIB=@RANLIB@ 50RANLIB=@RANLIB@
50INSTALL=@INSTALL@ 51INSTALL=@INSTALL@
51PERL=@PERL@ 52PERL=@PERL@
@@ -173,7 +174,7 @@ $(MANPAGES): $(MANPAGES_IN)
173 manpage=$(srcdir)/`echo $@ | sed 's/\.out$$//'`; \ 174 manpage=$(srcdir)/`echo $@ | sed 's/\.out$$//'`; \
174 fi; \ 175 fi; \
175 if test "$(MANTYPE)" = "man"; then \ 176 if test "$(MANTYPE)" = "man"; then \
176 $(FIXPATHSCMD) $${manpage} | $(PERL) $(srcdir)/mdoc2man.pl > $@; \ 177 $(FIXPATHSCMD) $${manpage} | $(AWK) -f $(srcdir)/mdoc2man.awk > $@; \
177 else \ 178 else \
178 $(FIXPATHSCMD) $${manpage} > $@; \ 179 $(FIXPATHSCMD) $${manpage} > $@; \
179 fi 180 fi
diff --git a/configure.ac b/configure.ac
index 23f3e5e68..9559bcb7e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.144 2003/09/06 06:44:39 dtucker Exp $ 1# $Id: configure.ac,v 1.145 2003/09/07 02:34:54 dtucker Exp $
2 2
3AC_INIT 3AC_INIT
4AC_CONFIG_SRCDIR([ssh.c]) 4AC_CONFIG_SRCDIR([ssh.c])
@@ -9,6 +9,7 @@ AC_CANONICAL_HOST
9AC_C_BIGENDIAN 9AC_C_BIGENDIAN
10 10
11# Checks for programs. 11# Checks for programs.
12AC_PROG_AWK
12AC_PROG_CPP 13AC_PROG_CPP
13AC_PROG_RANLIB 14AC_PROG_RANLIB
14AC_PROG_INSTALL 15AC_PROG_INSTALL
diff --git a/mdoc2man.awk b/mdoc2man.awk
new file mode 100644
index 000000000..856e2d7c5
--- /dev/null
+++ b/mdoc2man.awk
@@ -0,0 +1,340 @@
1#!/usr/bin/awk
2#
3# Version history:
4# v3, I put the program under a proper license
5# Dan Nelson <dnelson@allantgroup.com> added .An, .Aq and fixed a typo
6# v2, fixed to work on GNU awk --posix and MacOS X
7# v1, first attempt, didn't work on MacOS X
8#
9# Copyright (c) 2003 Peter Stuge <stuge-mdoc2man@cdy.org>
10#
11# Permission to use, copy, modify, and distribute this software for any
12# purpose with or without fee is hereby granted, provided that the above
13# copyright notice and this permission notice appear in all copies.
14#
15# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
16# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
18# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23
24BEGIN {
25 optlist=0
26 oldoptlist=0
27 nospace=0
28 synopsis=0
29 reference=0
30 block=0
31 ext=0
32 extopt=0
33 literal=0
34 prenl=0
35 line=""
36}
37
38function wtail() {
39 retval=""
40 while(w<nwords) {
41 if(length(retval))
42 retval=retval OFS
43 retval=retval words[++w]
44 }
45 return retval
46}
47
48function add(str) {
49 for(;prenl;prenl--)
50 line=line "\n"
51 line=line str
52}
53
54! /^\./ {
55 for(;prenl;prenl--)
56 print ""
57 print
58 if(literal)
59 print ".br"
60 next
61}
62
63/^\.\\"/ { next }
64
65{
66 option=0
67 parens=0
68 angles=0
69 sub("^\\.","")
70 nwords=split($0,words)
71 for(w=1;w<=nwords;w++) {
72 skip=0
73 if(match(words[w],"^Li|Pf$")) {
74 skip=1
75 } else if(match(words[w],"^Xo$")) {
76 skip=1
77 ext=1
78 if(length(line)&&!(match(line," $")||prenl))
79 add(OFS)
80 } else if(match(words[w],"^Xc$")) {
81 skip=1
82 ext=0
83 if(!extopt)
84 prenl++
85 w=nwords
86 } else if(match(words[w],"^Bd$")) {
87 skip=1
88 if(match(words[w+1],"-literal")) {
89 literal=1
90 prenl++
91 w=nwords
92 }
93 } else if(match(words[w],"^Ed$")) {
94 skip=1
95 literal=0
96 } else if(match(words[w],"^Ns$")) {
97 skip=1
98 if(!nospace)
99 nospace=1
100 sub(" $","",line)
101 } else if(match(words[w],"^No$")) {
102 skip=1
103 sub(" $","",line)
104 add(words[++w])
105 } else if(match(words[w],"^Dq$")) {
106 skip=1
107 add("``")
108 add(words[++w])
109 while(w<nwords&&!match(words[w+1],"^[\\.,]"))
110 add(OFS words[++w])
111 add("''")
112 if(!nospace&&match(words[w+1],"^[\\.,]"))
113 nospace=1
114 } else if(match(words[w],"^Sq|Ql$")) {
115 skip=1
116 add("`" words[++w] "'")
117 if(!nospace&&match(words[w+1],"^[\\.,]"))
118 nospace=1
119 } else if(match(words[w],"^Oo$")) {
120 skip=1
121 extopt=1
122 if(!nospace)
123 nospace=1
124 add("[")
125 } else if(match(words[w],"^Oc$")) {
126 skip=1
127 extopt=0
128 add("]")
129 }
130 if(!skip) {
131 if(!nospace&&length(line)&&!(match(line," $")||prenl))
132 add(OFS)
133 if(nospace==1)
134 nospace=0
135 }
136 if(match(words[w],"^Dd$")) {
137 date=wtail()
138 next
139 } else if(match(words[w],"^Dt$")) {
140 id=wtail()
141 next
142 } else if(match(words[w],"^Os$")) {
143 add(".TH " id " \"" date "\" \"" wtail() "\"")
144 } else if(match(words[w],"^Sh$")) {
145 add(".SH")
146 synopsis=match(words[w+1],"SYNOPSIS")
147 } else if(match(words[w],"^Xr$")) {
148 add("\\fB" words[++w] "\\fP(" words[++w] ")" words[++w])
149 } else if(match(words[w],"^Rs$")) {
150 split("",refauthors)
151 nrefauthors=0
152 reftitle=""
153 refissue=""
154 refdate=""
155 refopt=""
156 reference=1
157 next
158 } else if(match(words[w],"^Re$")) {
159 prenl++
160 for(i=nrefauthors-1;i>0;i--) {
161 add(refauthors[i])
162 if(i>1)
163 add(", ")
164 }
165 if(nrefauthors>1)
166 add(" and ")
167 add(refauthors[0] ", \\fI" reftitle "\\fP")
168 if(length(refissue))
169 add(", " refissue)
170 if(length(refdate))
171 add(", " refdate)
172 if(length(refopt))
173 add(", " refopt)
174 add(".")
175 reference=0
176 } else if(reference) {
177 if(match(words[w],"^%A$")) { refauthors[nrefauthors++]=wtail() }
178 if(match(words[w],"^%T$")) {
179 reftitle=wtail()
180 sub("^\"","",reftitle)
181 sub("\"$","",reftitle)
182 }
183 if(match(words[w],"^%N$")) { refissue=wtail() }
184 if(match(words[w],"^%D$")) { refdate=wtail() }
185 if(match(words[w],"^%O$")) { refopt=wtail() }
186 } else if(match(words[w],"^Nm$")) {
187 if(synopsis) {
188 add(".br")
189 prenl++
190 }
191 n=words[++w]
192 if(!length(name))
193 name=n
194 if(!length(n))
195 n=name
196 add("\\fB" n "\\fP")
197 if(!nospace&&match(words[w+1],"^[\\.,]"))
198 nospace=1
199 } else if(match(words[w],"^Nd$")) {
200 add("\\- " wtail())
201 } else if(match(words[w],"^Fl$")) {
202 add("\\fB\\-" words[++w] "\\fP")
203 if(!nospace&&match(words[w+1],"^[\\.,]"))
204 nospace=1
205 } else if(match(words[w],"^Ar$")) {
206 add("\\fI")
207 if(w==nwords)
208 add("file ...\\fP")
209 else {
210 add(words[++w] "\\fP")
211 while(match(words[w+1],"^\\|$"))
212 add(OFS words[++w] " \\fI" words[++w] "\\fP")
213 }
214 if(!nospace&&match(words[w+1],"^[\\.,]"))
215 nospace=1
216 } else if(match(words[w],"^Cm$")) {
217 add("\\fB" words[++w] "\\fP")
218 while(w<nwords&&match(words[w+1],"^[\\.,:;)]"))
219 add(words[++w])
220 } else if(match(words[w],"^Op$")) {
221 option=1
222 if(!nospace)
223 nospace=1
224 add("[")
225 } else if(match(words[w],"^Pp$")) {
226 prenl++
227 } else if(match(words[w],"^An$")) {
228 prenl++
229 } else if(match(words[w],"^Ss$")) {
230 add(".SS")
231 } else if(match(words[w],"^Pa$")&&!option) {
232 add("\\fI")
233 w++
234 if(match(words[w],"^\\."))
235 add("\\&")
236 add(words[w] "\\fP")
237 while(w<nwords&&match(words[w+1],"^[\\.,:;)]"))
238 add(words[++w])
239 } else if(match(words[w],"^Dv$")) {
240 add(".BR")
241 } else if(match(words[w],"^Em|Ev$")) {
242 add(".IR")
243 } else if(match(words[w],"^Pq$")) {
244 add("(")
245 nospace=1
246 parens=1
247 } else if(match(words[w],"^Aq$")) {
248 add("<")
249 nospace=1
250 angles=1
251 } else if(match(words[w],"^S[xy]$")) {
252 add(".B " wtail())
253 } else if(match(words[w],"^Ic$")) {
254 plain=1
255 add("\\fB")
256 while(w<nwords) {
257 w++
258 if(match(words[w],"^Op$")) {
259 w++
260 add("[")
261 words[nwords]=words[nwords] "]"
262 }
263 if(match(words[w],"^Ar$")) {
264 add("\\fI" words[++w] "\\fP")
265 } else if(match(words[w],"^[\\.,]")) {
266 sub(" $","",line)
267 if(plain) {
268 add("\\fP")
269 plain=0
270 }
271 add(words[w])
272 } else {
273 if(!plain) {
274 add("\\fB")
275 plain=1
276 }
277 add(words[w])
278 }
279 if(!nospace)
280 add(OFS)
281 }
282 sub(" $","",line)
283 if(plain)
284 add("\\fP")
285 } else if(match(words[w],"^Bl$")) {
286 oldoptlist=optlist
287 if(match(words[w+1],"-bullet"))
288 optlist=1
289 else if(match(words[w+1],"-enum")) {
290 optlist=2
291 enum=0
292 } else if(match(words[w+1],"-tag"))
293 optlist=3
294 else if(match(words[w+1],"-item"))
295 optlist=4
296 else if(match(words[w+1],"-bullet"))
297 optlist=1
298 w=nwords
299 } else if(match(words[w],"^El$")) {
300 optlist=oldoptlist
301 } else if(match(words[w],"^It$")&&optlist) {
302 if(optlist==1)
303 add(".IP \\(bu")
304 else if(optlist==2)
305 add(".IP " ++enum ".")
306 else if(optlist==3) {
307 add(".TP")
308 prenl++
309 if(match(words[w+1],"^Pa|Ev$")) {
310 add(".B")
311 w++
312 }
313 } else if(optlist==4)
314 add(".IP")
315 } else if(match(words[w],"^Sm$")) {
316 if(match(words[w+1],"off"))
317 nospace=2
318 else if(match(words[w+1],"on"))
319 nospace=0
320 w++
321 } else if(!skip) {
322 add(words[w])
323 }
324 }
325 if(match(line,"^\\.[^a-zA-Z]"))
326 sub("^\\.","",line)
327 if(parens)
328 add(")")
329 if(angles)
330 add(">")
331 if(option)
332 add("]")
333 if(ext&&!extopt&&!match(line," $"))
334 add(OFS)
335 if(!ext&&!extopt&&length(line)) {
336 print line
337 prenl=0
338 line=""
339 }
340}
diff --git a/mdoc2man.pl b/mdoc2man.pl
deleted file mode 100644
index 928fc5d7a..000000000
--- a/mdoc2man.pl
+++ /dev/null
@@ -1,592 +0,0 @@
1#!/usr/bin/perl
2###
3### Quick usage: mdoc2man.pl < mdoc_manpage.8 > man_manpage.8
4###
5###
6### Copyright (c) 2001 University of Illinois Board of Trustees
7### Copyright (c) 2001 Mark D. Roth
8### All rights reserved.
9###
10### Redistribution and use in source and binary forms, with or without
11### modification, are permitted provided that the following conditions
12### are met:
13### 1. Redistributions of source code must retain the above copyright
14### notice, this list of conditions and the following disclaimer.
15### 2. Redistributions in binary form must reproduce the above copyright
16### notice, this list of conditions and the following disclaimer in the
17### documentation and/or other materials provided with the distribution.
18### 3. All advertising materials mentioning features or use of this software
19### must display the following acknowledgement:
20### This product includes software developed by the University of
21### Illinois at Urbana, and their contributors.
22### 4. The University nor the names of their
23### contributors may be used to endorse or promote products derived from
24### this software without specific prior written permission.
25###
26### THIS SOFTWARE IS PROVIDED BY THE TRUSTEES AND CONTRIBUTORS ``AS IS'' AND
27### ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29### ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR CONTRIBUTORS BE LIABLE
30### FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31### DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32### OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33### HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34### LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35### OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36### SUCH DAMAGE.
37###
38
39use strict;
40
41my ($name, $date, $id);
42my ($line);
43my ($optlist, $oldoptlist, $nospace, $enum, $synopsis);
44my ($reference, $block, $ext, $extopt, $literal);
45my (@refauthors, $reftitle, $refissue, $refdate, $refopt);
46
47
48$optlist = 0; ### 1 = bullet, 2 = enum, 3 = tag, 4 = item
49$oldoptlist = 0;
50$nospace = 0;
51$synopsis = 0;
52$reference = 0;
53$block = 0;
54$ext = 0;
55$extopt = 0;
56$literal = 0;
57
58while ($line = <STDIN>)
59{
60 if ($line !~ /^\./)
61 {
62 print $line;
63 print ".br\n"
64 if ($literal);
65 next;
66 }
67
68 $line =~ s/^\.//;
69
70 next
71 if ($line =~ m/\\"/);
72
73 $line = ParseMacro($line);
74 print($line)
75 if (defined $line);
76}
77
78
79
80sub ParseMacro # ($line)
81{
82 my ($line) = @_;
83 my (@words, $retval, $option, $parens);
84
85 @words = split(/\s+/, $line);
86 $retval = '';
87 $option = 0;
88 $parens = 0;
89
90# print('@words = ', scalar(@words), ': ', join(' ', @words), "\n");
91
92 while ($_ = shift @words)
93 {
94# print "WORD: $_\n";
95
96 next
97 if (/^(Li|Pf)$/);
98
99 if (/^Xo$/)
100 {
101 $ext = 1;
102 $retval .= ' '
103 if ($retval ne '' && $retval !~ m/[\n ]$/);
104 next;
105 }
106
107 if (/^Xc$/)
108 {
109 $ext = 0;
110 $retval .= "\n"
111 if (! $extopt);
112 last;
113 }
114
115 if (/^Bd$/)
116 {
117 $literal = 1
118 if ($words[0] eq '-literal');
119 $retval .= "\n";
120 last;
121 }
122
123 if (/^Ed$/)
124 {
125 $literal = 0;
126 last;
127 }
128
129 if (/^Ns$/)
130 {
131 $nospace = 1
132 if (! $nospace);
133 $retval =~ s/ $//;
134 next;
135 }
136
137 if (/^No$/)
138 {
139 $retval =~ s/ $//;
140 $retval .= shift @words;
141 next;
142 }
143
144 if (/^Dq$/)
145 {
146 $retval .= '``';
147 do
148 {
149 $retval .= (shift @words) . ' ';
150 }
151 while (@words > 0 && $words[0] !~ m/^[\.,]/);
152 $retval =~ s/ $//;
153 $retval .= '\'\'';
154 $nospace = 1
155 if (! $nospace && $words[0] =~ m/^[\.,]/);
156 next;
157 }
158
159 if (/^(Sq|Ql)$/)
160 {
161 $retval .= '`' . (shift @words) . '\'';
162 $nospace = 1
163 if (! $nospace && $words[0] =~ m/^[\.,]/);
164 next;
165 }
166
167# if (/^Ic$/)
168# {
169# $retval .= '\\fB' . shift(@words) . '\\fP';
170# next;
171# }
172
173 if (/^Oo$/)
174 {
175# $retval .= "[\\c\n";
176 $extopt = 1;
177 $nospace = 1
178 if (! $nospace);
179 $retval .= '[';
180 next;
181 }
182
183 if (/^Oc$/)
184 {
185 $extopt = 0;
186 $retval .= ']';
187 next;
188 }
189
190 $retval .= ' '
191 if (! $nospace && $retval ne '' && $retval !~ m/[\n ]$/);
192 $nospace = 0
193 if ($nospace == 1);
194
195 if (/^Dd$/)
196 {
197 $date = join(' ', @words);
198 return undef;
199 }
200
201 if (/^Dt$/)
202 {
203 $id = join(' ', @words);
204 return undef;
205 }
206
207 if (/^Os$/)
208 {
209 $retval .= '.TH '
210 . $id
211 . " \"$date\" \""
212 . join(' ', @words)
213 . "\"";
214 last;
215 }
216
217 if (/^Sh$/)
218 {
219 $retval .= '.SH';
220 if ($words[0] eq 'SYNOPSIS')
221 {
222 $synopsis = 1;
223 }
224 else
225 {
226 $synopsis = 0;
227 }
228 next;
229 }
230
231 if (/^Xr$/)
232 {
233 $retval .= '\\fB' . (shift @words) .
234 '\\fP(' . (shift @words) . ')'
235 . (shift @words);
236 last;
237 }
238
239 if (/^Rs/)
240 {
241 @refauthors = ();
242 $reftitle = '';
243 $refissue = '';
244 $refdate = '';
245 $refopt = '';
246 $reference = 1;
247 last;
248 }
249
250 if (/^Re/)
251 {
252 $retval .= "\n";
253
254 # authors
255 while (scalar(@refauthors) > 1)
256 {
257 $retval .= shift(@refauthors) . ', ';
258 }
259 $retval .= 'and '
260 if ($retval ne '');
261 $retval .= shift(@refauthors);
262
263 # title
264 $retval .= ', \\fI' . $reftitle . '\\fP';
265
266 # issue
267 $retval .= ', ' . $refissue
268 if ($refissue ne '');
269
270 # date
271 $retval .= ', ' . $refdate
272 if ($refdate ne '');
273
274 # optional info
275 $retval .= ', ' . $refopt
276 if ($refopt ne '');
277
278 $retval .= ".\n";
279
280 $reference = 0;
281 last;
282 }
283
284 if ($reference)
285 {
286 if (/^%A$/)
287 {
288 unshift(@refauthors, join(' ', @words));
289 last;
290 }
291
292 if (/^%T$/)
293 {
294 $reftitle = join(' ', @words);
295 $reftitle =~ s/^"//;
296 $reftitle =~ s/"$//;
297 last;
298 }
299
300 if (/^%N$/)
301 {
302 $refissue = join(' ', @words);
303 last;
304 }
305
306 if (/^%D$/)
307 {
308 $refdate = join(' ', @words);
309 last;
310 }
311
312 if (/^%O$/)
313 {
314 $refopt = join(' ', @words);
315 last;
316 }
317 }
318
319 if (/^Nm$/)
320 {
321 my $n = $name;
322 $n = shift @words
323 if (@words > 0);
324 $name = $n unless $name;
325 $retval .= ".br\n"
326 if ($synopsis);
327 $retval .= "\\fB$n\\fP";
328 $nospace = 1
329 if (! $nospace && $words[0] =~ m/^[\.,]/);
330 next;
331 }
332
333 if (/^Nd$/)
334 {
335 $retval .= '\\-';
336 next;
337 }
338
339 if (/^Fl$/)
340 {
341 $retval .= '\\fB\\-' . (shift @words) . '\\fP';
342 $nospace = 1
343 if (! $nospace && $words[0] =~ m/^[\.,]/);
344 next;
345 }
346
347 if (/^Ar$/)
348 {
349 $retval .= '\\fI';
350 if (! defined $words[0])
351 {
352 $retval .= 'file ...\\fP';
353 }
354 else
355 {
356 $retval .= shift(@words) . '\\fP';
357 while ($words[0] eq '|')
358 {
359 $retval .= ' ' . shift(@words);
360 $retval .= ' \\fI' . shift(@words);
361 $retval .= '\\fP';
362 }
363 }
364 $nospace = 1
365 if (! $nospace && $words[0] =~ m/^[\.,]/);
366 next;
367 }
368
369 if (/^Cm$/)
370 {
371 $retval .= '\\fB' . (shift @words) . '\\fP';
372 while ($words[0] =~ m/^[\.,:)]$/)
373 {
374 $retval .= shift(@words);
375 }
376 next;
377 }
378
379 if (/^Op$/)
380 {
381 $option = 1;
382 $nospace = 1
383 if (! $nospace);
384 $retval .= '[';
385# my $tmp = pop(@words);
386# $tmp .= ']';
387# push(@words, $tmp);
388 next;
389 }
390
391 if (/^Pp$/)
392 {
393 $retval .= "\n";
394 next;
395 }
396
397 if (/^Ss$/)
398 {
399 $retval .= '.SS';
400 next;
401 }
402
403 if (/^Pa$/ && ! $option)
404 {
405 $retval .= '\\fI';
406 $retval .= '\\&'
407 if ($words[0] =~ m/^\./);
408 $retval .= (shift @words) . '\\fP';
409 while ($words[0] =~ m/^[\.,:;)]$/)
410 {
411 $retval .= shift(@words);
412 }
413# $nospace = 1
414# if (! $nospace && $words[0] =~ m/^[\.,:)]/);
415 next;
416 }
417
418 if (/^Dv$/)
419 {
420 $retval .= '.BR';
421 next;
422 }
423
424 if (/^(Em|Ev)$/)
425 {
426 $retval .= '.IR';
427 next;
428 }
429
430 if (/^Pq$/)
431 {
432 $retval .= '(';
433 $nospace = 1;
434 $parens = 1;
435 next;
436 }
437
438 if (/^(S[xy])$/)
439 {
440 $retval .= '.B ' . join(' ', @words);
441 last;
442 }
443
444 if (/^Ic$/)
445 {
446 $retval .= '\\fB';
447 while (defined $words[0]
448 && $words[0] !~ m/^[\.,]/)
449 {
450 if ($words[0] eq 'Op')
451 {
452 shift(@words);
453 $retval .= '[';
454 my $tmp = pop(@words);
455 $tmp .= ']';
456 push(@words, $tmp);
457 next;
458 }
459 if ($words[0] eq 'Ar')
460 {
461 shift @words;
462 $retval .= '\\fI';
463 $retval .= shift @words;
464 $retval .= '\\fP';
465 }
466 else
467 {
468 $retval .= shift @words;
469 }
470 $retval .= ' '
471 if (! $nospace);
472 }
473 $retval =~ s/ $//;
474 $retval .= '\\fP';
475 $retval .= shift @words
476 if (defined $words[0]);
477 last;
478 }
479
480 if (/^Bl$/)
481 {
482 $oldoptlist = $optlist;
483 if ($words[0] eq '-bullet')
484 {
485 $optlist = 1;
486 }
487 elsif ($words[0] eq '-enum')
488 {
489 $optlist = 2;
490 $enum = 0;
491 }
492 elsif ($words[0] eq '-tag')
493 {
494 $optlist = 3;
495 }
496 elsif ($words[0] eq '-item')
497 {
498 $optlist = 4;
499 }
500 last;
501 }
502
503 if (/^El$/)
504 {
505 $optlist = $oldoptlist;
506 next;
507 }
508
509 if ($optlist && /^It$/)
510 {
511 if ($optlist == 1)
512 {
513 # bullets
514 $retval .= '.IP \\(bu';
515 next;
516 }
517
518 if ($optlist == 2)
519 {
520 # enum
521 $retval .= '.IP ' . (++$enum) . '.';
522 next;
523 }
524
525 if ($optlist == 3)
526 {
527 # tags
528 $retval .= ".TP\n";
529 if ($words[0] =~ m/^(Pa|Ev)$/)
530 {
531 shift @words;
532 $retval .= '.B';
533 }
534 next;
535 }
536
537 if ($optlist == 4)
538 {
539 # item
540 $retval .= ".IP\n";
541 next;
542 }
543
544 next;
545 }
546
547 if (/^Sm$/)
548 {
549 if ($words[0] eq 'off')
550 {
551 $nospace = 2;
552 }
553 elsif ($words[0] eq 'on')
554 {
555# $retval .= "\n";
556 $nospace = 0;
557 }
558 shift @words;
559 next;
560 }
561
562 $retval .= "$_";
563 }
564
565 return undef
566 if ($retval eq '.');
567
568 $retval =~ s/^\.([^a-zA-Z])/$1/;
569# $retval =~ s/ $//;
570
571 $retval .= ')'
572 if ($parens == 1);
573
574 $retval .= ']'
575 if ($option == 1);
576
577# $retval .= ' '
578# if ($nospace && $retval ne '' && $retval !~ m/\n$/);
579
580# $retval .= ' '
581# if ($extended && $retval !~ m/ $/);
582
583 $retval .= ' '
584 if ($ext && ! $extopt && $retval !~ m/ $/);
585
586 $retval .= "\n"
587 if (! $ext && ! $extopt && $retval ne '' && $retval !~ m/\n$/);
588
589 return $retval;
590}
591
592