+ else if (id == charset_jisx0208_1978) \
+ { \
+ if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_USE_OLDJIS) \
+ id = charset_jisx0208; \
+ } \
+ CODING_ISO_DESIGNATION (coding, reg) = id; \
+ /* If there was an invalid designation to REG previously, and this \
+ designation is ASCII to REG, we should keep this designation \
+ sequence. */ \
+ if (prev == -2 && id == charset_ascii) \
+ chars_96 = -1; \
+ } while (0)
+
+
+/* Handle these composition sequence (ALT: alternate char):
+
+ (1) relative composition: ESC 0 CHAR ... ESC 1
+ (2) rulebase composition: ESC 2 CHAR RULE CHAR RULE ... CHAR ESC 1
+ (3) altchar composition: ESC 3 ALT ... ALT ESC 0 CHAR ... ESC 1
+ (4) alt&rule composition: ESC 4 ALT RULE ... ALT ESC 0 CHAR ... ESC 1
+
+ When the start sequence (ESC 0/2/3/4) is found, this annotation
+ header is produced.
+
+ [ -LENGTH(==-5) CODING_ANNOTATE_COMPOSITION_MASK NCHARS(==0) 0 METHOD ]
+
+ Then, upon reading CHAR or RULE (one or two bytes), these codes are
+ produced until the end sequence (ESC 1) is found:
+
+ (1) CHAR ... CHAR
+ (2) CHAR -2 DECODED-RULE CHAR -2 DECODED-RULE ... CHAR
+ (3) ALT ... ALT -1 -1 CHAR ... CHAR
+ (4) ALT -2 DECODED-RULE ALT -2 DECODED-RULE ... ALT -1 -1 CHAR ... CHAR
+
+ When the end sequence (ESC 1) is found, LENGTH and NCHARS in the
+ annotation header is updated as below:
+
+ (1) LENGTH: unchanged, NCHARS: number of CHARs
+ (2) LENGTH: unchanged, NCHARS: number of CHARs
+ (3) LENGTH: += number of ALTs + 2, NCHARS: number of CHARs
+ (4) LENGTH: += number of ALTs * 3, NCHARS: number of CHARs
+
+ If an error is found while composing, the annotation header is
+ changed to:
+
+ [ ESC '0'/'2'/'3'/'4' -2 0 ]
+
+ and the sequence [ -2 DECODED-RULE ] is changed to the original
+ byte sequence as below:
+ o the original byte sequence is B: [ B -1 ]
+ o the original byte sequence is B1 B2: [ B1 B2 ]
+ and the sequence [ -1 -1 ] is changed to the original byte
+ sequence:
+ [ ESC '0' ]
+*/
+
+/* Decode a composition rule C1 and maybe one more byte from the
+ source, and set RULE to the encoded composition rule, NBYTES to the
+ length of the composition rule. If the rule is invalid, set RULE
+ to some negative value. */
+
+#define DECODE_COMPOSITION_RULE(rule, nbytes) \
+ do { \
+ rule = c1 - 32; \
+ if (rule < 0) \
+ break; \
+ if (rule < 81) /* old format (before ver.21) */ \
+ { \
+ int gref = (rule) / 9; \
+ int nref = (rule) % 9; \
+ if (gref == 4) gref = 10; \
+ if (nref == 4) nref = 10; \
+ rule = COMPOSITION_ENCODE_RULE (gref, nref); \
+ nbytes = 1; \
+ } \
+ else /* new format (after ver.21) */ \