Whamcloud - gitweb
git://git.whamcloud.com
/
tools
/
e2fsprogs.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
ADD TAG: E2FSPROGS-1_19
[tools/e2fsprogs.git]
/
wordwrap.pl
1
#!/usr/bin/perl
2
#
3
# wordwrap.pl --- does word wrap
4
#
5
while (<>) {
6
if (/^#/) { # don't word wrap comments
7
print;
8
next;
9
}
10
next if (/^$/); # skip blank lines
11
$linelen = 0;
12
split;
13
while (defined($word = shift @_)) {
14
if ($linelen > 0) {
15
printf(" ");
16
}
17
$len = length($word) + 1;
18
$linelen += $len;
19
if ($linelen > 78) {
20
printf("\\\n ");
21
$linelen = 1+$len;
22
}
23
printf("%s", $word);
24
}
25
printf("\n");
26
}