1 #!/usr/local/bin/perl -p
3 # Converts a dom to a regular-expression DOM
4 s/([\(\)\[\]\{\}\.\+\*\?\|\\\^\$])/\\$1/g;
6 s/line="\d+"/line="\\d+"/g;
7 # Remove bogus A-circumflex
9 # Deal with unicode characters
10 s/([\x00-\x09\x0b-\x1f\x7f-\xff\x{0100}-\x{ffff}])/sprintf '\\\\u%04x', ord $1/ge;
11 # Handle the "Generated on" date
12 s/(Generated on: *).*/$1.*/;
13 # Handle the "Generated by" description
14 s/^( *Generated by *)/$1.*/;
15 # Accommodate different date formats
17 $time = '(\s+\d+:\d+:\d+(\s+[-+]\d+(\s+\(.+?\))?)?)?';
18 ($timere = $time) =~ s/\\([()])/\\\\\\$1/g;
20 s!(\d{4})([-/])(\d{2})\2(\d{2})$timere!\\d{4}[-/\]\\d{2}\[-/\]\\d{2}$time!go;
21 # Handle uppercase vs lowercase unicode
22 s/(\\u)([\da-f]{4})/$1(?i)$2/ig;
23 # Deal with revisions that may change
24 s/(prest release )\d+(\\\.\d+)+/$1\\d+(\\.\\d+)+/;
25 if ($AFTER_REVISION) {
26 s/\d+(\\\.\d+)+/\\d+(\\.\\d+)+/;
29 $AFTER_REVISION = /<revision>/;
30 # Deal with dates that may change
32 s
|\d
{4}[/-]\d{2}[/-]\d
{2}|\\d
{4}[/-]\\d{2}[/-]\\d
{2}|;
35 # Deal with perl eval numbers that may change in error messages
36 s/\\\((eval )(\d+)\\\).*/\\($1\\d+\\).*/;
37 $AFTER_DATE = /<date>/;
38 # Perl trapped error message changed between 5.8.0 and 5.8.6.
39 s/(: )(.*)( trapped by operation mask)/$1($2|.*)$3/;
40 # System messages may differ in different locales
41 s/(\\\[Errno \d+\\\])(.*)/$1($2|.*)/;
42 s/(\bstates: )(.*)/$1($2|.*)/;
44 s!^.*(/Text/Restructured/Writer/dom\\\.wrt, line )\d+!.*$1\\d+!;
45 # Handle line numbers in error messages
46 s!\S+(/\S+\\\.(?:pm|wrt),? line )(\d+)(, <\w+> line \d+)?!.*$1($2|\\d+)(, <\\w+> line \\d+)?!g;