summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-11-16 12:45:35 -0500
committergit <svn-admin@ruby-lang.org>2023-11-16 18:00:08 +0000
commit3bc41f4f0b0823e37ac0e89f7943dfe181e005b9 (patch)
tree3e3fc9ab653f6c1f6c1ec4fb23041a6955e800a5
parentce853559310c1c0ae0c37521a18b0ba402c48a1b (diff)
[ruby/prism] Add macGreek encoding
https://github.com/ruby/prism/commit/c36d3fc647
-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 4a6a6a5142..7dca938241 100644
--- a/prism/enc/pm_encoding.h
+++ b/prism/enc/pm_encoding.h
@@ -190,6 +190,7 @@ extern pm_encoding_t pm_encoding_iso_8859_14;
extern pm_encoding_t pm_encoding_iso_8859_15;
extern pm_encoding_t pm_encoding_iso_8859_16;
extern pm_encoding_t pm_encoding_koi8_r;
+extern pm_encoding_t pm_encoding_mac_greek;
extern pm_encoding_t pm_encoding_mac_iceland;
extern pm_encoding_t pm_encoding_mac_romania;
extern pm_encoding_t pm_encoding_shift_jis;
diff --git a/prism/enc/pm_tables.c b/prism/enc/pm_tables.c
index ed4b219dbf..8463c3efdb 100644
--- a/prism/enc/pm_tables.c
+++ b/prism/enc/pm_tables.c
@@ -722,6 +722,30 @@ static uint8_t pm_encoding_koi8_r_table[256] = {
/**
* Each element of the following table contains a bitfield that indicates a
+ * piece of information about the corresponding macGreek character.
+ */
+static uint8_t pm_encoding_mac_greek_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 macIceland character.
*/
static uint8_t pm_encoding_mac_iceland_table[256] = {
@@ -1078,6 +1102,7 @@ PRISM_ENCODING_TABLE(iso_8859_14)
PRISM_ENCODING_TABLE(iso_8859_15)
PRISM_ENCODING_TABLE(iso_8859_16)
PRISM_ENCODING_TABLE(koi8_r)
+PRISM_ENCODING_TABLE(mac_greek)
PRISM_ENCODING_TABLE(mac_iceland)
PRISM_ENCODING_TABLE(mac_romania)
PRISM_ENCODING_TABLE(windows_1250)
@@ -1402,6 +1427,16 @@ pm_encoding_t pm_encoding_koi8_r = {
.multibyte = false
};
+/** macGreek */
+pm_encoding_t pm_encoding_mac_greek = {
+ .name = "macGreek",
+ .char_width = pm_encoding_single_char_width,
+ .alnum_char = pm_encoding_mac_greek_alnum_char,
+ .alpha_char = pm_encoding_mac_greek_alpha_char,
+ .isupper_char = pm_encoding_mac_greek_isupper_char,
+ .multibyte = false
+};
+
/** macIceland */
pm_encoding_t pm_encoding_mac_iceland = {
.name = "macIceland",
diff --git a/prism/prism.c b/prism/prism.c
index 882a268887..ac2b572808 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -6135,6 +6135,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
ENCODING1("locale", pm_encoding_utf_8);
break;
case 'M': case 'm':
+ ENCODING1("macGreek", pm_encoding_mac_greek);
ENCODING1("macIceland", pm_encoding_mac_iceland);
ENCODING1("macRomania", pm_encoding_mac_romania);
break;
diff --git a/test/prism/encoding_test.rb b/test/prism/encoding_test.rb
index 8d0ff4ce28..4be230015a 100644
--- a/test/prism/encoding_test.rb
+++ b/test/prism/encoding_test.rb
@@ -38,6 +38,7 @@ module Prism
Encoding::ISO_8859_15 => 0x00...0x100,
Encoding::ISO_8859_16 => 0x00...0x100,
Encoding::KOI8_R => 0x00...0x100,
+ Encoding::MACGREEK => 0x00...0x100,
Encoding::MACICELAND => 0x00...0x100,
Encoding::MACROMANIA => 0x00...0x100,
Encoding::Windows_1250 => 0x00...0x100,