\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /bin/

Viewing File: splitdiff

#!/usr/bin/perl
#
# splitdiff - split up a diff made of incremental patches
# Copyright (C) 2001, 2002, 2003, 2011  Tim Waugh <twaugh@redhat.com>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

use Getopt::Std;
getopts('p:v-:adE', \%opts);
if ($opts{'-'} && $opts{'-'} eq 'version') {
    print "splitdiff - patchutils version 0.3.3\n";
    exit 0;
}
if ($opts{'-'} && $opts{'-'} eq 'help') {
    print "usage: splitdiff [OPTIONS] FILE\n";
    print "OPTIONS are:\n";
    print "  -a              split out every single file-level patch\n";
    print "  -p N            pathname components to ignore\n";
    print "  -d              use output filenames like a_b.c.patch for a/b.c\n";
    print "  -E              don't use .patch filename extension\n";
    exit 0;
}

# Read in the input.
open(IN, "<$ARGV[0]") || die "Can't open input file\n";
@input=<IN>;
close(IN);	

$part = 1;
my %written = ();
sub process {
    print "Lines $_[0] to $_[1]\n" if ($opts{v});
    if ($opts{d}) {
	$out = $_[2];
	$out =~ s,/,_,g;
    } else {
	$out = sprintf ("%s.part%03d", $ARGV[0], $part);
    }
    unless ($opts{E}) {
        $out = sprintf("%s.patch", $out);
    }
    if ($written{$_[2]}) { $mode = '>>' } else { $mode = '>' }
    $written{$_[2]} = $_[2];
    open(OUT, $mode, $out) or die "Can't open output file\n";
    for $i ($_[0] .. $_[1]) {
	unless (($i == $_[1]) && ($input[$i - 1] =~ /^diff\s+\S+/)) {
	    print OUT $input[$i - 1];
	}
    }
    close(OUT);
    print "Wrote ".$mode.$out."\n";
    $part++;
}

if($#ARGV != 0) {
    die "usage: splitdiff DIFF\n";
}
$getlist = 'lsdiff -n ';
$getlist .= '--strip='.$opts{p}.' ' if ($opts{p});
$getlist .= $ARGV[0]; # Yuck.  How do you do this properly in perl?
open(LIST, '-|', $getlist) or die "Can't run lsdiff";
@list = <LIST>;
close LIST;

my %seen = ();
my @this = ();
my $ready = 0;
my $linenum;
my $file;
for (@list) {
    /\s*(\d+)\s*(.*)$/;
    ($linenum, $file) = ($1, $2);
    if ($ready == 1) {
	process ($firstline, $linenum - 1, $prevfile);
	$ready = 0;
    }
    $prevfile = $file;
    push @this, [ $linenum, $file ];
    if ($opts{'a'} || $seen{$file}) {
	$firstline = $this[0]->[0];
	$ready = 1;
	if ($opts{v}) {
	    for (@this) {
		print $_->[0].": ".$_->[1]."\n";
	    }
	    print "\n";
	}
	@this = ();
    }
    $seen{$file} = $file;
}
if ($ready == 1) {
    process ($firstline, $linenum - 1, $file) if $linenum > $firstline;
    process ($linenum, $#input + 1, $file);
}

if ($part == 1) {
    print "Input contained no duplicate files; nothing to do\n";
}