1#!/usr/bin/perl -p
2
3BEGIN {
4    $cond = -1;
5}
6
7# Initialize the numeric register we use for conditionals
8if ($cond == -1) {
9    $_ = ".nr SL \@SEMAN\@\n.nr BA \@BAMAN\@\n.nr LC \@LCMAN\@\n.\\\"\n$_";
10    $cond = 0;
11}
12
13# Make SELinux_Spec conditional
14if (/(.*)SELinux_Spec\? (.*)$/) {
15    $_ = ".ie \\n(SL $_.el $1$2\n";
16} elsif (/^(.*SELinux_Spec ::=)/) {
17    $_ = ".if \\n(SL \\{\\\n$_";
18} elsif (/^(.*Tag_Spec ::=)/) {
19    $_ = "\\}\n$_";
20}
21
22if (/^\.S[Sh] "SELinux_Spec"/) {
23    $_ = ".if \\n(SL \\{\\\n$_";
24    $cond = 1;
25} elsif (/^\.IP "(role|type)"/) {
26    $_ = ".if \\n(SL \\{\\\n$_";
27    $cond = 1;
28} elsif (/^\.IP "use_loginclass"/) {
29    $_ = ".if \\n(LC \\{\\\n$_";
30    $cond = 1;
31} elsif ($cond && /^\.(Sh|SS|IP|PP)/) {
32    $_ = "\\}\n$_";
33    $cond = 0;
34}
35
36# Fix up broken pod2man formatting of F<@foo@/bar>
37s/\\fI\\f(\(C)?I\@([^\@]*)\\fI\@/\\fI\@$2\@/g;
38s/\\f\(\CW\@([^\@]*)\\fR\@/\@$1\@/g;
39#\f(CW@secure_path\fR@
40