diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2023-11-12 00:07:06 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-11-16 17:39:35 +0000 |
| commit | b0a188655d17ee5904c5167473fee4e2d3369c0f (patch) | |
| tree | 787bd85ccad041eb0fcec79ace9813b1670b55a1 | |
| parent | f93e4ac18e04377dea56941fc7ce599cdc7ddbcf (diff) | |
[ruby/prism] IBM852 encoding
https://github.com/ruby/prism/commit/45251fcbf1
| -rw-r--r-- | prism/enc/pm_encoding.h | 1 | ||||
| -rw-r--r-- | prism/enc/pm_tables.c | 35 | ||||
| -rw-r--r-- | prism/prism.c | 1 | ||||
| -rw-r--r-- | test/prism/encoding_test.rb | 1 |
4 files changed, 38 insertions, 0 deletions
diff --git a/prism/enc/pm_encoding.h b/prism/enc/pm_encoding.h index 33b8390286..94d0dc37d3 100644 --- a/prism/enc/pm_encoding.h +++ b/prism/enc/pm_encoding.h @@ -168,6 +168,7 @@ extern pm_encoding_t pm_encoding_ibm437; 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_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 f407d81496..ae628c9fad 100644 --- a/prism/enc/pm_tables.c +++ b/prism/enc/pm_tables.c @@ -194,6 +194,30 @@ static uint8_t pm_encoding_ibm775_table[256] = { /** * Each element of the following table contains a bitfield that indicates a + * piece of information about the corresponding IBM852 character. + */ +static uint8_t pm_encoding_ibm852_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. */ static uint8_t pm_encoding_iso_8859_1_table[256] = { @@ -864,6 +888,7 @@ PRISM_ENCODING_TABLE(ibm437) PRISM_ENCODING_TABLE(ibm720) PRISM_ENCODING_TABLE(ibm737) PRISM_ENCODING_TABLE(ibm775) +PRISM_ENCODING_TABLE(ibm852) PRISM_ENCODING_TABLE(iso_8859_1) PRISM_ENCODING_TABLE(iso_8859_2) PRISM_ENCODING_TABLE(iso_8859_3) @@ -982,6 +1007,16 @@ pm_encoding_t pm_encoding_ibm775 = { .multibyte = false }; +/** IBM850 */ +pm_encoding_t pm_encoding_ibm852 = { + .name = "IBM852", + .char_width = pm_encoding_single_char_width, + .alnum_char = pm_encoding_ibm852_alnum_char, + .alpha_char = pm_encoding_ibm852_alpha_char, + .isupper_char = pm_encoding_ibm852_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 949e7381a9..fa5bd9f629 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -6102,6 +6102,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star ENCODING1("IBM737", pm_encoding_ibm737); ENCODING1("IBM775", pm_encoding_ibm775); ENCODING1("IBM850", pm_encoding_cp850); + ENCODING1("IBM852", pm_encoding_ibm852); 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 f3aded64a9..2dbe15e927 100644 --- a/test/prism/encoding_test.rb +++ b/test/prism/encoding_test.rb @@ -18,6 +18,7 @@ module Prism Encoding::IBM720, Encoding::IBM737, Encoding::IBM775, + Encoding::IBM852, Encoding::ISO_8859_1, Encoding::ISO_8859_2, Encoding::ISO_8859_3, |
