From: imiyazaki Date: Mon, 20 Oct 2003 16:24:32 +0000 (+0000) Subject: use flock. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e585964b5360de83811118cc1c67d881bf841293;p=chise%2Fomega.git use flock. use /usr/local/lib/chise/omega as a default directory of scripts and DB's. --- diff --git a/outCMAP b/outCMAP index 78d3666..c70563a 100755 --- a/outCMAP +++ b/outCMAP @@ -3,10 +3,12 @@ # ver.0.2 use strict; -use vars qw($opt_in_cs $opt_out_cs $opt_protrude +use vars qw($omegadb_path + $opt_protrude $opt_order + $opt_in_cs $opt_out_cs $opt_help $usage $in_cs $out_cs $i @chars - @order $opt_order %order + @order %order $char $char_id $out_char $ids $ids_argc %ids $idsdb $idsdata_file $ids_start $font_start @@ -16,8 +18,11 @@ use vars qw($opt_in_cs $opt_out_cs $opt_protrude ); use Getopt::Long; use utf8; +use Fcntl ':flock'; use Chise_utils ':all'; +my $omegadb_path="/usr/local/lib/chise/omega"; + ### Options ### $opt_order='jtcgk'; @@ -97,12 +102,25 @@ if($opt_help exit 1; } -$idsdata_file="idsdata.pl"; +$omegadb_path=~s!/$!!; + +$idsdata_file="$omegadb_path/idsdata.pl"; $ids_start=0x00; $font_start=0; if(-e $idsdata_file){ - require $idsdata_file; + open(IDSDATA,"+<$idsdata_file") or die; + flock(IDSDATA,LOCK_EX); + seek(IDSDATA,0,0); + while(){ + eval $_; + } + seek(IDSDATA,0,0); +# require $idsdata_file; +}else{ + open(IDSDATA,">$idsdata_file") or die; + flock(IDSDATA,LOCK_EX); + seek(IDSDATA,0,0); } $ids_argc=0; @@ -192,7 +210,6 @@ while(<>){ } } -open(IDSDATA,">$idsdata_file") or die; print IDSDATA 'use utf8;',"\n"; foreach $ids (keys %ids){ print IDSDATA '$ids{\'',$ids,'\'}=[',join ",",@{$ids{$ids}},"];\n" if($perl56); @@ -201,6 +218,7 @@ foreach $ids (keys %ids){ print IDSDATA '$font_start=',$font_start,";\n"; print IDSDATA '$ids_start=',$ids_start,";\n"; print IDSDATA "1;"; +flock(IDSDATA,LOCK_UN); exit 0;