1#!/usr/bin/perl -p
2
3BEGIN {
4    %tags = ( 'a', 'BA', 'c', 'LC', 'r', 'SL', 't', 'SL');
5    $cond = -1;
6}
7
8# Initialize the numeric register we use for conditionals
9if ($cond == -1) {
10    $_ = ".nr SL \@SEMAN\@\n.nr BA \@BAMAN\@\n.nr LC \@LCMAN\@\n.nr PT \@password_timeout\@\n.\\\"\n$_";
11    $cond = 0;
12}
13
14# Add conditionals
15if (/^\.IP.*-([acrt])/) {
16    $_ = ".if \\n($tags{$1} \\{\\\n$_";
17    $cond = 1;
18} elsif ($cond && /^\.(Sh|SS|IP|PP)/) {
19    $_ = "\\}\n$_";
20    $cond = 0;
21}
22
23if (/-a.*auth_type/) {
24    $_ = ".if \\n($tags{'a'} $_";
25} elsif (/(-c.*class.*\||login_cap)/) {
26    $_ = ".if \\n($tags{'c'} $_";
27} elsif (/-r.*role.*-t.*type/) {
28    $_ = ".if \\n($tags{'r'} $_";
29}
30
31# Fix up broken pod2man formatting of F<@foo@/bar>
32s/\\fI\\f(\(C)?I\@([^\@]*)\\fI\@/\\fI\@$2\@/g;
33
34# Try to deal sensibly with password_timeout being set to 0 by default
35s/([^ ]*\@password_timeout\@[^ ]* minutes.$)/\n.ie \\n(PT $1\n.el unlimited./;
36