summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-11-11 23:50:23 -0500
committergit <svn-admin@ruby-lang.org>2023-11-16 17:39:34 +0000
commitef748f353bd02a88e1ce2488738e3e191e874f74 (patch)
tree6370921f966f51095c54bb2e285f65dbf961d0d0
parentae3c3467467b86b01eb53cf160104ebf39a92ad0 (diff)
[ruby/prism] IBM775 encoding
https://github.com/ruby/prism/commit/65175641b1
-rw-r--r--prism/enc/pm_encoding.h1
-rw-r--r--prism/enc/pm_tables.c35
-rw-r--r--prism/prism.c1
-rw-r--r--test/prism/encoding_test.rb1
4 files changed, 38 insertions, 0 deletions
diff --git a/prism/enc/pm_encoding.h b/prism/enc/pm_encoding.h
index 440db11d3a..33b8390286 100644
--- a/prism/enc/pm_encoding.h
+++ b/prism/enc/pm_encoding.h
@@ -167,6 +167,7 @@ extern pm_encoding_t pm_encoding_gbk;
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_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 0fbc48ee54..f407d81496 100644
--- a/prism/enc/pm_tables.c
+++ b/prism/enc/pm_tables.c
@@ -170,6 +170,30 @@ static uint8_t pm_encoding_ibm737_table[256] = {
/**
* Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding IBM775 character.
+ */
+static uint8_t pm_encoding_ibm775_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] = {
@@ -839,6 +863,7 @@ PRISM_ENCODING_TABLE(cp855)
PRISM_ENCODING_TABLE(ibm437)
PRISM_ENCODING_TABLE(ibm720)
PRISM_ENCODING_TABLE(ibm737)
+PRISM_ENCODING_TABLE(ibm775)
PRISM_ENCODING_TABLE(iso_8859_1)
PRISM_ENCODING_TABLE(iso_8859_2)
PRISM_ENCODING_TABLE(iso_8859_3)
@@ -947,6 +972,16 @@ pm_encoding_t pm_encoding_ibm737 = {
.multibyte = false
};
+/** IBM775 */
+pm_encoding_t pm_encoding_ibm775 = {
+ .name = "IBM775",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_ibm775_alnum_char,
+ .alpha_char = pm_encoding_ibm775_alpha_char,
+ .isupper_char = pm_encoding_ibm775_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 62c85fa96f..fd12dd05fa 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -6075,6 +6075,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
ENCODING2("IBM437", "CP437", pm_encoding_ibm437);
ENCODING2("IBM720", "CP720", pm_encoding_ibm720);
ENCODING2("IBM737", "CP737", pm_encoding_ibm737);
+ ENCODING2("IBM775", "CP775", pm_encoding_ibm775);
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 ddff798a7e..f3aded64a9 100644
--- a/test/prism/encoding_test.rb
+++ b/test/prism/encoding_test.rb
@@ -17,6 +17,7 @@ module Prism
Encoding::IBM437,
Encoding::IBM720,
Encoding::IBM737,
+ Encoding::IBM775,
Encoding::ISO_8859_1,
Encoding::ISO_8859_2,
Encoding::ISO_8859_3,