/[suikacvs]/markup/html/html5/spec-ja/common.pl
Suika

Diff of /markup/html/html5/spec-ja/common.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by wakaba, Sun Oct 26 06:22:32 2008 UTC revision 1.11 by wakaba, Sun Oct 26 08:44:19 2008 UTC
# Line 6  my $data2_dir_name = q[data2/]; Line 6  my $data2_dir_name = q[data2/];
6  my $data2_suffix = q[.dat];  my $data2_suffix = q[.dat];
7  my $lock_suffix = q[.lock];  my $lock_suffix = q[.lock];
8  my $fallback_file_name = $data2_dir_name . 'fallback' . $data2_suffix;  my $fallback_file_name = $data2_dir_name . 'fallback' . $data2_suffix;
9    my $patch_file_name = $data2_dir_name . 'modified.txt';
10    
11  our $UseCVS //= 1;  our $UseCVS //= 1;
12    
# Line 88  sub write_data_file ($$) { Line 89  sub write_data_file ($$) {
89    print $file Data::Dumper::Dumper ($data);    print $file Data::Dumper::Dumper ($data);
90    close $file;    close $file;
91    unless ($had_file) {    unless ($had_file) {
92      system 'cvs', 'add', $file_name if $UseCVS;      system_ ('cvs', 'add', $file_name) if $UseCVS;
93    }    }
94  } # write_data_file  } # write_data_file
95    
# Line 97  sub hash_to_file_name ($) { Line 98  sub hash_to_file_name ($) {
98  } # hash_to_file_name  } # hash_to_file_name
99    
100  my $Entry = {};  my $Entry = {};
101    my $ModifiedHash = {};
102    
103  sub get_entry ($) {  sub get_entry ($) {
104    my $hash = shift;    my $hash = shift;
# Line 134  sub set_entry ($$$) { Line 136  sub set_entry ($$$) {
136      delete $Entry->{$file_name}->{pattern}->{$hash};      delete $Entry->{$file_name}->{pattern}->{$hash};
137    }    }
138    $Entry->{$file_name}->{modified} = 1;    $Entry->{$file_name}->{modified} = 1;
139      $ModifiedHash->{$hash} = 1;
140  } # set_entry  } # set_entry
141    
142  use Fcntl ':flock';  use Fcntl ':flock';
# Line 153  sub lock_entry ($) { Line 156  sub lock_entry ($) {
156  sub commit_entries ($) {  sub commit_entries ($) {
157    for my $file_name (keys %{$Entry}) {    for my $file_name (keys %{$Entry}) {
158      if ($Entry->{$file_name}->{modified}) {      if ($Entry->{$file_name}->{modified}) {
159          delete $Entry->{$file_name}->{modified};
160        write_data_file ($file_name => $Entry->{$file_name});        write_data_file ($file_name => $Entry->{$file_name});
161      }      }
162    }    }
163    
164      open my $file, '>>', $patch_file_name or die "$0: $patch_file_name: $!";
165      for (keys %$ModifiedHash) {
166        print $file "$_\n";
167      }
168      close $file;
169    
170    my $msg = shift // $0;    my $msg = shift // $0;
171    system 'cvs', 'commit', -m => $msg if $UseCVS;    system_ ('cvs', 'commit', -m => $msg, $data2_dir_name) if $UseCVS;
172  } # commit_entries  } # commit_entries
173    
174  sub get_all_entries () {  sub get_all_entries () {
# Line 183  sub get_fallback_entry ($) { Line 193  sub get_fallback_entry ($) {
193    return $FallbackEntry->{$hash} // {};    return $FallbackEntry->{$hash} // {};
194  } # get_fallback_entry  } # get_fallback_entry
195    
196    sub get_entry_or_fallback_entry ($) {
197      my $hash = shift;
198    
199      my ($is_pattern, $entry) = get_entry ($hash);
200      unless (defined $entry->{en}) {
201        $entry = get_fallback_entry ($hash);
202      }
203      $entry->{tags} ||= [] if defined $entry->{en};
204      $entry->{isPattern} = 1 if $is_pattern;
205    
206      return $entry;
207    } # get_entry_or_fallback_entry
208    
209  sub set_fallback_entry ($$) {  sub set_fallback_entry ($$) {
210    my ($hash, $value) = @_;    my ($hash, $value) = @_;
211    unless (defined $FallbackEntry) {    unless (defined $FallbackEntry) {
# Line 200  sub save_fallback_entries () { Line 223  sub save_fallback_entries () {
223        if defined $FallbackEntry;        if defined $FallbackEntry;
224  } # save_fallback_entries  } # save_fallback_entries
225    
226    sub get_modified_hashes () {
227      open my $file, '<', $patch_file_name or die "$0: $patch_file_name: $!";
228      return map {tr/\x0D\x0A//d; $_} <$file>;
229    } # get_modified_hashes
230    
231    sub clear_modified_hashes () {
232      open my $file, '>', $patch_file_name;
233      close $file;
234    } # clear_modified_hashes
235    
236  sub htescape ($) {  sub htescape ($) {
237    my $s = shift;    my $s = shift;
238    $s =~ s/&/&amp;/g;    $s =~ s/&/&amp;/g;
# Line 208  sub htescape ($) { Line 241  sub htescape ($) {
241    return $s;    return $s;
242  } # htescape  } # htescape
243    
244    sub system_ (@) {
245      (system join (' ', map {quotemeta $_} @_) . " > /dev/null") == 0
246          or die "$0: $?";
247    } # system_
248    
249  1;  1;
250    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.11

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24