comparison src/coding.h @ 29006:bf92db6e609a

(enum iso_code_class_type): Member ISO_control_code is devided into ISO_control_0 and ISO_control_1. (struct coding_system): New members src_multibyte, dst_multibyte, errors, and result. Delete member fake_multibyte. (CODING_REQUIRE_DECODING): Return 1 if coding->dst_multibyte is nonzero. (CODING_REQUIRE_ENCODING): Return 1 if coding->src_multibyte is nonzero.
author Kenichi Handa <handa@m17n.org>
date Fri, 19 May 2000 23:56:15 +0000
parents 01292435daaf
children a0dc7fa92f5d
comparison
equal deleted inserted replaced
29005:b396df3a5181 29006:bf92db6e609a
70 70
71 /* All code (1-byte) of ISO2022 is classified into one of the 71 /* All code (1-byte) of ISO2022 is classified into one of the
72 followings. */ 72 followings. */
73 enum iso_code_class_type 73 enum iso_code_class_type
74 { 74 {
75 ISO_control_code, /* Control codes in the range 75 ISO_control_0, /* Control codes in the range
76 0x00..0x1F, 0x7F, and 0x80..0x9F, 76 0x00..0x1F and 0x7F, except for the
77 except for the following seven 77 following 5 codes. */
78 codes. */
79 ISO_carriage_return, /* ISO_CODE_CR (0x0D) */ 78 ISO_carriage_return, /* ISO_CODE_CR (0x0D) */
80 ISO_shift_out, /* ISO_CODE_SO (0x0E) */ 79 ISO_shift_out, /* ISO_CODE_SO (0x0E) */
81 ISO_shift_in, /* ISO_CODE_SI (0x0F) */ 80 ISO_shift_in, /* ISO_CODE_SI (0x0F) */
82 ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */ 81 ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */
83 ISO_escape, /* ISO_CODE_SO (0x1B) */ 82 ISO_escape, /* ISO_CODE_SO (0x1B) */
83 ISO_control_1, /* Control codes in the range
84 0x80..0x9F, except for the
85 following 3 codes. */
84 ISO_single_shift_2, /* ISO_CODE_SS2 (0x8E) */ 86 ISO_single_shift_2, /* ISO_CODE_SS2 (0x8E) */
85 ISO_single_shift_3, /* ISO_CODE_SS3 (0x8F) */ 87 ISO_single_shift_3, /* ISO_CODE_SS3 (0x8F) */
86 ISO_control_sequence_introducer, /* ISO_CODE_CSI (0x9B) */ 88 ISO_control_sequence_introducer, /* ISO_CODE_CSI (0x9B) */
87 ISO_0x20_or_0x7F, /* Codes of the values 0x20 or 0x7F. */ 89 ISO_0x20_or_0x7F, /* Codes of the values 0x20 or 0x7F. */
88 ISO_graphic_plane_0, /* Graphic codes in the range 0x21..0x7E. */ 90 ISO_graphic_plane_0, /* Graphic codes in the range 0x21..0x7E. */
393 } spec; 395 } spec;
394 396
395 /* Index number of coding category of the coding system. */ 397 /* Index number of coding category of the coding system. */
396 int category_idx; 398 int category_idx;
397 399
400 unsigned src_multibyte : 1;
401 unsigned dst_multibyte : 1;
402
398 /* How may heading bytes we can skip for decoding. This is set to 403 /* How may heading bytes we can skip for decoding. This is set to
399 -1 in setup_coding_system, and updated by detect_coding. So, 404 -1 in setup_coding_system, and updated by detect_coding. So,
400 when this is equal to the byte length of the text being 405 when this is equal to the byte length of the text being
401 converted, we can skip the actual conversion process. */ 406 converted, we can skip the actual conversion process. */
402 int heading_ascii; 407 int heading_ascii;
403 408
404 /* The following members are set by encoding/decoding routine. */ 409 /* The following members are set by encoding/decoding routine. */
405 int produced, produced_char, consumed, consumed_char; 410 int produced, produced_char, consumed, consumed_char;
406 411
407 /* Encoding routines set this to 1 when they produce a byte sequence 412 /* Number of error source data found in a decoding routine. */
408 which can be parsed as a multibyte character. Decoding routines 413 int errors;
409 set this to 1 when they encounter an invalid code and, as the 414
410 result, produce an unexpected multibyte character. */ 415 /* Finish status of code conversion. It should be one of macros
411 int fake_multibyte; 416 CODING_FINISH_XXXX. */
417 int result;
412 418
413 /* The following members are all Lisp symbols. We don't have to 419 /* The following members are all Lisp symbols. We don't have to
414 protect them from GC because the current garbage collection 420 protect them from GC because the current garbage collection
415 doesn't relocate Lisp symbols. But, when it is changed, we must 421 doesn't relocate Lisp symbols. But, when it is changed, we must
416 find a way to protect them. */ 422 find a way to protect them. */
442 ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK) 448 ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK)
443 449
444 /* Return 1 if the coding system CODING requires code conversion on 450 /* Return 1 if the coding system CODING requires code conversion on
445 decoding. */ 451 decoding. */
446 #define CODING_REQUIRE_DECODING(coding) \ 452 #define CODING_REQUIRE_DECODING(coding) \
447 ((coding)->common_flags & CODING_REQUIRE_DECODING_MASK) 453 ((coding)->dst_multibyte \
454 || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK)
448 455
449 /* Return 1 if the coding system CODING requires code conversion on 456 /* Return 1 if the coding system CODING requires code conversion on
450 encoding. */ 457 encoding. */
451 #define CODING_REQUIRE_ENCODING(coding) \ 458 #define CODING_REQUIRE_ENCODING(coding) \
452 ((coding)->common_flags & CODING_REQUIRE_ENCODING_MASK) 459 ((coding)->src_multibyte \
460 || (coding)->common_flags & CODING_REQUIRE_ENCODING_MASK)
453 461
454 /* Return 1 if the coding system CODING requires some kind of code 462 /* Return 1 if the coding system CODING requires some kind of code
455 detection. */ 463 detection. */
456 #define CODING_REQUIRE_DETECTION(coding) \ 464 #define CODING_REQUIRE_DETECTION(coding) \
457 ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK) 465 ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK)
458 466
467 /* Return 1 if the coding system CODING requires code conversion on
468 decoding or some kind of code detection. */
459 #define CODING_MAY_REQUIRE_DECODING(coding) \ 469 #define CODING_MAY_REQUIRE_DECODING(coding) \
460 ((coding)->common_flags \ 470 (CODING_REQUIRE_DECODING (coding) \
461 & (CODING_REQUIRE_DETECTION_MASK | CODING_REQUIRE_DECODING_MASK)) 471 || CODING_REQUIRE_DETECTION (coding))
462 472
463 /* Index for each coding category in `coding_category_table' */ 473 /* Index for each coding category in `coding_category_table' */
464 #define CODING_CATEGORY_IDX_EMACS_MULE 0 474 #define CODING_CATEGORY_IDX_EMACS_MULE 0
465 #define CODING_CATEGORY_IDX_SJIS 1 475 #define CODING_CATEGORY_IDX_SJIS 1
466 #define CODING_CATEGORY_IDX_ISO_7 2 476 #define CODING_CATEGORY_IDX_ISO_7 2