author | Brendan Donegan brendand@symbian.org |
Thu, 23 Jul 2009 12:00:46 +0100 | |
changeset 274 | d1e42f09003c |
parent 138 | d3c5dd0ae0b0 |
permissions | -rw-r--r-- |
138
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
2 |
# Copyright (c) 2009 Symbian Foundation Ltd |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
3 |
# This component and the accompanying materials are made available |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
4 |
# under the terms of the License "Eclipse Public License v1.0" |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
5 |
# which accompanies this distribution, and is available |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
7 |
# |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
8 |
# Initial Contributors: |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
9 |
# Symbian Foundation Ltd - initial contribution. |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
10 |
# |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
11 |
# Contributors: |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
12 |
# Matt Davies <mattd@symbian.org> |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
13 |
# |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
14 |
# Description: |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
15 |
# dumprecipe.pl : Gives you the recipe starting with the given line number |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
16 |
# perl dumprecipe.pl <log> <line> |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
17 |
# |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
18 |
# Tool is generally for use with yarp, to look at individual errors, and was written as the logs are too verbose for many editors to handle. |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
19 |
# As usual, this tool is rough and ready. |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
20 |
|
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
21 |
|
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
22 |
use strict; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
23 |
|
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
24 |
my $file = shift @ARGV; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
25 |
my $number = shift @ARGV; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
26 |
my %numbers; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
27 |
if(!-e $number && $number =~ m/^\d+$/) |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
28 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
29 |
$numbers{$number} = $number; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
30 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
31 |
else |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
32 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
33 |
open(NUMBERS, "<$number") or die "Couldn't open $number"; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
34 |
while(my $line = <NUMBERS>) |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
35 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
36 |
if($line =~ m/(\d+)\s+(\S+)/) |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
37 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
38 |
$numbers{$1} = "$2($1)"; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
39 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
40 |
elsif($line =~ m/(\d+)/) |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
41 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
42 |
$numbers{$1} = $1; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
43 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
44 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
45 |
close NUMBERS; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
46 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
47 |
|
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
48 |
|
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
49 |
open(FILE,"<$file") or die "Coudln't open file $file\n"; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
50 |
my $linecount = 0; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
51 |
my $recipe = 0; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
52 |
while(my $line = <FILE>) |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
53 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
54 |
++$linecount; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
55 |
|
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
56 |
if(!$recipe && defined $numbers{$linecount}) |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
57 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
58 |
$recipe = $numbers{$linecount}; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
59 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
60 |
if($recipe) |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
61 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
62 |
print $recipe."\t".$line; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
63 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
64 |
if($line =~ m/<\/recipe>/) |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
65 |
{ |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
66 |
$recipe = 0; |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
67 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
68 |
} |
d3c5dd0ae0b0
Added yarp.pl - (Yet Another Raptor Parser) and dump_recipe_at_line.pl
Matt Davies <mattd@symbian.org>
parents:
diff
changeset
|
69 |
#print $linecount; |