comparison src/coding.c @ 89780:a53cb5864a40

(detect_coding_iso_2022): Fix handling of SS2 and SS3. (detect_coding): Treat '\0' as normal ASCII byte.. (detect_coding_system): Likewise.
author Kenichi Handa <handa@m17n.org>
date Thu, 29 Jan 2004 01:25:50 +0000
parents 74c503490829
children b5f22f538c1f
comparison
equal deleted inserted replaced
89779:74c503490829 89780:a53cb5864a40
2614 single_shifting = 0; 2614 single_shifting = 0;
2615 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE; 2615 rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_7_ELSE;
2616 found |= CATEGORY_MASK_ISO_8_ELSE; 2616 found |= CATEGORY_MASK_ISO_8_ELSE;
2617 goto check_extra_latin; 2617 goto check_extra_latin;
2618 2618
2619
2620 case ISO_CODE_SS2: 2619 case ISO_CODE_SS2:
2621 case ISO_CODE_SS3: 2620 case ISO_CODE_SS3:
2622 /* Single shift. */ 2621 /* Single shift. */
2623 if (inhibit_iso_escape_detection) 2622 if (inhibit_iso_escape_detection)
2624 break; 2623 break;
2625 single_shifting = 1; 2624 single_shifting = 0;
2626 rejected |= CATEGORY_MASK_ISO_7BIT; 2625 rejected |= CATEGORY_MASK_ISO_7BIT;
2627 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) 2626 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
2628 & CODING_ISO_FLAG_SINGLE_SHIFT) 2627 & CODING_ISO_FLAG_SINGLE_SHIFT)
2629 found |= CATEGORY_MASK_ISO_8_1; 2628 found |= CATEGORY_MASK_ISO_8_1, single_shifting = 1;
2630 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2]) 2629 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2])
2631 & CODING_ISO_FLAG_SINGLE_SHIFT) 2630 & CODING_ISO_FLAG_SINGLE_SHIFT)
2632 found |= CATEGORY_MASK_ISO_8_2; 2631 found |= CATEGORY_MASK_ISO_8_2, single_shifting = 1;
2632 if (single_shifting)
2633 break;
2633 goto check_extra_latin; 2634 goto check_extra_latin;
2634 2635
2635 default: 2636 default:
2636 if (c < 0) 2637 if (c < 0)
2637 continue; 2638 continue;
2678 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1]) 2679 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
2679 & CODING_ISO_FLAG_LATIN_EXTRA) 2680 & CODING_ISO_FLAG_LATIN_EXTRA)
2680 found |= CATEGORY_MASK_ISO_8_1; 2681 found |= CATEGORY_MASK_ISO_8_1;
2681 else 2682 else
2682 rejected |= CATEGORY_MASK_ISO_8_1; 2683 rejected |= CATEGORY_MASK_ISO_8_1;
2683 if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2]) 2684 rejected |= CATEGORY_MASK_ISO_8_2;
2684 & CODING_ISO_FLAG_LATIN_EXTRA)
2685 found |= CATEGORY_MASK_ISO_8_2;
2686 else
2687 rejected |= CATEGORY_MASK_ISO_8_2;
2688 } 2685 }
2689 } 2686 }
2690 detect_info->rejected |= CATEGORY_MASK_ISO; 2687 detect_info->rejected |= CATEGORY_MASK_ISO;
2691 return 0; 2688 return 0;
2692 2689
5347 int c, i; 5344 int c, i;
5348 5345
5349 for (i = 0, src = coding->source; src < src_end; i++, src++) 5346 for (i = 0, src = coding->source; src < src_end; i++, src++)
5350 { 5347 {
5351 c = *src; 5348 c = *src;
5352 if (c & 0x80 || (c < 0x20 && (c == 0 5349 if (c & 0x80 || (c < 0x20 && (c == ISO_CODE_ESC
5353 || c == ISO_CODE_ESC
5354 || c == ISO_CODE_SI 5350 || c == ISO_CODE_SI
5355 || c == ISO_CODE_SO))) 5351 || c == ISO_CODE_SO)))
5356 break; 5352 break;
5357 } 5353 }
5358 coding->head_ascii = src - (coding->source + coding->consumed); 5354 coding->head_ascii = src - (coding->source + coding->consumed);
6876 6872
6877 /* Skip all ASCII bytes except for a few ISO2022 controls. */ 6873 /* Skip all ASCII bytes except for a few ISO2022 controls. */
6878 for (i = 0; src < src_end; i++, src++) 6874 for (i = 0; src < src_end; i++, src++)
6879 { 6875 {
6880 c = *src; 6876 c = *src;
6881 if (c & 0x80 || (c < 0x20 && (c == 0 6877 if (c & 0x80 || (c < 0x20 && (c == ISO_CODE_ESC
6882 || c == ISO_CODE_ESC
6883 || c == ISO_CODE_SI 6878 || c == ISO_CODE_SI
6884 || c == ISO_CODE_SO))) 6879 || c == ISO_CODE_SO)))
6885 break; 6880 break;
6886 } 6881 }
6887 coding.head_ascii = src - coding.source; 6882 coding.head_ascii = src - coding.source;