blob: fca9626ead2b9ee91ed07eca8b90cae7437a5679 [file] [log] [blame]
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +08001#!/usr/bin/env perl
2#
3# Convert check-parsing.sh's log to diff format.
4#
5
6if(-t STDIN && $#ARGV == -1) {
7 print STDERR "Usage: check-parsing-log2diff.pl < check-parsing.sh.log > diff.patch\n";
8 exit(1);
9}
10
11$state = 0;
12while(<>) {
13 if ($state == 0) {
14 if (/^Checking\s*(.+?)\s*against\s*(.+?)$/) {
15 $source = $1;
16 $target = $2;
17 } elsif (/^\-\-\-\s(.+?)\s.*/) {
18 print "--- a/dev/null " . "\n";
19 } elsif (/^\+\+\+\s(.+?)\s.*/) {
20 print "+++ b" . $target . "\n";
21 $state = 1;
22 }
23 } else {
24 if (/^Checking\s*(.+?)\s*against\s*(.+?)$/) {
25 $source = $1;
26 $target = $2;
27 $state = 0;
28 } else {
29 print $_;
30 }
31 }
32}