#!/usr/bin/perl -w use strict; use Carp; my @d = <>; sub l_ok ($) { my ($i) = @_; return unless $i < @d; $_ = $d[$i]; 1; } sub l ($) { confess unless l_ok $_[0]; }; our ($ifilehead, $ihunkhead, $ichunk); our ($before, $after); for ($ifilehead = 0; l_ok $ifilehead; $ifilehead++) { m{^diff} or next; while (l_ok $ifilehead and m{^index|^---|^\Q+++\E}) { } $ihunkhead = $ifilehead; while (l_ok $ihunkhead) { m{^\@\@} or confess; $ichunk = $ihunkhead + 1; for (;;) { l_ok $ichunk or last; while (l_ok $ichunk and } confess unless m{^\@\@}; while (<>){ if (m/^diff.*/) { my $headline = }