#!/usr/bin/perl # Split a patch into many smaller patches # $1 -- The first argument is the name of the patches # $2 -- The second arguement can be the starting count use strict; my($OUT, $STATE, $count, $filename); if($ARGV[0] eq ""){ print "Usage: cat patch | splitpatch \n"; exit; } $count = 1; if($ARGV[1] ne ""){ $count = $ARGV[1]; } print "Starting counter is $count\n"; $count--; while(){ if(/^diff.*/){ $count++; # Leaky $filename = `printf $ARGV[0]-%03d $count`; open OUT, "> $filename"; open STATE, "> $filename-state"; print STATE "Ready\n"; print "$filename\n"; } print OUT $_; } close OUT;