diff options
| author | duerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-18 08:10:57 +0000 |
|---|---|---|
| committer | duerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-18 08:10:57 +0000 |
| commit | bc7926478a4716634f8f7066a7ff1c9012d1caa4 (patch) | |
| tree | 2bf5d9ef0c73501675d34bd6f85cbe613640ef06 /tool/transcode-tblgen.rb | |
| parent | 63cbd24fa3584ac1ca05246f558de451d0f68e8a (diff) | |
| download | ruby-bc7926478a4716634f8f7066a7ff1c9012d1caa4.tar.gz ruby-bc7926478a4716634f8f7066a7ff1c9012d1caa4.tar.xz ruby-bc7926478a4716634f8f7066a7ff1c9012d1caa4.zip | |
* tool/transcode-tblgen.rb: added set_valid_byte_pattern
to reduce coupling between table generation script and
specific encodings.
* enc/trans/single_byte.trans: using set_valid_byte_pattern
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/transcode-tblgen.rb')
| -rw-r--r-- | tool/transcode-tblgen.rb | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb index b785e0739..870d971e9 100644 --- a/tool/transcode-tblgen.rb +++ b/tool/transcode-tblgen.rb @@ -726,28 +726,23 @@ ValidEncoding = { {81-fe}{30-39}{81-fe}{30-39}', } -{ - 'ASCII-8BIT' => '1byte', - 'ISO-8859-1' => '1byte', - 'ISO-8859-2' => '1byte', - 'ISO-8859-3' => '1byte', - 'ISO-8859-4' => '1byte', - 'ISO-8859-5' => '1byte', - 'ISO-8859-6' => '1byte', - 'ISO-8859-7' => '1byte', - 'ISO-8859-8' => '1byte', - 'ISO-8859-9' => '1byte', - 'ISO-8859-10' => '1byte', - 'ISO-8859-11' => '1byte', - 'ISO-8859-13' => '1byte', - 'ISO-8859-14' => '1byte', - 'ISO-8859-15' => '1byte', - 'WINDOWS-1252' => '1byte', - 'Windows-31J' => 'Shift_JIS', - 'eucJP-ms' => 'EUC-JP' -}.each {|k, v| - ValidEncoding[k] = ValidEncoding.fetch(v) -} +def set_valid_byte_pattern (encoding, pattern_or_label) + pattern = + if ValidEncoding[pattern_or_label] + ValidEncoding[pattern_or_label] + else + pattern_or_label + end + if ValidEncoding[encoding] and ValidEncoding[encoding]!=pattern + raise ArgumentError, "trying to change valid byte pattern for encoding #{encoding} from #{ValidEncoding[encoding]} to #{pattern}" + end + ValidEncoding[encoding] = pattern +end + +# the following may be used in different places, so keep them here for the moment +set_valid_byte_pattern 'ASCII-8BIT', '1byte' +set_valid_byte_pattern 'Windows-31J', 'Shift_JIS' +set_valid_byte_pattern 'eucJP-ms', 'EUC-JP' def make_signature(filename, src) "src=#{filename.dump}, len=#{src.length}, checksum=#{src.sum}" |
