Mercurial > hg > xemacs-beta
comparison src/file-coding.c @ 388:aabb7f5b1c81 r21-2-9
Import from CVS: tag r21-2-9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:09:42 +0200 |
parents | 8626e4521993 |
children | 6719134a07c2 |
comparison
equal
deleted
inserted
replaced
387:f892a9d0bb8d | 388:aabb7f5b1c81 |
---|---|
3584 | 3584 |
3585 static int | 3585 static int |
3586 detect_coding_iso2022 (struct detection_state *st, CONST unsigned char *src, | 3586 detect_coding_iso2022 (struct detection_state *st, CONST unsigned char *src, |
3587 unsigned int n) | 3587 unsigned int n) |
3588 { | 3588 { |
3589 int c; | |
3590 int mask; | 3589 int mask; |
3591 | 3590 |
3592 /* #### There are serious deficiencies in the recognition mechanism | 3591 /* #### There are serious deficiencies in the recognition mechanism |
3593 here. This needs to be much smarter if it's going to cut it. */ | 3592 here. This needs to be much smarter if it's going to cut it. |
3593 The sequence "\xff\x0f" is currently detected as LOCK_SHIFT while | |
3594 it should be detected as Latin-1. | |
3595 All the ISO2022 stuff in this file should be synced up with the | |
3596 code from FSF Emacs-20.4, in which Mule should be more or less stable. | |
3597 Perhaps we should wait till R2L works in FSF Emacs? */ | |
3594 | 3598 |
3595 if (!st->iso2022.initted) | 3599 if (!st->iso2022.initted) |
3596 { | 3600 { |
3597 reset_iso2022 (Qnil, &st->iso2022.iso); | 3601 reset_iso2022 (Qnil, &st->iso2022.iso); |
3598 st->iso2022.mask = (CODING_CATEGORY_ISO_7_MASK | | 3602 st->iso2022.mask = (CODING_CATEGORY_ISO_7_MASK | |
3608 | 3612 |
3609 mask = st->iso2022.mask; | 3613 mask = st->iso2022.mask; |
3610 | 3614 |
3611 while (n--) | 3615 while (n--) |
3612 { | 3616 { |
3613 c = *src++; | 3617 int c = *src++; |
3614 if (c >= 0xA0) | 3618 if (c >= 0xA0) |
3615 { | 3619 { |
3616 mask &= ~CODING_CATEGORY_ISO_7_MASK; | 3620 mask &= ~CODING_CATEGORY_ISO_7_MASK; |
3617 st->iso2022.high_byte_count++; | 3621 st->iso2022.high_byte_count++; |
3618 } | 3622 } |
3771 | 3775 |
3772 static void | 3776 static void |
3773 decode_coding_iso2022 (Lstream *decoding, CONST unsigned char *src, | 3777 decode_coding_iso2022 (Lstream *decoding, CONST unsigned char *src, |
3774 unsigned_char_dynarr *dst, unsigned int n) | 3778 unsigned_char_dynarr *dst, unsigned int n) |
3775 { | 3779 { |
3776 unsigned char c; | |
3777 unsigned int flags, ch; | 3780 unsigned int flags, ch; |
3778 enum eol_type eol_type; | 3781 enum eol_type eol_type; |
3779 struct decoding_stream *str = DECODING_STREAM_DATA (decoding); | 3782 struct decoding_stream *str = DECODING_STREAM_DATA (decoding); |
3780 Lisp_Object coding_system; | 3783 Lisp_Object coding_system; |
3781 unsigned_char_dynarr *real_dst = dst; | 3784 unsigned_char_dynarr *real_dst = dst; |
3787 if (flags & CODING_STATE_COMPOSITE) | 3790 if (flags & CODING_STATE_COMPOSITE) |
3788 dst = str->iso2022.composite_chars; | 3791 dst = str->iso2022.composite_chars; |
3789 | 3792 |
3790 while (n--) | 3793 while (n--) |
3791 { | 3794 { |
3792 c = *src++; | 3795 unsigned char c = *src++; |
3793 if (flags & CODING_STATE_ESCAPE) | 3796 if (flags & CODING_STATE_ESCAPE) |
3794 { /* Within ESC sequence */ | 3797 { /* Within ESC sequence */ |
3795 int retval = parse_iso2022_esc (coding_system, &str->iso2022, | 3798 int retval = parse_iso2022_esc (coding_system, &str->iso2022, |
3796 c, &flags, 1); | 3799 c, &flags, 1); |
3797 | 3800 |
3902 : !BYTE_ASCII_P (c) ? str->iso2022.register_right | 3905 : !BYTE_ASCII_P (c) ? str->iso2022.register_right |
3903 : str->iso2022.register_left); | 3906 : str->iso2022.register_left); |
3904 charset = str->iso2022.charset[reg]; | 3907 charset = str->iso2022.charset[reg]; |
3905 | 3908 |
3906 /* Error checking: */ | 3909 /* Error checking: */ |
3907 if (NILP (charset) || str->iso2022.invalid_designated[reg] | 3910 if (! CHARSETP (charset) |
3911 || str->iso2022.invalid_designated[reg] | |
3908 || (((c & 0x7F) == ' ' || (c & 0x7F) == ISO_CODE_DEL) | 3912 || (((c & 0x7F) == ' ' || (c & 0x7F) == ISO_CODE_DEL) |
3909 && XCHARSET_CHARS (charset) == 94)) | 3913 && XCHARSET_CHARS (charset) == 94)) |
3910 /* Mrmph. We are trying to invoke a register that has no | 3914 /* Mrmph. We are trying to invoke a register that has no |
3911 or an invalid charset in it, or trying to add a character | 3915 or an invalid charset in it, or trying to add a character |
3912 outside the range of the charset. Insert that char literally | 3916 outside the range of the charset. Insert that char literally |