source:
git/lib/fixmsgs.pl
@
ecdb631
| Last change on this file since ecdb631 was ffe7b714, checked in by , 14 years ago | |
|---|---|
|
|
| File size: 676 bytes | |
| Rev | Line | |
|---|---|---|
| [a39f74f] | 1 | #!/usr/bin/perl -w |
| [a269915] | 2 | require 5.008; |
| [ffe7b714] | 3 | use open ':encoding(utf8)'; |
| [a39f74f] | 4 | use strict; |
| 5 | ||
| 6 | use integer; | |
| 7 | ||
| 8 | my @ent = (); | |
| [ffe7b714] | 9 | for (128..65536) { |
| [a39f74f] | 10 | $ent[$_] = "#$_"; |
| 11 | } | |
| 12 | ||
| 13 | open ENT, "named-entities.txt" or die $!; | |
| 14 | while (<ENT>) { | |
| 15 | my ($e, $v) = /^(\w+),(\d+)/; | |
| 16 | $ent[$v] = $e; | |
| 17 | } | |
| 18 | close ENT; | |
| 19 | ||
| 20 | while (<>) { | |
| 21 | if (/^\s*#/) { | |
| 22 | print; | |
| 23 | next; | |
| 24 | } | |
| 25 | ||
| 26 | my ($pre, $msg) = /^([-\w,]+:\s*\d+\s+)(.*)/; | |
| 27 | ||
| [ffe7b714] | 28 | $msg =~ s/([\x{80}-\x{ffff}])/"&".$ent[ord($1)].";"/ge; |
| [a39f74f] | 29 | |
| 30 | $msg =~ s/'\%s'/`%s'/g; | |
| [417e9b3] | 31 | $msg =~ s/^([^`']* )\%s'/$1`%s'/; |
| 32 | $msg =~ s/^([^`']* `\%s'[^`']* )\%s'/$1`%s'/; | |
| 33 | $pre =~ s/: (\d\d\d\b)/:$1/; | |
| 34 | $pre =~ s/:(\d\d\b)/: $1/; | |
| 35 | $pre =~ s/: ?(\d\b)/: $1/; | |
| [a39f74f] | 36 | |
| 37 | print "$pre$msg\n"; | |
| 38 | } |
Note: See TracBrowser
for help on using the repository browser.
