summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/bibsort/rofvms.awk
blob: 469786a3c6786828d490d2eb7fa8cf7ca31bc6f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# rofvms.awk -*-awk-*-
# Filter to convert nroff -man output to VMS .hlp file format according
# to the rules:
#
#	13 or more consecutive blank lines are reduced to 1
#	3--12 consecutive blank lines are dropped
#	2 consecutive blank lines are reduced to 1
#	All others output verbatim.
#
# The peculiar number 13 handles the case where a paragraph break
# coincides with a page break.
#
# In addition, whenever a line in non-blank in column 1, and then
# previous line was blank, we insert a blank line; this provides
# vertical space before a section heading.
#
# The output of nroff -man on different UNIX systems is regrettably
# quite variable in appearance; this file is likely to need
# modifications on other than Sun OS.
#
# Too bad nroff doesn't have an option to suppress titling!
#
# The NAME section head becomes 1 DVI, and others become
# 2 XXX followed by XXX.
# [05-Aug-89]

# Match and delete page headers: xxx(nnn) .... xxx(nnn)
/^[A-Za-z][-_A-Za-z0-9]*\([0-9A-Za-z]+\).*[A-Za-z][-_A-Za-z0-9]*\([0-9A-Za-z]+\)$/  {next;}

# Match and delete page footers: Sun Release ...nnn
# These vary from system to system, so extra patterns may be needed here
/^Sun Release.*[0-9]+$/ {next;}	# Sun OS x.x
/^Printed.*[0-9]+$/ {next;}	# BSD 4.3
/^Page [0-9].*$/ {next;}	# Silicon Graphics
/^Version.*Last change:/ {next;}# bibclean.txt on SunOS 4.1.1


# Match all lines and do blank line processing
{
    if (NF == 0)	# blank line
	nb++;
    else		# non blank line
    {
	if ((nb == 1) || (nb == 2) || (nb >= 13))
	    printf("\n");
	else if ((nb > 0) && (substr($0,1,1) != " ") && (nf > 0))
	    printf("\n");
	if ($0 == "NAME")	# level 1 header
	    $0 = "1 DVI";
	else if (substr($0,1,1) != " ") # level 2 header
	{
	    header = $0;
	    gsub(/ /,"-",header);
	    $0 = "2 " header "\n " $0;
	}
	printf("%s\n",$0);
	nb = 0;
	nf++;
    }
}