projects
/
chise
/
perl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
change regular expression in &de_er
[chise/perl.git]
/
Chise_utils
/
Chise_utils.pm
diff --git
a/Chise_utils/Chise_utils.pm
b/Chise_utils/Chise_utils.pm
index
8414736
..
5967978
100644
(file)
--- a/
Chise_utils/Chise_utils.pm
+++ b/
Chise_utils/Chise_utils.pm
@@
-193,8
+193,9
@@
sub get_chars_matching{
}
}
else{
}
}
else{
-# # fall back if DB inconsistency exists.
+# never fall back.
# unless(@res){
# unless(@res){
+# # fall back if DB inconsistency exists.
if(&get_db($atr)){
foreach $char (keys %{$chardb{$atr}}){
if($chardb{$atr}->{$char} eq $value){
if(&get_db($atr)){
foreach $char (keys %{$chardb{$atr}}){
if($chardb{$atr}->{$char} eq $value){
@@
-227,22
+228,21
@@
sub get_chars_for{
}
}
}
}
}
}
- foreach (keys %res){
- if($res{$_}==$i){
- push @res,$_;
- }
- }
- return @res;
+ return grep {defined($res{$_}) and $res{$_}==$i} (keys %res);
}
sub de_er{
my($er)=@_;
my($output_char,$atr,$value);
}
sub de_er{
my($er)=@_;
my($output_char,$atr,$value);
+ my($prefix,$suffix);
+ $er=~/^(amp|&)?(.+?)(;)?$/
+ and $prefix=$1,$er=$2,$suffix=$3;
+ $prefix or $prefix="",$suffix or $suffix="";
if($er=~/^\d+$/){
$output_char=pack("U",$er);
}elsif($er=~/^U[\+\-]([a-fA-F\d]+)/){
$output_char=pack("U",hex($1));
if($er=~/^\d+$/){
$output_char=pack("U",$er);
}elsif($er=~/^U[\+\-]([a-fA-F\d]+)/){
$output_char=pack("U",hex($1));
- }elsif($er=~/(?:I\-)?($er_prefix_re)\-?([0-9a-fA-F]+)/){
+ }elsif($er=~/^(?:I\-)?($er_prefix_re)\-?([0-9a-fA-F]+)$/){
($atr,$value)=($1,$2);
unless($er_alias{$atr}=~/daikanwa|gt/){
$value=hex($value);
($atr,$value)=($1,$2);
unless($er_alias{$atr}=~/daikanwa|gt/){
$value=hex($value);
@@
-250,9
+250,9
@@
sub de_er{
($output_char)=&get_chars_matching($er_alias{$atr},$value);
}
if($output_char){
($output_char)=&get_chars_matching($er_alias{$atr},$value);
}
if($output_char){
- return $output_char;
+ return $output_char;
}else{
}else{
- return $er;
+ return $prefix.$er.$suffix;
}
}
}
}