diff options
| author | Kenichi Handa | 1997-07-31 05:55:12 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-07-31 05:55:12 +0000 |
| commit | 19a8d9e0f8663165ecd9d5b673b890b0780605dc (patch) | |
| tree | 40e020cae408398a77f1596e5041542b926e36ca /src/coding.c | |
| parent | 0f36e5fc3b831900fe90978442875f8a87cc209a (diff) | |
| download | emacs-19a8d9e0f8663165ecd9d5b673b890b0780605dc.tar.gz emacs-19a8d9e0f8663165ecd9d5b673b890b0780605dc.zip | |
(encode_coding_iso2022): Write out invalid multibyte
forms in a buffer as is.
(detect_coding_mask): If ISO_CODE_CSI appears in an invalid
sequence, ignore it.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/src/coding.c b/src/coding.c index bd824bceee2..2ebf0a2eade 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -1495,12 +1495,26 @@ encode_coding_iso2022 (coding, source, destination, | |||
| 1495 | 1495 | ||
| 1496 | case EMACS_leading_code_2: | 1496 | case EMACS_leading_code_2: |
| 1497 | ONE_MORE_BYTE (c2); | 1497 | ONE_MORE_BYTE (c2); |
| 1498 | ENCODE_ISO_CHARACTER (c1, c2, /* dummy */ c3); | 1498 | if (c2 < 0xA0) |
| 1499 | { | ||
| 1500 | /* invalid sequence */ | ||
| 1501 | *dst++ = c1; | ||
| 1502 | *dst++ = c2; | ||
| 1503 | } | ||
| 1504 | else | ||
| 1505 | ENCODE_ISO_CHARACTER (c1, c2, /* dummy */ c3); | ||
| 1499 | break; | 1506 | break; |
| 1500 | 1507 | ||
| 1501 | case EMACS_leading_code_3: | 1508 | case EMACS_leading_code_3: |
| 1502 | TWO_MORE_BYTES (c2, c3); | 1509 | TWO_MORE_BYTES (c2, c3); |
| 1503 | if (c1 < LEADING_CODE_PRIVATE_11) | 1510 | if (c2 < 0xA0 || c3 < 0xA0) |
| 1511 | { | ||
| 1512 | /* invalid sequence */ | ||
| 1513 | *dst++ = c1; | ||
| 1514 | *dst++ = c2; | ||
| 1515 | *dst++ = c3; | ||
| 1516 | } | ||
| 1517 | else if (c1 < LEADING_CODE_PRIVATE_11) | ||
| 1504 | ENCODE_ISO_CHARACTER (c1, c2, c3); | 1518 | ENCODE_ISO_CHARACTER (c1, c2, c3); |
| 1505 | else | 1519 | else |
| 1506 | ENCODE_ISO_CHARACTER (c2, c3, /* dummy */ c4); | 1520 | ENCODE_ISO_CHARACTER (c2, c3, /* dummy */ c4); |
| @@ -1508,12 +1522,27 @@ encode_coding_iso2022 (coding, source, destination, | |||
| 1508 | 1522 | ||
| 1509 | case EMACS_leading_code_4: | 1523 | case EMACS_leading_code_4: |
| 1510 | THREE_MORE_BYTES (c2, c3, c4); | 1524 | THREE_MORE_BYTES (c2, c3, c4); |
| 1511 | ENCODE_ISO_CHARACTER (c2, c3, c4); | 1525 | if (c2 < 0xA0 || c3 < 0xA0 || c4 < 0xA0) |
| 1526 | { | ||
| 1527 | /* invalid sequence */ | ||
| 1528 | *dst++ = c1; | ||
| 1529 | *dst++ = c2; | ||
| 1530 | *dst++ = c3; | ||
| 1531 | *dst++ = c4; | ||
| 1532 | } | ||
| 1533 | else | ||
| 1534 | ENCODE_ISO_CHARACTER (c2, c3, c4); | ||
| 1512 | break; | 1535 | break; |
| 1513 | 1536 | ||
| 1514 | case EMACS_leading_code_composition: | 1537 | case EMACS_leading_code_composition: |
| 1515 | ONE_MORE_BYTE (c1); | 1538 | ONE_MORE_BYTE (c2); |
| 1516 | if (c1 == 0xFF) | 1539 | if (c2 < 0xA0) |
| 1540 | { | ||
| 1541 | /* invalid sequence */ | ||
| 1542 | *dst++ = c1; | ||
| 1543 | *dst++ = c2; | ||
| 1544 | } | ||
| 1545 | else if (c2 == 0xFF) | ||
| 1517 | { | 1546 | { |
| 1518 | coding->composing = COMPOSING_WITH_RULE_HEAD; | 1547 | coding->composing = COMPOSING_WITH_RULE_HEAD; |
| 1519 | ENCODE_COMPOSITION_WITH_RULE_START; | 1548 | ENCODE_COMPOSITION_WITH_RULE_START; |
| @@ -2555,7 +2584,7 @@ detect_coding_mask (src, src_bytes) | |||
| 2555 | /* No valid ISO2022 code follows C. Try again. */ | 2584 | /* No valid ISO2022 code follows C. Try again. */ |
| 2556 | goto label_loop_detect_coding; | 2585 | goto label_loop_detect_coding; |
| 2557 | } | 2586 | } |
| 2558 | else if (c == ISO_CODE_SS2 || c == ISO_CODE_SS3 || c == ISO_CODE_CSI) | 2587 | else if (c == ISO_CODE_SS2 || c == ISO_CODE_SS3) |
| 2559 | /* C is an ISO2022 specific control code of C1, | 2588 | /* C is an ISO2022 specific control code of C1, |
| 2560 | or the first byte of SJIS's 2-byte character code, | 2589 | or the first byte of SJIS's 2-byte character code, |
| 2561 | or a leading code of Emacs. */ | 2590 | or a leading code of Emacs. */ |
| @@ -2563,6 +2592,17 @@ detect_coding_mask (src, src_bytes) | |||
| 2563 | | detect_coding_sjis (src, src_end) | 2592 | | detect_coding_sjis (src, src_end) |
| 2564 | | detect_coding_emacs_mule (src, src_end)); | 2593 | | detect_coding_emacs_mule (src, src_end)); |
| 2565 | 2594 | ||
| 2595 | else if (c == ISO_CODE_CSI | ||
| 2596 | && (src < src_end | ||
| 2597 | && (*src == ']' | ||
| 2598 | || (src + 1 < src_end | ||
| 2599 | && src[1] == ']' | ||
| 2600 | && (*src == '0' || *src == '1' || *src == '2'))))) | ||
| 2601 | /* C is an ISO2022's control-sequence-introducer. */ | ||
| 2602 | mask = (detect_coding_iso2022 (src, src_end) | ||
| 2603 | | detect_coding_sjis (src, src_end) | ||
| 2604 | | detect_coding_emacs_mule (src, src_end)); | ||
| 2605 | |||
| 2566 | else if (c < 0xA0) | 2606 | else if (c < 0xA0) |
| 2567 | /* C is the first byte of SJIS character code, | 2607 | /* C is the first byte of SJIS character code, |
| 2568 | or a leading-code of Emacs. */ | 2608 | or a leading-code of Emacs. */ |