Fix #338: re.sub() flag argument at wrong position.
[docutils.git] / prest / tbin / rexml
blobcb913fac4f1d0916a55bc1fe577de8212c00da02
1 #!/usr/local/bin/perl -p
3 # Converts a dom to a regular-expression DOM
4 s/([\(\)\[\]\{\}\.\+\*\?\|\\\^\$])/\\$1/g;
5 s/id\d+/id\\d+/g;
6 s/line="\d+"/line="\\d+"/g;
7 # Remove bogus A-circumflex
8 s/\xc2//g;
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
16 s|(\d\d\d\d)-(\d\d)-(\d\d)|$1\[-/\]$2\[-/\]$3|g;
17 # Handle uppercase vs lowercase unicode
18 s/(\\u)([\da-f]{4})/$1(?i)$2/ig;
19 # Deal with revisions that may change
20 if ($AFTER_REVISION) {
21 s/\d+(\\\.\d+)+/\\d+(\\.\\d+)+/;
22 $AFTER_REVISION = 0;
24 $AFTER_REVISION = /<revision>/;
25 # Deal with dates that may change
26 if ($AFTER_DATE) {
27 s|\d{4}[/-]\d{2}[/-]\d{2}|\\d{4}[/-]\\d{2}[/-]\\d{2}|;
28 $AFTER_DATE = 0;
30 # Deal with perl eval numbers that may change in error messages
31 s/(eval )(\d+)/$1\\d+/;
32 $AFTER_DATE = /<date>/;
33 # Perl trapped error message changed between 5.8.0 and 5.8.6.
34 s/(: )(.*)( trapped by operation mask)/$1($2|.*)$3/;