Bi-Ruei, Chiu | 1fa31c9 | 2016-05-16 13:50:09 +0800 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | # |
| 3 | # Convert check-parsing.sh's log to diff format. |
| 4 | # |
| 5 | |
| 6 | if(-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; |
| 12 | while(<>) { |
| 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 | } |