| 1 |
#!/usr/bin/perl |
| 2 |
# |
| 3 |
# Tidies up the output of svn2cl to clean it up a touch. |
| 4 |
# It is fancier than before, but probably no better written. |
| 5 |
# (though there are noticably more comments!) |
| 6 |
|
| 7 |
|
| 8 |
my $inFileList = 0; |
| 9 |
my $stuff = ""; |
| 10 |
my $prefix = "trunk/net-snmp/"; |
| 11 |
|
| 12 |
if ( $ARGV[0] =~ /^V/ ) { |
| 13 |
$b = shift @ARGV; |
| 14 |
$prefix = "branches/$b/net-snmp/"; |
| 15 |
} |
| 16 |
|
| 17 |
$line1 = <>; |
| 18 |
if ( $line1 !~ /^svn/ ) { print $line1; } |
| 19 |
while (<>) { |
| 20 |
s/^\t/ /; |
| 21 |
# |
| 22 |
# Note when we're just starting to look at |
| 23 |
# the list of files.... |
| 24 |
# |
| 25 |
if (/^ *\*/) { |
| 26 |
$_ =~ s/^ *\* //; |
| 27 |
$inFileList = 1; |
| 28 |
$stuff = ""; |
| 29 |
} |
| 30 |
if ( $inFileList ) { |
| 31 |
# |
| 32 |
# ... and filter out just those from the branch |
| 33 |
# that we're working with. |
| 34 |
# |
| 35 |
if (/$prefix/) { |
| 36 |
# |
| 37 |
# XXX: This code implicitly assumes that each entry |
| 38 |
# appears on a separate line. Which is *probably* |
| 39 |
# true given the folding done by svn2cl. |
| 40 |
# But short paths (e.g. top-level files) may |
| 41 |
# break this assumption, as would extending the |
| 42 |
# folding point for svn2cl |
| 43 |
# ToDo: Strip the prefix (or skip the entry) for |
| 44 |
# each token individually, rather than per-line. |
| 45 |
# |
| 46 |
$z = $_; |
| 47 |
$z =~ s/[ \t]*$prefix/ /; |
| 48 |
$stuff .= $z; |
| 49 |
} else { |
| 50 |
$stuff .= " ".$_; |
| 51 |
} |
| 52 |
if ( /:/ ) { |
| 53 |
# |
| 54 |
# At the end of this list, we need to reformat it |
| 55 |
# so that the lines aren't too long or too short |
| 56 |
# |
| 57 |
# Flatten things into a single line, |
| 58 |
# and make sure it ends in a colon |
| 59 |
$stuff =~ s/\n//g; |
| 60 |
if ( $stuff =~ /,$/) { $stuff =~ s/,$/:/; } |
| 61 |
|
| 62 |
# |
| 63 |
# If the line is too long, then start re-folding it |
| 64 |
# |
| 65 |
if ( $stuff =~ /.{70}/ ) { |
| 66 |
@z = split /\s/, $stuff; |
| 67 |
$line = "*"; |
| 68 |
while ($#z >= 0) { |
| 69 |
$z = shift @z; |
| 70 |
if ( "$line $z" =~ /.{70}/ ) { |
| 71 |
print " $line\n"; |
| 72 |
$line = " $z"; |
| 73 |
} else { |
| 74 |
$line .= " $z"; |
| 75 |
} |
| 76 |
} |
| 77 |
print " $line\n\n"; |
| 78 |
} else { |
| 79 |
# |
| 80 |
# Otherwise, print the list as it stands |
| 81 |
# |
| 82 |
print " *$stuff\n\n"; |
| 83 |
} |
| 84 |
$stuff = ""; |
| 85 |
$inFileList = 0; |
| 86 |
} |
| 87 |
} else { |
| 88 |
|
| 89 |
# |
| 90 |
# If we're not processing the list of files, |
| 91 |
# then just pass things through. |
| 92 |
print $_; |
| 93 |
} |
| 94 |
} |