Skip to content

Commit 4a26a65

Browse files
haldunmatzbot
authored andcommitted
[ruby/prism] Add macTurkish
ruby/prism@2232d4b6a0
1 parent 940f2e7 commit 4a26a65

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

prism/enc/pm_encoding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ extern pm_encoding_t pm_encoding_koi8_r;
193193
extern pm_encoding_t pm_encoding_mac_greek;
194194
extern pm_encoding_t pm_encoding_mac_iceland;
195195
extern pm_encoding_t pm_encoding_mac_romania;
196+
extern pm_encoding_t pm_encoding_mac_turkish;
196197
extern pm_encoding_t pm_encoding_shift_jis;
197198
extern pm_encoding_t pm_encoding_utf_8;
198199
extern pm_encoding_t pm_encoding_utf8_mac;

prism/enc/pm_tables.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,30 @@ static uint8_t pm_encoding_mac_romania_table[256] = {
792792
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
793793
};
794794

795+
/**
796+
* Each element of the following table contains a bitfield that indicates a
797+
* piece of information about the corresponding macTurkish character.
798+
*/
799+
static uint8_t pm_encoding_mac_turkish_table[256] = {
800+
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
801+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
802+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
803+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
804+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
805+
0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
806+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
807+
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
808+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
809+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
810+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
811+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
812+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
813+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
814+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
815+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
816+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
817+
};
818+
795819
/**
796820
* Each element of the following table contains a bitfield that indicates a
797821
* piece of information about the corresponding windows-1250 character.
@@ -1105,6 +1129,7 @@ PRISM_ENCODING_TABLE(koi8_r)
11051129
PRISM_ENCODING_TABLE(mac_greek)
11061130
PRISM_ENCODING_TABLE(mac_iceland)
11071131
PRISM_ENCODING_TABLE(mac_romania)
1132+
PRISM_ENCODING_TABLE(mac_turkish)
11081133
PRISM_ENCODING_TABLE(windows_1250)
11091134
PRISM_ENCODING_TABLE(windows_1251)
11101135
PRISM_ENCODING_TABLE(windows_1252)
@@ -1457,6 +1482,16 @@ pm_encoding_t pm_encoding_mac_romania = {
14571482
.multibyte = false
14581483
};
14591484

1485+
/** macTurkish */
1486+
pm_encoding_t pm_encoding_mac_turkish = {
1487+
.name = "macTurkish",
1488+
.char_width = pm_encoding_single_char_width,
1489+
.alnum_char = pm_encoding_mac_turkish_alnum_char,
1490+
.alpha_char = pm_encoding_mac_turkish_alpha_char,
1491+
.isupper_char = pm_encoding_mac_turkish_isupper_char,
1492+
.multibyte = false
1493+
};
1494+
14601495
/** Windows-1250 */
14611496
pm_encoding_t pm_encoding_windows_1250 = {
14621497
.name = "Windows-1250",

prism/prism.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6138,6 +6138,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
61386138
ENCODING1("macGreek", pm_encoding_mac_greek);
61396139
ENCODING1("macIceland", pm_encoding_mac_iceland);
61406140
ENCODING1("macRomania", pm_encoding_mac_romania);
6141+
ENCODING1("macTurkish", pm_encoding_mac_turkish);
61416142
break;
61426143
case 'P': case 'p':
61436144
ENCODING1("PCK", pm_encoding_windows_31j);

test/prism/encoding_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class EncodingTest < TestCase
4141
Encoding::MACGREEK => 0x00...0x100,
4242
Encoding::MACICELAND => 0x00...0x100,
4343
Encoding::MACROMANIA => 0x00...0x100,
44+
Encoding::MACTURKISH => 0x00...0x100,
4445
Encoding::Windows_1250 => 0x00...0x100,
4546
Encoding::Windows_1251 => 0x00...0x100,
4647
Encoding::Windows_1252 => 0x00...0x100,

0 commit comments

Comments
 (0)