Blame dist/changelogfix

Packit fcad23
#!/usr/bin/perl
Packit fcad23
#
Packit fcad23
# Tidies up the output of svn2cl to clean it up a touch.
Packit fcad23
# It is fancier than before, but probably no better written.
Packit fcad23
#     (though there are noticably more comments!)
Packit fcad23
Packit fcad23
Packit fcad23
my $inFileList = 0;
Packit fcad23
my $stuff      = "";
Packit fcad23
my $prefix     = "trunk/net-snmp/";
Packit fcad23
Packit fcad23
if ( $ARGV[0] =~ /^V/ ) {
Packit fcad23
    $b = shift @ARGV;
Packit fcad23
    $prefix    = "branches/$b/net-snmp/";
Packit fcad23
}
Packit fcad23
Packit fcad23
$line1 = <>;
Packit fcad23
if ( $line1 !~ /^svn/ ) { print $line1; }
Packit fcad23
while (<>) {
Packit fcad23
    s/^\t/ /;
Packit fcad23
    #
Packit fcad23
    # Note when we're just starting to look at
Packit fcad23
    #   the list of files....
Packit fcad23
    #
Packit fcad23
    if (/^ *\*/) {
Packit fcad23
        $_ =~ s/^ *\* //;
Packit fcad23
        $inFileList = 1;
Packit fcad23
        $stuff = "";
Packit fcad23
    }
Packit fcad23
    if ( $inFileList ) { 
Packit fcad23
        #
Packit fcad23
        #  ... and filter out just those from the branch
Packit fcad23
        #      that we're working with.
Packit fcad23
        #
Packit fcad23
        if (/$prefix/) { 
Packit fcad23
            #
Packit fcad23
            #  XXX: This code implicitly assumes that each entry
Packit fcad23
            #       appears on a separate line.  Which is *probably*
Packit fcad23
            #       true given the folding done by svn2cl.
Packit fcad23
            #         But short paths (e.g. top-level files) may
Packit fcad23
            #       break this assumption, as would extending the
Packit fcad23
            #       folding point for svn2cl
Packit fcad23
            # ToDo:   Strip the prefix (or skip the entry) for
Packit fcad23
            #       each token individually, rather than per-line.
Packit fcad23
            #
Packit fcad23
            $z = $_;
Packit fcad23
            $z =~ s/[ \t]*$prefix/ /;
Packit fcad23
            $stuff .= $z;
Packit fcad23
        } else {
Packit fcad23
            $stuff .= " ".$_;
Packit fcad23
        }
Packit fcad23
        if ( /:/ ) {
Packit fcad23
            #
Packit fcad23
            # At the end of this list, we need to reformat it
Packit fcad23
            #   so that the lines aren't too long or too short
Packit fcad23
            #
Packit fcad23
            # Flatten things into a single line,
Packit fcad23
            #   and make sure it ends in a colon
Packit fcad23
            $stuff =~ s/\n//g;
Packit fcad23
            if ( $stuff =~ /,$/) { $stuff =~ s/,$/:/; }
Packit fcad23
Packit fcad23
            #
Packit fcad23
            #  If the line is too long, then start re-folding it
Packit fcad23
            #
Packit fcad23
            if ( $stuff =~ /.{70}/ ) {
Packit fcad23
                @z = split /\s/, $stuff;
Packit fcad23
                $line = "*";
Packit fcad23
                while ($#z >= 0) {
Packit fcad23
                    $z = shift @z;
Packit fcad23
                    if ( "$line $z" =~ /.{70}/ ) {
Packit fcad23
                        print "   $line\n";
Packit fcad23
                        $line = "   $z";
Packit fcad23
                    } else {
Packit fcad23
                        $line .= " $z";
Packit fcad23
                    }
Packit fcad23
                }
Packit fcad23
                print "   $line\n\n";
Packit fcad23
            } else {
Packit fcad23
                #
Packit fcad23
                #  Otherwise, print the list as it stands
Packit fcad23
                #
Packit fcad23
                print "   *$stuff\n\n";
Packit fcad23
            }
Packit fcad23
            $stuff = "";
Packit fcad23
            $inFileList = 0;
Packit fcad23
        }
Packit fcad23
    } else {
Packit fcad23
Packit fcad23
        #
Packit fcad23
        # If we're not processing the list of files,
Packit fcad23
        #   then just pass things through.
Packit fcad23
        print $_;
Packit fcad23
    }
Packit fcad23
}