summaryrefslogtreecommitdiff
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>1999-03-20 07:47:54 +0000
committerKenichi Handa <handa@m17n.org>1999-03-20 07:47:54 +0000
commit6f5510294b0838b74ae6be126808b2b8618dc0c2 (patch)
tree14b63aee02c526b2986570c388a042be8c0aa13a /src/coding.c
parent00d6521642fbdf95fd9d1fc546e38af4ba504e95 (diff)
downloademacs-6f5510294b0838b74ae6be126808b2b8618dc0c2.tar.gz
(ENCODE_ISO_CHARACTER): Check validity of CHARSET. If
invalid, produce the buffer internal byte sequence without encoding.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c72
1 files changed, 46 insertions, 26 deletions
diff --git a/src/coding.c b/src/coding.c
index cf6bab223bb..4f91bbb1543 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1610,32 +1610,52 @@ decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes)
dst = encode_invocation_designation (charset, coding, dst); \
} while (1)
-#define ENCODE_ISO_CHARACTER(charset, c1, c2) \
- do { \
- int c_alt, charset_alt; \
- if (!NILP (translation_table) \
- && ((c_alt = translate_char (translation_table, -1, \
- charset, c1, c2)) \
- >= 0)) \
- SPLIT_CHAR (c_alt, charset_alt, c1, c2); \
- else \
- charset_alt = charset; \
- if (CHARSET_DIMENSION (charset_alt) == 1) \
- { \
- if (charset == CHARSET_ASCII \
- && coding->flags & CODING_FLAG_ISO_USE_ROMAN) \
- charset_alt = charset_latin_jisx0201; \
- ENCODE_ISO_CHARACTER_DIMENSION1 (charset_alt, c1); \
- } \
- else \
- { \
- if (charset == charset_jisx0208 \
- && coding->flags & CODING_FLAG_ISO_USE_OLDJIS) \
- charset_alt = charset_jisx0208_1978; \
- ENCODE_ISO_CHARACTER_DIMENSION2 (charset_alt, c1, c2); \
- } \
- if (! COMPOSING_P (coding->composing)) \
- coding->consumed_char++; \
+#define ENCODE_ISO_CHARACTER(charset, c1, c2) \
+ do { \
+ int c_alt, charset_alt; \
+ if (!NILP (translation_table) \
+ && ((c_alt = translate_char (translation_table, -1, \
+ charset, c1, c2)) \
+ >= 0)) \
+ SPLIT_CHAR (c_alt, charset_alt, c1, c2); \
+ else \
+ charset_alt = charset; \
+ if (CHARSET_DEFINED_P (charset_alt)) \
+ { \
+ if (CHARSET_DIMENSION (charset_alt) == 1) \
+ { \
+ if (charset == CHARSET_ASCII \
+ && coding->flags & CODING_FLAG_ISO_USE_ROMAN) \
+ charset_alt = charset_latin_jisx0201; \
+ ENCODE_ISO_CHARACTER_DIMENSION1 (charset_alt, c1); \
+ } \
+ else \
+ { \
+ if (charset == charset_jisx0208 \
+ && coding->flags & CODING_FLAG_ISO_USE_OLDJIS) \
+ charset_alt = charset_jisx0208_1978; \
+ ENCODE_ISO_CHARACTER_DIMENSION2 (charset_alt, c1, c2); \
+ } \
+ } \
+ else \
+ { \
+ if (coding->flags & CODING_FLAG_ISO_SEVEN_BITS) \
+ { \
+ *dst++ = charset & 0x7f; \
+ *dst++ = c1 & 0x7f; \
+ if (c2) \
+ *dst++ = c2 & 0x7f; \
+ } \
+ else \
+ { \
+ *dst++ = charset; \
+ *dst++ = c1; \
+ if (c2) \
+ *dst++ = c2; \
+ } \
+ } \
+ if (! COMPOSING_P (coding->composing)) \
+ coding->consumed_char++; \
} while (0)
/* Produce designation and invocation codes at a place pointed by DST