michael@0: #!/usr/local/bin/perl -w michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: use IO::File; michael@0: my(%tagtofilemap); michael@0: $tagtofilemap{"kCNS1986-1" } = IO::File->new("|sort> cns1986p1.txt") michael@0: or die "cannot open cns1986p1.txt"; michael@0: $tagtofilemap{"kCNS1986-2" } = IO::File->new("|sort> cns1986p2.txt") michael@0: or die "cannot open cns1986p2.txt"; michael@0: $tagtofilemap{"kCNS1986-E" } = IO::File->new("|sort> cns1986p14.txt") michael@0: or die "cannot open cns1986p14.txt"; michael@0: $tagtofilemap{"kCNS1992-1" } = IO::File->new("|sort> cns1992p1.txt") michael@0: or die "cannot open cns1992p1.txt"; michael@0: $tagtofilemap{"kCNS1992-2" } = IO::File->new("|sort> cns1992p2.txt") michael@0: or die "cannot open cns1992p2.txt"; michael@0: $tagtofilemap{"kCNS1992-3" } = IO::File->new("|sort> cns1992p3.txt") michael@0: or die "cannot open cns1992p3.txt"; michael@0: $tagtofilemap{"kIRG_TSource-1" } = IO::File->new("|sort> cnsIRGTp1.txt") michael@0: or die "cannot open cnsIRGTp1.txt"; michael@0: $tagtofilemap{"kIRG_TSource-2" } = IO::File->new("|sort> cnsIRGTp2.txt") michael@0: or die "cannot open cnsIRGTp2.txt"; michael@0: $tagtofilemap{"kIRG_TSource-3" } = IO::File->new("|sort> cnsIRGTp3.txt") michael@0: or die "cannot open cnsIRGTp3.txt"; michael@0: $tagtofilemap{"kIRG_TSource-4" } = IO::File->new("|sort> cnsIRGTp4.txt") michael@0: or die "cannot open cnsIRGTp4.txt"; michael@0: $tagtofilemap{"kIRG_TSource-5" } = IO::File->new("|sort> cnsIRGTp5.txt") michael@0: or die "cannot open cnsIRGTp5.txt"; michael@0: $tagtofilemap{"kIRG_TSource-6" } = IO::File->new("|sort> cnsIRGTp6.txt") michael@0: or die "cannot open cnsIRGTp6.txt"; michael@0: $tagtofilemap{"kIRG_TSource-7" } = IO::File->new("|sort> cnsIRGTp7.txt") michael@0: or die "cannot open cnsIRGTp7.txt"; michael@0: $tagtofilemap{"kIRG_TSource-F" } = IO::File->new("|sort> cnsIRGTp15.txt") michael@0: or die "cannot open cnsIRGTp15.txt"; michael@0: $tagtofilemap{"kIRG_TSource-3ExtB" } = IO::File->new("|sort> cnsIRGTp3ExtB.txt") michael@0: or die "cannot open cnsIRGTp3ExtB.txt"; michael@0: $tagtofilemap{"kIRG_TSource-4ExtB" } = IO::File->new("|sort> cnsIRGTp4ExtB.txt") michael@0: or die "cannot open cnsIRGTp4ExtB.txt"; michael@0: $tagtofilemap{"kIRG_TSource-5ExtB" } = IO::File->new("|sort> cnsIRGTp5ExtB.txt") michael@0: or die "cannot open cnsIRGTp5ExtB.txt"; michael@0: $tagtofilemap{"kIRG_TSource-6ExtB" } = IO::File->new("|sort> cnsIRGTp6ExtB.txt") michael@0: or die "cannot open cnsIRGTp6ExtB.txt"; michael@0: $tagtofilemap{"kIRG_TSource-7ExtB" } = IO::File->new("|sort> cnsIRGTp7ExtB.txt") michael@0: or die "cannot open cnsIRGTp7ExtB.txt"; michael@0: $tagtofilemap{"kIRG_TSource-FExtB" } = IO::File->new("|sort> cnsIRGTp15ExtB.txt") michael@0: or die "cannot open cnsIRGTp15ExtB.txt"; michael@0: michael@0: $nonhan = IO::File->new("< nonhan.txt") michael@0: or die "cannot open nonhan.txt"; michael@0: michael@0: while(defined($line = $nonhan->getline())) michael@0: { michael@0: $tagtofilemap{"kCNS1986-1"}->print($line); michael@0: $tagtofilemap{"kCNS1992-1"}->print($line); michael@0: $tagtofilemap{"kIRG_TSource-1"}->print($line); michael@0: } michael@0: michael@0: while() michael@0: { michael@0: if(/^U/) michael@0: { michael@0: chop(); michael@0: ($u,$tag,$value) = split(/\t/,$_); michael@0: if($tag =~ m/(kCNS|kIRG_TSource)/) michael@0: { michael@0: ($pnum, $cvalue) = split(/-/,$value); michael@0: $tagkey = $tag . "-" . $pnum; michael@0: if(length($u) > 6) { michael@0: $tagkey .= "ExtB"; michael@0: } michael@0: $fd = $tagtofilemap{$tagkey}; michael@0: if(length($u) > 6) { michael@0: $mapping = substr($u,3,4); # trunkcate 0x2 from 0x2abcd michael@0: } else { michael@0: $mapping = substr($u,2,4); # trunkcate 0x from 0xabcd michael@0: } michael@0: $fd->print("0x" . $cvalue . "\t0x" . $mapping . "\t# \n"); michael@0: } michael@0: } michael@0: } michael@0: