/[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.12 by wakaba, Sun Oct 26 09:26:56 2008 UTC
# Line 7  my $data2_suffix = q[.dat]; Line 7  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    
10    ## SEE ALSO: |Makefile|.
11    my $patch_file_name = $data2_dir_name . 'modified.txt';
12    
13  our $UseCVS //= 1;  our $UseCVS //= 1;
14    
15  sub normalize ($) {  sub normalize ($) {
# Line 88  sub write_data_file ($$) { Line 91  sub write_data_file ($$) {
91    print $file Data::Dumper::Dumper ($data);    print $file Data::Dumper::Dumper ($data);
92    close $file;    close $file;
93    unless ($had_file) {    unless ($had_file) {
94      system 'cvs', 'add', $file_name if $UseCVS;      system_ ('cvs', 'add', $file_name) if $UseCVS;
95    }    }
96  } # write_data_file  } # write_data_file
97    
# Line 97  sub hash_to_file_name ($) { Line 100  sub hash_to_file_name ($) {
100  } # hash_to_file_name  } # hash_to_file_name
101    
102  my $Entry = {};  my $Entry = {};
103    my $ModifiedHash = {};
104    
105  sub get_entry ($) {  sub get_entry ($) {
106    my $hash = shift;    my $hash = shift;
# Line 134  sub set_entry ($$$) { Line 138  sub set_entry ($$$) {
138      delete $Entry->{$file_name}->{pattern}->{$hash};      delete $Entry->{$file_name}->{pattern}->{$hash};
139    }    }
140    $Entry->{$file_name}->{modified} = 1;    $Entry->{$file_name}->{modified} = 1;
141      $ModifiedHash->{$hash} = 1;
142  } # set_entry  } # set_entry
143    
144  use Fcntl ':flock';  use Fcntl ':flock';
# Line 153  sub lock_entry ($) { Line 158  sub lock_entry ($) {
158  sub commit_entries ($) {  sub commit_entries ($) {
159    for my $file_name (keys %{$Entry}) {    for my $file_name (keys %{$Entry}) {
160      if ($Entry->{$file_name}->{modified}) {      if ($Entry->{$file_name}->{modified}) {
161          delete $Entry->{$file_name}->{modified};
162        write_data_file ($file_name => $Entry->{$file_name});        write_data_file ($file_name => $Entry->{$file_name});
163      }      }
164    }    }
165    
166      open my $file, '>>', $patch_file_name or die "$0: $patch_file_name: $!";
167      for (keys %$ModifiedHash) {
168        print $file "$_\n";
169      }
170      close $file;
171    
172    my $msg = shift // $0;    my $msg = shift // $0;
173    system 'cvs', 'commit', -m => $msg if $UseCVS;    system_ ('cvs', 'commit', -m => $msg, $data2_dir_name) if $UseCVS;
174  } # commit_entries  } # commit_entries
175    
176  sub get_all_entries () {  sub get_all_entries () {
# Line 183  sub get_fallback_entry ($) { Line 195  sub get_fallback_entry ($) {
195    return $FallbackEntry->{$hash} // {};    return $FallbackEntry->{$hash} // {};
196  } # get_fallback_entry  } # get_fallback_entry
197    
198    sub get_entry_or_fallback_entry ($) {
199      my $hash = shift;
200    
201      my ($is_pattern, $entry) = get_entry ($hash);
202      unless (defined $entry->{en}) {
203        $entry = get_fallback_entry ($hash);
204      }
205      $entry->{tags} ||= [] if defined $entry->{en};
206      $entry->{isPattern} = 1 if $is_pattern;
207    
208      return $entry;
209    } # get_entry_or_fallback_entry
210    
211  sub set_fallback_entry ($$) {  sub set_fallback_entry ($$) {
212    my ($hash, $value) = @_;    my ($hash, $value) = @_;
213    unless (defined $FallbackEntry) {    unless (defined $FallbackEntry) {
# Line 200  sub save_fallback_entries () { Line 225  sub save_fallback_entries () {
225        if defined $FallbackEntry;        if defined $FallbackEntry;
226  } # save_fallback_entries  } # save_fallback_entries
227    
228    sub get_modified_hashes () {
229      open my $file, '<', $patch_file_name or die "$0: $patch_file_name: $!";
230      return map {tr/\x0D\x0A//d; $_} <$file>;
231    } # get_modified_hashes
232    
233    sub clear_modified_hashes () {
234      open my $file, '>', $patch_file_name;
235      close $file;
236    } # clear_modified_hashes
237    
238  sub htescape ($) {  sub htescape ($) {
239    my $s = shift;    my $s = shift;
240    $s =~ s/&/&amp;/g;    $s =~ s/&/&amp;/g;
# Line 208  sub htescape ($) { Line 243  sub htescape ($) {
243    return $s;    return $s;
244  } # htescape  } # htescape
245    
246    sub system_ (@) {
247      (system join (' ', map {quotemeta $_} @_) . " > /dev/null") == 0
248          or die "$0: $?";
249    } # system_
250    
251  1;  1;
252    

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24