[ruby/prism] Add macCyrillic encoding

https://github.com/ruby/prism/commit/220b40921a
This commit is contained in:
Orhan Toy 2023-11-19 00:23:03 +01:00 коммит произвёл git
Родитель db6492092f
Коммит 71a30b7596
4 изменённых файлов: 38 добавлений и 0 удалений

Просмотреть файл

@ -193,6 +193,7 @@ 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_cent_euro;
extern pm_encoding_t pm_encoding_mac_cyrillic;
extern pm_encoding_t pm_encoding_mac_greek;
extern pm_encoding_t pm_encoding_mac_iceland;
extern pm_encoding_t pm_encoding_mac_roman;

Просмотреть файл

@ -768,6 +768,30 @@ static uint8_t pm_encoding_mac_cent_euro_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 macCyrillic character.
*/
static uint8_t pm_encoding_mac_cyrillic_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 macGreek character.
@ -1272,6 +1296,7 @@ PRISM_ENCODING_TABLE(iso_8859_15)
PRISM_ENCODING_TABLE(iso_8859_16)
PRISM_ENCODING_TABLE(koi8_r)
PRISM_ENCODING_TABLE(mac_cent_euro)
PRISM_ENCODING_TABLE(mac_cyrillic)
PRISM_ENCODING_TABLE(mac_greek)
PRISM_ENCODING_TABLE(mac_iceland)
PRISM_ENCODING_TABLE(mac_roman)
@ -1622,6 +1647,16 @@ pm_encoding_t pm_encoding_mac_cent_euro = {
.multibyte = false
};
/** macCyrillic */
pm_encoding_t pm_encoding_mac_cyrillic = {
.name = "macCyrillic",
.char_width = pm_encoding_single_char_width,
.alnum_char = pm_encoding_mac_cyrillic_alnum_char,
.alpha_char = pm_encoding_mac_cyrillic_alpha_char,
.isupper_char = pm_encoding_mac_cyrillic_isupper_char,
.multibyte = false
};
/** macGreek */
pm_encoding_t pm_encoding_mac_greek = {
.name = "macGreek",

Просмотреть файл

@ -6140,6 +6140,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
break;
case 'M': case 'm':
ENCODING1("macCentEuro", pm_encoding_mac_cent_euro);
ENCODING1("macCyrillic", pm_encoding_mac_cyrillic);
ENCODING1("macGreek", pm_encoding_mac_greek);
ENCODING1("macIceland", pm_encoding_mac_iceland);
ENCODING1("macRoman", pm_encoding_mac_roman);

Просмотреть файл

@ -40,6 +40,7 @@ module Prism
Encoding::ISO_8859_16 => 0x00...0x100,
Encoding::KOI8_R => 0x00...0x100,
Encoding::MACCENTEURO => 0x00...0x100,
Encoding::MACCYRILLIC => 0x00...0x100,
Encoding::MACGREEK => 0x00...0x100,
Encoding::MACICELAND => 0x00...0x100,
Encoding::MACROMAN => 0x00...0x100,