From 84d98edf1b6124c9253810350e89949783e2c44e Mon Sep 17 00:00:00 2001 From: imiyazaki Date: Sat, 18 Oct 2003 11:15:35 +0000 Subject: [PATCH] add new DB structure. --- Chise_utils/Chise_utils.pm | 79 ++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/Chise_utils/Chise_utils.pm b/Chise_utils/Chise_utils.pm index aa95af1..184409c 100644 --- a/Chise_utils/Chise_utils.pm +++ b/Chise_utils/Chise_utils.pm @@ -31,7 +31,6 @@ our %EXPORT_TAGS = ( 'all' => [ qw( &get_char_attribute &get_chars_matching &get_chars_containing - &get_chars_matching &get_chars_for &de_er &ids_argc @@ -47,26 +46,22 @@ our $VERSION = '0.01'; # Preloaded methods go here. my $DB_HOME=""; -if(-e '/usr/local/lib/chise/char-db'){ - $DB_HOME='/usr/local/lib/chise/char-db'; -}elsif(-e '/usr/local/lib/xemacs-21.4.11/i686-pc-linux/char-db'){ - $DB_HOME='/usr/local/lib/xemacs-21.4.11/i686-pc-linux/char-db'; -}elsif(-e '/usr/local/lib/xemacs-21.4.11/powerpc-apple-darwin6.4/char-db'){ - $DB_HOME='/usr/local/lib/xemacs-21.4.11/powerpc-apple-darwin6.4/char-db'; -}elsif(-e '/usr/local/xemacs-utf2000/lib/xemacs-21.4.11/powerpc-apple-darwin6.4/char-db'){ - $DB_HOME='/usr/local/xemacs-utf2000/lib/xemacs-21.4.11/powerpc-apple-darwin6.4/char-db'; -}elsif(-e '/usr/local/lib/xemacs-21.4.10/i686-pc-linux/char-db'){ - $DB_HOME='/usr/local/lib/xemacs-21.4.10/i686-pc-linux/char-db'; -}elsif(-e '/usr/local/lib/xemacs-21.4.10/powerpc-apple-darwin6.4/char-db'){ - $DB_HOME='/usr/local/lib/xemacs-21.4.10/powerpc-apple-darwin6.4/char-db'; -}elsif(-e '/usr/local/xemacs-utf2000/lib/xemacs-21.4.10/powerpc-apple-darwin6.4/char-db'){ - $DB_HOME='/usr/local/xemacs-utf2000/lib/xemacs-21.4.10/powerpc-apple-darwin6.4/char-db'; -}elsif(-e 'd:/work/chise/char-db'){ - $DB_HOME='d:/work/chise/char-db'; -}else{ - print STDERR "No database found.\n"; - print STDERR "Pleas set \$DB_HOME to Chise_utils.pm.\n"; - exit 1; +unless($DB_HOME){ + if(-e '/usr/local/lib/chise/db'){ + $DB_HOME='/usr/local/lib/chise/db'; + }elsif(-e '/usr/lib/chise/db'){ + $DB_HOME='/usr/lib/chise/db'; + }elsif(-e '/sw/lib/chise/db'){ + $DB_HOME='/sw/lib/chise/db'; + }elsif(-e '/usr/local/lib/chise/char-db'){ + $DB_HOME='/usr/local/lib/chise/char-db'; + }elsif(-e 'd:/work/chise/char-db'){ + $DB_HOME='d:/work/chise/char-db'; + }else{ + print STDERR "No database found.\n"; + print STDERR "Pleas set \$DB_HOME to Chise_utils.pm.\n"; + exit 1; + } } $idc="\x{2ff0}-\x{2fff}"; @@ -105,18 +100,36 @@ my %er_alias = 'M','ideograph-daikanwa', ); -for (glob "$DB_HOME/system-char-id/*"){ - next if(/\.txt$/); - $atr=$_; - $atr=~s!$DB_HOME/system-char-id/!!; - $db{$atr}=$_; -} - -for (glob "$DB_HOME/*"){ - next if(/\.txt$/ or /system-char-id/); - $atr=$_; - $atr=~s!$DB_HOME/!!; - $reverse_db{$atr}=$_."/system-char-id"; +if(-d "$DB_HOME/character"){ + for (glob "$DB_HOME/character/feature/*"){ + next if(/\.txt$/); + $atr=$_; + $atr=~s!$DB_HOME/character/feature/!!; + $db{$atr}=$_; + } + for (glob "$DB_HOME/character/by-feature/*"){ + next if(/\.txt$/); + $atr=$_; + $atr=~s!$DB_HOME/character/feature/!!; + $reverse_db{$atr}=$_; + } +}elsif(-d "$DB_HOME/system-char-id"){ + for (glob "$DB_HOME/system-char-id/*"){ + next if(/\.txt$/); + $atr=$_; + $atr=~s!$DB_HOME/system-char-id/!!; + $db{$atr}=$_; + } + for (glob "$DB_HOME/*"){ + next if(/\.txt$/ or /system-char-id/); + $atr=$_; + $atr=~s!$DB_HOME/!!; + $reverse_db{$atr}=$_."/system-char-id"; + } +}else{ + print STDERR "No database found.\n"; + print STDERR "Pleas set \$DB_HOME to Chise_utils.pm correctly.\n"; + exit 1; } sub get_db{ -- 1.7.10.4