1;
}
-sub l ($) { confess unless l_ok $_[0]; };
+sub l ($) {
+ my ($i) = @_;
+ confess $i unless l_ok $i;
+};
-our ($ifilehead, $ihunkhead, $ichunk);
+our ($ifilehead, $ihunkhead, $ichunkstart, $ichunkend);
our ($before, $after);
+sub analyse_chunk () {
+ print Dumper($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;
+ m{^\@\@} or confess "$_ ?";
+ my $i = $ihunkhead + 1;
for (;;) {
- l_ok $ichunk or last;
-
- while (l_ok $ichunk and
+ if (!l_ok $i or m{^ } or m{^\@\@}) {
+ if (defined $ichunkstart) {
+ $ichunkend = $i;
+ analyse_chunk();
+ $ichunkstart = $ichunkend = $before = $after = undef;
+ }
+ l_ok $i or last;
+ m{^\@\@} and last;
+ } elif (m{^[-+]}) {
+ my $which = $& eq '-' ? \$before : \$after;
+ $ichunkfirst //= $i;
+ $$which //= '';
+ $$which .= $';
+ } else {
+ confess "$_ ?";
+ }
+ }
+ $ihunkhead = $i;
}
-
- confess unless m{^\@\@};
-
-
-while (<>){
- if (m/^diff.*/) {
- my $headline =
}