intl/uconv/tools/unihan2cns.pl

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 #!/usr/local/bin/perl -w
michael@0 2 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5
michael@0 6 use IO::File;
michael@0 7 my(%tagtofilemap);
michael@0 8 $tagtofilemap{"kCNS1986-1" } = IO::File->new("|sort> cns1986p1.txt")
michael@0 9 or die "cannot open cns1986p1.txt";
michael@0 10 $tagtofilemap{"kCNS1986-2" } = IO::File->new("|sort> cns1986p2.txt")
michael@0 11 or die "cannot open cns1986p2.txt";
michael@0 12 $tagtofilemap{"kCNS1986-E" } = IO::File->new("|sort> cns1986p14.txt")
michael@0 13 or die "cannot open cns1986p14.txt";
michael@0 14 $tagtofilemap{"kCNS1992-1" } = IO::File->new("|sort> cns1992p1.txt")
michael@0 15 or die "cannot open cns1992p1.txt";
michael@0 16 $tagtofilemap{"kCNS1992-2" } = IO::File->new("|sort> cns1992p2.txt")
michael@0 17 or die "cannot open cns1992p2.txt";
michael@0 18 $tagtofilemap{"kCNS1992-3" } = IO::File->new("|sort> cns1992p3.txt")
michael@0 19 or die "cannot open cns1992p3.txt";
michael@0 20 $tagtofilemap{"kIRG_TSource-1" } = IO::File->new("|sort> cnsIRGTp1.txt")
michael@0 21 or die "cannot open cnsIRGTp1.txt";
michael@0 22 $tagtofilemap{"kIRG_TSource-2" } = IO::File->new("|sort> cnsIRGTp2.txt")
michael@0 23 or die "cannot open cnsIRGTp2.txt";
michael@0 24 $tagtofilemap{"kIRG_TSource-3" } = IO::File->new("|sort> cnsIRGTp3.txt")
michael@0 25 or die "cannot open cnsIRGTp3.txt";
michael@0 26 $tagtofilemap{"kIRG_TSource-4" } = IO::File->new("|sort> cnsIRGTp4.txt")
michael@0 27 or die "cannot open cnsIRGTp4.txt";
michael@0 28 $tagtofilemap{"kIRG_TSource-5" } = IO::File->new("|sort> cnsIRGTp5.txt")
michael@0 29 or die "cannot open cnsIRGTp5.txt";
michael@0 30 $tagtofilemap{"kIRG_TSource-6" } = IO::File->new("|sort> cnsIRGTp6.txt")
michael@0 31 or die "cannot open cnsIRGTp6.txt";
michael@0 32 $tagtofilemap{"kIRG_TSource-7" } = IO::File->new("|sort> cnsIRGTp7.txt")
michael@0 33 or die "cannot open cnsIRGTp7.txt";
michael@0 34 $tagtofilemap{"kIRG_TSource-F" } = IO::File->new("|sort> cnsIRGTp15.txt")
michael@0 35 or die "cannot open cnsIRGTp15.txt";
michael@0 36 $tagtofilemap{"kIRG_TSource-3ExtB" } = IO::File->new("|sort> cnsIRGTp3ExtB.txt")
michael@0 37 or die "cannot open cnsIRGTp3ExtB.txt";
michael@0 38 $tagtofilemap{"kIRG_TSource-4ExtB" } = IO::File->new("|sort> cnsIRGTp4ExtB.txt")
michael@0 39 or die "cannot open cnsIRGTp4ExtB.txt";
michael@0 40 $tagtofilemap{"kIRG_TSource-5ExtB" } = IO::File->new("|sort> cnsIRGTp5ExtB.txt")
michael@0 41 or die "cannot open cnsIRGTp5ExtB.txt";
michael@0 42 $tagtofilemap{"kIRG_TSource-6ExtB" } = IO::File->new("|sort> cnsIRGTp6ExtB.txt")
michael@0 43 or die "cannot open cnsIRGTp6ExtB.txt";
michael@0 44 $tagtofilemap{"kIRG_TSource-7ExtB" } = IO::File->new("|sort> cnsIRGTp7ExtB.txt")
michael@0 45 or die "cannot open cnsIRGTp7ExtB.txt";
michael@0 46 $tagtofilemap{"kIRG_TSource-FExtB" } = IO::File->new("|sort> cnsIRGTp15ExtB.txt")
michael@0 47 or die "cannot open cnsIRGTp15ExtB.txt";
michael@0 48
michael@0 49 $nonhan = IO::File->new("< nonhan.txt")
michael@0 50 or die "cannot open nonhan.txt";
michael@0 51
michael@0 52 while(defined($line = $nonhan->getline()))
michael@0 53 {
michael@0 54 $tagtofilemap{"kCNS1986-1"}->print($line);
michael@0 55 $tagtofilemap{"kCNS1992-1"}->print($line);
michael@0 56 $tagtofilemap{"kIRG_TSource-1"}->print($line);
michael@0 57 }
michael@0 58
michael@0 59 while(<STDIN>)
michael@0 60 {
michael@0 61 if(/^U/)
michael@0 62 {
michael@0 63 chop();
michael@0 64 ($u,$tag,$value) = split(/\t/,$_);
michael@0 65 if($tag =~ m/(kCNS|kIRG_TSource)/)
michael@0 66 {
michael@0 67 ($pnum, $cvalue) = split(/-/,$value);
michael@0 68 $tagkey = $tag . "-" . $pnum;
michael@0 69 if(length($u) > 6) {
michael@0 70 $tagkey .= "ExtB";
michael@0 71 }
michael@0 72 $fd = $tagtofilemap{$tagkey};
michael@0 73 if(length($u) > 6) {
michael@0 74 $mapping = substr($u,3,4); # trunkcate 0x2 from 0x2abcd
michael@0 75 } else {
michael@0 76 $mapping = substr($u,2,4); # trunkcate 0x from 0xabcd
michael@0 77 }
michael@0 78 $fd->print("0x" . $cvalue . "\t0x" . $mapping . "\t# <CJK>\n");
michael@0 79 }
michael@0 80 }
michael@0 81 }
michael@0 82

mercurial