xref: /aosp_15_r20/external/e2fsprogs/wordwrap.pl (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker#!/usr/bin/perl
2*6a54128fSAndroid Build Coastguard Worker#
3*6a54128fSAndroid Build Coastguard Worker# wordwrap.pl --- does word wrap
4*6a54128fSAndroid Build Coastguard Worker#
5*6a54128fSAndroid Build Coastguard Workerwhile (<>) {
6*6a54128fSAndroid Build Coastguard Worker    if (/^#/) {		# don't word wrap comments
7*6a54128fSAndroid Build Coastguard Worker	print;
8*6a54128fSAndroid Build Coastguard Worker	next;
9*6a54128fSAndroid Build Coastguard Worker    }
10*6a54128fSAndroid Build Coastguard Worker    next if (/^$/);	# skip blank lines
11*6a54128fSAndroid Build Coastguard Worker    $linelen = 0;
12*6a54128fSAndroid Build Coastguard Worker    @words = split;
13*6a54128fSAndroid Build Coastguard Worker    while (defined($word = shift @words)) {
14*6a54128fSAndroid Build Coastguard Worker	$word =~ s#\$\(srcdir\)/\.\./version.h#\$\(top_srcdir\)/version.h#;
15*6a54128fSAndroid Build Coastguard Worker	$word =~ s#\$\(srcdir\)/.\.\/\.\./version.h#\$\(top_srcdir\)/version.h#;
16*6a54128fSAndroid Build Coastguard Worker	$word =~ s#\$\(srcdir\)/.\.\/et/com_err.h#\$\(top_srcdir\)/lib/et/com_err.h#;
17*6a54128fSAndroid Build Coastguard Worker	if ($linelen > 0) {
18*6a54128fSAndroid Build Coastguard Worker	    printf(" ");
19*6a54128fSAndroid Build Coastguard Worker	}
20*6a54128fSAndroid Build Coastguard Worker	$len = length($word) + 1;
21*6a54128fSAndroid Build Coastguard Worker	$linelen += $len;
22*6a54128fSAndroid Build Coastguard Worker	if ($linelen > 78) {
23*6a54128fSAndroid Build Coastguard Worker	    printf("\\\n ");
24*6a54128fSAndroid Build Coastguard Worker	    $linelen = 1+$len;
25*6a54128fSAndroid Build Coastguard Worker	}
26*6a54128fSAndroid Build Coastguard Worker	printf("%s", $word);
27*6a54128fSAndroid Build Coastguard Worker    }
28*6a54128fSAndroid Build Coastguard Worker    printf("\n");
29*6a54128fSAndroid Build Coastguard Worker}
30