summaryrefslogtreecommitdiff
path: root/lib/unicore/mktables
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-07-26 22:42:30 -0600
committerKarl Williamson <khw@cpan.org>2015-01-21 22:47:29 -0700
commit96f226dcd1c032e4aa63811b6c7dcd3377c58e60 (patch)
tree75f270f8192c78f6116d6d750f90596368495497 /lib/unicore/mktables
parentdac6f618109778d73776927716e7efcf3b033bb9 (diff)
downloadperl-96f226dcd1c032e4aa63811b6c7dcd3377c58e60.tar.gz
mktables: Verify Unihan files versions
Most Unicode files contain versioning information. Prior to this patch, mktables did not verify that the Unihan inputs were the correct version. This is in part because we don't usually compile the Unihan properties, and because the beta files for Unicode 7.0 had the version information in the same syntax as the rest of the files, so I thought we only had to wait till 7.0 came out, and we would get the protection automatically with the code that was already there. But the format changed between beta and release, so this patch adds code to check for the released format.
Diffstat (limited to 'lib/unicore/mktables')
-rw-r--r--lib/unicore/mktables22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/unicore/mktables b/lib/unicore/mktables
index 7569573e4b..6276d1ee4c 100644
--- a/lib/unicore/mktables
+++ b/lib/unicore/mktables
@@ -2512,18 +2512,28 @@ END
}
$handle{$addr} = $file_handle; # Cache the open file handle
- if ($v_version ge v3.2.0
- && lc($file) ne 'unicodedata.txt'
-
- # Unihan files used another format until v7
- && ($v_version ge v7.0.0 || $file !~ /^Unihan/i))
- {
+ if ($v_version ge v3.2.0 && lc($file) ne 'unicodedata.txt') {
+ if ($file !~ /^Unihan/i) {
$_ = <$file_handle>;
if ($_ !~ / - $string_version \. /x) {
chomp;
$_ =~ s/^#\s*//;
die Carp::my_carp("File '$file' is version '$_'. It should be version $string_version");
}
+ }
+ else {
+ while (<$file_handle>) {
+ if ($_ !~ /^#/) {
+ Carp::my_carp_bug("Could not find the expected version info in file '$file'");
+ last;
+ }
+ chomp;
+ $_ =~ s/^#\s*//;
+ next if $_ !~ / version: /x;
+ last if $_ =~ /$string_version/;
+ die Carp::my_carp("File '$file' is '$_'. It should be version $string_version");
+ }
+ }
}
}