aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2003-05-31 00:56:42 +0000
committerKenichi Handa2003-05-31 00:56:42 +0000
commitfd3ae0b9def77d98c4936581f7d0ab004bdde16e (patch)
tree5c1e0b2194ad909754f743c06f2667d6bc9180c1 /src/coding.c
parent3867c42d6082681641bb39ecf4454adb10dc7d7d (diff)
downloademacs-fd3ae0b9def77d98c4936581f7d0ab004bdde16e.tar.gz
emacs-fd3ae0b9def77d98c4936581f7d0ab004bdde16e.zip
(DECODE_EMACS_MULE_COMPOSITION_CHAR): If coding->flags
is nonzero, accept multibyte form of eight-bit-control chars. (decode_composition_emacs_mule): Likewise. (decode_coding_emacs_mule): Likewise. (encode_coding_emacs_mule): If coding->flags is nonzero, produce multibyte form of eight-bit-control chars.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/coding.c b/src/coding.c
index 584ad730903..2982dd3c86f 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -712,7 +712,7 @@ detect_coding_emacs_mule (src, src_end, multibytep)
712#define DECODE_EMACS_MULE_COMPOSITION_CHAR(c, p) \ 712#define DECODE_EMACS_MULE_COMPOSITION_CHAR(c, p) \
713 do { \ 713 do { \
714 int bytes; \ 714 int bytes; \
715 \ 715 \
716 c = SAFE_ONE_MORE_BYTE (); \ 716 c = SAFE_ONE_MORE_BYTE (); \
717 if (c < 0) \ 717 if (c < 0) \
718 break; \ 718 break; \
@@ -743,7 +743,10 @@ detect_coding_emacs_mule (src, src_end, multibytep)
743 break; \ 743 break; \
744 *p++ = c; \ 744 *p++ = c; \
745 } \ 745 } \
746 if (UNIBYTE_STR_AS_MULTIBYTE_P (p0, p - p0, bytes)) \ 746 if (UNIBYTE_STR_AS_MULTIBYTE_P (p0, p - p0, bytes) \
747 || (coding->flags /* We are recovering a file. */ \
748 && p0[0] == LEADING_CODE_8_BIT_CONTROL \
749 && ! CHAR_HEAD_P (p0[1]))) \
747 c = STRING_CHAR (p0, bytes); \ 750 c = STRING_CHAR (p0, bytes); \
748 else \ 751 else \
749 c = -1; \ 752 c = -1; \
@@ -847,7 +850,10 @@ decode_composition_emacs_mule (coding, src, src_end,
847 else 850 else
848 { 851 {
849 int bytes; 852 int bytes;
850 if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes)) 853 if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes)
854 || (coding->flags /* We are recovering a file. */
855 && src[0] == LEADING_CODE_8_BIT_CONTROL
856 && ! CHAR_HEAD_P (src[1])))
851 c = STRING_CHAR (src, bytes); 857 c = STRING_CHAR (src, bytes);
852 else 858 else
853 c = *src, bytes = 1; 859 c = *src, bytes = 1;
@@ -1001,7 +1007,10 @@ decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes)
1001 p = tmp; 1007 p = tmp;
1002 src++; 1008 src++;
1003 } 1009 }
1004 else if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes)) 1010 else if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes)
1011 || (coding->flags /* We are recovering a file. */
1012 && src[0] == LEADING_CODE_8_BIT_CONTROL
1013 && ! CHAR_HEAD_P (src[1])))
1005 { 1014 {
1006 p = src; 1015 p = src;
1007 src += bytes; 1016 src += bytes;
@@ -1132,7 +1141,22 @@ encode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes)
1132 EMIT_ONE_BYTE ('\r'); 1141 EMIT_ONE_BYTE ('\r');
1133 } 1142 }
1134 else if (SINGLE_BYTE_CHAR_P (c)) 1143 else if (SINGLE_BYTE_CHAR_P (c))
1135 EMIT_ONE_BYTE (c); 1144 {
1145 if (coding->flags && ! ASCII_BYTE_P (c))
1146 {
1147 /* As we are auto saving, retain the multibyte form for
1148 8-bit chars. */
1149 unsigned char buf[MAX_MULTIBYTE_LENGTH];
1150 int bytes = CHAR_STRING (c, buf);
1151
1152 if (bytes == 1)
1153 EMIT_ONE_BYTE (buf[0]);
1154 else
1155 EMIT_TWO_BYTES (buf[0], buf[1]);
1156 }
1157 else
1158 EMIT_ONE_BYTE (c);
1159 }
1136 else 1160 else
1137 EMIT_BYTES (src_base, src); 1161 EMIT_BYTES (src_base, src);
1138 coding->consumed_char++; 1162 coding->consumed_char++;