From 076d0957b9f2f293a58a8572d7004e90b8affded Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Sun, 12 Nov 2023 00:09:10 -0500 Subject: [ruby/prism] IBM855 encoding https://github.com/ruby/prism/commit/9354ad1848 --- prism/enc/pm_encoding.h | 1 + prism/enc/pm_tables.c | 35 +++++++++++++++++++++++++++++++++++ prism/prism.c | 1 + test/prism/encoding_test.rb | 1 + 4 files changed, 38 insertions(+) diff --git a/prism/enc/pm_encoding.h b/prism/enc/pm_encoding.h index 94d0dc37d3..777387c885 100644 --- a/prism/enc/pm_encoding.h +++ b/prism/enc/pm_encoding.h @@ -169,6 +169,7 @@ extern pm_encoding_t pm_encoding_ibm720; extern pm_encoding_t pm_encoding_ibm737; extern pm_encoding_t pm_encoding_ibm775; extern pm_encoding_t pm_encoding_ibm852; +extern pm_encoding_t pm_encoding_ibm855; extern pm_encoding_t pm_encoding_iso_8859_1; extern pm_encoding_t pm_encoding_iso_8859_2; extern pm_encoding_t pm_encoding_iso_8859_3; diff --git a/prism/enc/pm_tables.c b/prism/enc/pm_tables.c index ae628c9fad..ab4ac358e4 100644 --- a/prism/enc/pm_tables.c +++ b/prism/enc/pm_tables.c @@ -216,6 +216,30 @@ static uint8_t pm_encoding_ibm852_table[256] = { 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 IBM855 character. + */ +static uint8_t pm_encoding_ibm855_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 ISO-8859-1 character. @@ -889,6 +913,7 @@ PRISM_ENCODING_TABLE(ibm720) PRISM_ENCODING_TABLE(ibm737) PRISM_ENCODING_TABLE(ibm775) PRISM_ENCODING_TABLE(ibm852) +PRISM_ENCODING_TABLE(ibm855) PRISM_ENCODING_TABLE(iso_8859_1) PRISM_ENCODING_TABLE(iso_8859_2) PRISM_ENCODING_TABLE(iso_8859_3) @@ -1017,6 +1042,16 @@ pm_encoding_t pm_encoding_ibm852 = { .multibyte = false }; +/** IBM855 */ +pm_encoding_t pm_encoding_ibm855 = { + .name = "IBM855", + .char_width = pm_encoding_single_char_width, + .alnum_char = pm_encoding_ibm855_alnum_char, + .alpha_char = pm_encoding_ibm855_alpha_char, + .isupper_char = pm_encoding_ibm855_isupper_char, + .multibyte = false +}; + /** ISO-8859-1 */ pm_encoding_t pm_encoding_iso_8859_1 = { .name = "ISO-8859-1", diff --git a/prism/prism.c b/prism/prism.c index fa5bd9f629..d6b9e28a73 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -6103,6 +6103,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star ENCODING1("IBM775", pm_encoding_ibm775); ENCODING1("IBM850", pm_encoding_cp850); ENCODING1("IBM852", pm_encoding_ibm852); + ENCODING1("IBM855", pm_encoding_ibm855); ENCODING2("ISO-8859-1", "ISO8859-1", pm_encoding_iso_8859_1); ENCODING2("ISO-8859-2", "ISO8859-2", pm_encoding_iso_8859_2); ENCODING2("ISO-8859-3", "ISO8859-3", pm_encoding_iso_8859_3); diff --git a/test/prism/encoding_test.rb b/test/prism/encoding_test.rb index 2dbe15e927..fe2c33febb 100644 --- a/test/prism/encoding_test.rb +++ b/test/prism/encoding_test.rb @@ -19,6 +19,7 @@ module Prism Encoding::IBM737, Encoding::IBM775, Encoding::IBM852, + Encoding::IBM855, Encoding::ISO_8859_1, Encoding::ISO_8859_2, Encoding::ISO_8859_3, -- cgit v1.2.3