diff options
| author | Derek Moore <42558474+derekcmoore@users.noreply.github.com> | 2023-11-19 21:02:50 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-11-20 02:02:55 +0000 |
| commit | 701b0650de8a5b1436ce1abc65e0fcc2be480c2d (patch) | |
| tree | 37b9e9df1b389995c7945de590b021e1a2d3cfb9 | |
| parent | 9aee12cc28cbca40306784e54e38558688caa9f7 (diff) | |
[ruby/prism] feat: add encoding for IBM865
(https://github.com/ruby/prism/pull/1884)
* feat: add encoding for IBM865
* style: fix incorrect autoformat
https://github.com/ruby/prism/commit/14c6ae0182
| -rw-r--r-- | prism/enc/pm_encoding.h | 1 | ||||
| -rw-r--r-- | prism/enc/pm_tables.c | 35 | ||||
| -rw-r--r-- | prism/prism.c | 2 | ||||
| -rw-r--r-- | test/prism/encoding_test.rb | 1 |
4 files changed, 39 insertions, 0 deletions
diff --git a/prism/enc/pm_encoding.h b/prism/enc/pm_encoding.h index bd7d7ba1f2..a062bbe591 100644 --- a/prism/enc/pm_encoding.h +++ b/prism/enc/pm_encoding.h @@ -177,6 +177,7 @@ extern pm_encoding_t pm_encoding_ibm860; extern pm_encoding_t pm_encoding_ibm861; extern pm_encoding_t pm_encoding_ibm862; extern pm_encoding_t pm_encoding_ibm864; +extern pm_encoding_t pm_encoding_ibm865; extern pm_encoding_t pm_encoding_ibm866; extern pm_encoding_t pm_encoding_iso_8859_1; extern pm_encoding_t pm_encoding_iso_8859_2; diff --git a/prism/enc/pm_tables.c b/prism/enc/pm_tables.c index a4d479998a..87c7bfb495 100644 --- a/prism/enc/pm_tables.c +++ b/prism/enc/pm_tables.c @@ -386,6 +386,30 @@ static uint8_t pm_encoding_ibm864_table[256] = { /** * Each element of the following table contains a bitfield that indicates a + * piece of information about the corresponding IBM865 character. + */ +static uint8_t pm_encoding_ibm865_table[256] = { +// 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x + 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx +}; + +/** + * Each element of the following table contains a bitfield that indicates a * piece of information about the corresponding IBM866 character. */ static uint8_t pm_encoding_ibm866_table[256] = { @@ -1328,6 +1352,7 @@ PRISM_ENCODING_TABLE(ibm860) PRISM_ENCODING_TABLE(ibm861) PRISM_ENCODING_TABLE(ibm862) PRISM_ENCODING_TABLE(ibm864) +PRISM_ENCODING_TABLE(ibm865) PRISM_ENCODING_TABLE(ibm866) PRISM_ENCODING_TABLE(iso_8859_1) PRISM_ENCODING_TABLE(iso_8859_2) @@ -1538,6 +1563,16 @@ pm_encoding_t pm_encoding_ibm864 = { }; /** IBM866 */ +pm_encoding_t pm_encoding_ibm865 = { + .name = "IBM865", + .char_width = pm_encoding_single_char_width, + .alnum_char = pm_encoding_ibm865_alnum_char, + .alpha_char = pm_encoding_ibm865_alpha_char, + .isupper_char = pm_encoding_ibm865_isupper_char, + .multibyte = false +}; + +/** IBM866 */ pm_encoding_t pm_encoding_ibm866 = { .name = "IBM866", .char_width = pm_encoding_single_char_width, diff --git a/prism/prism.c b/prism/prism.c index 850b35c3c7..86d9fce00f 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -6077,6 +6077,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star ENCODING1("CP861", pm_encoding_ibm861); ENCODING1("CP862", pm_encoding_ibm862); ENCODING1("CP864", pm_encoding_ibm864); + ENCODING1("CP865", pm_encoding_ibm865); ENCODING1("CP866", pm_encoding_ibm866); ENCODING1("CP874", pm_encoding_windows_874); ENCODING1("CP878", pm_encoding_koi8_r); @@ -6118,6 +6119,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star ENCODING1("IBM861", pm_encoding_ibm861); ENCODING1("IBM862", pm_encoding_ibm862); ENCODING1("IBM864", pm_encoding_ibm864); + ENCODING1("IBM865", pm_encoding_ibm865); ENCODING1("IBM866", pm_encoding_ibm866); ENCODING2("ISO-8859-1", "ISO8859-1", pm_encoding_iso_8859_1); ENCODING2("ISO-8859-2", "ISO8859-2", pm_encoding_iso_8859_2); diff --git a/test/prism/encoding_test.rb b/test/prism/encoding_test.rb index ce9a2fc998..bc9aae8e8a 100644 --- a/test/prism/encoding_test.rb +++ b/test/prism/encoding_test.rb @@ -24,6 +24,7 @@ module Prism Encoding::IBM861 => 0x00...0x100, Encoding::IBM862 => 0x00...0x100, Encoding::IBM864 => 0x00...0x100, + Encoding::IBM865 => 0x00...0x100, Encoding::IBM866 => 0x00...0x100, Encoding::ISO_8859_1 => 0x00...0x100, Encoding::ISO_8859_2 => 0x00...0x100, |
