Skip to content

Commit 220b409

Browse files
committed
Add macCyrillic encoding
1 parent e8f6885 commit 220b409

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

bin/encodings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ when "iso-8859-15" then table(Encoding::ISO8859_15)
8282
when "iso-8859-16" then table(Encoding::ISO8859_16)
8383
when "koi8-r" then table(Encoding::KOI8_R)
8484
when "maccenteuro" then table(Encoding::MACCENTEURO)
85+
when "maccyrillic" then table(Encoding::MACCYRILLIC)
8586
when "macgreek" then table(Encoding::MACGREEK)
8687
when "maciceland" then table(Encoding::MACICELAND)
8788
when "macroman" then table(Encoding::MACROMAN)

docs/encoding.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The key of the comment can be either "encoding" or "coding". The value of the co
4848
* `ISO-8859-16`
4949
* `KOI8-R`
5050
* `macCentEuro`
51+
* `macCyrillic`
5152
* `macGreek`
5253
* `macIceland`
5354
* `macRoman`

include/prism/enc/pm_encoding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ extern pm_encoding_t pm_encoding_iso_8859_15;
192192
extern pm_encoding_t pm_encoding_iso_8859_16;
193193
extern pm_encoding_t pm_encoding_koi8_r;
194194
extern pm_encoding_t pm_encoding_mac_cent_euro;
195+
extern pm_encoding_t pm_encoding_mac_cyrillic;
195196
extern pm_encoding_t pm_encoding_mac_greek;
196197
extern pm_encoding_t pm_encoding_mac_iceland;
197198
extern pm_encoding_t pm_encoding_mac_roman;

src/enc/pm_tables.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,30 @@ static uint8_t pm_encoding_mac_cent_euro_table[256] = {
768768
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
769769
};
770770

771+
/**
772+
* Each element of the following table contains a bitfield that indicates a
773+
* piece of information about the corresponding macCyrillic character.
774+
*/
775+
static uint8_t pm_encoding_mac_cyrillic_table[256] = {
776+
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
777+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
778+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
779+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
780+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
781+
0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
782+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
783+
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
784+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
785+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
786+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
787+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
788+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
789+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
790+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
791+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
792+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
793+
};
794+
771795
/**
772796
* Each element of the following table contains a bitfield that indicates a
773797
* piece of information about the corresponding macGreek character.
@@ -1272,6 +1296,7 @@ PRISM_ENCODING_TABLE(iso_8859_15)
12721296
PRISM_ENCODING_TABLE(iso_8859_16)
12731297
PRISM_ENCODING_TABLE(koi8_r)
12741298
PRISM_ENCODING_TABLE(mac_cent_euro)
1299+
PRISM_ENCODING_TABLE(mac_cyrillic)
12751300
PRISM_ENCODING_TABLE(mac_greek)
12761301
PRISM_ENCODING_TABLE(mac_iceland)
12771302
PRISM_ENCODING_TABLE(mac_roman)
@@ -1622,6 +1647,16 @@ pm_encoding_t pm_encoding_mac_cent_euro = {
16221647
.multibyte = false
16231648
};
16241649

1650+
/** macCyrillic */
1651+
pm_encoding_t pm_encoding_mac_cyrillic = {
1652+
.name = "macCyrillic",
1653+
.char_width = pm_encoding_single_char_width,
1654+
.alnum_char = pm_encoding_mac_cyrillic_alnum_char,
1655+
.alpha_char = pm_encoding_mac_cyrillic_alpha_char,
1656+
.isupper_char = pm_encoding_mac_cyrillic_isupper_char,
1657+
.multibyte = false
1658+
};
1659+
16251660
/** macGreek */
16261661
pm_encoding_t pm_encoding_mac_greek = {
16271662
.name = "macGreek",

src/prism.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6139,6 +6139,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
61396139
break;
61406140
case 'M': case 'm':
61416141
ENCODING1("macCentEuro", pm_encoding_mac_cent_euro);
6142+
ENCODING1("macCyrillic", pm_encoding_mac_cyrillic);
61426143
ENCODING1("macGreek", pm_encoding_mac_greek);
61436144
ENCODING1("macIceland", pm_encoding_mac_iceland);
61446145
ENCODING1("macRoman", pm_encoding_mac_roman);

test/prism/encoding_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class EncodingTest < TestCase
4040
Encoding::ISO_8859_16 => 0x00...0x100,
4141
Encoding::KOI8_R => 0x00...0x100,
4242
Encoding::MACCENTEURO => 0x00...0x100,
43+
Encoding::MACCYRILLIC => 0x00...0x100,
4344
Encoding::MACGREEK => 0x00...0x100,
4445
Encoding::MACICELAND => 0x00...0x100,
4546
Encoding::MACROMAN => 0x00...0x100,

0 commit comments

Comments
 (0)