summaryrefslogtreecommitdiff
path: root/wordwrap.pl
blob: 646bbc35d22d49e599bc8bbff82edb95bf89fdd0 (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
#!/usr/bin/perl
#
# wordwrap.pl --- does word wrap
#
while (<>) {
    if (/^#/) {		# don't word wrap comments
	print;
	next;
    }
    next if (/^$/);	# skip blank lines
    $linelen = 0;
    split;
    while (defined($word = shift @_)) {
	$word =~ s#\$\(srcdir\)/\.\./version.h#\$\(top_srcdir\)/version.h#;
	$word =~ s#\$\(srcdir\)/.\.\/\.\./version.h#\$\(top_srcdir\)/version.h#;
	$word =~ s#\$\(srcdir\)/.\.\/et/com_err.h#\$\(top_srcdir\)/lib/et/com_err.h#;
	if ($linelen > 0) {
	    printf(" ");
	}
	$len = length($word) + 1;
	$linelen += $len;
	if ($linelen > 78) {
	    printf("\\\n ");
	    $linelen = 1+$len;
	}
	printf("%s", $word);
    }
    printf("\n");
}