author | William Roberts <williamr@symbian.org> |
Fri, 03 Sep 2010 13:41:03 +0100 | |
changeset 320 | e9c03eb287f9 |
parent 258 | 08436a227940 |
permissions | -rw-r--r-- |
177 | 1 |
#!perl -w |
2 |
# Copyright (c) 2009 Symbian Foundation Ltd |
|
3 |
# This component and the accompanying materials are made available |
|
4 |
# under the terms of the License "Eclipse Public License v1.0" |
|
5 |
# which accompanies this distribution, and is available |
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
# |
|
8 |
# Initial Contributors: |
|
9 |
# Symbian Foundation Ltd - initial contribution. |
|
10 |
# |
|
11 |
# Contributors: |
|
258
08436a227940
Add author information. Reviewed descriptions
Dario Sestito <darios@symbian.org>
parents:
177
diff
changeset
|
12 |
# Dario Sestito <darios@symbian.org> |
177 | 13 |
# |
14 |
# Description: |
|
15 |
# Preprocess a raptor log, trying to countermeasure a list of known anomalies |
|
16 |
||
17 |
use strict; |
|
18 |
||
19 |
use Getopt::Long; |
|
20 |
||
21 |
my $help = 0; |
|
22 |
GetOptions( |
|
23 |
'help!' => \$help, |
|
24 |
); |
|
25 |
||
26 |
if ($help) |
|
27 |
{ |
|
28 |
warn <<"EOF"; |
|
29 |
Preprocess a raptor log, trying to countermeasure a list of known anomalies |
|
30 |
||
31 |
Usage: perl preprocess_log.pl < INFILE > OUTFILE |
|
32 |
EOF |
|
33 |
exit(0); |
|
34 |
} |
|
35 |
||
36 |
while (my $line = <>) |
|
37 |
{ |
|
38 |
if ($line =~ m{<[^<^>]+>.*&.*</[^<^>]+>}) |
|
39 |
{ |
|
40 |
$line = escape_ampersand($line); |
|
41 |
} |
|
42 |
elsif ($line =~ m{<\?xml\s.*encoding=.*\".*\?>}) |
|
43 |
{ |
|
44 |
$line = set_encoding_utf8($line); |
|
45 |
} |
|
46 |
elsif ($line =~ m{<archive.*?[^/]>}) |
|
47 |
{ |
|
48 |
$line = unterminated_archive_tag($line, scalar <>, $.) |
|
49 |
} |
|
50 |
elsif ($line =~ m{make.exe: Circular .* <- .* dependency dropped.}) |
|
51 |
{ |
|
52 |
$line = escape_left_angle_bracket($line); |
|
53 |
} |
|
54 |
||
55 |
print $line; |
|
56 |
} |
|
57 |
||
58 |
sub escape_ampersand |
|
59 |
{ |
|
60 |
my ($line) = @_; |
|
61 |
||
62 |
warn "escape_ampersand\n"; |
|
63 |
warn "in: $line"; |
|
64 |
||
65 |
$line =~ s,&,&,g; |
|
66 |
||
67 |
warn "out: $line"; |
|
68 |
return $line; |
|
69 |
} |
|
70 |
||
71 |
sub set_encoding_utf8 |
|
72 |
{ |
|
73 |
my ($line) = @_; |
|
74 |
||
75 |
warn "set_encoding_utf8\n"; |
|
76 |
warn "in: $line"; |
|
77 |
||
78 |
$line =~ s,encoding=".*",encoding="utf-8",; |
|
79 |
||
80 |
warn "out: $line"; |
|
81 |
return $line; |
|
82 |
} |
|
83 |
||
84 |
sub unterminated_archive_tag |
|
85 |
{ |
|
86 |
my $line = shift; |
|
87 |
my $nextLine = shift; |
|
88 |
my $lineNum = shift; |
|
89 |
||
90 |
if ($nextLine !~ m{(<member>)|(</archive>)}) |
|
91 |
{ |
|
92 |
warn "unterminated_archive_tag\n"; |
|
93 |
warn "in: $line"; |
|
94 |
$line =~ s{>}{/>}; |
|
95 |
warn "out: $line"; |
|
96 |
} |
|
97 |
||
98 |
return $line . $nextLine; |
|
99 |
} |
|
100 |
||
101 |
sub escape_left_angle_bracket |
|
102 |
{ |
|
103 |
my ($line) = @_; |
|
104 |
||
105 |
warn "escape_left_angle_bracket\n"; |
|
106 |
warn "in: $line"; |
|
107 |
||
108 |
$line =~ s,<,<,g; |
|
109 |
||
110 |
warn "out: $line"; |
|
111 |
return $line; |
|
112 |
} |