Blame dist/changelogfix

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