use vars qw($cmapfile $db_home $encoding
%cs_var
$ucs $cid $last
- $ciddb_filename $ciddb
+ $ciddb_filename $ciddb %ciddb %cid
);
use BerkeleyDB;
use Chise_utils ':all';
print STDERR "Removing old DB $db_home/$ciddb_filename.\n";
unlink "$db_home/$ciddb_filename";
}
-$ciddb=new BerkeleyDB::Hash
- -Filename => "$db_home/$ciddb_filename", -Flags => DB_CREATE
+
+$ciddb=tie %ciddb, 'BerkeleyDB::Hash',
+ -Filename => "$db_home/$ciddb_filename",
+ -Flags => DB_CREATE|DB_TRUNCATE,
+ -Pagesize => 512,
or die $!;
my $in_cidrange=0;
close(CMAP);
print STDERR "done!\n";
+print STDERR "Storing data to CHISE DB...";
+foreach my $char (sort keys %cid){
+ unless($ciddb->db_put("?".$char,$cid{$char})==0){
+ die $!;
+ }
+}
+print STDERR "done!\n";
+
+undef $ciddb;
+untie %ciddb;
+
exit 0;
sub store_cid{
if($debug){
print STDERR sprintf("%X:%d\n",unpack("U",$char),$cid);
}
- unless($ciddb->db_put("?".$char,$cid)==0){
- die $!;
- }
+ $cid{$char}=$cid;
}
sub replace_char_id{