diff options
| author | Bill Wohler | 2012-11-24 19:43:02 -0800 |
|---|---|---|
| committer | Bill Wohler | 2012-11-24 19:43:02 -0800 |
| commit | 5244bc019bf7376caff3bb198ff674e0ad9fb0e6 (patch) | |
| tree | 02ee1615e904771f692ec2957c79a08ae029a13d /src/coding.c | |
| parent | 9f7e719509474e92f85955e22e57ffeebd4e96f3 (diff) | |
| parent | c07a6ded1df2f4156badc9add2953579622c3722 (diff) | |
| download | emacs-5244bc019bf7376caff3bb198ff674e0ad9fb0e6.tar.gz emacs-5244bc019bf7376caff3bb198ff674e0ad9fb0e6.zip | |
Merge from trunk.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 1028 |
1 files changed, 489 insertions, 539 deletions
diff --git a/src/coding.c b/src/coding.c index e15d725af3a..56202e4861d 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Coding system handler (conversion, detection, etc). | 1 | /* Coding system handler (conversion, detection, etc). |
| 2 | Copyright (C) 2001-2011 Free Software Foundation, Inc. | 2 | Copyright (C) 2001-2012 Free Software Foundation, Inc. |
| 3 | Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, | 3 | Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
| 4 | 2005, 2006, 2007, 2008, 2009, 2010, 2011 | 4 | 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
| 5 | National Institute of Advanced Industrial Science and Technology (AIST) | 5 | National Institute of Advanced Industrial Science and Technology (AIST) |
| @@ -147,19 +147,19 @@ STRUCT CODING_SYSTEM | |||
| 147 | CODING conforms to the format of XXX, and update the members of | 147 | CODING conforms to the format of XXX, and update the members of |
| 148 | DETECT_INFO. | 148 | DETECT_INFO. |
| 149 | 149 | ||
| 150 | Return 1 if the byte sequence conforms to XXX, otherwise return 0. | 150 | Return true if the byte sequence conforms to XXX. |
| 151 | 151 | ||
| 152 | Below is the template of these functions. */ | 152 | Below is the template of these functions. */ |
| 153 | 153 | ||
| 154 | #if 0 | 154 | #if 0 |
| 155 | static int | 155 | static bool |
| 156 | detect_coding_XXX (struct coding_system *coding, | 156 | detect_coding_XXX (struct coding_system *coding, |
| 157 | struct coding_detection_info *detect_info) | 157 | struct coding_detection_info *detect_info) |
| 158 | { | 158 | { |
| 159 | const unsigned char *src = coding->source; | 159 | const unsigned char *src = coding->source; |
| 160 | const unsigned char *src_end = coding->source + coding->src_bytes; | 160 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 161 | int multibytep = coding->src_multibyte; | 161 | bool multibytep = coding->src_multibyte; |
| 162 | EMACS_INT consumed_chars = 0; | 162 | ptrdiff_t consumed_chars = 0; |
| 163 | int found = 0; | 163 | int found = 0; |
| 164 | ...; | 164 | ...; |
| 165 | 165 | ||
| @@ -212,7 +212,7 @@ decode_coding_XXXX (struct coding_system *coding) | |||
| 212 | /* A buffer to produce decoded characters. */ | 212 | /* A buffer to produce decoded characters. */ |
| 213 | int *charbuf = coding->charbuf + coding->charbuf_used; | 213 | int *charbuf = coding->charbuf + coding->charbuf_used; |
| 214 | int *charbuf_end = coding->charbuf + coding->charbuf_size; | 214 | int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 215 | int multibytep = coding->src_multibyte; | 215 | bool multibytep = coding->src_multibyte; |
| 216 | 216 | ||
| 217 | while (1) | 217 | while (1) |
| 218 | { | 218 | { |
| @@ -260,13 +260,13 @@ decode_coding_XXXX (struct coding_system *coding) | |||
| 260 | static void | 260 | static void |
| 261 | encode_coding_XXX (struct coding_system *coding) | 261 | encode_coding_XXX (struct coding_system *coding) |
| 262 | { | 262 | { |
| 263 | int multibytep = coding->dst_multibyte; | 263 | bool multibytep = coding->dst_multibyte; |
| 264 | int *charbuf = coding->charbuf; | 264 | int *charbuf = coding->charbuf; |
| 265 | int *charbuf_end = charbuf->charbuf + coding->charbuf_used; | 265 | int *charbuf_end = charbuf->charbuf + coding->charbuf_used; |
| 266 | unsigned char *dst = coding->destination + coding->produced; | 266 | unsigned char *dst = coding->destination + coding->produced; |
| 267 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 267 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 268 | unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_; | 268 | unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_; |
| 269 | EMACS_INT produced_chars = 0; | 269 | ptrdiff_t produced_chars = 0; |
| 270 | 270 | ||
| 271 | for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++) | 271 | for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++) |
| 272 | { | 272 | { |
| @@ -285,11 +285,10 @@ encode_coding_XXX (struct coding_system *coding) | |||
| 285 | 285 | ||
| 286 | #include <config.h> | 286 | #include <config.h> |
| 287 | #include <stdio.h> | 287 | #include <stdio.h> |
| 288 | #include <setjmp.h> | ||
| 289 | 288 | ||
| 290 | #include "lisp.h" | 289 | #include "lisp.h" |
| 291 | #include "buffer.h" | ||
| 292 | #include "character.h" | 290 | #include "character.h" |
| 291 | #include "buffer.h" | ||
| 293 | #include "charset.h" | 292 | #include "charset.h" |
| 294 | #include "ccl.h" | 293 | #include "ccl.h" |
| 295 | #include "composite.h" | 294 | #include "composite.h" |
| @@ -344,6 +343,10 @@ Lisp_Object Qcoding_system_p, Qcoding_system_error; | |||
| 344 | Lisp_Object Qemacs_mule, Qraw_text; | 343 | Lisp_Object Qemacs_mule, Qraw_text; |
| 345 | Lisp_Object Qutf_8_emacs; | 344 | Lisp_Object Qutf_8_emacs; |
| 346 | 345 | ||
| 346 | #if defined (WINDOWSNT) || defined (CYGWIN) | ||
| 347 | static Lisp_Object Qutf_16le; | ||
| 348 | #endif | ||
| 349 | |||
| 347 | /* Coding-systems are handed between Emacs Lisp programs and C internal | 350 | /* Coding-systems are handed between Emacs Lisp programs and C internal |
| 348 | routines by the following three variables. */ | 351 | routines by the following three variables. */ |
| 349 | /* Coding system to be used to encode text for terminal display when | 352 | /* Coding system to be used to encode text for terminal display when |
| @@ -416,7 +419,7 @@ enum iso_code_class_type | |||
| 416 | ISO_shift_out, /* ISO_CODE_SO (0x0E) */ | 419 | ISO_shift_out, /* ISO_CODE_SO (0x0E) */ |
| 417 | ISO_shift_in, /* ISO_CODE_SI (0x0F) */ | 420 | ISO_shift_in, /* ISO_CODE_SI (0x0F) */ |
| 418 | ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */ | 421 | ISO_single_shift_2_7, /* ISO_CODE_SS2_7 (0x19) */ |
| 419 | ISO_escape, /* ISO_CODE_SO (0x1B) */ | 422 | ISO_escape, /* ISO_CODE_ESC (0x1B) */ |
| 420 | ISO_control_1, /* Control codes in the range | 423 | ISO_control_1, /* Control codes in the range |
| 421 | 0x80..0x9F, except for the | 424 | 0x80..0x9F, except for the |
| 422 | following 3 codes. */ | 425 | following 3 codes. */ |
| @@ -651,8 +654,8 @@ static struct coding_system coding_categories[coding_category_max]; | |||
| 651 | 654 | ||
| 652 | /* Safely get one byte from the source text pointed by SRC which ends | 655 | /* Safely get one byte from the source text pointed by SRC which ends |
| 653 | at SRC_END, and set C to that byte. If there are not enough bytes | 656 | at SRC_END, and set C to that byte. If there are not enough bytes |
| 654 | in the source, it jumps to `no_more_source'. If multibytep is | 657 | in the source, it jumps to 'no_more_source'. If MULTIBYTEP, |
| 655 | nonzero, and a multibyte character is found at SRC, set C to the | 658 | and a multibyte character is found at SRC, set C to the |
| 656 | negative value of the character code. The caller should declare | 659 | negative value of the character code. The caller should declare |
| 657 | and set these variables appropriately in advance: | 660 | and set these variables appropriately in advance: |
| 658 | src, src_end, multibytep */ | 661 | src, src_end, multibytep */ |
| @@ -685,7 +688,7 @@ static struct coding_system coding_categories[coding_category_max]; | |||
| 685 | /* Safely get two bytes from the source text pointed by SRC which ends | 688 | /* Safely get two bytes from the source text pointed by SRC which ends |
| 686 | at SRC_END, and set C1 and C2 to those bytes while skipping the | 689 | at SRC_END, and set C1 and C2 to those bytes while skipping the |
| 687 | heading multibyte characters. If there are not enough bytes in the | 690 | heading multibyte characters. If there are not enough bytes in the |
| 688 | source, it jumps to `no_more_source'. If multibytep is nonzero and | 691 | source, it jumps to 'no_more_source'. If MULTIBYTEP and |
| 689 | a multibyte character is found for C2, set C2 to the negative value | 692 | a multibyte character is found for C2, set C2 to the negative value |
| 690 | of the character code. The caller should declare and set these | 693 | of the character code. The caller should declare and set these |
| 691 | variables appropriately in advance: | 694 | variables appropriately in advance: |
| @@ -746,8 +749,8 @@ static struct coding_system coding_categories[coding_category_max]; | |||
| 746 | 749 | ||
| 747 | 750 | ||
| 748 | /* Store a byte C in the place pointed by DST and increment DST to the | 751 | /* Store a byte C in the place pointed by DST and increment DST to the |
| 749 | next free point, and increment PRODUCED_CHARS. If MULTIBYTEP is | 752 | next free point, and increment PRODUCED_CHARS. If MULTIBYTEP, |
| 750 | nonzero, store in an appropriate multibyte from. The caller should | 753 | store in an appropriate multibyte form. The caller should |
| 751 | declare and set the variables `dst' and `multibytep' appropriately | 754 | declare and set the variables `dst' and `multibytep' appropriately |
| 752 | in advance. */ | 755 | in advance. */ |
| 753 | 756 | ||
| @@ -806,81 +809,6 @@ static struct coding_system coding_categories[coding_category_max]; | |||
| 806 | } while (0) | 809 | } while (0) |
| 807 | 810 | ||
| 808 | 811 | ||
| 809 | /* Prototypes for static functions. */ | ||
| 810 | static void record_conversion_result (struct coding_system *coding, | ||
| 811 | enum coding_result_code result); | ||
| 812 | static int detect_coding_utf_8 (struct coding_system *, | ||
| 813 | struct coding_detection_info *info); | ||
| 814 | static void decode_coding_utf_8 (struct coding_system *); | ||
| 815 | static int encode_coding_utf_8 (struct coding_system *); | ||
| 816 | |||
| 817 | static int detect_coding_utf_16 (struct coding_system *, | ||
| 818 | struct coding_detection_info *info); | ||
| 819 | static void decode_coding_utf_16 (struct coding_system *); | ||
| 820 | static int encode_coding_utf_16 (struct coding_system *); | ||
| 821 | |||
| 822 | static int detect_coding_iso_2022 (struct coding_system *, | ||
| 823 | struct coding_detection_info *info); | ||
| 824 | static void decode_coding_iso_2022 (struct coding_system *); | ||
| 825 | static int encode_coding_iso_2022 (struct coding_system *); | ||
| 826 | |||
| 827 | static int detect_coding_emacs_mule (struct coding_system *, | ||
| 828 | struct coding_detection_info *info); | ||
| 829 | static void decode_coding_emacs_mule (struct coding_system *); | ||
| 830 | static int encode_coding_emacs_mule (struct coding_system *); | ||
| 831 | |||
| 832 | static int detect_coding_sjis (struct coding_system *, | ||
| 833 | struct coding_detection_info *info); | ||
| 834 | static void decode_coding_sjis (struct coding_system *); | ||
| 835 | static int encode_coding_sjis (struct coding_system *); | ||
| 836 | |||
| 837 | static int detect_coding_big5 (struct coding_system *, | ||
| 838 | struct coding_detection_info *info); | ||
| 839 | static void decode_coding_big5 (struct coding_system *); | ||
| 840 | static int encode_coding_big5 (struct coding_system *); | ||
| 841 | |||
| 842 | static int detect_coding_ccl (struct coding_system *, | ||
| 843 | struct coding_detection_info *info); | ||
| 844 | static void decode_coding_ccl (struct coding_system *); | ||
| 845 | static int encode_coding_ccl (struct coding_system *); | ||
| 846 | |||
| 847 | static void decode_coding_raw_text (struct coding_system *); | ||
| 848 | static int encode_coding_raw_text (struct coding_system *); | ||
| 849 | |||
| 850 | static EMACS_INT coding_set_source (struct coding_system *); | ||
| 851 | static EMACS_INT coding_set_destination (struct coding_system *); | ||
| 852 | static void coding_alloc_by_realloc (struct coding_system *, EMACS_INT); | ||
| 853 | static void coding_alloc_by_making_gap (struct coding_system *, | ||
| 854 | EMACS_INT, EMACS_INT); | ||
| 855 | static unsigned char *alloc_destination (struct coding_system *, | ||
| 856 | EMACS_INT, unsigned char *); | ||
| 857 | static void setup_iso_safe_charsets (Lisp_Object); | ||
| 858 | static int encode_designation_at_bol (struct coding_system *, | ||
| 859 | int *, int *, unsigned char *); | ||
| 860 | static int detect_eol (const unsigned char *, | ||
| 861 | EMACS_INT, enum coding_category); | ||
| 862 | static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); | ||
| 863 | static void decode_eol (struct coding_system *); | ||
| 864 | static Lisp_Object get_translation_table (Lisp_Object, int, int *); | ||
| 865 | static Lisp_Object get_translation (Lisp_Object, int *, int *); | ||
| 866 | static int produce_chars (struct coding_system *, Lisp_Object, int); | ||
| 867 | static inline void produce_charset (struct coding_system *, int *, | ||
| 868 | EMACS_INT); | ||
| 869 | static void produce_annotation (struct coding_system *, EMACS_INT); | ||
| 870 | static int decode_coding (struct coding_system *); | ||
| 871 | static inline int *handle_composition_annotation (EMACS_INT, EMACS_INT, | ||
| 872 | struct coding_system *, | ||
| 873 | int *, EMACS_INT *); | ||
| 874 | static inline int *handle_charset_annotation (EMACS_INT, EMACS_INT, | ||
| 875 | struct coding_system *, | ||
| 876 | int *, EMACS_INT *); | ||
| 877 | static void consume_chars (struct coding_system *, Lisp_Object, int); | ||
| 878 | static int encode_coding (struct coding_system *); | ||
| 879 | static Lisp_Object make_conversion_work_buffer (int); | ||
| 880 | static Lisp_Object code_conversion_restore (Lisp_Object); | ||
| 881 | static inline int char_encodable_p (int, Lisp_Object); | ||
| 882 | static Lisp_Object make_subsidiaries (Lisp_Object); | ||
| 883 | |||
| 884 | static void | 812 | static void |
| 885 | record_conversion_result (struct coding_system *coding, | 813 | record_conversion_result (struct coding_system *coding, |
| 886 | enum coding_result_code result) | 814 | enum coding_result_code result) |
| @@ -922,12 +850,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 922 | 850 | ||
| 923 | #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ | 851 | #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ |
| 924 | do { \ | 852 | do { \ |
| 925 | EMACS_INT offset; \ | 853 | ptrdiff_t offset; \ |
| 926 | \ | 854 | \ |
| 927 | charset_map_loaded = 0; \ | 855 | charset_map_loaded = 0; \ |
| 928 | c = DECODE_CHAR (charset, code); \ | 856 | c = DECODE_CHAR (charset, code); \ |
| 929 | if (charset_map_loaded \ | 857 | if (charset_map_loaded \ |
| 930 | && (offset = coding_set_source (coding))) \ | 858 | && (offset = coding_change_source (coding))) \ |
| 931 | { \ | 859 | { \ |
| 932 | src += offset; \ | 860 | src += offset; \ |
| 933 | src_base += offset; \ | 861 | src_base += offset; \ |
| @@ -937,12 +865,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 937 | 865 | ||
| 938 | #define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ | 866 | #define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ |
| 939 | do { \ | 867 | do { \ |
| 940 | EMACS_INT offset; \ | 868 | ptrdiff_t offset; \ |
| 941 | \ | 869 | \ |
| 942 | charset_map_loaded = 0; \ | 870 | charset_map_loaded = 0; \ |
| 943 | code = ENCODE_CHAR (charset, c); \ | 871 | code = ENCODE_CHAR (charset, c); \ |
| 944 | if (charset_map_loaded \ | 872 | if (charset_map_loaded \ |
| 945 | && (offset = coding_set_destination (coding))) \ | 873 | && (offset = coding_change_destination (coding))) \ |
| 946 | { \ | 874 | { \ |
| 947 | dst += offset; \ | 875 | dst += offset; \ |
| 948 | dst_end += offset; \ | 876 | dst_end += offset; \ |
| @@ -951,12 +879,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 951 | 879 | ||
| 952 | #define CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, code_return, charset) \ | 880 | #define CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, code_return, charset) \ |
| 953 | do { \ | 881 | do { \ |
| 954 | EMACS_INT offset; \ | 882 | ptrdiff_t offset; \ |
| 955 | \ | 883 | \ |
| 956 | charset_map_loaded = 0; \ | 884 | charset_map_loaded = 0; \ |
| 957 | charset = char_charset (c, charset_list, code_return); \ | 885 | charset = char_charset (c, charset_list, code_return); \ |
| 958 | if (charset_map_loaded \ | 886 | if (charset_map_loaded \ |
| 959 | && (offset = coding_set_destination (coding))) \ | 887 | && (offset = coding_change_destination (coding))) \ |
| 960 | { \ | 888 | { \ |
| 961 | dst += offset; \ | 889 | dst += offset; \ |
| 962 | dst_end += offset; \ | 890 | dst_end += offset; \ |
| @@ -965,12 +893,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 965 | 893 | ||
| 966 | #define CODING_CHAR_CHARSET_P(coding, dst, dst_end, c, charset, result) \ | 894 | #define CODING_CHAR_CHARSET_P(coding, dst, dst_end, c, charset, result) \ |
| 967 | do { \ | 895 | do { \ |
| 968 | EMACS_INT offset; \ | 896 | ptrdiff_t offset; \ |
| 969 | \ | 897 | \ |
| 970 | charset_map_loaded = 0; \ | 898 | charset_map_loaded = 0; \ |
| 971 | result = CHAR_CHARSET_P (c, charset); \ | 899 | result = CHAR_CHARSET_P (c, charset); \ |
| 972 | if (charset_map_loaded \ | 900 | if (charset_map_loaded \ |
| 973 | && (offset = coding_set_destination (coding))) \ | 901 | && (offset = coding_change_destination (coding))) \ |
| 974 | { \ | 902 | { \ |
| 975 | dst += offset; \ | 903 | dst += offset; \ |
| 976 | dst_end += offset; \ | 904 | dst_end += offset; \ |
| @@ -987,7 +915,7 @@ record_conversion_result (struct coding_system *coding, | |||
| 987 | do { \ | 915 | do { \ |
| 988 | if (dst + (bytes) >= dst_end) \ | 916 | if (dst + (bytes) >= dst_end) \ |
| 989 | { \ | 917 | { \ |
| 990 | EMACS_INT more_bytes = charbuf_end - charbuf + (bytes); \ | 918 | ptrdiff_t more_bytes = charbuf_end - charbuf + (bytes); \ |
| 991 | \ | 919 | \ |
| 992 | dst = alloc_destination (coding, more_bytes, dst); \ | 920 | dst = alloc_destination (coding, more_bytes, dst); \ |
| 993 | dst_end = coding->destination + coding->dst_bytes; \ | 921 | dst_end = coding->destination + coding->dst_bytes; \ |
| @@ -996,74 +924,24 @@ record_conversion_result (struct coding_system *coding, | |||
| 996 | 924 | ||
| 997 | 925 | ||
| 998 | /* Store multibyte form of the character C in P, and advance P to the | 926 | /* Store multibyte form of the character C in P, and advance P to the |
| 999 | end of the multibyte form. This is like CHAR_STRING_ADVANCE but it | 927 | end of the multibyte form. This used to be like CHAR_STRING_ADVANCE |
| 1000 | never calls MAYBE_UNIFY_CHAR. */ | 928 | without ever calling MAYBE_UNIFY_CHAR, but nowadays we don't call |
| 1001 | 929 | MAYBE_UNIFY_CHAR in CHAR_STRING_ADVANCE. */ | |
| 1002 | #define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) \ | ||
| 1003 | do { \ | ||
| 1004 | if ((c) <= MAX_1_BYTE_CHAR) \ | ||
| 1005 | *(p)++ = (c); \ | ||
| 1006 | else if ((c) <= MAX_2_BYTE_CHAR) \ | ||
| 1007 | *(p)++ = (0xC0 | ((c) >> 6)), \ | ||
| 1008 | *(p)++ = (0x80 | ((c) & 0x3F)); \ | ||
| 1009 | else if ((c) <= MAX_3_BYTE_CHAR) \ | ||
| 1010 | *(p)++ = (0xE0 | ((c) >> 12)), \ | ||
| 1011 | *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \ | ||
| 1012 | *(p)++ = (0x80 | ((c) & 0x3F)); \ | ||
| 1013 | else if ((c) <= MAX_4_BYTE_CHAR) \ | ||
| 1014 | *(p)++ = (0xF0 | (c >> 18)), \ | ||
| 1015 | *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \ | ||
| 1016 | *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \ | ||
| 1017 | *(p)++ = (0x80 | (c & 0x3F)); \ | ||
| 1018 | else if ((c) <= MAX_5_BYTE_CHAR) \ | ||
| 1019 | *(p)++ = 0xF8, \ | ||
| 1020 | *(p)++ = (0x80 | ((c >> 18) & 0x0F)), \ | ||
| 1021 | *(p)++ = (0x80 | ((c >> 12) & 0x3F)), \ | ||
| 1022 | *(p)++ = (0x80 | ((c >> 6) & 0x3F)), \ | ||
| 1023 | *(p)++ = (0x80 | (c & 0x3F)); \ | ||
| 1024 | else \ | ||
| 1025 | (p) += BYTE8_STRING ((c) - 0x3FFF80, p); \ | ||
| 1026 | } while (0) | ||
| 1027 | 930 | ||
| 931 | #define CHAR_STRING_ADVANCE_NO_UNIFY(c, p) CHAR_STRING_ADVANCE(c, p) | ||
| 1028 | 932 | ||
| 1029 | /* Return the character code of character whose multibyte form is at | 933 | /* Return the character code of character whose multibyte form is at |
| 1030 | P, and advance P to the end of the multibyte form. This is like | 934 | P, and advance P to the end of the multibyte form. This used to be |
| 1031 | STRING_CHAR_ADVANCE, but it never calls MAYBE_UNIFY_CHAR. */ | 935 | like STRING_CHAR_ADVANCE without ever calling MAYBE_UNIFY_CHAR, but |
| 1032 | 936 | nowadays STRING_CHAR_ADVANCE doesn't call MAYBE_UNIFY_CHAR. */ | |
| 1033 | #define STRING_CHAR_ADVANCE_NO_UNIFY(p) \ | ||
| 1034 | (!((p)[0] & 0x80) \ | ||
| 1035 | ? *(p)++ \ | ||
| 1036 | : ! ((p)[0] & 0x20) \ | ||
| 1037 | ? ((p) += 2, \ | ||
| 1038 | ((((p)[-2] & 0x1F) << 6) \ | ||
| 1039 | | ((p)[-1] & 0x3F) \ | ||
| 1040 | | ((unsigned char) ((p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \ | ||
| 1041 | : ! ((p)[0] & 0x10) \ | ||
| 1042 | ? ((p) += 3, \ | ||
| 1043 | ((((p)[-3] & 0x0F) << 12) \ | ||
| 1044 | | (((p)[-2] & 0x3F) << 6) \ | ||
| 1045 | | ((p)[-1] & 0x3F))) \ | ||
| 1046 | : ! ((p)[0] & 0x08) \ | ||
| 1047 | ? ((p) += 4, \ | ||
| 1048 | ((((p)[-4] & 0xF) << 18) \ | ||
| 1049 | | (((p)[-3] & 0x3F) << 12) \ | ||
| 1050 | | (((p)[-2] & 0x3F) << 6) \ | ||
| 1051 | | ((p)[-1] & 0x3F))) \ | ||
| 1052 | : ((p) += 5, \ | ||
| 1053 | ((((p)[-4] & 0x3F) << 18) \ | ||
| 1054 | | (((p)[-3] & 0x3F) << 12) \ | ||
| 1055 | | (((p)[-2] & 0x3F) << 6) \ | ||
| 1056 | | ((p)[-1] & 0x3F)))) | ||
| 1057 | |||
| 1058 | |||
| 1059 | /* Update coding->source from coding->src_object, and return how many | ||
| 1060 | bytes coding->source was changed. */ | ||
| 1061 | 937 | ||
| 1062 | static EMACS_INT | 938 | #define STRING_CHAR_ADVANCE_NO_UNIFY(p) STRING_CHAR_ADVANCE(p) |
| 939 | |||
| 940 | /* Set coding->source from coding->src_object. */ | ||
| 941 | |||
| 942 | static void | ||
| 1063 | coding_set_source (struct coding_system *coding) | 943 | coding_set_source (struct coding_system *coding) |
| 1064 | { | 944 | { |
| 1065 | const unsigned char *orig = coding->source; | ||
| 1066 | |||
| 1067 | if (BUFFERP (coding->src_object)) | 945 | if (BUFFERP (coding->src_object)) |
| 1068 | { | 946 | { |
| 1069 | struct buffer *buf = XBUFFER (coding->src_object); | 947 | struct buffer *buf = XBUFFER (coding->src_object); |
| @@ -1082,18 +960,26 @@ coding_set_source (struct coding_system *coding) | |||
| 1082 | /* Otherwise, the source is C string and is never relocated | 960 | /* Otherwise, the source is C string and is never relocated |
| 1083 | automatically. Thus we don't have to update anything. */ | 961 | automatically. Thus we don't have to update anything. */ |
| 1084 | } | 962 | } |
| 963 | } | ||
| 964 | |||
| 965 | |||
| 966 | /* Set coding->source from coding->src_object, and return how many | ||
| 967 | bytes coding->source was changed. */ | ||
| 968 | |||
| 969 | static ptrdiff_t | ||
| 970 | coding_change_source (struct coding_system *coding) | ||
| 971 | { | ||
| 972 | const unsigned char *orig = coding->source; | ||
| 973 | coding_set_source (coding); | ||
| 1085 | return coding->source - orig; | 974 | return coding->source - orig; |
| 1086 | } | 975 | } |
| 1087 | 976 | ||
| 1088 | 977 | ||
| 1089 | /* Update coding->destination from coding->dst_object, and return how | 978 | /* Set coding->destination from coding->dst_object. */ |
| 1090 | many bytes coding->destination was changed. */ | ||
| 1091 | 979 | ||
| 1092 | static EMACS_INT | 980 | static void |
| 1093 | coding_set_destination (struct coding_system *coding) | 981 | coding_set_destination (struct coding_system *coding) |
| 1094 | { | 982 | { |
| 1095 | const unsigned char *orig = coding->destination; | ||
| 1096 | |||
| 1097 | if (BUFFERP (coding->dst_object)) | 983 | if (BUFFERP (coding->dst_object)) |
| 1098 | { | 984 | { |
| 1099 | if (BUFFERP (coding->src_object) && coding->src_pos < 0) | 985 | if (BUFFERP (coding->src_object) && coding->src_pos < 0) |
| @@ -1118,23 +1004,34 @@ coding_set_destination (struct coding_system *coding) | |||
| 1118 | /* Otherwise, the destination is C string and is never relocated | 1004 | /* Otherwise, the destination is C string and is never relocated |
| 1119 | automatically. Thus we don't have to update anything. */ | 1005 | automatically. Thus we don't have to update anything. */ |
| 1120 | } | 1006 | } |
| 1007 | } | ||
| 1008 | |||
| 1009 | |||
| 1010 | /* Set coding->destination from coding->dst_object, and return how | ||
| 1011 | many bytes coding->destination was changed. */ | ||
| 1012 | |||
| 1013 | static ptrdiff_t | ||
| 1014 | coding_change_destination (struct coding_system *coding) | ||
| 1015 | { | ||
| 1016 | const unsigned char *orig = coding->destination; | ||
| 1017 | coding_set_destination (coding); | ||
| 1121 | return coding->destination - orig; | 1018 | return coding->destination - orig; |
| 1122 | } | 1019 | } |
| 1123 | 1020 | ||
| 1124 | 1021 | ||
| 1125 | static void | 1022 | static void |
| 1126 | coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) | 1023 | coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes) |
| 1127 | { | 1024 | { |
| 1128 | if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) | 1025 | if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) |
| 1129 | string_overflow (); | 1026 | string_overflow (); |
| 1130 | coding->destination = (unsigned char *) xrealloc (coding->destination, | 1027 | coding->destination = xrealloc (coding->destination, |
| 1131 | coding->dst_bytes + bytes); | 1028 | coding->dst_bytes + bytes); |
| 1132 | coding->dst_bytes += bytes; | 1029 | coding->dst_bytes += bytes; |
| 1133 | } | 1030 | } |
| 1134 | 1031 | ||
| 1135 | static void | 1032 | static void |
| 1136 | coding_alloc_by_making_gap (struct coding_system *coding, | 1033 | coding_alloc_by_making_gap (struct coding_system *coding, |
| 1137 | EMACS_INT gap_head_used, EMACS_INT bytes) | 1034 | ptrdiff_t gap_head_used, ptrdiff_t bytes) |
| 1138 | { | 1035 | { |
| 1139 | if (EQ (coding->src_object, coding->dst_object)) | 1036 | if (EQ (coding->src_object, coding->dst_object)) |
| 1140 | { | 1037 | { |
| @@ -1142,7 +1039,7 @@ coding_alloc_by_making_gap (struct coding_system *coding, | |||
| 1142 | consumed data at the tail. To preserve those data, we at | 1039 | consumed data at the tail. To preserve those data, we at |
| 1143 | first make the gap size to zero, then increase the gap | 1040 | first make the gap size to zero, then increase the gap |
| 1144 | size. */ | 1041 | size. */ |
| 1145 | EMACS_INT add = GAP_SIZE; | 1042 | ptrdiff_t add = GAP_SIZE; |
| 1146 | 1043 | ||
| 1147 | GPT += gap_head_used, GPT_BYTE += gap_head_used; | 1044 | GPT += gap_head_used, GPT_BYTE += gap_head_used; |
| 1148 | GAP_SIZE = 0; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; | 1045 | GAP_SIZE = 0; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; |
| @@ -1163,10 +1060,10 @@ coding_alloc_by_making_gap (struct coding_system *coding, | |||
| 1163 | 1060 | ||
| 1164 | 1061 | ||
| 1165 | static unsigned char * | 1062 | static unsigned char * |
| 1166 | alloc_destination (struct coding_system *coding, EMACS_INT nbytes, | 1063 | alloc_destination (struct coding_system *coding, ptrdiff_t nbytes, |
| 1167 | unsigned char *dst) | 1064 | unsigned char *dst) |
| 1168 | { | 1065 | { |
| 1169 | EMACS_INT offset = dst - coding->destination; | 1066 | ptrdiff_t offset = dst - coding->destination; |
| 1170 | 1067 | ||
| 1171 | if (BUFFERP (coding->dst_object)) | 1068 | if (BUFFERP (coding->dst_object)) |
| 1172 | { | 1069 | { |
| @@ -1246,8 +1143,7 @@ alloc_destination (struct coding_system *coding, EMACS_INT nbytes, | |||
| 1246 | /*** 3. UTF-8 ***/ | 1143 | /*** 3. UTF-8 ***/ |
| 1247 | 1144 | ||
| 1248 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | 1145 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
| 1249 | Check if a text is encoded in UTF-8. If it is, return 1, else | 1146 | Return true if a text is encoded in UTF-8. */ |
| 1250 | return 0. */ | ||
| 1251 | 1147 | ||
| 1252 | #define UTF_8_1_OCTET_P(c) ((c) < 0x80) | 1148 | #define UTF_8_1_OCTET_P(c) ((c) < 0x80) |
| 1253 | #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) | 1149 | #define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) |
| @@ -1260,16 +1156,16 @@ alloc_destination (struct coding_system *coding, EMACS_INT nbytes, | |||
| 1260 | #define UTF_8_BOM_2 0xBB | 1156 | #define UTF_8_BOM_2 0xBB |
| 1261 | #define UTF_8_BOM_3 0xBF | 1157 | #define UTF_8_BOM_3 0xBF |
| 1262 | 1158 | ||
| 1263 | static int | 1159 | static bool |
| 1264 | detect_coding_utf_8 (struct coding_system *coding, | 1160 | detect_coding_utf_8 (struct coding_system *coding, |
| 1265 | struct coding_detection_info *detect_info) | 1161 | struct coding_detection_info *detect_info) |
| 1266 | { | 1162 | { |
| 1267 | const unsigned char *src = coding->source, *src_base; | 1163 | const unsigned char *src = coding->source, *src_base; |
| 1268 | const unsigned char *src_end = coding->source + coding->src_bytes; | 1164 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 1269 | int multibytep = coding->src_multibyte; | 1165 | bool multibytep = coding->src_multibyte; |
| 1270 | EMACS_INT consumed_chars = 0; | 1166 | ptrdiff_t consumed_chars = 0; |
| 1271 | int bom_found = 0; | 1167 | bool bom_found = 0; |
| 1272 | int found = 0; | 1168 | bool found = 0; |
| 1273 | 1169 | ||
| 1274 | detect_info->checked |= CATEGORY_MASK_UTF_8; | 1170 | detect_info->checked |= CATEGORY_MASK_UTF_8; |
| 1275 | /* A coding system of this category is always ASCII compatible. */ | 1171 | /* A coding system of this category is always ASCII compatible. */ |
| @@ -1352,11 +1248,11 @@ decode_coding_utf_8 (struct coding_system *coding) | |||
| 1352 | const unsigned char *src_base; | 1248 | const unsigned char *src_base; |
| 1353 | int *charbuf = coding->charbuf + coding->charbuf_used; | 1249 | int *charbuf = coding->charbuf + coding->charbuf_used; |
| 1354 | int *charbuf_end = coding->charbuf + coding->charbuf_size; | 1250 | int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 1355 | EMACS_INT consumed_chars = 0, consumed_chars_base = 0; | 1251 | ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; |
| 1356 | int multibytep = coding->src_multibyte; | 1252 | bool multibytep = coding->src_multibyte; |
| 1357 | enum utf_bom_type bom = CODING_UTF_8_BOM (coding); | 1253 | enum utf_bom_type bom = CODING_UTF_8_BOM (coding); |
| 1358 | int eol_dos = | 1254 | bool eol_dos |
| 1359 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 1255 | = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 1360 | int byte_after_cr = -1; | 1256 | int byte_after_cr = -1; |
| 1361 | 1257 | ||
| 1362 | if (bom != utf_without_bom) | 1258 | if (bom != utf_without_bom) |
| @@ -1495,15 +1391,15 @@ decode_coding_utf_8 (struct coding_system *coding) | |||
| 1495 | } | 1391 | } |
| 1496 | 1392 | ||
| 1497 | 1393 | ||
| 1498 | static int | 1394 | static bool |
| 1499 | encode_coding_utf_8 (struct coding_system *coding) | 1395 | encode_coding_utf_8 (struct coding_system *coding) |
| 1500 | { | 1396 | { |
| 1501 | int multibytep = coding->dst_multibyte; | 1397 | bool multibytep = coding->dst_multibyte; |
| 1502 | int *charbuf = coding->charbuf; | 1398 | int *charbuf = coding->charbuf; |
| 1503 | int *charbuf_end = charbuf + coding->charbuf_used; | 1399 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 1504 | unsigned char *dst = coding->destination + coding->produced; | 1400 | unsigned char *dst = coding->destination + coding->produced; |
| 1505 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 1401 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 1506 | EMACS_INT produced_chars = 0; | 1402 | ptrdiff_t produced_chars = 0; |
| 1507 | int c; | 1403 | int c; |
| 1508 | 1404 | ||
| 1509 | if (CODING_UTF_8_BOM (coding) == utf_with_bom) | 1405 | if (CODING_UTF_8_BOM (coding) == utf_with_bom) |
| @@ -1559,8 +1455,7 @@ encode_coding_utf_8 (struct coding_system *coding) | |||
| 1559 | 1455 | ||
| 1560 | 1456 | ||
| 1561 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | 1457 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
| 1562 | Check if a text is encoded in one of UTF-16 based coding systems. | 1458 | Return true if a text is encoded in one of UTF-16 based coding systems. */ |
| 1563 | If it is, return 1, else return 0. */ | ||
| 1564 | 1459 | ||
| 1565 | #define UTF_16_HIGH_SURROGATE_P(val) \ | 1460 | #define UTF_16_HIGH_SURROGATE_P(val) \ |
| 1566 | (((val) & 0xFC00) == 0xD800) | 1461 | (((val) & 0xFC00) == 0xD800) |
| @@ -1569,13 +1464,13 @@ encode_coding_utf_8 (struct coding_system *coding) | |||
| 1569 | (((val) & 0xFC00) == 0xDC00) | 1464 | (((val) & 0xFC00) == 0xDC00) |
| 1570 | 1465 | ||
| 1571 | 1466 | ||
| 1572 | static int | 1467 | static bool |
| 1573 | detect_coding_utf_16 (struct coding_system *coding, | 1468 | detect_coding_utf_16 (struct coding_system *coding, |
| 1574 | struct coding_detection_info *detect_info) | 1469 | struct coding_detection_info *detect_info) |
| 1575 | { | 1470 | { |
| 1576 | const unsigned char *src = coding->source; | 1471 | const unsigned char *src = coding->source; |
| 1577 | const unsigned char *src_end = coding->source + coding->src_bytes; | 1472 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 1578 | int multibytep = coding->src_multibyte; | 1473 | bool multibytep = coding->src_multibyte; |
| 1579 | int c1, c2; | 1474 | int c1, c2; |
| 1580 | 1475 | ||
| 1581 | detect_info->checked |= CATEGORY_MASK_UTF_16; | 1476 | detect_info->checked |= CATEGORY_MASK_UTF_16; |
| @@ -1661,13 +1556,13 @@ decode_coding_utf_16 (struct coding_system *coding) | |||
| 1661 | int *charbuf = coding->charbuf + coding->charbuf_used; | 1556 | int *charbuf = coding->charbuf + coding->charbuf_used; |
| 1662 | /* We may produces at most 3 chars in one loop. */ | 1557 | /* We may produces at most 3 chars in one loop. */ |
| 1663 | int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; | 1558 | int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; |
| 1664 | EMACS_INT consumed_chars = 0, consumed_chars_base = 0; | 1559 | ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; |
| 1665 | int multibytep = coding->src_multibyte; | 1560 | bool multibytep = coding->src_multibyte; |
| 1666 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); | 1561 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
| 1667 | enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); | 1562 | enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); |
| 1668 | int surrogate = CODING_UTF_16_SURROGATE (coding); | 1563 | int surrogate = CODING_UTF_16_SURROGATE (coding); |
| 1669 | int eol_dos = | 1564 | bool eol_dos |
| 1670 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 1565 | = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 1671 | int byte_after_cr1 = -1, byte_after_cr2 = -1; | 1566 | int byte_after_cr1 = -1, byte_after_cr2 = -1; |
| 1672 | 1567 | ||
| 1673 | if (bom == utf_with_bom) | 1568 | if (bom == utf_with_bom) |
| @@ -1777,18 +1672,18 @@ decode_coding_utf_16 (struct coding_system *coding) | |||
| 1777 | coding->charbuf_used = charbuf - coding->charbuf; | 1672 | coding->charbuf_used = charbuf - coding->charbuf; |
| 1778 | } | 1673 | } |
| 1779 | 1674 | ||
| 1780 | static int | 1675 | static bool |
| 1781 | encode_coding_utf_16 (struct coding_system *coding) | 1676 | encode_coding_utf_16 (struct coding_system *coding) |
| 1782 | { | 1677 | { |
| 1783 | int multibytep = coding->dst_multibyte; | 1678 | bool multibytep = coding->dst_multibyte; |
| 1784 | int *charbuf = coding->charbuf; | 1679 | int *charbuf = coding->charbuf; |
| 1785 | int *charbuf_end = charbuf + coding->charbuf_used; | 1680 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 1786 | unsigned char *dst = coding->destination + coding->produced; | 1681 | unsigned char *dst = coding->destination + coding->produced; |
| 1787 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 1682 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 1788 | int safe_room = 8; | 1683 | int safe_room = 8; |
| 1789 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); | 1684 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
| 1790 | int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; | 1685 | bool big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; |
| 1791 | EMACS_INT produced_chars = 0; | 1686 | ptrdiff_t produced_chars = 0; |
| 1792 | int c; | 1687 | int c; |
| 1793 | 1688 | ||
| 1794 | if (bom != utf_without_bom) | 1689 | if (bom != utf_without_bom) |
| @@ -1912,17 +1807,16 @@ char emacs_mule_bytes[256]; | |||
| 1912 | 1807 | ||
| 1913 | 1808 | ||
| 1914 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | 1809 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
| 1915 | Check if a text is encoded in `emacs-mule'. If it is, return 1, | 1810 | Return true if a text is encoded in 'emacs-mule'. */ |
| 1916 | else return 0. */ | ||
| 1917 | 1811 | ||
| 1918 | static int | 1812 | static bool |
| 1919 | detect_coding_emacs_mule (struct coding_system *coding, | 1813 | detect_coding_emacs_mule (struct coding_system *coding, |
| 1920 | struct coding_detection_info *detect_info) | 1814 | struct coding_detection_info *detect_info) |
| 1921 | { | 1815 | { |
| 1922 | const unsigned char *src = coding->source, *src_base; | 1816 | const unsigned char *src = coding->source, *src_base; |
| 1923 | const unsigned char *src_end = coding->source + coding->src_bytes; | 1817 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 1924 | int multibytep = coding->src_multibyte; | 1818 | bool multibytep = coding->src_multibyte; |
| 1925 | EMACS_INT consumed_chars = 0; | 1819 | ptrdiff_t consumed_chars = 0; |
| 1926 | int c; | 1820 | int c; |
| 1927 | int found = 0; | 1821 | int found = 0; |
| 1928 | 1822 | ||
| @@ -2011,12 +1905,12 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, | |||
| 2011 | { | 1905 | { |
| 2012 | const unsigned char *src_end = coding->source + coding->src_bytes; | 1906 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 2013 | const unsigned char *src_base = src; | 1907 | const unsigned char *src_base = src; |
| 2014 | int multibytep = coding->src_multibyte; | 1908 | bool multibytep = coding->src_multibyte; |
| 2015 | int charset_ID; | 1909 | int charset_ID; |
| 2016 | unsigned code; | 1910 | unsigned code; |
| 2017 | int c; | 1911 | int c; |
| 2018 | int consumed_chars = 0; | 1912 | int consumed_chars = 0; |
| 2019 | int mseq_found = 0; | 1913 | bool mseq_found = 0; |
| 2020 | 1914 | ||
| 2021 | ONE_MORE_BYTE (c); | 1915 | ONE_MORE_BYTE (c); |
| 2022 | if (c < 0) | 1916 | if (c < 0) |
| @@ -2113,7 +2007,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src, | |||
| 2113 | break; | 2007 | break; |
| 2114 | 2008 | ||
| 2115 | default: | 2009 | default: |
| 2116 | abort (); | 2010 | emacs_abort (); |
| 2117 | } | 2011 | } |
| 2118 | CODING_DECODE_CHAR (coding, src, src_base, src_end, | 2012 | CODING_DECODE_CHAR (coding, src, src_base, src_end, |
| 2119 | CHARSET_FROM_ID (charset_ID), code, c); | 2013 | CHARSET_FROM_ID (charset_ID), code, c); |
| @@ -2392,13 +2286,13 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2392 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3) | 2286 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3) |
| 2393 | /* We can produce up to 2 characters in a loop. */ | 2287 | /* We can produce up to 2 characters in a loop. */ |
| 2394 | - 1; | 2288 | - 1; |
| 2395 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 2289 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 2396 | int multibytep = coding->src_multibyte; | 2290 | bool multibytep = coding->src_multibyte; |
| 2397 | EMACS_INT char_offset = coding->produced_char; | 2291 | ptrdiff_t char_offset = coding->produced_char; |
| 2398 | EMACS_INT last_offset = char_offset; | 2292 | ptrdiff_t last_offset = char_offset; |
| 2399 | int last_id = charset_ascii; | 2293 | int last_id = charset_ascii; |
| 2400 | int eol_dos = | 2294 | bool eol_dos |
| 2401 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 2295 | = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 2402 | int byte_after_cr = -1; | 2296 | int byte_after_cr = -1; |
| 2403 | struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; | 2297 | struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; |
| 2404 | 2298 | ||
| @@ -2407,7 +2301,7 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2407 | int i; | 2301 | int i; |
| 2408 | 2302 | ||
| 2409 | if (charbuf_end - charbuf < cmp_status->length) | 2303 | if (charbuf_end - charbuf < cmp_status->length) |
| 2410 | abort (); | 2304 | emacs_abort (); |
| 2411 | for (i = 0; i < cmp_status->length; i++) | 2305 | for (i = 0; i < cmp_status->length; i++) |
| 2412 | *charbuf++ = cmp_status->carryover[i]; | 2306 | *charbuf++ = cmp_status->carryover[i]; |
| 2413 | coding->annotated = 1; | 2307 | coding->annotated = 1; |
| @@ -2467,7 +2361,7 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2467 | original pointer to buffer text, and fix up all related | 2361 | original pointer to buffer text, and fix up all related |
| 2468 | pointers after the call. */ | 2362 | pointers after the call. */ |
| 2469 | const unsigned char *orig = coding->source; | 2363 | const unsigned char *orig = coding->source; |
| 2470 | EMACS_INT offset; | 2364 | ptrdiff_t offset; |
| 2471 | 2365 | ||
| 2472 | c = emacs_mule_char (coding, src_base, &nbytes, &nchars, &id, | 2366 | c = emacs_mule_char (coding, src_base, &nbytes, &nchars, &id, |
| 2473 | cmp_status); | 2367 | cmp_status); |
| @@ -2639,16 +2533,16 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2639 | } while (0); | 2533 | } while (0); |
| 2640 | 2534 | ||
| 2641 | 2535 | ||
| 2642 | static int | 2536 | static bool |
| 2643 | encode_coding_emacs_mule (struct coding_system *coding) | 2537 | encode_coding_emacs_mule (struct coding_system *coding) |
| 2644 | { | 2538 | { |
| 2645 | int multibytep = coding->dst_multibyte; | 2539 | bool multibytep = coding->dst_multibyte; |
| 2646 | int *charbuf = coding->charbuf; | 2540 | int *charbuf = coding->charbuf; |
| 2647 | int *charbuf_end = charbuf + coding->charbuf_used; | 2541 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 2648 | unsigned char *dst = coding->destination + coding->produced; | 2542 | unsigned char *dst = coding->destination + coding->produced; |
| 2649 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 2543 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 2650 | int safe_room = 8; | 2544 | int safe_room = 8; |
| 2651 | EMACS_INT produced_chars = 0; | 2545 | ptrdiff_t produced_chars = 0; |
| 2652 | Lisp_Object attrs, charset_list; | 2546 | Lisp_Object attrs, charset_list; |
| 2653 | int c; | 2547 | int c; |
| 2654 | int preferred_charset_id = -1; | 2548 | int preferred_charset_id = -1; |
| @@ -2656,8 +2550,8 @@ encode_coding_emacs_mule (struct coding_system *coding) | |||
| 2656 | CODING_GET_INFO (coding, attrs, charset_list); | 2550 | CODING_GET_INFO (coding, attrs, charset_list); |
| 2657 | if (! EQ (charset_list, Vemacs_mule_charset_list)) | 2551 | if (! EQ (charset_list, Vemacs_mule_charset_list)) |
| 2658 | { | 2552 | { |
| 2659 | CODING_ATTR_CHARSET_LIST (attrs) | 2553 | charset_list = Vemacs_mule_charset_list; |
| 2660 | = charset_list = Vemacs_mule_charset_list; | 2554 | ASET (attrs, coding_attr_charset_list, charset_list); |
| 2661 | } | 2555 | } |
| 2662 | 2556 | ||
| 2663 | while (charbuf < charbuf_end) | 2557 | while (charbuf < charbuf_end) |
| @@ -2681,7 +2575,7 @@ encode_coding_emacs_mule (struct coding_system *coding) | |||
| 2681 | preferred_charset_id = -1; | 2575 | preferred_charset_id = -1; |
| 2682 | break; | 2576 | break; |
| 2683 | default: | 2577 | default: |
| 2684 | abort (); | 2578 | emacs_abort (); |
| 2685 | } | 2579 | } |
| 2686 | charbuf += -c - 1; | 2580 | charbuf += -c - 1; |
| 2687 | continue; | 2581 | continue; |
| @@ -2704,7 +2598,7 @@ encode_coding_emacs_mule (struct coding_system *coding) | |||
| 2704 | 2598 | ||
| 2705 | if (preferred_charset_id >= 0) | 2599 | if (preferred_charset_id >= 0) |
| 2706 | { | 2600 | { |
| 2707 | int result; | 2601 | bool result; |
| 2708 | 2602 | ||
| 2709 | charset = CHARSET_FROM_ID (preferred_charset_id); | 2603 | charset = CHARSET_FROM_ID (preferred_charset_id); |
| 2710 | CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); | 2604 | CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); |
| @@ -2941,7 +2835,7 @@ setup_iso_safe_charsets (Lisp_Object attrs) | |||
| 2941 | Lisp_Object request; | 2835 | Lisp_Object request; |
| 2942 | Lisp_Object reg_usage; | 2836 | Lisp_Object reg_usage; |
| 2943 | Lisp_Object tail; | 2837 | Lisp_Object tail; |
| 2944 | int reg94, reg96; | 2838 | EMACS_INT reg94, reg96; |
| 2945 | int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | 2839 | int flags = XINT (AREF (attrs, coding_attr_iso_flags)); |
| 2946 | int max_charset_id; | 2840 | int max_charset_id; |
| 2947 | 2841 | ||
| @@ -2949,8 +2843,8 @@ setup_iso_safe_charsets (Lisp_Object attrs) | |||
| 2949 | if ((flags & CODING_ISO_FLAG_FULL_SUPPORT) | 2843 | if ((flags & CODING_ISO_FLAG_FULL_SUPPORT) |
| 2950 | && ! EQ (charset_list, Viso_2022_charset_list)) | 2844 | && ! EQ (charset_list, Viso_2022_charset_list)) |
| 2951 | { | 2845 | { |
| 2952 | CODING_ATTR_CHARSET_LIST (attrs) | 2846 | charset_list = Viso_2022_charset_list; |
| 2953 | = charset_list = Viso_2022_charset_list; | 2847 | ASET (attrs, coding_attr_charset_list, charset_list); |
| 2954 | ASET (attrs, coding_attr_safe_charsets, Qnil); | 2848 | ASET (attrs, coding_attr_safe_charsets, Qnil); |
| 2955 | } | 2849 | } |
| 2956 | 2850 | ||
| @@ -2999,20 +2893,20 @@ setup_iso_safe_charsets (Lisp_Object attrs) | |||
| 2999 | 2893 | ||
| 3000 | 2894 | ||
| 3001 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | 2895 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
| 3002 | Check if a text is encoded in one of ISO-2022 based coding systems. | 2896 | Return true if a text is encoded in one of ISO-2022 based coding |
| 3003 | If it is, return 1, else return 0. */ | 2897 | systems. */ |
| 3004 | 2898 | ||
| 3005 | static int | 2899 | static bool |
| 3006 | detect_coding_iso_2022 (struct coding_system *coding, | 2900 | detect_coding_iso_2022 (struct coding_system *coding, |
| 3007 | struct coding_detection_info *detect_info) | 2901 | struct coding_detection_info *detect_info) |
| 3008 | { | 2902 | { |
| 3009 | const unsigned char *src = coding->source, *src_base = src; | 2903 | const unsigned char *src = coding->source, *src_base = src; |
| 3010 | const unsigned char *src_end = coding->source + coding->src_bytes; | 2904 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 3011 | int multibytep = coding->src_multibyte; | 2905 | bool multibytep = coding->src_multibyte; |
| 3012 | int single_shifting = 0; | 2906 | bool single_shifting = 0; |
| 3013 | int id; | 2907 | int id; |
| 3014 | int c, c1; | 2908 | int c, c1; |
| 3015 | EMACS_INT consumed_chars = 0; | 2909 | ptrdiff_t consumed_chars = 0; |
| 3016 | int i; | 2910 | int i; |
| 3017 | int rejected = 0; | 2911 | int rejected = 0; |
| 3018 | int found = 0; | 2912 | int found = 0; |
| @@ -3171,7 +3065,7 @@ detect_coding_iso_2022 (struct coding_system *coding, | |||
| 3171 | break; | 3065 | break; |
| 3172 | check_extra_latin: | 3066 | check_extra_latin: |
| 3173 | if (! VECTORP (Vlatin_extra_code_table) | 3067 | if (! VECTORP (Vlatin_extra_code_table) |
| 3174 | || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c])) | 3068 | || NILP (AREF (Vlatin_extra_code_table, c))) |
| 3175 | { | 3069 | { |
| 3176 | rejected = CATEGORY_MASK_ISO; | 3070 | rejected = CATEGORY_MASK_ISO; |
| 3177 | break; | 3071 | break; |
| @@ -3372,8 +3266,6 @@ detect_coding_iso_2022 (struct coding_system *coding, | |||
| 3372 | 3266 | ||
| 3373 | /* Finish the current composition as invalid. */ | 3267 | /* Finish the current composition as invalid. */ |
| 3374 | 3268 | ||
| 3375 | static int finish_composition (int *, struct composition_status *); | ||
| 3376 | |||
| 3377 | static int | 3269 | static int |
| 3378 | finish_composition (int *charbuf, struct composition_status *cmp_status) | 3270 | finish_composition (int *charbuf, struct composition_status *cmp_status) |
| 3379 | { | 3271 | { |
| @@ -3522,8 +3414,8 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3522 | loop and one more charset annotation at the end. */ | 3414 | loop and one more charset annotation at the end. */ |
| 3523 | int *charbuf_end | 3415 | int *charbuf_end |
| 3524 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); | 3416 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); |
| 3525 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 3417 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 3526 | int multibytep = coding->src_multibyte; | 3418 | bool multibytep = coding->src_multibyte; |
| 3527 | /* Charsets invoked to graphic plane 0 and 1 respectively. */ | 3419 | /* Charsets invoked to graphic plane 0 and 1 respectively. */ |
| 3528 | int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | 3420 | int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
| 3529 | int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); | 3421 | int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); |
| @@ -3532,11 +3424,11 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3532 | int c; | 3424 | int c; |
| 3533 | struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); | 3425 | struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); |
| 3534 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); | 3426 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); |
| 3535 | EMACS_INT char_offset = coding->produced_char; | 3427 | ptrdiff_t char_offset = coding->produced_char; |
| 3536 | EMACS_INT last_offset = char_offset; | 3428 | ptrdiff_t last_offset = char_offset; |
| 3537 | int last_id = charset_ascii; | 3429 | int last_id = charset_ascii; |
| 3538 | int eol_dos = | 3430 | bool eol_dos |
| 3539 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 3431 | = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 3540 | int byte_after_cr = -1; | 3432 | int byte_after_cr = -1; |
| 3541 | int i; | 3433 | int i; |
| 3542 | 3434 | ||
| @@ -3546,7 +3438,7 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3546 | if (cmp_status->state != COMPOSING_NO) | 3438 | if (cmp_status->state != COMPOSING_NO) |
| 3547 | { | 3439 | { |
| 3548 | if (charbuf_end - charbuf < cmp_status->length) | 3440 | if (charbuf_end - charbuf < cmp_status->length) |
| 3549 | abort (); | 3441 | emacs_abort (); |
| 3550 | for (i = 0; i < cmp_status->length; i++) | 3442 | for (i = 0; i < cmp_status->length; i++) |
| 3551 | *charbuf++ = cmp_status->carryover[i]; | 3443 | *charbuf++ = cmp_status->carryover[i]; |
| 3552 | coding->annotated = 1; | 3444 | coding->annotated = 1; |
| @@ -3928,7 +3820,7 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3928 | break; | 3820 | break; |
| 3929 | 3821 | ||
| 3930 | default: | 3822 | default: |
| 3931 | abort (); | 3823 | emacs_abort (); |
| 3932 | } | 3824 | } |
| 3933 | 3825 | ||
| 3934 | if (cmp_status->state == COMPOSING_NO | 3826 | if (cmp_status->state == COMPOSING_NO |
| @@ -4245,7 +4137,7 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 4245 | 4137 | ||
| 4246 | #define ENCODE_ISO_CHARACTER(charset, c) \ | 4138 | #define ENCODE_ISO_CHARACTER(charset, c) \ |
| 4247 | do { \ | 4139 | do { \ |
| 4248 | int code; \ | 4140 | unsigned code; \ |
| 4249 | CODING_ENCODE_CHAR (coding, dst, dst_end, (charset), (c), code); \ | 4141 | CODING_ENCODE_CHAR (coding, dst, dst_end, (charset), (c), code); \ |
| 4250 | \ | 4142 | \ |
| 4251 | if (CHARSET_DIMENSION (charset) == 1) \ | 4143 | if (CHARSET_DIMENSION (charset) == 1) \ |
| @@ -4262,10 +4154,10 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 4262 | static unsigned char * | 4154 | static unsigned char * |
| 4263 | encode_invocation_designation (struct charset *charset, | 4155 | encode_invocation_designation (struct charset *charset, |
| 4264 | struct coding_system *coding, | 4156 | struct coding_system *coding, |
| 4265 | unsigned char *dst, EMACS_INT *p_nchars) | 4157 | unsigned char *dst, ptrdiff_t *p_nchars) |
| 4266 | { | 4158 | { |
| 4267 | int multibytep = coding->dst_multibyte; | 4159 | bool multibytep = coding->dst_multibyte; |
| 4268 | EMACS_INT produced_chars = *p_nchars; | 4160 | ptrdiff_t produced_chars = *p_nchars; |
| 4269 | int reg; /* graphic register number */ | 4161 | int reg; /* graphic register number */ |
| 4270 | int id = CHARSET_ID (charset); | 4162 | int id = CHARSET_ID (charset); |
| 4271 | 4163 | ||
| @@ -4351,7 +4243,7 @@ encode_invocation_designation (struct charset *charset, | |||
| 4351 | If the current block ends before any end-of-line, we may fail to | 4243 | If the current block ends before any end-of-line, we may fail to |
| 4352 | find all the necessary designations. */ | 4244 | find all the necessary designations. */ |
| 4353 | 4245 | ||
| 4354 | static int | 4246 | static ptrdiff_t |
| 4355 | encode_designation_at_bol (struct coding_system *coding, | 4247 | encode_designation_at_bol (struct coding_system *coding, |
| 4356 | int *charbuf, int *charbuf_end, | 4248 | int *charbuf, int *charbuf_end, |
| 4357 | unsigned char *dst) | 4249 | unsigned char *dst) |
| @@ -4361,8 +4253,8 @@ encode_designation_at_bol (struct coding_system *coding, | |||
| 4361 | /* Table of charsets to be designated to each graphic register. */ | 4253 | /* Table of charsets to be designated to each graphic register. */ |
| 4362 | int r[4]; | 4254 | int r[4]; |
| 4363 | int c, found = 0, reg; | 4255 | int c, found = 0, reg; |
| 4364 | EMACS_INT produced_chars = 0; | 4256 | ptrdiff_t produced_chars = 0; |
| 4365 | int multibytep = coding->dst_multibyte; | 4257 | bool multibytep = coding->dst_multibyte; |
| 4366 | Lisp_Object attrs; | 4258 | Lisp_Object attrs; |
| 4367 | Lisp_Object charset_list; | 4259 | Lisp_Object charset_list; |
| 4368 | 4260 | ||
| @@ -4404,21 +4296,21 @@ encode_designation_at_bol (struct coding_system *coding, | |||
| 4404 | 4296 | ||
| 4405 | /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ | 4297 | /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ |
| 4406 | 4298 | ||
| 4407 | static int | 4299 | static bool |
| 4408 | encode_coding_iso_2022 (struct coding_system *coding) | 4300 | encode_coding_iso_2022 (struct coding_system *coding) |
| 4409 | { | 4301 | { |
| 4410 | int multibytep = coding->dst_multibyte; | 4302 | bool multibytep = coding->dst_multibyte; |
| 4411 | int *charbuf = coding->charbuf; | 4303 | int *charbuf = coding->charbuf; |
| 4412 | int *charbuf_end = charbuf + coding->charbuf_used; | 4304 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 4413 | unsigned char *dst = coding->destination + coding->produced; | 4305 | unsigned char *dst = coding->destination + coding->produced; |
| 4414 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 4306 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 4415 | int safe_room = 16; | 4307 | int safe_room = 16; |
| 4416 | int bol_designation | 4308 | bool bol_designation |
| 4417 | = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL | 4309 | = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL |
| 4418 | && CODING_ISO_BOL (coding)); | 4310 | && CODING_ISO_BOL (coding)); |
| 4419 | EMACS_INT produced_chars = 0; | 4311 | ptrdiff_t produced_chars = 0; |
| 4420 | Lisp_Object attrs, eol_type, charset_list; | 4312 | Lisp_Object attrs, eol_type, charset_list; |
| 4421 | int ascii_compatible; | 4313 | bool ascii_compatible; |
| 4422 | int c; | 4314 | int c; |
| 4423 | int preferred_charset_id = -1; | 4315 | int preferred_charset_id = -1; |
| 4424 | 4316 | ||
| @@ -4446,13 +4338,13 @@ encode_coding_iso_2022 (struct coding_system *coding) | |||
| 4446 | /* We have to produce designation sequences if any now. */ | 4338 | /* We have to produce designation sequences if any now. */ |
| 4447 | unsigned char desig_buf[16]; | 4339 | unsigned char desig_buf[16]; |
| 4448 | int nbytes; | 4340 | int nbytes; |
| 4449 | EMACS_INT offset; | 4341 | ptrdiff_t offset; |
| 4450 | 4342 | ||
| 4451 | charset_map_loaded = 0; | 4343 | charset_map_loaded = 0; |
| 4452 | nbytes = encode_designation_at_bol (coding, charbuf, charbuf_end, | 4344 | nbytes = encode_designation_at_bol (coding, charbuf, charbuf_end, |
| 4453 | desig_buf); | 4345 | desig_buf); |
| 4454 | if (charset_map_loaded | 4346 | if (charset_map_loaded |
| 4455 | && (offset = coding_set_destination (coding))) | 4347 | && (offset = coding_change_destination (coding))) |
| 4456 | { | 4348 | { |
| 4457 | dst += offset; | 4349 | dst += offset; |
| 4458 | dst_end += offset; | 4350 | dst_end += offset; |
| @@ -4483,7 +4375,7 @@ encode_coding_iso_2022 (struct coding_system *coding) | |||
| 4483 | preferred_charset_id = -1; | 4375 | preferred_charset_id = -1; |
| 4484 | break; | 4376 | break; |
| 4485 | default: | 4377 | default: |
| 4486 | abort (); | 4378 | emacs_abort (); |
| 4487 | } | 4379 | } |
| 4488 | charbuf += -c - 1; | 4380 | charbuf += -c - 1; |
| 4489 | continue; | 4381 | continue; |
| @@ -4505,8 +4397,9 @@ encode_coding_iso_2022 (struct coding_system *coding) | |||
| 4505 | CODING_ISO_DESIGNATION (coding, i) | 4397 | CODING_ISO_DESIGNATION (coding, i) |
| 4506 | = CODING_ISO_INITIAL (coding, i); | 4398 | = CODING_ISO_INITIAL (coding, i); |
| 4507 | } | 4399 | } |
| 4508 | bol_designation | 4400 | bol_designation = ((CODING_ISO_FLAGS (coding) |
| 4509 | = CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL; | 4401 | & CODING_ISO_FLAG_DESIGNATE_AT_BOL) |
| 4402 | != 0); | ||
| 4510 | } | 4403 | } |
| 4511 | else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) | 4404 | else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) |
| 4512 | ENCODE_RESET_PLANE_AND_REGISTER (); | 4405 | ENCODE_RESET_PLANE_AND_REGISTER (); |
| @@ -4533,7 +4426,7 @@ encode_coding_iso_2022 (struct coding_system *coding) | |||
| 4533 | 4426 | ||
| 4534 | if (preferred_charset_id >= 0) | 4427 | if (preferred_charset_id >= 0) |
| 4535 | { | 4428 | { |
| 4536 | int result; | 4429 | bool result; |
| 4537 | 4430 | ||
| 4538 | charset = CHARSET_FROM_ID (preferred_charset_id); | 4431 | charset = CHARSET_FROM_ID (preferred_charset_id); |
| 4539 | CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); | 4432 | CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); |
| @@ -4613,17 +4506,16 @@ encode_coding_iso_2022 (struct coding_system *coding) | |||
| 4613 | */ | 4506 | */ |
| 4614 | 4507 | ||
| 4615 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | 4508 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
| 4616 | Check if a text is encoded in SJIS. If it is, return | 4509 | Return true if a text is encoded in SJIS. */ |
| 4617 | CATEGORY_MASK_SJIS, else return 0. */ | ||
| 4618 | 4510 | ||
| 4619 | static int | 4511 | static bool |
| 4620 | detect_coding_sjis (struct coding_system *coding, | 4512 | detect_coding_sjis (struct coding_system *coding, |
| 4621 | struct coding_detection_info *detect_info) | 4513 | struct coding_detection_info *detect_info) |
| 4622 | { | 4514 | { |
| 4623 | const unsigned char *src = coding->source, *src_base; | 4515 | const unsigned char *src = coding->source, *src_base; |
| 4624 | const unsigned char *src_end = coding->source + coding->src_bytes; | 4516 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 4625 | int multibytep = coding->src_multibyte; | 4517 | bool multibytep = coding->src_multibyte; |
| 4626 | EMACS_INT consumed_chars = 0; | 4518 | ptrdiff_t consumed_chars = 0; |
| 4627 | int found = 0; | 4519 | int found = 0; |
| 4628 | int c; | 4520 | int c; |
| 4629 | Lisp_Object attrs, charset_list; | 4521 | Lisp_Object attrs, charset_list; |
| @@ -4670,17 +4562,16 @@ detect_coding_sjis (struct coding_system *coding, | |||
| 4670 | } | 4562 | } |
| 4671 | 4563 | ||
| 4672 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | 4564 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
| 4673 | Check if a text is encoded in BIG5. If it is, return | 4565 | Return true if a text is encoded in BIG5. */ |
| 4674 | CATEGORY_MASK_BIG5, else return 0. */ | ||
| 4675 | 4566 | ||
| 4676 | static int | 4567 | static bool |
| 4677 | detect_coding_big5 (struct coding_system *coding, | 4568 | detect_coding_big5 (struct coding_system *coding, |
| 4678 | struct coding_detection_info *detect_info) | 4569 | struct coding_detection_info *detect_info) |
| 4679 | { | 4570 | { |
| 4680 | const unsigned char *src = coding->source, *src_base; | 4571 | const unsigned char *src = coding->source, *src_base; |
| 4681 | const unsigned char *src_end = coding->source + coding->src_bytes; | 4572 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 4682 | int multibytep = coding->src_multibyte; | 4573 | bool multibytep = coding->src_multibyte; |
| 4683 | EMACS_INT consumed_chars = 0; | 4574 | ptrdiff_t consumed_chars = 0; |
| 4684 | int found = 0; | 4575 | int found = 0; |
| 4685 | int c; | 4576 | int c; |
| 4686 | 4577 | ||
| @@ -4717,8 +4608,7 @@ detect_coding_big5 (struct coding_system *coding, | |||
| 4717 | return 1; | 4608 | return 1; |
| 4718 | } | 4609 | } |
| 4719 | 4610 | ||
| 4720 | /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". | 4611 | /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ |
| 4721 | If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ | ||
| 4722 | 4612 | ||
| 4723 | static void | 4613 | static void |
| 4724 | decode_coding_sjis (struct coding_system *coding) | 4614 | decode_coding_sjis (struct coding_system *coding) |
| @@ -4731,16 +4621,16 @@ decode_coding_sjis (struct coding_system *coding) | |||
| 4731 | the end. */ | 4621 | the end. */ |
| 4732 | int *charbuf_end | 4622 | int *charbuf_end |
| 4733 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); | 4623 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
| 4734 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 4624 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 4735 | int multibytep = coding->src_multibyte; | 4625 | bool multibytep = coding->src_multibyte; |
| 4736 | struct charset *charset_roman, *charset_kanji, *charset_kana; | 4626 | struct charset *charset_roman, *charset_kanji, *charset_kana; |
| 4737 | struct charset *charset_kanji2; | 4627 | struct charset *charset_kanji2; |
| 4738 | Lisp_Object attrs, charset_list, val; | 4628 | Lisp_Object attrs, charset_list, val; |
| 4739 | EMACS_INT char_offset = coding->produced_char; | 4629 | ptrdiff_t char_offset = coding->produced_char; |
| 4740 | EMACS_INT last_offset = char_offset; | 4630 | ptrdiff_t last_offset = char_offset; |
| 4741 | int last_id = charset_ascii; | 4631 | int last_id = charset_ascii; |
| 4742 | int eol_dos = | 4632 | bool eol_dos |
| 4743 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 4633 | = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 4744 | int byte_after_cr = -1; | 4634 | int byte_after_cr = -1; |
| 4745 | 4635 | ||
| 4746 | CODING_GET_INFO (coding, attrs, charset_list); | 4636 | CODING_GET_INFO (coding, attrs, charset_list); |
| @@ -4849,15 +4739,15 @@ decode_coding_big5 (struct coding_system *coding) | |||
| 4849 | the end. */ | 4739 | the end. */ |
| 4850 | int *charbuf_end | 4740 | int *charbuf_end |
| 4851 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); | 4741 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
| 4852 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 4742 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 4853 | int multibytep = coding->src_multibyte; | 4743 | bool multibytep = coding->src_multibyte; |
| 4854 | struct charset *charset_roman, *charset_big5; | 4744 | struct charset *charset_roman, *charset_big5; |
| 4855 | Lisp_Object attrs, charset_list, val; | 4745 | Lisp_Object attrs, charset_list, val; |
| 4856 | EMACS_INT char_offset = coding->produced_char; | 4746 | ptrdiff_t char_offset = coding->produced_char; |
| 4857 | EMACS_INT last_offset = char_offset; | 4747 | ptrdiff_t last_offset = char_offset; |
| 4858 | int last_id = charset_ascii; | 4748 | int last_id = charset_ascii; |
| 4859 | int eol_dos = | 4749 | bool eol_dos |
| 4860 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 4750 | = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 4861 | int byte_after_cr = -1; | 4751 | int byte_after_cr = -1; |
| 4862 | 4752 | ||
| 4863 | CODING_GET_INFO (coding, attrs, charset_list); | 4753 | CODING_GET_INFO (coding, attrs, charset_list); |
| @@ -4939,21 +4829,20 @@ decode_coding_big5 (struct coding_system *coding) | |||
| 4939 | `japanese-jisx0208', `chinese-big5-1', and `chinese-big5-2'. We | 4829 | `japanese-jisx0208', `chinese-big5-1', and `chinese-big5-2'. We |
| 4940 | are sure that all these charsets are registered as official charset | 4830 | are sure that all these charsets are registered as official charset |
| 4941 | (i.e. do not have extended leading-codes). Characters of other | 4831 | (i.e. do not have extended leading-codes). Characters of other |
| 4942 | charsets are produced without any encoding. If SJIS_P is 1, encode | 4832 | charsets are produced without any encoding. */ |
| 4943 | SJIS text, else encode BIG5 text. */ | ||
| 4944 | 4833 | ||
| 4945 | static int | 4834 | static bool |
| 4946 | encode_coding_sjis (struct coding_system *coding) | 4835 | encode_coding_sjis (struct coding_system *coding) |
| 4947 | { | 4836 | { |
| 4948 | int multibytep = coding->dst_multibyte; | 4837 | bool multibytep = coding->dst_multibyte; |
| 4949 | int *charbuf = coding->charbuf; | 4838 | int *charbuf = coding->charbuf; |
| 4950 | int *charbuf_end = charbuf + coding->charbuf_used; | 4839 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 4951 | unsigned char *dst = coding->destination + coding->produced; | 4840 | unsigned char *dst = coding->destination + coding->produced; |
| 4952 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 4841 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 4953 | int safe_room = 4; | 4842 | int safe_room = 4; |
| 4954 | EMACS_INT produced_chars = 0; | 4843 | ptrdiff_t produced_chars = 0; |
| 4955 | Lisp_Object attrs, charset_list, val; | 4844 | Lisp_Object attrs, charset_list, val; |
| 4956 | int ascii_compatible; | 4845 | bool ascii_compatible; |
| 4957 | struct charset *charset_kanji, *charset_kana; | 4846 | struct charset *charset_kanji, *charset_kana; |
| 4958 | struct charset *charset_kanji2; | 4847 | struct charset *charset_kanji2; |
| 4959 | int c; | 4848 | int c; |
| @@ -5000,7 +4889,7 @@ encode_coding_sjis (struct coding_system *coding) | |||
| 5000 | } | 4889 | } |
| 5001 | } | 4890 | } |
| 5002 | if (code == CHARSET_INVALID_CODE (charset)) | 4891 | if (code == CHARSET_INVALID_CODE (charset)) |
| 5003 | abort (); | 4892 | emacs_abort (); |
| 5004 | if (charset == charset_kanji) | 4893 | if (charset == charset_kanji) |
| 5005 | { | 4894 | { |
| 5006 | int c1, c2; | 4895 | int c1, c2; |
| @@ -5036,18 +4925,18 @@ encode_coding_sjis (struct coding_system *coding) | |||
| 5036 | return 0; | 4925 | return 0; |
| 5037 | } | 4926 | } |
| 5038 | 4927 | ||
| 5039 | static int | 4928 | static bool |
| 5040 | encode_coding_big5 (struct coding_system *coding) | 4929 | encode_coding_big5 (struct coding_system *coding) |
| 5041 | { | 4930 | { |
| 5042 | int multibytep = coding->dst_multibyte; | 4931 | bool multibytep = coding->dst_multibyte; |
| 5043 | int *charbuf = coding->charbuf; | 4932 | int *charbuf = coding->charbuf; |
| 5044 | int *charbuf_end = charbuf + coding->charbuf_used; | 4933 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 5045 | unsigned char *dst = coding->destination + coding->produced; | 4934 | unsigned char *dst = coding->destination + coding->produced; |
| 5046 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 4935 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 5047 | int safe_room = 4; | 4936 | int safe_room = 4; |
| 5048 | EMACS_INT produced_chars = 0; | 4937 | ptrdiff_t produced_chars = 0; |
| 5049 | Lisp_Object attrs, charset_list, val; | 4938 | Lisp_Object attrs, charset_list, val; |
| 5050 | int ascii_compatible; | 4939 | bool ascii_compatible; |
| 5051 | struct charset *charset_big5; | 4940 | struct charset *charset_big5; |
| 5052 | int c; | 4941 | int c; |
| 5053 | 4942 | ||
| @@ -5090,7 +4979,7 @@ encode_coding_big5 (struct coding_system *coding) | |||
| 5090 | } | 4979 | } |
| 5091 | } | 4980 | } |
| 5092 | if (code == CHARSET_INVALID_CODE (charset)) | 4981 | if (code == CHARSET_INVALID_CODE (charset)) |
| 5093 | abort (); | 4982 | emacs_abort (); |
| 5094 | if (charset == charset_big5) | 4983 | if (charset == charset_big5) |
| 5095 | { | 4984 | { |
| 5096 | int c1, c2; | 4985 | int c1, c2; |
| @@ -5112,21 +5001,20 @@ encode_coding_big5 (struct coding_system *coding) | |||
| 5112 | /*** 10. CCL handlers ***/ | 5001 | /*** 10. CCL handlers ***/ |
| 5113 | 5002 | ||
| 5114 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | 5003 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
| 5115 | Check if a text is encoded in a coding system of which | 5004 | Return true if a text is encoded in a coding system of which |
| 5116 | encoder/decoder are written in CCL program. If it is, return | 5005 | encoder/decoder are written in CCL program. */ |
| 5117 | CATEGORY_MASK_CCL, else return 0. */ | ||
| 5118 | 5006 | ||
| 5119 | static int | 5007 | static bool |
| 5120 | detect_coding_ccl (struct coding_system *coding, | 5008 | detect_coding_ccl (struct coding_system *coding, |
| 5121 | struct coding_detection_info *detect_info) | 5009 | struct coding_detection_info *detect_info) |
| 5122 | { | 5010 | { |
| 5123 | const unsigned char *src = coding->source, *src_base; | 5011 | const unsigned char *src = coding->source, *src_base; |
| 5124 | const unsigned char *src_end = coding->source + coding->src_bytes; | 5012 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 5125 | int multibytep = coding->src_multibyte; | 5013 | bool multibytep = coding->src_multibyte; |
| 5126 | EMACS_INT consumed_chars = 0; | 5014 | ptrdiff_t consumed_chars = 0; |
| 5127 | int found = 0; | 5015 | int found = 0; |
| 5128 | unsigned char *valids; | 5016 | unsigned char *valids; |
| 5129 | EMACS_INT head_ascii = coding->head_ascii; | 5017 | ptrdiff_t head_ascii = coding->head_ascii; |
| 5130 | Lisp_Object attrs; | 5018 | Lisp_Object attrs; |
| 5131 | 5019 | ||
| 5132 | detect_info->checked |= CATEGORY_MASK_CCL; | 5020 | detect_info->checked |= CATEGORY_MASK_CCL; |
| @@ -5163,8 +5051,8 @@ decode_coding_ccl (struct coding_system *coding) | |||
| 5163 | const unsigned char *src_end = coding->source + coding->src_bytes; | 5051 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 5164 | int *charbuf = coding->charbuf + coding->charbuf_used; | 5052 | int *charbuf = coding->charbuf + coding->charbuf_used; |
| 5165 | int *charbuf_end = coding->charbuf + coding->charbuf_size; | 5053 | int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 5166 | EMACS_INT consumed_chars = 0; | 5054 | ptrdiff_t consumed_chars = 0; |
| 5167 | int multibytep = coding->src_multibyte; | 5055 | bool multibytep = coding->src_multibyte; |
| 5168 | struct ccl_program *ccl = &coding->spec.ccl->ccl; | 5056 | struct ccl_program *ccl = &coding->spec.ccl->ccl; |
| 5169 | int source_charbuf[1024]; | 5057 | int source_charbuf[1024]; |
| 5170 | int source_byteidx[1025]; | 5058 | int source_byteidx[1025]; |
| @@ -5175,6 +5063,7 @@ decode_coding_ccl (struct coding_system *coding) | |||
| 5175 | while (1) | 5063 | while (1) |
| 5176 | { | 5064 | { |
| 5177 | const unsigned char *p = src; | 5065 | const unsigned char *p = src; |
| 5066 | ptrdiff_t offset; | ||
| 5178 | int i = 0; | 5067 | int i = 0; |
| 5179 | 5068 | ||
| 5180 | if (multibytep) | 5069 | if (multibytep) |
| @@ -5192,8 +5081,17 @@ decode_coding_ccl (struct coding_system *coding) | |||
| 5192 | 5081 | ||
| 5193 | if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) | 5082 | if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) |
| 5194 | ccl->last_block = 1; | 5083 | ccl->last_block = 1; |
| 5084 | /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */ | ||
| 5085 | charset_map_loaded = 0; | ||
| 5195 | ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, | 5086 | ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, |
| 5196 | charset_list); | 5087 | charset_list); |
| 5088 | if (charset_map_loaded | ||
| 5089 | && (offset = coding_change_source (coding))) | ||
| 5090 | { | ||
| 5091 | p += offset; | ||
| 5092 | src += offset; | ||
| 5093 | src_end += offset; | ||
| 5094 | } | ||
| 5197 | charbuf += ccl->produced; | 5095 | charbuf += ccl->produced; |
| 5198 | if (multibytep) | 5096 | if (multibytep) |
| 5199 | src += source_byteidx[ccl->consumed]; | 5097 | src += source_byteidx[ccl->consumed]; |
| @@ -5225,17 +5123,17 @@ decode_coding_ccl (struct coding_system *coding) | |||
| 5225 | coding->charbuf_used = charbuf - coding->charbuf; | 5123 | coding->charbuf_used = charbuf - coding->charbuf; |
| 5226 | } | 5124 | } |
| 5227 | 5125 | ||
| 5228 | static int | 5126 | static bool |
| 5229 | encode_coding_ccl (struct coding_system *coding) | 5127 | encode_coding_ccl (struct coding_system *coding) |
| 5230 | { | 5128 | { |
| 5231 | struct ccl_program *ccl = &coding->spec.ccl->ccl; | 5129 | struct ccl_program *ccl = &coding->spec.ccl->ccl; |
| 5232 | int multibytep = coding->dst_multibyte; | 5130 | bool multibytep = coding->dst_multibyte; |
| 5233 | int *charbuf = coding->charbuf; | 5131 | int *charbuf = coding->charbuf; |
| 5234 | int *charbuf_end = charbuf + coding->charbuf_used; | 5132 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 5235 | unsigned char *dst = coding->destination + coding->produced; | 5133 | unsigned char *dst = coding->destination + coding->produced; |
| 5236 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 5134 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 5237 | int destination_charbuf[1024]; | 5135 | int destination_charbuf[1024]; |
| 5238 | EMACS_INT produced_chars = 0; | 5136 | ptrdiff_t produced_chars = 0; |
| 5239 | int i; | 5137 | int i; |
| 5240 | Lisp_Object attrs, charset_list; | 5138 | Lisp_Object attrs, charset_list; |
| 5241 | 5139 | ||
| @@ -5246,8 +5144,15 @@ encode_coding_ccl (struct coding_system *coding) | |||
| 5246 | 5144 | ||
| 5247 | do | 5145 | do |
| 5248 | { | 5146 | { |
| 5147 | ptrdiff_t offset; | ||
| 5148 | |||
| 5149 | /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */ | ||
| 5150 | charset_map_loaded = 0; | ||
| 5249 | ccl_driver (ccl, charbuf, destination_charbuf, | 5151 | ccl_driver (ccl, charbuf, destination_charbuf, |
| 5250 | charbuf_end - charbuf, 1024, charset_list); | 5152 | charbuf_end - charbuf, 1024, charset_list); |
| 5153 | if (charset_map_loaded | ||
| 5154 | && (offset = coding_change_destination (coding))) | ||
| 5155 | dst += offset; | ||
| 5251 | if (multibytep) | 5156 | if (multibytep) |
| 5252 | { | 5157 | { |
| 5253 | ASSURE_DESTINATION (ccl->produced * 2); | 5158 | ASSURE_DESTINATION (ccl->produced * 2); |
| @@ -5290,7 +5195,6 @@ encode_coding_ccl (struct coding_system *coding) | |||
| 5290 | return 0; | 5195 | return 0; |
| 5291 | } | 5196 | } |
| 5292 | 5197 | ||
| 5293 | |||
| 5294 | 5198 | ||
| 5295 | /*** 10, 11. no-conversion handlers ***/ | 5199 | /*** 10, 11. no-conversion handlers ***/ |
| 5296 | 5200 | ||
| @@ -5299,8 +5203,8 @@ encode_coding_ccl (struct coding_system *coding) | |||
| 5299 | static void | 5203 | static void |
| 5300 | decode_coding_raw_text (struct coding_system *coding) | 5204 | decode_coding_raw_text (struct coding_system *coding) |
| 5301 | { | 5205 | { |
| 5302 | int eol_dos = | 5206 | bool eol_dos |
| 5303 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 5207 | = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 5304 | 5208 | ||
| 5305 | coding->chars_at_source = 1; | 5209 | coding->chars_at_source = 1; |
| 5306 | coding->consumed_char = coding->src_chars; | 5210 | coding->consumed_char = coding->src_chars; |
| @@ -5315,15 +5219,15 @@ decode_coding_raw_text (struct coding_system *coding) | |||
| 5315 | record_conversion_result (coding, CODING_RESULT_SUCCESS); | 5219 | record_conversion_result (coding, CODING_RESULT_SUCCESS); |
| 5316 | } | 5220 | } |
| 5317 | 5221 | ||
| 5318 | static int | 5222 | static bool |
| 5319 | encode_coding_raw_text (struct coding_system *coding) | 5223 | encode_coding_raw_text (struct coding_system *coding) |
| 5320 | { | 5224 | { |
| 5321 | int multibytep = coding->dst_multibyte; | 5225 | bool multibytep = coding->dst_multibyte; |
| 5322 | int *charbuf = coding->charbuf; | 5226 | int *charbuf = coding->charbuf; |
| 5323 | int *charbuf_end = coding->charbuf + coding->charbuf_used; | 5227 | int *charbuf_end = coding->charbuf + coding->charbuf_used; |
| 5324 | unsigned char *dst = coding->destination + coding->produced; | 5228 | unsigned char *dst = coding->destination + coding->produced; |
| 5325 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 5229 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 5326 | EMACS_INT produced_chars = 0; | 5230 | ptrdiff_t produced_chars = 0; |
| 5327 | int c; | 5231 | int c; |
| 5328 | 5232 | ||
| 5329 | if (multibytep) | 5233 | if (multibytep) |
| @@ -5396,21 +5300,20 @@ encode_coding_raw_text (struct coding_system *coding) | |||
| 5396 | } | 5300 | } |
| 5397 | 5301 | ||
| 5398 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". | 5302 | /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". |
| 5399 | Check if a text is encoded in a charset-based coding system. If it | 5303 | Return true if a text is encoded in a charset-based coding system. */ |
| 5400 | is, return 1, else return 0. */ | ||
| 5401 | 5304 | ||
| 5402 | static int | 5305 | static bool |
| 5403 | detect_coding_charset (struct coding_system *coding, | 5306 | detect_coding_charset (struct coding_system *coding, |
| 5404 | struct coding_detection_info *detect_info) | 5307 | struct coding_detection_info *detect_info) |
| 5405 | { | 5308 | { |
| 5406 | const unsigned char *src = coding->source, *src_base; | 5309 | const unsigned char *src = coding->source, *src_base; |
| 5407 | const unsigned char *src_end = coding->source + coding->src_bytes; | 5310 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 5408 | int multibytep = coding->src_multibyte; | 5311 | bool multibytep = coding->src_multibyte; |
| 5409 | EMACS_INT consumed_chars = 0; | 5312 | ptrdiff_t consumed_chars = 0; |
| 5410 | Lisp_Object attrs, valids, name; | 5313 | Lisp_Object attrs, valids, name; |
| 5411 | int found = 0; | 5314 | int found = 0; |
| 5412 | EMACS_INT head_ascii = coding->head_ascii; | 5315 | ptrdiff_t head_ascii = coding->head_ascii; |
| 5413 | int check_latin_extra = 0; | 5316 | bool check_latin_extra = 0; |
| 5414 | 5317 | ||
| 5415 | detect_info->checked |= CATEGORY_MASK_CHARSET; | 5318 | detect_info->checked |= CATEGORY_MASK_CHARSET; |
| 5416 | 5319 | ||
| @@ -5446,7 +5349,7 @@ detect_coding_charset (struct coding_system *coding, | |||
| 5446 | if (c < 0xA0 | 5349 | if (c < 0xA0 |
| 5447 | && check_latin_extra | 5350 | && check_latin_extra |
| 5448 | && (!VECTORP (Vlatin_extra_code_table) | 5351 | && (!VECTORP (Vlatin_extra_code_table) |
| 5449 | || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))) | 5352 | || NILP (AREF (Vlatin_extra_code_table, c)))) |
| 5450 | break; | 5353 | break; |
| 5451 | found = CATEGORY_MASK_CHARSET; | 5354 | found = CATEGORY_MASK_CHARSET; |
| 5452 | } | 5355 | } |
| @@ -5513,15 +5416,15 @@ decode_coding_charset (struct coding_system *coding) | |||
| 5513 | the end. */ | 5416 | the end. */ |
| 5514 | int *charbuf_end | 5417 | int *charbuf_end |
| 5515 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); | 5418 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
| 5516 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 5419 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 5517 | int multibytep = coding->src_multibyte; | 5420 | bool multibytep = coding->src_multibyte; |
| 5518 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); | 5421 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); |
| 5519 | Lisp_Object valids; | 5422 | Lisp_Object valids; |
| 5520 | EMACS_INT char_offset = coding->produced_char; | 5423 | ptrdiff_t char_offset = coding->produced_char; |
| 5521 | EMACS_INT last_offset = char_offset; | 5424 | ptrdiff_t last_offset = char_offset; |
| 5522 | int last_id = charset_ascii; | 5425 | int last_id = charset_ascii; |
| 5523 | int eol_dos = | 5426 | bool eol_dos |
| 5524 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 5427 | = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| 5525 | int byte_after_cr = -1; | 5428 | int byte_after_cr = -1; |
| 5526 | 5429 | ||
| 5527 | valids = AREF (attrs, coding_attr_charset_valids); | 5430 | valids = AREF (attrs, coding_attr_charset_valids); |
| @@ -5630,18 +5533,18 @@ decode_coding_charset (struct coding_system *coding) | |||
| 5630 | coding->charbuf_used = charbuf - coding->charbuf; | 5533 | coding->charbuf_used = charbuf - coding->charbuf; |
| 5631 | } | 5534 | } |
| 5632 | 5535 | ||
| 5633 | static int | 5536 | static bool |
| 5634 | encode_coding_charset (struct coding_system *coding) | 5537 | encode_coding_charset (struct coding_system *coding) |
| 5635 | { | 5538 | { |
| 5636 | int multibytep = coding->dst_multibyte; | 5539 | bool multibytep = coding->dst_multibyte; |
| 5637 | int *charbuf = coding->charbuf; | 5540 | int *charbuf = coding->charbuf; |
| 5638 | int *charbuf_end = charbuf + coding->charbuf_used; | 5541 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 5639 | unsigned char *dst = coding->destination + coding->produced; | 5542 | unsigned char *dst = coding->destination + coding->produced; |
| 5640 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 5543 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 5641 | int safe_room = MAX_MULTIBYTE_LENGTH; | 5544 | int safe_room = MAX_MULTIBYTE_LENGTH; |
| 5642 | EMACS_INT produced_chars = 0; | 5545 | ptrdiff_t produced_chars = 0; |
| 5643 | Lisp_Object attrs, charset_list; | 5546 | Lisp_Object attrs, charset_list; |
| 5644 | int ascii_compatible; | 5547 | bool ascii_compatible; |
| 5645 | int c; | 5548 | int c; |
| 5646 | 5549 | ||
| 5647 | CODING_GET_INFO (coding, attrs, charset_list); | 5550 | CODING_GET_INFO (coding, attrs, charset_list); |
| @@ -5847,7 +5750,6 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding) | |||
| 5847 | coding->encoder = encode_coding_emacs_mule; | 5750 | coding->encoder = encode_coding_emacs_mule; |
| 5848 | coding->common_flags | 5751 | coding->common_flags |
| 5849 | |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); | 5752 | |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); |
| 5850 | coding->spec.emacs_mule.full_support = 1; | ||
| 5851 | if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) | 5753 | if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) |
| 5852 | && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) | 5754 | && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) |
| 5853 | { | 5755 | { |
| @@ -5865,7 +5767,6 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding) | |||
| 5865 | SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); | 5767 | SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
| 5866 | coding->max_charset_id = max_charset_id; | 5768 | coding->max_charset_id = max_charset_id; |
| 5867 | coding->safe_charsets = SDATA (safe_charsets); | 5769 | coding->safe_charsets = SDATA (safe_charsets); |
| 5868 | coding->spec.emacs_mule.full_support = 1; | ||
| 5869 | } | 5770 | } |
| 5870 | coding->spec.emacs_mule.cmp_status.state = COMPOSING_NO; | 5771 | coding->spec.emacs_mule.cmp_status.state = COMPOSING_NO; |
| 5871 | coding->spec.emacs_mule.cmp_status.method = COMPOSITION_NO; | 5772 | coding->spec.emacs_mule.cmp_status.method = COMPOSITION_NO; |
| @@ -6188,7 +6089,7 @@ complement_process_encoding_system (Lisp_Object coding_system) | |||
| 6188 | #define MAX_EOL_CHECK_COUNT 3 | 6089 | #define MAX_EOL_CHECK_COUNT 3 |
| 6189 | 6090 | ||
| 6190 | static int | 6091 | static int |
| 6191 | detect_eol (const unsigned char *source, EMACS_INT src_bytes, | 6092 | detect_eol (const unsigned char *source, ptrdiff_t src_bytes, |
| 6192 | enum coding_category category) | 6093 | enum coding_category category) |
| 6193 | { | 6094 | { |
| 6194 | const unsigned char *src = source, *src_end = src + src_bytes; | 6095 | const unsigned char *src = source, *src_end = src + src_bytes; |
| @@ -6198,11 +6099,9 @@ detect_eol (const unsigned char *source, EMACS_INT src_bytes, | |||
| 6198 | 6099 | ||
| 6199 | if ((1 << category) & CATEGORY_MASK_UTF_16) | 6100 | if ((1 << category) & CATEGORY_MASK_UTF_16) |
| 6200 | { | 6101 | { |
| 6201 | int msb, lsb; | 6102 | bool msb = category == (coding_category_utf_16_le |
| 6202 | 6103 | | coding_category_utf_16_le_nosig); | |
| 6203 | msb = category == (coding_category_utf_16_le | 6104 | bool lsb = !msb; |
| 6204 | | coding_category_utf_16_le_nosig); | ||
| 6205 | lsb = 1 - msb; | ||
| 6206 | 6105 | ||
| 6207 | while (src + 1 < src_end) | 6106 | while (src + 1 < src_end) |
| 6208 | { | 6107 | { |
| @@ -6317,7 +6216,7 @@ static void | |||
| 6317 | detect_coding (struct coding_system *coding) | 6216 | detect_coding (struct coding_system *coding) |
| 6318 | { | 6217 | { |
| 6319 | const unsigned char *src, *src_end; | 6218 | const unsigned char *src, *src_end; |
| 6320 | int saved_mode = coding->mode; | 6219 | unsigned int saved_mode = coding->mode; |
| 6321 | 6220 | ||
| 6322 | coding->consumed = coding->consumed_char = 0; | 6221 | coding->consumed = coding->consumed_char = 0; |
| 6323 | coding->produced = coding->produced_char = 0; | 6222 | coding->produced = coding->produced_char = 0; |
| @@ -6332,7 +6231,7 @@ detect_coding (struct coding_system *coding) | |||
| 6332 | { | 6231 | { |
| 6333 | int c, i; | 6232 | int c, i; |
| 6334 | struct coding_detection_info detect_info; | 6233 | struct coding_detection_info detect_info; |
| 6335 | int null_byte_found = 0, eight_bit_found = 0; | 6234 | bool null_byte_found = 0, eight_bit_found = 0; |
| 6336 | 6235 | ||
| 6337 | detect_info.checked = detect_info.found = detect_info.rejected = 0; | 6236 | detect_info.checked = detect_info.found = detect_info.rejected = 0; |
| 6338 | for (src = coding->source; src < src_end; src++) | 6237 | for (src = coding->source; src < src_end; src++) |
| @@ -6406,6 +6305,9 @@ detect_coding (struct coding_system *coding) | |||
| 6406 | { | 6305 | { |
| 6407 | category = coding_priorities[i]; | 6306 | category = coding_priorities[i]; |
| 6408 | this = coding_categories + category; | 6307 | this = coding_categories + category; |
| 6308 | /* Some of this->detector (e.g. detect_coding_sjis) | ||
| 6309 | require this information. */ | ||
| 6310 | coding->id = this->id; | ||
| 6409 | if (this->id < 0) | 6311 | if (this->id < 0) |
| 6410 | { | 6312 | { |
| 6411 | /* No coding system of this category is defined. */ | 6313 | /* No coding system of this category is defined. */ |
| @@ -6549,7 +6451,7 @@ decode_eol (struct coding_system *coding) | |||
| 6549 | } | 6451 | } |
| 6550 | else if (EQ (eol_type, Qdos)) | 6452 | else if (EQ (eol_type, Qdos)) |
| 6551 | { | 6453 | { |
| 6552 | EMACS_INT n = 0; | 6454 | ptrdiff_t n = 0; |
| 6553 | 6455 | ||
| 6554 | if (NILP (coding->dst_object)) | 6456 | if (NILP (coding->dst_object)) |
| 6555 | { | 6457 | { |
| @@ -6564,9 +6466,9 @@ decode_eol (struct coding_system *coding) | |||
| 6564 | } | 6466 | } |
| 6565 | else | 6467 | else |
| 6566 | { | 6468 | { |
| 6567 | EMACS_INT pos_byte = coding->dst_pos_byte; | 6469 | ptrdiff_t pos_byte = coding->dst_pos_byte; |
| 6568 | EMACS_INT pos = coding->dst_pos; | 6470 | ptrdiff_t pos = coding->dst_pos; |
| 6569 | EMACS_INT pos_end = pos + coding->produced_char - 1; | 6471 | ptrdiff_t pos_end = pos + coding->produced_char - 1; |
| 6570 | 6472 | ||
| 6571 | while (pos < pos_end) | 6473 | while (pos < pos_end) |
| 6572 | { | 6474 | { |
| @@ -6591,11 +6493,11 @@ decode_eol (struct coding_system *coding) | |||
| 6591 | 6493 | ||
| 6592 | 6494 | ||
| 6593 | /* Return a translation table (or list of them) from coding system | 6495 | /* Return a translation table (or list of them) from coding system |
| 6594 | attribute vector ATTRS for encoding (ENCODEP is nonzero) or | 6496 | attribute vector ATTRS for encoding (if ENCODEP) or decoding (if |
| 6595 | decoding (ENCODEP is zero). */ | 6497 | not ENCODEP). */ |
| 6596 | 6498 | ||
| 6597 | static Lisp_Object | 6499 | static Lisp_Object |
| 6598 | get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup) | 6500 | get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup) |
| 6599 | { | 6501 | { |
| 6600 | Lisp_Object standard, translation_table; | 6502 | Lisp_Object standard, translation_table; |
| 6601 | Lisp_Object val; | 6503 | Lisp_Object val; |
| @@ -6706,8 +6608,8 @@ get_translation (Lisp_Object trans, int *buf, int *buf_end) | |||
| 6706 | { | 6608 | { |
| 6707 | Lisp_Object val = XCAR (trans); | 6609 | Lisp_Object val = XCAR (trans); |
| 6708 | Lisp_Object from = XCAR (val); | 6610 | Lisp_Object from = XCAR (val); |
| 6709 | int len = ASIZE (from); | 6611 | ptrdiff_t len = ASIZE (from); |
| 6710 | int i; | 6612 | ptrdiff_t i; |
| 6711 | 6613 | ||
| 6712 | for (i = 0; i < len; i++) | 6614 | for (i = 0; i < len; i++) |
| 6713 | { | 6615 | { |
| @@ -6725,12 +6627,12 @@ get_translation (Lisp_Object trans, int *buf, int *buf_end) | |||
| 6725 | 6627 | ||
| 6726 | static int | 6628 | static int |
| 6727 | produce_chars (struct coding_system *coding, Lisp_Object translation_table, | 6629 | produce_chars (struct coding_system *coding, Lisp_Object translation_table, |
| 6728 | int last_block) | 6630 | bool last_block) |
| 6729 | { | 6631 | { |
| 6730 | unsigned char *dst = coding->destination + coding->produced; | 6632 | unsigned char *dst = coding->destination + coding->produced; |
| 6731 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 6633 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 6732 | EMACS_INT produced; | 6634 | ptrdiff_t produced; |
| 6733 | EMACS_INT produced_chars = 0; | 6635 | ptrdiff_t produced_chars = 0; |
| 6734 | int carryover = 0; | 6636 | int carryover = 0; |
| 6735 | 6637 | ||
| 6736 | if (! coding->chars_at_source) | 6638 | if (! coding->chars_at_source) |
| @@ -6747,11 +6649,12 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6747 | 6649 | ||
| 6748 | while (buf < buf_end) | 6650 | while (buf < buf_end) |
| 6749 | { | 6651 | { |
| 6750 | int c = *buf, i; | 6652 | int c = *buf; |
| 6653 | ptrdiff_t i; | ||
| 6751 | 6654 | ||
| 6752 | if (c >= 0) | 6655 | if (c >= 0) |
| 6753 | { | 6656 | { |
| 6754 | EMACS_INT from_nchars = 1, to_nchars = 1; | 6657 | ptrdiff_t from_nchars = 1, to_nchars = 1; |
| 6755 | Lisp_Object trans = Qnil; | 6658 | Lisp_Object trans = Qnil; |
| 6756 | 6659 | ||
| 6757 | LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); | 6660 | LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); |
| @@ -6827,8 +6730,8 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6827 | { | 6730 | { |
| 6828 | if (coding->src_multibyte) | 6731 | if (coding->src_multibyte) |
| 6829 | { | 6732 | { |
| 6830 | int multibytep = 1; | 6733 | bool multibytep = 1; |
| 6831 | EMACS_INT consumed_chars = 0; | 6734 | ptrdiff_t consumed_chars = 0; |
| 6832 | 6735 | ||
| 6833 | while (1) | 6736 | while (1) |
| 6834 | { | 6737 | { |
| @@ -6842,14 +6745,14 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6842 | dst_end = (unsigned char *) src; | 6745 | dst_end = (unsigned char *) src; |
| 6843 | if (dst == dst_end) | 6746 | if (dst == dst_end) |
| 6844 | { | 6747 | { |
| 6845 | EMACS_INT offset = src - coding->source; | 6748 | ptrdiff_t offset = src - coding->source; |
| 6846 | 6749 | ||
| 6847 | dst = alloc_destination (coding, src_end - src + 1, | 6750 | dst = alloc_destination (coding, src_end - src + 1, |
| 6848 | dst); | 6751 | dst); |
| 6849 | dst_end = coding->destination + coding->dst_bytes; | 6752 | dst_end = coding->destination + coding->dst_bytes; |
| 6850 | coding_set_source (coding); | 6753 | coding_set_source (coding); |
| 6851 | src = coding->source + offset; | 6754 | src = coding->source + offset; |
| 6852 | src_end = coding->source + coding->src_bytes; | 6755 | src_end = coding->source + coding->consumed; |
| 6853 | if (EQ (coding->src_object, coding->dst_object)) | 6756 | if (EQ (coding->src_object, coding->dst_object)) |
| 6854 | dst_end = (unsigned char *) src; | 6757 | dst_end = (unsigned char *) src; |
| 6855 | } | 6758 | } |
| @@ -6863,7 +6766,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6863 | else | 6766 | else |
| 6864 | while (src < src_end) | 6767 | while (src < src_end) |
| 6865 | { | 6768 | { |
| 6866 | int multibytep = 1; | 6769 | bool multibytep = 1; |
| 6867 | int c = *src++; | 6770 | int c = *src++; |
| 6868 | 6771 | ||
| 6869 | if (dst >= dst_end - 1) | 6772 | if (dst >= dst_end - 1) |
| @@ -6872,8 +6775,8 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6872 | dst_end = (unsigned char *) src; | 6775 | dst_end = (unsigned char *) src; |
| 6873 | if (dst >= dst_end - 1) | 6776 | if (dst >= dst_end - 1) |
| 6874 | { | 6777 | { |
| 6875 | EMACS_INT offset = src - coding->source; | 6778 | ptrdiff_t offset = src - coding->source; |
| 6876 | EMACS_INT more_bytes; | 6779 | ptrdiff_t more_bytes; |
| 6877 | 6780 | ||
| 6878 | if (EQ (coding->src_object, coding->dst_object)) | 6781 | if (EQ (coding->src_object, coding->dst_object)) |
| 6879 | more_bytes = ((src_end - src) / 2) + 2; | 6782 | more_bytes = ((src_end - src) / 2) + 2; |
| @@ -6883,7 +6786,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6883 | dst_end = coding->destination + coding->dst_bytes; | 6786 | dst_end = coding->destination + coding->dst_bytes; |
| 6884 | coding_set_source (coding); | 6787 | coding_set_source (coding); |
| 6885 | src = coding->source + offset; | 6788 | src = coding->source + offset; |
| 6886 | src_end = coding->source + coding->src_bytes; | 6789 | src_end = coding->source + coding->consumed; |
| 6887 | if (EQ (coding->src_object, coding->dst_object)) | 6790 | if (EQ (coding->src_object, coding->dst_object)) |
| 6888 | dst_end = (unsigned char *) src; | 6791 | dst_end = (unsigned char *) src; |
| 6889 | } | 6792 | } |
| @@ -6895,16 +6798,16 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6895 | { | 6798 | { |
| 6896 | if (!EQ (coding->src_object, coding->dst_object)) | 6799 | if (!EQ (coding->src_object, coding->dst_object)) |
| 6897 | { | 6800 | { |
| 6898 | EMACS_INT require = coding->src_bytes - coding->dst_bytes; | 6801 | ptrdiff_t require = coding->src_bytes - coding->dst_bytes; |
| 6899 | 6802 | ||
| 6900 | if (require > 0) | 6803 | if (require > 0) |
| 6901 | { | 6804 | { |
| 6902 | EMACS_INT offset = src - coding->source; | 6805 | ptrdiff_t offset = src - coding->source; |
| 6903 | 6806 | ||
| 6904 | dst = alloc_destination (coding, require, dst); | 6807 | dst = alloc_destination (coding, require, dst); |
| 6905 | coding_set_source (coding); | 6808 | coding_set_source (coding); |
| 6906 | src = coding->source + offset; | 6809 | src = coding->source + offset; |
| 6907 | src_end = coding->source + coding->src_bytes; | 6810 | src_end = coding->source + coding->consumed; |
| 6908 | } | 6811 | } |
| 6909 | } | 6812 | } |
| 6910 | produced_chars = coding->consumed_char; | 6813 | produced_chars = coding->consumed_char; |
| @@ -6926,11 +6829,11 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6926 | [ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ] | 6829 | [ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ] |
| 6927 | */ | 6830 | */ |
| 6928 | 6831 | ||
| 6929 | static inline void | 6832 | static void |
| 6930 | produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) | 6833 | produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos) |
| 6931 | { | 6834 | { |
| 6932 | int len; | 6835 | int len; |
| 6933 | EMACS_INT to; | 6836 | ptrdiff_t to; |
| 6934 | enum composition_method method; | 6837 | enum composition_method method; |
| 6935 | Lisp_Object components; | 6838 | Lisp_Object components; |
| 6936 | 6839 | ||
| @@ -6970,10 +6873,10 @@ produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) | |||
| 6970 | [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] | 6873 | [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] |
| 6971 | */ | 6874 | */ |
| 6972 | 6875 | ||
| 6973 | static inline void | 6876 | static void |
| 6974 | produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) | 6877 | produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos) |
| 6975 | { | 6878 | { |
| 6976 | EMACS_INT from = pos - charbuf[2]; | 6879 | ptrdiff_t from = pos - charbuf[2]; |
| 6977 | struct charset *charset = CHARSET_FROM_ID (charbuf[3]); | 6880 | struct charset *charset = CHARSET_FROM_ID (charbuf[3]); |
| 6978 | 6881 | ||
| 6979 | Fput_text_property (make_number (from), make_number (pos), | 6882 | Fput_text_property (make_number (from), make_number (pos), |
| @@ -6991,7 +6894,7 @@ produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) | |||
| 6991 | coding->charbuf = NULL; \ | 6894 | coding->charbuf = NULL; \ |
| 6992 | while (size > 1024) \ | 6895 | while (size > 1024) \ |
| 6993 | { \ | 6896 | { \ |
| 6994 | coding->charbuf = (int *) alloca (sizeof (int) * size); \ | 6897 | coding->charbuf = alloca (sizeof (int) * size); \ |
| 6995 | if (coding->charbuf) \ | 6898 | if (coding->charbuf) \ |
| 6996 | break; \ | 6899 | break; \ |
| 6997 | size >>= 1; \ | 6900 | size >>= 1; \ |
| @@ -6999,14 +6902,14 @@ produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) | |||
| 6999 | if (! coding->charbuf) \ | 6902 | if (! coding->charbuf) \ |
| 7000 | { \ | 6903 | { \ |
| 7001 | record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ | 6904 | record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ |
| 7002 | return coding->result; \ | 6905 | return; \ |
| 7003 | } \ | 6906 | } \ |
| 7004 | coding->charbuf_size = size; \ | 6907 | coding->charbuf_size = size; \ |
| 7005 | } while (0) | 6908 | } while (0) |
| 7006 | 6909 | ||
| 7007 | 6910 | ||
| 7008 | static void | 6911 | static void |
| 7009 | produce_annotation (struct coding_system *coding, EMACS_INT pos) | 6912 | produce_annotation (struct coding_system *coding, ptrdiff_t pos) |
| 7010 | { | 6913 | { |
| 7011 | int *charbuf = coding->charbuf; | 6914 | int *charbuf = coding->charbuf; |
| 7012 | int *charbuf_end = charbuf + coding->charbuf_used; | 6915 | int *charbuf_end = charbuf + coding->charbuf_used; |
| @@ -7060,7 +6963,7 @@ produce_annotation (struct coding_system *coding, EMACS_INT pos) | |||
| 7060 | CODING->dst_object. | 6963 | CODING->dst_object. |
| 7061 | */ | 6964 | */ |
| 7062 | 6965 | ||
| 7063 | static int | 6966 | static void |
| 7064 | decode_coding (struct coding_system *coding) | 6967 | decode_coding (struct coding_system *coding) |
| 7065 | { | 6968 | { |
| 7066 | Lisp_Object attrs; | 6969 | Lisp_Object attrs; |
| @@ -7079,12 +6982,20 @@ decode_coding (struct coding_system *coding) | |||
| 7079 | undo_list = Qt; | 6982 | undo_list = Qt; |
| 7080 | if (BUFFERP (coding->dst_object)) | 6983 | if (BUFFERP (coding->dst_object)) |
| 7081 | { | 6984 | { |
| 7082 | if (current_buffer != XBUFFER (coding->dst_object)) | 6985 | set_buffer_internal (XBUFFER (coding->dst_object)); |
| 7083 | set_buffer_internal (XBUFFER (coding->dst_object)); | ||
| 7084 | if (GPT != PT) | 6986 | if (GPT != PT) |
| 7085 | move_gap_both (PT, PT_BYTE); | 6987 | move_gap_both (PT, PT_BYTE); |
| 6988 | |||
| 6989 | /* We must disable undo_list in order to record the whole insert | ||
| 6990 | transaction via record_insert at the end. But doing so also | ||
| 6991 | disables the recording of the first change to the undo_list. | ||
| 6992 | Therefore we check for first change here and record it via | ||
| 6993 | record_first_change if needed. */ | ||
| 6994 | if (MODIFF <= SAVE_MODIFF) | ||
| 6995 | record_first_change (); | ||
| 6996 | |||
| 7086 | undo_list = BVAR (current_buffer, undo_list); | 6997 | undo_list = BVAR (current_buffer, undo_list); |
| 7087 | BVAR (current_buffer, undo_list) = Qt; | 6998 | bset_undo_list (current_buffer, Qt); |
| 7088 | } | 6999 | } |
| 7089 | 7000 | ||
| 7090 | coding->consumed = coding->consumed_char = 0; | 7001 | coding->consumed = coding->consumed_char = 0; |
| @@ -7106,7 +7017,7 @@ decode_coding (struct coding_system *coding) | |||
| 7106 | } | 7017 | } |
| 7107 | do | 7018 | do |
| 7108 | { | 7019 | { |
| 7109 | EMACS_INT pos = coding->dst_pos + coding->produced_char; | 7020 | ptrdiff_t pos = coding->dst_pos + coding->produced_char; |
| 7110 | 7021 | ||
| 7111 | coding_set_source (coding); | 7022 | coding_set_source (coding); |
| 7112 | coding->annotated = 0; | 7023 | coding->annotated = 0; |
| @@ -7181,10 +7092,9 @@ decode_coding (struct coding_system *coding) | |||
| 7181 | decode_eol (coding); | 7092 | decode_eol (coding); |
| 7182 | if (BUFFERP (coding->dst_object)) | 7093 | if (BUFFERP (coding->dst_object)) |
| 7183 | { | 7094 | { |
| 7184 | BVAR (current_buffer, undo_list) = undo_list; | 7095 | bset_undo_list (current_buffer, undo_list); |
| 7185 | record_insert (coding->dst_pos, coding->produced_char); | 7096 | record_insert (coding->dst_pos, coding->produced_char); |
| 7186 | } | 7097 | } |
| 7187 | return coding->result; | ||
| 7188 | } | 7098 | } |
| 7189 | 7099 | ||
| 7190 | 7100 | ||
| @@ -7198,12 +7108,12 @@ decode_coding (struct coding_system *coding) | |||
| 7198 | position of a composition after POS (if any) or to LIMIT, and | 7108 | position of a composition after POS (if any) or to LIMIT, and |
| 7199 | return BUF. */ | 7109 | return BUF. */ |
| 7200 | 7110 | ||
| 7201 | static inline int * | 7111 | static int * |
| 7202 | handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, | 7112 | handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit, |
| 7203 | struct coding_system *coding, int *buf, | 7113 | struct coding_system *coding, int *buf, |
| 7204 | EMACS_INT *stop) | 7114 | ptrdiff_t *stop) |
| 7205 | { | 7115 | { |
| 7206 | EMACS_INT start, end; | 7116 | ptrdiff_t start, end; |
| 7207 | Lisp_Object prop; | 7117 | Lisp_Object prop; |
| 7208 | 7118 | ||
| 7209 | if (! find_composition (pos, limit, &start, &end, &prop, coding->src_object) | 7119 | if (! find_composition (pos, limit, &start, &end, &prop, coding->src_object) |
| @@ -7225,7 +7135,7 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, | |||
| 7225 | if (method != COMPOSITION_RELATIVE) | 7135 | if (method != COMPOSITION_RELATIVE) |
| 7226 | { | 7136 | { |
| 7227 | Lisp_Object components; | 7137 | Lisp_Object components; |
| 7228 | int len, i, i_byte; | 7138 | ptrdiff_t i, len, i_byte; |
| 7229 | 7139 | ||
| 7230 | components = COMPOSITION_COMPONENTS (prop); | 7140 | components = COMPOSITION_COMPONENTS (prop); |
| 7231 | if (VECTORP (components)) | 7141 | if (VECTORP (components)) |
| @@ -7256,7 +7166,7 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, | |||
| 7256 | *buf++ = XINT (XCAR (components)); | 7166 | *buf++ = XINT (XCAR (components)); |
| 7257 | } | 7167 | } |
| 7258 | else | 7168 | else |
| 7259 | abort (); | 7169 | emacs_abort (); |
| 7260 | *head -= len; | 7170 | *head -= len; |
| 7261 | } | 7171 | } |
| 7262 | } | 7172 | } |
| @@ -7281,10 +7191,10 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, | |||
| 7281 | If the property value is nil, set *STOP to the position where the | 7191 | If the property value is nil, set *STOP to the position where the |
| 7282 | property value is non-nil (limiting by LIMIT), and return BUF. */ | 7192 | property value is non-nil (limiting by LIMIT), and return BUF. */ |
| 7283 | 7193 | ||
| 7284 | static inline int * | 7194 | static int * |
| 7285 | handle_charset_annotation (EMACS_INT pos, EMACS_INT limit, | 7195 | handle_charset_annotation (ptrdiff_t pos, ptrdiff_t limit, |
| 7286 | struct coding_system *coding, int *buf, | 7196 | struct coding_system *coding, int *buf, |
| 7287 | EMACS_INT *stop) | 7197 | ptrdiff_t *stop) |
| 7288 | { | 7198 | { |
| 7289 | Lisp_Object val, next; | 7199 | Lisp_Object val, next; |
| 7290 | int id; | 7200 | int id; |
| @@ -7311,12 +7221,12 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7311 | int *buf_end = coding->charbuf + coding->charbuf_size; | 7221 | int *buf_end = coding->charbuf + coding->charbuf_size; |
| 7312 | const unsigned char *src = coding->source + coding->consumed; | 7222 | const unsigned char *src = coding->source + coding->consumed; |
| 7313 | const unsigned char *src_end = coding->source + coding->src_bytes; | 7223 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 7314 | EMACS_INT pos = coding->src_pos + coding->consumed_char; | 7224 | ptrdiff_t pos = coding->src_pos + coding->consumed_char; |
| 7315 | EMACS_INT end_pos = coding->src_pos + coding->src_chars; | 7225 | ptrdiff_t end_pos = coding->src_pos + coding->src_chars; |
| 7316 | int multibytep = coding->src_multibyte; | 7226 | bool multibytep = coding->src_multibyte; |
| 7317 | Lisp_Object eol_type; | 7227 | Lisp_Object eol_type; |
| 7318 | int c; | 7228 | int c; |
| 7319 | EMACS_INT stop, stop_composition, stop_charset; | 7229 | ptrdiff_t stop, stop_composition, stop_charset; |
| 7320 | int *lookup_buf = NULL; | 7230 | int *lookup_buf = NULL; |
| 7321 | 7231 | ||
| 7322 | if (! NILP (translation_table)) | 7232 | if (! NILP (translation_table)) |
| @@ -7365,7 +7275,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7365 | 7275 | ||
| 7366 | if (! multibytep) | 7276 | if (! multibytep) |
| 7367 | { | 7277 | { |
| 7368 | EMACS_INT bytes; | 7278 | int bytes; |
| 7369 | 7279 | ||
| 7370 | if (coding->encoder == encode_coding_raw_text | 7280 | if (coding->encoder == encode_coding_raw_text |
| 7371 | || coding->encoder == encode_coding_ccl) | 7281 | || coding->encoder == encode_coding_ccl) |
| @@ -7396,7 +7306,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7396 | *buf++ = c; | 7306 | *buf++ = c; |
| 7397 | else | 7307 | else |
| 7398 | { | 7308 | { |
| 7399 | int from_nchars = 1, to_nchars = 1; | 7309 | ptrdiff_t from_nchars = 1, to_nchars = 1; |
| 7400 | int *lookup_buf_end; | 7310 | int *lookup_buf_end; |
| 7401 | const unsigned char *p = src; | 7311 | const unsigned char *p = src; |
| 7402 | int i; | 7312 | int i; |
| @@ -7417,7 +7327,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7417 | else | 7327 | else |
| 7418 | { | 7328 | { |
| 7419 | to_nchars = ASIZE (trans); | 7329 | to_nchars = ASIZE (trans); |
| 7420 | if (buf + to_nchars > buf_end) | 7330 | if (buf_end - buf < to_nchars) |
| 7421 | break; | 7331 | break; |
| 7422 | c = XINT (AREF (trans, 0)); | 7332 | c = XINT (AREF (trans, 0)); |
| 7423 | } | 7333 | } |
| @@ -7460,7 +7370,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7460 | If CODING->dst_object is nil, the encoded data is placed at the | 7370 | If CODING->dst_object is nil, the encoded data is placed at the |
| 7461 | memory area specified by CODING->destination. */ | 7371 | memory area specified by CODING->destination. */ |
| 7462 | 7372 | ||
| 7463 | static int | 7373 | static void |
| 7464 | encode_coding (struct coding_system *coding) | 7374 | encode_coding (struct coding_system *coding) |
| 7465 | { | 7375 | { |
| 7466 | Lisp_Object attrs; | 7376 | Lisp_Object attrs; |
| @@ -7502,8 +7412,6 @@ encode_coding (struct coding_system *coding) | |||
| 7502 | 7412 | ||
| 7503 | if (BUFFERP (coding->dst_object) && coding->produced_char > 0) | 7413 | if (BUFFERP (coding->dst_object) && coding->produced_char > 0) |
| 7504 | insert_from_gap (coding->produced_char, coding->produced); | 7414 | insert_from_gap (coding->produced_char, coding->produced); |
| 7505 | |||
| 7506 | return (coding->result); | ||
| 7507 | } | 7415 | } |
| 7508 | 7416 | ||
| 7509 | 7417 | ||
| @@ -7517,26 +7425,27 @@ static Lisp_Object Vcode_conversion_workbuf_name; | |||
| 7517 | versions of Vcode_conversion_workbuf_name. */ | 7425 | versions of Vcode_conversion_workbuf_name. */ |
| 7518 | static Lisp_Object Vcode_conversion_reused_workbuf; | 7426 | static Lisp_Object Vcode_conversion_reused_workbuf; |
| 7519 | 7427 | ||
| 7520 | /* 1 iff Vcode_conversion_reused_workbuf is already in use. */ | 7428 | /* True iff Vcode_conversion_reused_workbuf is already in use. */ |
| 7521 | static int reused_workbuf_in_use; | 7429 | static bool reused_workbuf_in_use; |
| 7522 | 7430 | ||
| 7523 | 7431 | ||
| 7524 | /* Return a working buffer of code conversion. MULTIBYTE specifies the | 7432 | /* Return a working buffer of code conversion. MULTIBYTE specifies the |
| 7525 | multibyteness of returning buffer. */ | 7433 | multibyteness of returning buffer. */ |
| 7526 | 7434 | ||
| 7527 | static Lisp_Object | 7435 | static Lisp_Object |
| 7528 | make_conversion_work_buffer (int multibyte) | 7436 | make_conversion_work_buffer (bool multibyte) |
| 7529 | { | 7437 | { |
| 7530 | Lisp_Object name, workbuf; | 7438 | Lisp_Object name, workbuf; |
| 7531 | struct buffer *current; | 7439 | struct buffer *current; |
| 7532 | 7440 | ||
| 7533 | if (reused_workbuf_in_use++) | 7441 | if (reused_workbuf_in_use) |
| 7534 | { | 7442 | { |
| 7535 | name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); | 7443 | name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); |
| 7536 | workbuf = Fget_buffer_create (name); | 7444 | workbuf = Fget_buffer_create (name); |
| 7537 | } | 7445 | } |
| 7538 | else | 7446 | else |
| 7539 | { | 7447 | { |
| 7448 | reused_workbuf_in_use = 1; | ||
| 7540 | if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf))) | 7449 | if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf))) |
| 7541 | Vcode_conversion_reused_workbuf | 7450 | Vcode_conversion_reused_workbuf |
| 7542 | = Fget_buffer_create (Vcode_conversion_workbuf_name); | 7451 | = Fget_buffer_create (Vcode_conversion_workbuf_name); |
| @@ -7549,8 +7458,8 @@ make_conversion_work_buffer (int multibyte) | |||
| 7549 | doesn't compile new regexps. */ | 7458 | doesn't compile new regexps. */ |
| 7550 | Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt); | 7459 | Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt); |
| 7551 | Ferase_buffer (); | 7460 | Ferase_buffer (); |
| 7552 | BVAR (current_buffer, undo_list) = Qt; | 7461 | bset_undo_list (current_buffer, Qt); |
| 7553 | BVAR (current_buffer, enable_multibyte_characters) = multibyte ? Qt : Qnil; | 7462 | bset_enable_multibyte_characters (current_buffer, multibyte ? Qt : Qnil); |
| 7554 | set_buffer_internal (current); | 7463 | set_buffer_internal (current); |
| 7555 | return workbuf; | 7464 | return workbuf; |
| 7556 | } | 7465 | } |
| @@ -7569,7 +7478,7 @@ code_conversion_restore (Lisp_Object arg) | |||
| 7569 | { | 7478 | { |
| 7570 | if (EQ (workbuf, Vcode_conversion_reused_workbuf)) | 7479 | if (EQ (workbuf, Vcode_conversion_reused_workbuf)) |
| 7571 | reused_workbuf_in_use = 0; | 7480 | reused_workbuf_in_use = 0; |
| 7572 | else if (! NILP (Fbuffer_live_p (workbuf))) | 7481 | else |
| 7573 | Fkill_buffer (workbuf); | 7482 | Fkill_buffer (workbuf); |
| 7574 | } | 7483 | } |
| 7575 | set_buffer_internal (XBUFFER (current)); | 7484 | set_buffer_internal (XBUFFER (current)); |
| @@ -7578,7 +7487,7 @@ code_conversion_restore (Lisp_Object arg) | |||
| 7578 | } | 7487 | } |
| 7579 | 7488 | ||
| 7580 | Lisp_Object | 7489 | Lisp_Object |
| 7581 | code_conversion_save (int with_work_buf, int multibyte) | 7490 | code_conversion_save (bool with_work_buf, bool multibyte) |
| 7582 | { | 7491 | { |
| 7583 | Lisp_Object workbuf = Qnil; | 7492 | Lisp_Object workbuf = Qnil; |
| 7584 | 7493 | ||
| @@ -7589,11 +7498,11 @@ code_conversion_save (int with_work_buf, int multibyte) | |||
| 7589 | return workbuf; | 7498 | return workbuf; |
| 7590 | } | 7499 | } |
| 7591 | 7500 | ||
| 7592 | int | 7501 | void |
| 7593 | decode_coding_gap (struct coding_system *coding, | 7502 | decode_coding_gap (struct coding_system *coding, |
| 7594 | EMACS_INT chars, EMACS_INT bytes) | 7503 | ptrdiff_t chars, ptrdiff_t bytes) |
| 7595 | { | 7504 | { |
| 7596 | int count = SPECPDL_INDEX (); | 7505 | ptrdiff_t count = SPECPDL_INDEX (); |
| 7597 | Lisp_Object attrs; | 7506 | Lisp_Object attrs; |
| 7598 | 7507 | ||
| 7599 | code_conversion_save (0, 0); | 7508 | code_conversion_save (0, 0); |
| @@ -7620,7 +7529,7 @@ decode_coding_gap (struct coding_system *coding, | |||
| 7620 | attrs = CODING_ID_ATTRS (coding->id); | 7529 | attrs = CODING_ID_ATTRS (coding->id); |
| 7621 | if (! NILP (CODING_ATTR_POST_READ (attrs))) | 7530 | if (! NILP (CODING_ATTR_POST_READ (attrs))) |
| 7622 | { | 7531 | { |
| 7623 | EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; | 7532 | ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
| 7624 | Lisp_Object val; | 7533 | Lisp_Object val; |
| 7625 | 7534 | ||
| 7626 | TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); | 7535 | TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
| @@ -7632,7 +7541,6 @@ decode_coding_gap (struct coding_system *coding, | |||
| 7632 | } | 7541 | } |
| 7633 | 7542 | ||
| 7634 | unbind_to (count, Qnil); | 7543 | unbind_to (count, Qnil); |
| 7635 | return coding->result; | ||
| 7636 | } | 7544 | } |
| 7637 | 7545 | ||
| 7638 | 7546 | ||
| @@ -7668,18 +7576,18 @@ decode_coding_gap (struct coding_system *coding, | |||
| 7668 | void | 7576 | void |
| 7669 | decode_coding_object (struct coding_system *coding, | 7577 | decode_coding_object (struct coding_system *coding, |
| 7670 | Lisp_Object src_object, | 7578 | Lisp_Object src_object, |
| 7671 | EMACS_INT from, EMACS_INT from_byte, | 7579 | ptrdiff_t from, ptrdiff_t from_byte, |
| 7672 | EMACS_INT to, EMACS_INT to_byte, | 7580 | ptrdiff_t to, ptrdiff_t to_byte, |
| 7673 | Lisp_Object dst_object) | 7581 | Lisp_Object dst_object) |
| 7674 | { | 7582 | { |
| 7675 | int count = SPECPDL_INDEX (); | 7583 | ptrdiff_t count = SPECPDL_INDEX (); |
| 7676 | unsigned char *destination IF_LINT (= NULL); | 7584 | unsigned char *destination IF_LINT (= NULL); |
| 7677 | EMACS_INT dst_bytes IF_LINT (= 0); | 7585 | ptrdiff_t dst_bytes IF_LINT (= 0); |
| 7678 | EMACS_INT chars = to - from; | 7586 | ptrdiff_t chars = to - from; |
| 7679 | EMACS_INT bytes = to_byte - from_byte; | 7587 | ptrdiff_t bytes = to_byte - from_byte; |
| 7680 | Lisp_Object attrs; | 7588 | Lisp_Object attrs; |
| 7681 | int saved_pt = -1, saved_pt_byte IF_LINT (= 0); | 7589 | ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0); |
| 7682 | int need_marker_adjustment = 0; | 7590 | bool need_marker_adjustment = 0; |
| 7683 | Lisp_Object old_deactivate_mark; | 7591 | Lisp_Object old_deactivate_mark; |
| 7684 | 7592 | ||
| 7685 | old_deactivate_mark = Vdeactivate_mark; | 7593 | old_deactivate_mark = Vdeactivate_mark; |
| @@ -7769,7 +7677,7 @@ decode_coding_object (struct coding_system *coding, | |||
| 7769 | if (! NILP (CODING_ATTR_POST_READ (attrs))) | 7677 | if (! NILP (CODING_ATTR_POST_READ (attrs))) |
| 7770 | { | 7678 | { |
| 7771 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 7679 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 7772 | EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; | 7680 | ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
| 7773 | Lisp_Object val; | 7681 | Lisp_Object val; |
| 7774 | 7682 | ||
| 7775 | TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); | 7683 | TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
| @@ -7858,17 +7766,17 @@ decode_coding_object (struct coding_system *coding, | |||
| 7858 | void | 7766 | void |
| 7859 | encode_coding_object (struct coding_system *coding, | 7767 | encode_coding_object (struct coding_system *coding, |
| 7860 | Lisp_Object src_object, | 7768 | Lisp_Object src_object, |
| 7861 | EMACS_INT from, EMACS_INT from_byte, | 7769 | ptrdiff_t from, ptrdiff_t from_byte, |
| 7862 | EMACS_INT to, EMACS_INT to_byte, | 7770 | ptrdiff_t to, ptrdiff_t to_byte, |
| 7863 | Lisp_Object dst_object) | 7771 | Lisp_Object dst_object) |
| 7864 | { | 7772 | { |
| 7865 | int count = SPECPDL_INDEX (); | 7773 | ptrdiff_t count = SPECPDL_INDEX (); |
| 7866 | EMACS_INT chars = to - from; | 7774 | ptrdiff_t chars = to - from; |
| 7867 | EMACS_INT bytes = to_byte - from_byte; | 7775 | ptrdiff_t bytes = to_byte - from_byte; |
| 7868 | Lisp_Object attrs; | 7776 | Lisp_Object attrs; |
| 7869 | int saved_pt = -1, saved_pt_byte IF_LINT (= 0); | 7777 | ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0); |
| 7870 | int need_marker_adjustment = 0; | 7778 | bool need_marker_adjustment = 0; |
| 7871 | int kill_src_buffer = 0; | 7779 | bool kill_src_buffer = 0; |
| 7872 | Lisp_Object old_deactivate_mark; | 7780 | Lisp_Object old_deactivate_mark; |
| 7873 | 7781 | ||
| 7874 | old_deactivate_mark = Vdeactivate_mark; | 7782 | old_deactivate_mark = Vdeactivate_mark; |
| @@ -7912,15 +7820,12 @@ encode_coding_object (struct coding_system *coding, | |||
| 7912 | } | 7820 | } |
| 7913 | 7821 | ||
| 7914 | { | 7822 | { |
| 7915 | Lisp_Object args[3]; | ||
| 7916 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 7823 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 7917 | 7824 | ||
| 7918 | GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, | 7825 | GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object, |
| 7919 | old_deactivate_mark); | 7826 | old_deactivate_mark); |
| 7920 | args[0] = CODING_ATTR_PRE_WRITE (attrs); | 7827 | safe_call2 (CODING_ATTR_PRE_WRITE (attrs), |
| 7921 | args[1] = make_number (BEG); | 7828 | make_number (BEG), make_number (Z)); |
| 7922 | args[2] = make_number (Z); | ||
| 7923 | safe_call (3, args); | ||
| 7924 | UNGCPRO; | 7829 | UNGCPRO; |
| 7925 | } | 7830 | } |
| 7926 | if (XBUFFER (coding->src_object) != current_buffer) | 7831 | if (XBUFFER (coding->src_object) != current_buffer) |
| @@ -7987,7 +7892,7 @@ encode_coding_object (struct coding_system *coding, | |||
| 7987 | { | 7892 | { |
| 7988 | ptrdiff_t dst_bytes = max (1, coding->src_chars); | 7893 | ptrdiff_t dst_bytes = max (1, coding->src_chars); |
| 7989 | coding->dst_object = Qnil; | 7894 | coding->dst_object = Qnil; |
| 7990 | coding->destination = (unsigned char *) xmalloc (dst_bytes); | 7895 | coding->destination = xmalloc (dst_bytes); |
| 7991 | coding->dst_bytes = dst_bytes; | 7896 | coding->dst_bytes = dst_bytes; |
| 7992 | coding->dst_multibyte = 0; | 7897 | coding->dst_multibyte = 0; |
| 7993 | } | 7898 | } |
| @@ -8070,6 +7975,40 @@ preferred_coding_system (void) | |||
| 8070 | return CODING_ID_NAME (id); | 7975 | return CODING_ID_NAME (id); |
| 8071 | } | 7976 | } |
| 8072 | 7977 | ||
| 7978 | #if defined (WINDOWSNT) || defined (CYGWIN) | ||
| 7979 | |||
| 7980 | Lisp_Object | ||
| 7981 | from_unicode (Lisp_Object str) | ||
| 7982 | { | ||
| 7983 | CHECK_STRING (str); | ||
| 7984 | if (!STRING_MULTIBYTE (str) && | ||
| 7985 | SBYTES (str) & 1) | ||
| 7986 | { | ||
| 7987 | str = Fsubstring (str, make_number (0), make_number (-1)); | ||
| 7988 | } | ||
| 7989 | |||
| 7990 | return code_convert_string_norecord (str, Qutf_16le, 0); | ||
| 7991 | } | ||
| 7992 | |||
| 7993 | wchar_t * | ||
| 7994 | to_unicode (Lisp_Object str, Lisp_Object *buf) | ||
| 7995 | { | ||
| 7996 | *buf = code_convert_string_norecord (str, Qutf_16le, 1); | ||
| 7997 | /* We need to make a another copy (in addition to the one made by | ||
| 7998 | code_convert_string_norecord) to ensure that the final string is | ||
| 7999 | _doubly_ zero terminated --- that is, that the string is | ||
| 8000 | terminated by two zero bytes and one utf-16le null character. | ||
| 8001 | Because strings are already terminated with a single zero byte, | ||
| 8002 | we just add one additional zero. */ | ||
| 8003 | str = make_uninit_string (SBYTES (*buf) + 1); | ||
| 8004 | memcpy (SDATA (str), SDATA (*buf), SBYTES (*buf)); | ||
| 8005 | SDATA (str) [SBYTES (*buf)] = '\0'; | ||
| 8006 | *buf = str; | ||
| 8007 | return WCSDATA (*buf); | ||
| 8008 | } | ||
| 8009 | |||
| 8010 | #endif /* WINDOWSNT || CYGWIN */ | ||
| 8011 | |||
| 8073 | 8012 | ||
| 8074 | #ifdef emacs | 8013 | #ifdef emacs |
| 8075 | /*** 8. Emacs Lisp library functions ***/ | 8014 | /*** 8. Emacs Lisp library functions ***/ |
| @@ -8112,7 +8051,7 @@ are lower-case). */) | |||
| 8112 | (Lisp_Object prompt, Lisp_Object default_coding_system) | 8051 | (Lisp_Object prompt, Lisp_Object default_coding_system) |
| 8113 | { | 8052 | { |
| 8114 | Lisp_Object val; | 8053 | Lisp_Object val; |
| 8115 | int count = SPECPDL_INDEX (); | 8054 | ptrdiff_t count = SPECPDL_INDEX (); |
| 8116 | 8055 | ||
| 8117 | if (SYMBOLP (default_coding_system)) | 8056 | if (SYMBOLP (default_coding_system)) |
| 8118 | default_coding_system = SYMBOL_NAME (default_coding_system); | 8057 | default_coding_system = SYMBOL_NAME (default_coding_system); |
| @@ -8147,10 +8086,10 @@ function `define-coding-system'. */) | |||
| 8147 | 8086 | ||
| 8148 | 8087 | ||
| 8149 | /* Detect how the bytes at SRC of length SRC_BYTES are encoded. If | 8088 | /* Detect how the bytes at SRC of length SRC_BYTES are encoded. If |
| 8150 | HIGHEST is nonzero, return the coding system of the highest | 8089 | HIGHEST, return the coding system of the highest |
| 8151 | priority among the detected coding systems. Otherwise return a | 8090 | priority among the detected coding systems. Otherwise return a |
| 8152 | list of detected coding systems sorted by their priorities. If | 8091 | list of detected coding systems sorted by their priorities. If |
| 8153 | MULTIBYTEP is nonzero, it is assumed that the bytes are in correct | 8092 | MULTIBYTEP, it is assumed that the bytes are in correct |
| 8154 | multibyte form but contains only ASCII and eight-bit chars. | 8093 | multibyte form but contains only ASCII and eight-bit chars. |
| 8155 | Otherwise, the bytes are raw bytes. | 8094 | Otherwise, the bytes are raw bytes. |
| 8156 | 8095 | ||
| @@ -8164,8 +8103,8 @@ function `define-coding-system'. */) | |||
| 8164 | 8103 | ||
| 8165 | Lisp_Object | 8104 | Lisp_Object |
| 8166 | detect_coding_system (const unsigned char *src, | 8105 | detect_coding_system (const unsigned char *src, |
| 8167 | EMACS_INT src_chars, EMACS_INT src_bytes, | 8106 | ptrdiff_t src_chars, ptrdiff_t src_bytes, |
| 8168 | int highest, int multibytep, | 8107 | bool highest, bool multibytep, |
| 8169 | Lisp_Object coding_system) | 8108 | Lisp_Object coding_system) |
| 8170 | { | 8109 | { |
| 8171 | const unsigned char *src_end = src + src_bytes; | 8110 | const unsigned char *src_end = src + src_bytes; |
| @@ -8175,7 +8114,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8175 | ptrdiff_t id; | 8114 | ptrdiff_t id; |
| 8176 | struct coding_detection_info detect_info; | 8115 | struct coding_detection_info detect_info; |
| 8177 | enum coding_category base_category; | 8116 | enum coding_category base_category; |
| 8178 | int null_byte_found = 0, eight_bit_found = 0; | 8117 | bool null_byte_found = 0, eight_bit_found = 0; |
| 8179 | 8118 | ||
| 8180 | if (NILP (coding_system)) | 8119 | if (NILP (coding_system)) |
| 8181 | coding_system = Qundecided; | 8120 | coding_system = Qundecided; |
| @@ -8484,8 +8423,8 @@ If optional argument HIGHEST is non-nil, return the coding system of | |||
| 8484 | highest priority. */) | 8423 | highest priority. */) |
| 8485 | (Lisp_Object start, Lisp_Object end, Lisp_Object highest) | 8424 | (Lisp_Object start, Lisp_Object end, Lisp_Object highest) |
| 8486 | { | 8425 | { |
| 8487 | int from, to; | 8426 | ptrdiff_t from, to; |
| 8488 | int from_byte, to_byte; | 8427 | ptrdiff_t from_byte, to_byte; |
| 8489 | 8428 | ||
| 8490 | CHECK_NUMBER_COERCE_MARKER (start); | 8429 | CHECK_NUMBER_COERCE_MARKER (start); |
| 8491 | CHECK_NUMBER_COERCE_MARKER (end); | 8430 | CHECK_NUMBER_COERCE_MARKER (end); |
| @@ -8531,7 +8470,7 @@ highest priority. */) | |||
| 8531 | } | 8470 | } |
| 8532 | 8471 | ||
| 8533 | 8472 | ||
| 8534 | static inline int | 8473 | static bool |
| 8535 | char_encodable_p (int c, Lisp_Object attrs) | 8474 | char_encodable_p (int c, Lisp_Object attrs) |
| 8536 | { | 8475 | { |
| 8537 | Lisp_Object tail; | 8476 | Lisp_Object tail; |
| @@ -8565,7 +8504,7 @@ DEFUN ("find-coding-systems-region-internal", | |||
| 8565 | (Lisp_Object start, Lisp_Object end, Lisp_Object exclude) | 8504 | (Lisp_Object start, Lisp_Object end, Lisp_Object exclude) |
| 8566 | { | 8505 | { |
| 8567 | Lisp_Object coding_attrs_list, safe_codings; | 8506 | Lisp_Object coding_attrs_list, safe_codings; |
| 8568 | EMACS_INT start_byte, end_byte; | 8507 | ptrdiff_t start_byte, end_byte; |
| 8569 | const unsigned char *p, *pbeg, *pend; | 8508 | const unsigned char *p, *pbeg, *pend; |
| 8570 | int c; | 8509 | int c; |
| 8571 | Lisp_Object tail, elt, work_table; | 8510 | Lisp_Object tail, elt, work_table; |
| @@ -8659,7 +8598,7 @@ DEFUN ("find-coding-systems-region-internal", | |||
| 8659 | } | 8598 | } |
| 8660 | if (charset_map_loaded) | 8599 | if (charset_map_loaded) |
| 8661 | { | 8600 | { |
| 8662 | EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | 8601 | ptrdiff_t p_offset = p - pbeg, pend_offset = pend - pbeg; |
| 8663 | 8602 | ||
| 8664 | if (STRINGP (start)) | 8603 | if (STRINGP (start)) |
| 8665 | pbeg = SDATA (start); | 8604 | pbeg = SDATA (start); |
| @@ -8697,13 +8636,13 @@ for un-encodable characters. In that case, START and END are indexes | |||
| 8697 | to the string. */) | 8636 | to the string. */) |
| 8698 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) | 8637 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) |
| 8699 | { | 8638 | { |
| 8700 | int n; | 8639 | EMACS_INT n; |
| 8701 | struct coding_system coding; | 8640 | struct coding_system coding; |
| 8702 | Lisp_Object attrs, charset_list, translation_table; | 8641 | Lisp_Object attrs, charset_list, translation_table; |
| 8703 | Lisp_Object positions; | 8642 | Lisp_Object positions; |
| 8704 | int from, to; | 8643 | ptrdiff_t from, to; |
| 8705 | const unsigned char *p, *stop, *pend; | 8644 | const unsigned char *p, *stop, *pend; |
| 8706 | int ascii_compatible; | 8645 | bool ascii_compatible; |
| 8707 | 8646 | ||
| 8708 | setup_coding_system (Fcheck_coding_system (coding_system), &coding); | 8647 | setup_coding_system (Fcheck_coding_system (coding_system), &coding); |
| 8709 | attrs = CODING_ID_ATTRS (coding.id); | 8648 | attrs = CODING_ID_ATTRS (coding.id); |
| @@ -8734,11 +8673,10 @@ to the string. */) | |||
| 8734 | CHECK_STRING (string); | 8673 | CHECK_STRING (string); |
| 8735 | CHECK_NATNUM (start); | 8674 | CHECK_NATNUM (start); |
| 8736 | CHECK_NATNUM (end); | 8675 | CHECK_NATNUM (end); |
| 8676 | if (! (XINT (start) <= XINT (end) && XINT (end) <= SCHARS (string))) | ||
| 8677 | args_out_of_range_3 (string, start, end); | ||
| 8737 | from = XINT (start); | 8678 | from = XINT (start); |
| 8738 | to = XINT (end); | 8679 | to = XINT (end); |
| 8739 | if (from > to | ||
| 8740 | || to > SCHARS (string)) | ||
| 8741 | args_out_of_range_3 (string, start, end); | ||
| 8742 | if (! STRING_MULTIBYTE (string)) | 8680 | if (! STRING_MULTIBYTE (string)) |
| 8743 | return Qnil; | 8681 | return Qnil; |
| 8744 | p = SDATA (string) + string_char_to_byte (string, from); | 8682 | p = SDATA (string) + string_char_to_byte (string, from); |
| @@ -8824,8 +8762,8 @@ is nil. */) | |||
| 8824 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list) | 8762 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list) |
| 8825 | { | 8763 | { |
| 8826 | Lisp_Object list; | 8764 | Lisp_Object list; |
| 8827 | EMACS_INT start_byte, end_byte; | 8765 | ptrdiff_t start_byte, end_byte; |
| 8828 | int pos; | 8766 | ptrdiff_t pos; |
| 8829 | const unsigned char *p, *pbeg, *pend; | 8767 | const unsigned char *p, *pbeg, *pend; |
| 8830 | int c; | 8768 | int c; |
| 8831 | Lisp_Object tail, elt, attrs; | 8769 | Lisp_Object tail, elt, attrs; |
| @@ -8898,7 +8836,7 @@ is nil. */) | |||
| 8898 | } | 8836 | } |
| 8899 | if (charset_map_loaded) | 8837 | if (charset_map_loaded) |
| 8900 | { | 8838 | { |
| 8901 | EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | 8839 | ptrdiff_t p_offset = p - pbeg, pend_offset = pend - pbeg; |
| 8902 | 8840 | ||
| 8903 | if (STRINGP (start)) | 8841 | if (STRINGP (start)) |
| 8904 | pbeg = SDATA (start); | 8842 | pbeg = SDATA (start); |
| @@ -8928,10 +8866,10 @@ is nil. */) | |||
| 8928 | static Lisp_Object | 8866 | static Lisp_Object |
| 8929 | code_convert_region (Lisp_Object start, Lisp_Object end, | 8867 | code_convert_region (Lisp_Object start, Lisp_Object end, |
| 8930 | Lisp_Object coding_system, Lisp_Object dst_object, | 8868 | Lisp_Object coding_system, Lisp_Object dst_object, |
| 8931 | int encodep, int norecord) | 8869 | bool encodep, bool norecord) |
| 8932 | { | 8870 | { |
| 8933 | struct coding_system coding; | 8871 | struct coding_system coding; |
| 8934 | EMACS_INT from, from_byte, to, to_byte; | 8872 | ptrdiff_t from, from_byte, to, to_byte; |
| 8935 | Lisp_Object src_object; | 8873 | Lisp_Object src_object; |
| 8936 | 8874 | ||
| 8937 | CHECK_NUMBER_COERCE_MARKER (start); | 8875 | CHECK_NUMBER_COERCE_MARKER (start); |
| @@ -9016,10 +8954,11 @@ not fully specified.) */) | |||
| 9016 | 8954 | ||
| 9017 | Lisp_Object | 8955 | Lisp_Object |
| 9018 | code_convert_string (Lisp_Object string, Lisp_Object coding_system, | 8956 | code_convert_string (Lisp_Object string, Lisp_Object coding_system, |
| 9019 | Lisp_Object dst_object, int encodep, int nocopy, int norecord) | 8957 | Lisp_Object dst_object, bool encodep, bool nocopy, |
| 8958 | bool norecord) | ||
| 9020 | { | 8959 | { |
| 9021 | struct coding_system coding; | 8960 | struct coding_system coding; |
| 9022 | EMACS_INT chars, bytes; | 8961 | ptrdiff_t chars, bytes; |
| 9023 | 8962 | ||
| 9024 | CHECK_STRING (string); | 8963 | CHECK_STRING (string); |
| 9025 | if (NILP (coding_system)) | 8964 | if (NILP (coding_system)) |
| @@ -9064,7 +9003,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system, | |||
| 9064 | 9003 | ||
| 9065 | Lisp_Object | 9004 | Lisp_Object |
| 9066 | code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, | 9005 | code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, |
| 9067 | int encodep) | 9006 | bool encodep) |
| 9068 | { | 9007 | { |
| 9069 | return code_convert_string (string, coding_system, Qt, encodep, 0, 1); | 9008 | return code_convert_string (string, coding_system, Qt, encodep, 0, 1); |
| 9070 | } | 9009 | } |
| @@ -9278,10 +9217,10 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern | |||
| 9278 | terminal_coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; | 9217 | terminal_coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK; |
| 9279 | terminal_coding->src_multibyte = 1; | 9218 | terminal_coding->src_multibyte = 1; |
| 9280 | terminal_coding->dst_multibyte = 0; | 9219 | terminal_coding->dst_multibyte = 0; |
| 9281 | if (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK) | 9220 | tset_charset_list |
| 9282 | term->charset_list = coding_charset_list (terminal_coding); | 9221 | (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK |
| 9283 | else | 9222 | ? coding_charset_list (terminal_coding) |
| 9284 | term->charset_list = Fcons (make_number (charset_ascii), Qnil); | 9223 | : Fcons (make_number (charset_ascii), Qnil))); |
| 9285 | return Qnil; | 9224 | return Qnil; |
| 9286 | } | 9225 | } |
| 9287 | 9226 | ||
| @@ -9394,9 +9333,9 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) | |||
| 9394 | error ("Too few arguments"); | 9333 | error ("Too few arguments"); |
| 9395 | operation = args[0]; | 9334 | operation = args[0]; |
| 9396 | if (!SYMBOLP (operation) | 9335 | if (!SYMBOLP (operation) |
| 9397 | || !NATNUMP (target_idx = Fget (operation, Qtarget_idx))) | 9336 | || (target_idx = Fget (operation, Qtarget_idx), !NATNUMP (target_idx))) |
| 9398 | error ("Invalid first argument"); | 9337 | error ("Invalid first argument"); |
| 9399 | if (nargs < 1 + XFASTINT (target_idx)) | 9338 | if (nargs <= 1 + XFASTINT (target_idx)) |
| 9400 | error ("Too few arguments for operation `%s'", | 9339 | error ("Too few arguments for operation `%s'", |
| 9401 | SDATA (SYMBOL_NAME (operation))); | 9340 | SDATA (SYMBOL_NAME (operation))); |
| 9402 | target = args[XFASTINT (target_idx) + 1]; | 9341 | target = args[XFASTINT (target_idx) + 1]; |
| @@ -9465,7 +9404,7 @@ usage: (set-coding-system-priority &rest coding-systems) */) | |||
| 9465 | (ptrdiff_t nargs, Lisp_Object *args) | 9404 | (ptrdiff_t nargs, Lisp_Object *args) |
| 9466 | { | 9405 | { |
| 9467 | ptrdiff_t i, j; | 9406 | ptrdiff_t i, j; |
| 9468 | int changed[coding_category_max]; | 9407 | bool changed[coding_category_max]; |
| 9469 | enum coding_category priorities[coding_category_max]; | 9408 | enum coding_category priorities[coding_category_max]; |
| 9470 | 9409 | ||
| 9471 | memset (changed, 0, sizeof changed); | 9410 | memset (changed, 0, sizeof changed); |
| @@ -9499,7 +9438,7 @@ usage: (set-coding-system-priority &rest coding-systems) */) | |||
| 9499 | && changed[coding_priorities[j]]) | 9438 | && changed[coding_priorities[j]]) |
| 9500 | j++; | 9439 | j++; |
| 9501 | if (j == coding_category_max) | 9440 | if (j == coding_category_max) |
| 9502 | abort (); | 9441 | emacs_abort (); |
| 9503 | priorities[i] = coding_priorities[j]; | 9442 | priorities[i] = coding_priorities[j]; |
| 9504 | } | 9443 | } |
| 9505 | 9444 | ||
| @@ -9550,7 +9489,7 @@ make_subsidiaries (Lisp_Object base) | |||
| 9550 | { | 9489 | { |
| 9551 | Lisp_Object subsidiaries; | 9490 | Lisp_Object subsidiaries; |
| 9552 | ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base)); | 9491 | ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base)); |
| 9553 | char *buf = (char *) alloca (base_name_len + 6); | 9492 | char *buf = alloca (base_name_len + 6); |
| 9554 | int i; | 9493 | int i; |
| 9555 | 9494 | ||
| 9556 | memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); | 9495 | memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len); |
| @@ -9588,16 +9527,16 @@ usage: (define-coding-system-internal ...) */) | |||
| 9588 | 9527 | ||
| 9589 | name = args[coding_arg_name]; | 9528 | name = args[coding_arg_name]; |
| 9590 | CHECK_SYMBOL (name); | 9529 | CHECK_SYMBOL (name); |
| 9591 | CODING_ATTR_BASE_NAME (attrs) = name; | 9530 | ASET (attrs, coding_attr_base_name, name); |
| 9592 | 9531 | ||
| 9593 | val = args[coding_arg_mnemonic]; | 9532 | val = args[coding_arg_mnemonic]; |
| 9594 | if (! STRINGP (val)) | 9533 | if (! STRINGP (val)) |
| 9595 | CHECK_CHARACTER (val); | 9534 | CHECK_CHARACTER (val); |
| 9596 | CODING_ATTR_MNEMONIC (attrs) = val; | 9535 | ASET (attrs, coding_attr_mnemonic, val); |
| 9597 | 9536 | ||
| 9598 | coding_type = args[coding_arg_coding_type]; | 9537 | coding_type = args[coding_arg_coding_type]; |
| 9599 | CHECK_SYMBOL (coding_type); | 9538 | CHECK_SYMBOL (coding_type); |
| 9600 | CODING_ATTR_TYPE (attrs) = coding_type; | 9539 | ASET (attrs, coding_attr_type, coding_type); |
| 9601 | 9540 | ||
| 9602 | charset_list = args[coding_arg_charset_list]; | 9541 | charset_list = args[coding_arg_charset_list]; |
| 9603 | if (SYMBOLP (charset_list)) | 9542 | if (SYMBOLP (charset_list)) |
| @@ -9615,8 +9554,12 @@ usage: (define-coding-system-internal ...) */) | |||
| 9615 | charset_list = Vemacs_mule_charset_list; | 9554 | charset_list = Vemacs_mule_charset_list; |
| 9616 | } | 9555 | } |
| 9617 | for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | 9556 | for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
| 9618 | if (max_charset_id < XFASTINT (XCAR (tail))) | 9557 | { |
| 9619 | max_charset_id = XFASTINT (XCAR (tail)); | 9558 | if (! RANGED_INTEGERP (0, XCAR (tail), INT_MAX - 1)) |
| 9559 | error ("Invalid charset-list"); | ||
| 9560 | if (max_charset_id < XFASTINT (XCAR (tail))) | ||
| 9561 | max_charset_id = XFASTINT (XCAR (tail)); | ||
| 9562 | } | ||
| 9620 | } | 9563 | } |
| 9621 | else | 9564 | else |
| 9622 | { | 9565 | { |
| @@ -9640,49 +9583,49 @@ usage: (define-coding-system-internal ...) */) | |||
| 9640 | max_charset_id = charset->id; | 9583 | max_charset_id = charset->id; |
| 9641 | } | 9584 | } |
| 9642 | } | 9585 | } |
| 9643 | CODING_ATTR_CHARSET_LIST (attrs) = charset_list; | 9586 | ASET (attrs, coding_attr_charset_list, charset_list); |
| 9644 | 9587 | ||
| 9645 | safe_charsets = make_uninit_string (max_charset_id + 1); | 9588 | safe_charsets = make_uninit_string (max_charset_id + 1); |
| 9646 | memset (SDATA (safe_charsets), 255, max_charset_id + 1); | 9589 | memset (SDATA (safe_charsets), 255, max_charset_id + 1); |
| 9647 | for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | 9590 | for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
| 9648 | SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); | 9591 | SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); |
| 9649 | CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets; | 9592 | ASET (attrs, coding_attr_safe_charsets, safe_charsets); |
| 9650 | 9593 | ||
| 9651 | CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p]; | 9594 | ASET (attrs, coding_attr_ascii_compat, args[coding_arg_ascii_compatible_p]); |
| 9652 | 9595 | ||
| 9653 | val = args[coding_arg_decode_translation_table]; | 9596 | val = args[coding_arg_decode_translation_table]; |
| 9654 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) | 9597 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
| 9655 | CHECK_SYMBOL (val); | 9598 | CHECK_SYMBOL (val); |
| 9656 | CODING_ATTR_DECODE_TBL (attrs) = val; | 9599 | ASET (attrs, coding_attr_decode_tbl, val); |
| 9657 | 9600 | ||
| 9658 | val = args[coding_arg_encode_translation_table]; | 9601 | val = args[coding_arg_encode_translation_table]; |
| 9659 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) | 9602 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
| 9660 | CHECK_SYMBOL (val); | 9603 | CHECK_SYMBOL (val); |
| 9661 | CODING_ATTR_ENCODE_TBL (attrs) = val; | 9604 | ASET (attrs, coding_attr_encode_tbl, val); |
| 9662 | 9605 | ||
| 9663 | val = args[coding_arg_post_read_conversion]; | 9606 | val = args[coding_arg_post_read_conversion]; |
| 9664 | CHECK_SYMBOL (val); | 9607 | CHECK_SYMBOL (val); |
| 9665 | CODING_ATTR_POST_READ (attrs) = val; | 9608 | ASET (attrs, coding_attr_post_read, val); |
| 9666 | 9609 | ||
| 9667 | val = args[coding_arg_pre_write_conversion]; | 9610 | val = args[coding_arg_pre_write_conversion]; |
| 9668 | CHECK_SYMBOL (val); | 9611 | CHECK_SYMBOL (val); |
| 9669 | CODING_ATTR_PRE_WRITE (attrs) = val; | 9612 | ASET (attrs, coding_attr_pre_write, val); |
| 9670 | 9613 | ||
| 9671 | val = args[coding_arg_default_char]; | 9614 | val = args[coding_arg_default_char]; |
| 9672 | if (NILP (val)) | 9615 | if (NILP (val)) |
| 9673 | CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' '); | 9616 | ASET (attrs, coding_attr_default_char, make_number (' ')); |
| 9674 | else | 9617 | else |
| 9675 | { | 9618 | { |
| 9676 | CHECK_CHARACTER (val); | 9619 | CHECK_CHARACTER (val); |
| 9677 | CODING_ATTR_DEFAULT_CHAR (attrs) = val; | 9620 | ASET (attrs, coding_attr_default_char, val); |
| 9678 | } | 9621 | } |
| 9679 | 9622 | ||
| 9680 | val = args[coding_arg_for_unibyte]; | 9623 | val = args[coding_arg_for_unibyte]; |
| 9681 | CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt; | 9624 | ASET (attrs, coding_attr_for_unibyte, NILP (val) ? Qnil : Qt); |
| 9682 | 9625 | ||
| 9683 | val = args[coding_arg_plist]; | 9626 | val = args[coding_arg_plist]; |
| 9684 | CHECK_LIST (val); | 9627 | CHECK_LIST (val); |
| 9685 | CODING_ATTR_PLIST (attrs) = val; | 9628 | ASET (attrs, coding_attr_plist, val); |
| 9686 | 9629 | ||
| 9687 | if (EQ (coding_type, Qcharset)) | 9630 | if (EQ (coding_type, Qcharset)) |
| 9688 | { | 9631 | { |
| @@ -9707,7 +9650,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 9707 | int idx = (dim - 1) * 4; | 9650 | int idx = (dim - 1) * 4; |
| 9708 | 9651 | ||
| 9709 | if (CHARSET_ASCII_COMPATIBLE_P (charset)) | 9652 | if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
| 9710 | CODING_ATTR_ASCII_COMPAT (attrs) = Qt; | 9653 | ASET (attrs, coding_attr_ascii_compat, Qt); |
| 9711 | 9654 | ||
| 9712 | for (i = charset->code_space[idx]; | 9655 | for (i = charset->code_space[idx]; |
| 9713 | i <= charset->code_space[idx + 1]; i++) | 9656 | i <= charset->code_space[idx + 1]; i++) |
| @@ -9769,30 +9712,30 @@ usage: (define-coding-system-internal ...) */) | |||
| 9769 | 9712 | ||
| 9770 | val = args[coding_arg_ccl_valids]; | 9713 | val = args[coding_arg_ccl_valids]; |
| 9771 | valids = Fmake_string (make_number (256), make_number (0)); | 9714 | valids = Fmake_string (make_number (256), make_number (0)); |
| 9772 | for (tail = val; !NILP (tail); tail = Fcdr (tail)) | 9715 | for (tail = val; CONSP (tail); tail = XCDR (tail)) |
| 9773 | { | 9716 | { |
| 9774 | int from, to; | 9717 | int from, to; |
| 9775 | 9718 | ||
| 9776 | val = Fcar (tail); | 9719 | val = XCAR (tail); |
| 9777 | if (INTEGERP (val)) | 9720 | if (INTEGERP (val)) |
| 9778 | { | 9721 | { |
| 9779 | from = to = XINT (val); | 9722 | if (! (0 <= XINT (val) && XINT (val) <= 255)) |
| 9780 | if (from < 0 || from > 255) | ||
| 9781 | args_out_of_range_3 (val, make_number (0), make_number (255)); | 9723 | args_out_of_range_3 (val, make_number (0), make_number (255)); |
| 9724 | from = to = XINT (val); | ||
| 9782 | } | 9725 | } |
| 9783 | else | 9726 | else |
| 9784 | { | 9727 | { |
| 9785 | CHECK_CONS (val); | 9728 | CHECK_CONS (val); |
| 9786 | CHECK_NATNUM_CAR (val); | 9729 | CHECK_NATNUM_CAR (val); |
| 9787 | CHECK_NATNUM_CDR (val); | 9730 | CHECK_NUMBER_CDR (val); |
| 9788 | from = XINT (XCAR (val)); | 9731 | if (XINT (XCAR (val)) > 255) |
| 9789 | if (from > 255) | ||
| 9790 | args_out_of_range_3 (XCAR (val), | 9732 | args_out_of_range_3 (XCAR (val), |
| 9791 | make_number (0), make_number (255)); | 9733 | make_number (0), make_number (255)); |
| 9792 | to = XINT (XCDR (val)); | 9734 | from = XINT (XCAR (val)); |
| 9793 | if (to < from || to > 255) | 9735 | if (! (from <= XINT (XCDR (val)) && XINT (XCDR (val)) <= 255)) |
| 9794 | args_out_of_range_3 (XCDR (val), | 9736 | args_out_of_range_3 (XCDR (val), |
| 9795 | XCAR (val), make_number (255)); | 9737 | XCAR (val), make_number (255)); |
| 9738 | to = XINT (XCDR (val)); | ||
| 9796 | } | 9739 | } |
| 9797 | for (i = from; i <= to; i++) | 9740 | for (i = from; i <= to; i++) |
| 9798 | SSET (valids, i, 1); | 9741 | SSET (valids, i, 1); |
| @@ -9805,7 +9748,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 9805 | { | 9748 | { |
| 9806 | Lisp_Object bom, endian; | 9749 | Lisp_Object bom, endian; |
| 9807 | 9750 | ||
| 9808 | CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; | 9751 | ASET (attrs, coding_attr_ascii_compat, Qnil); |
| 9809 | 9752 | ||
| 9810 | if (nargs < coding_arg_utf16_max) | 9753 | if (nargs < coding_arg_utf16_max) |
| 9811 | goto short_args; | 9754 | goto short_args; |
| @@ -9858,7 +9801,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 9858 | CHECK_CHARSET_GET_CHARSET (val, charset); | 9801 | CHECK_CHARSET_GET_CHARSET (val, charset); |
| 9859 | ASET (initial, i, make_number (CHARSET_ID (charset))); | 9802 | ASET (initial, i, make_number (CHARSET_ID (charset))); |
| 9860 | if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset)) | 9803 | if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset)) |
| 9861 | CODING_ATTR_ASCII_COMPAT (attrs) = Qt; | 9804 | ASET (attrs, coding_attr_ascii_compat, Qt); |
| 9862 | } | 9805 | } |
| 9863 | else | 9806 | else |
| 9864 | ASET (initial, i, make_number (-1)); | 9807 | ASET (initial, i, make_number (-1)); |
| @@ -9870,12 +9813,12 @@ usage: (define-coding-system-internal ...) */) | |||
| 9870 | CHECK_NUMBER_CDR (reg_usage); | 9813 | CHECK_NUMBER_CDR (reg_usage); |
| 9871 | 9814 | ||
| 9872 | request = Fcopy_sequence (args[coding_arg_iso2022_request]); | 9815 | request = Fcopy_sequence (args[coding_arg_iso2022_request]); |
| 9873 | for (tail = request; ! NILP (tail); tail = Fcdr (tail)) | 9816 | for (tail = request; CONSP (tail); tail = XCDR (tail)) |
| 9874 | { | 9817 | { |
| 9875 | int id; | 9818 | int id; |
| 9876 | Lisp_Object tmp1; | 9819 | Lisp_Object tmp1; |
| 9877 | 9820 | ||
| 9878 | val = Fcar (tail); | 9821 | val = XCAR (tail); |
| 9879 | CHECK_CONS (val); | 9822 | CHECK_CONS (val); |
| 9880 | tmp1 = XCAR (val); | 9823 | tmp1 = XCAR (val); |
| 9881 | CHECK_CHARSET_GET_ID (tmp1, id); | 9824 | CHECK_CHARSET_GET_ID (tmp1, id); |
| @@ -9887,9 +9830,10 @@ usage: (define-coding-system-internal ...) */) | |||
| 9887 | 9830 | ||
| 9888 | flags = args[coding_arg_iso2022_flags]; | 9831 | flags = args[coding_arg_iso2022_flags]; |
| 9889 | CHECK_NATNUM (flags); | 9832 | CHECK_NATNUM (flags); |
| 9890 | i = XINT (flags); | 9833 | i = XINT (flags) & INT_MAX; |
| 9891 | if (EQ (args[coding_arg_charset_list], Qiso_2022)) | 9834 | if (EQ (args[coding_arg_charset_list], Qiso_2022)) |
| 9892 | flags = make_number (i | CODING_ISO_FLAG_FULL_SUPPORT); | 9835 | i |= CODING_ISO_FLAG_FULL_SUPPORT; |
| 9836 | flags = make_number (i); | ||
| 9893 | 9837 | ||
| 9894 | ASET (attrs, coding_attr_iso_initial, initial); | 9838 | ASET (attrs, coding_attr_iso_initial, initial); |
| 9895 | ASET (attrs, coding_attr_iso_usage, reg_usage); | 9839 | ASET (attrs, coding_attr_iso_usage, reg_usage); |
| @@ -9918,13 +9862,13 @@ usage: (define-coding-system-internal ...) */) | |||
| 9918 | } | 9862 | } |
| 9919 | if (category != coding_category_iso_8_1 | 9863 | if (category != coding_category_iso_8_1 |
| 9920 | && category != coding_category_iso_8_2) | 9864 | && category != coding_category_iso_8_2) |
| 9921 | CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; | 9865 | ASET (attrs, coding_attr_ascii_compat, Qnil); |
| 9922 | } | 9866 | } |
| 9923 | else if (EQ (coding_type, Qemacs_mule)) | 9867 | else if (EQ (coding_type, Qemacs_mule)) |
| 9924 | { | 9868 | { |
| 9925 | if (EQ (args[coding_arg_charset_list], Qemacs_mule)) | 9869 | if (EQ (args[coding_arg_charset_list], Qemacs_mule)) |
| 9926 | ASET (attrs, coding_attr_emacs_mule_full, Qt); | 9870 | ASET (attrs, coding_attr_emacs_mule_full, Qt); |
| 9927 | CODING_ATTR_ASCII_COMPAT (attrs) = Qt; | 9871 | ASET (attrs, coding_attr_ascii_compat, Qt); |
| 9928 | category = coding_category_emacs_mule; | 9872 | category = coding_category_emacs_mule; |
| 9929 | } | 9873 | } |
| 9930 | else if (EQ (coding_type, Qshift_jis)) | 9874 | else if (EQ (coding_type, Qshift_jis)) |
| @@ -9941,7 +9885,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 9941 | error ("Dimension of charset %s is not one", | 9885 | error ("Dimension of charset %s is not one", |
| 9942 | SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); | 9886 | SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 9943 | if (CHARSET_ASCII_COMPATIBLE_P (charset)) | 9887 | if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
| 9944 | CODING_ATTR_ASCII_COMPAT (attrs) = Qt; | 9888 | ASET (attrs, coding_attr_ascii_compat, Qt); |
| 9945 | 9889 | ||
| 9946 | charset_list = XCDR (charset_list); | 9890 | charset_list = XCDR (charset_list); |
| 9947 | charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | 9891 | charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); |
| @@ -9979,7 +9923,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 9979 | error ("Dimension of charset %s is not one", | 9923 | error ("Dimension of charset %s is not one", |
| 9980 | SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); | 9924 | SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); |
| 9981 | if (CHARSET_ASCII_COMPATIBLE_P (charset)) | 9925 | if (CHARSET_ASCII_COMPATIBLE_P (charset)) |
| 9982 | CODING_ATTR_ASCII_COMPAT (attrs) = Qt; | 9926 | ASET (attrs, coding_attr_ascii_compat, Qt); |
| 9983 | 9927 | ||
| 9984 | charset_list = XCDR (charset_list); | 9928 | charset_list = XCDR (charset_list); |
| 9985 | charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); | 9929 | charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); |
| @@ -9993,14 +9937,12 @@ usage: (define-coding-system-internal ...) */) | |||
| 9993 | else if (EQ (coding_type, Qraw_text)) | 9937 | else if (EQ (coding_type, Qraw_text)) |
| 9994 | { | 9938 | { |
| 9995 | category = coding_category_raw_text; | 9939 | category = coding_category_raw_text; |
| 9996 | CODING_ATTR_ASCII_COMPAT (attrs) = Qt; | 9940 | ASET (attrs, coding_attr_ascii_compat, Qt); |
| 9997 | } | 9941 | } |
| 9998 | else if (EQ (coding_type, Qutf_8)) | 9942 | else if (EQ (coding_type, Qutf_8)) |
| 9999 | { | 9943 | { |
| 10000 | Lisp_Object bom; | 9944 | Lisp_Object bom; |
| 10001 | 9945 | ||
| 10002 | CODING_ATTR_ASCII_COMPAT (attrs) = Qt; | ||
| 10003 | |||
| 10004 | if (nargs < coding_arg_utf8_max) | 9946 | if (nargs < coding_arg_utf8_max) |
| 10005 | goto short_args; | 9947 | goto short_args; |
| 10006 | 9948 | ||
| @@ -10014,6 +9956,8 @@ usage: (define-coding-system-internal ...) */) | |||
| 10014 | CHECK_CODING_SYSTEM (val); | 9956 | CHECK_CODING_SYSTEM (val); |
| 10015 | } | 9957 | } |
| 10016 | ASET (attrs, coding_attr_utf_bom, bom); | 9958 | ASET (attrs, coding_attr_utf_bom, bom); |
| 9959 | if (NILP (bom)) | ||
| 9960 | ASET (attrs, coding_attr_ascii_compat, Qt); | ||
| 10017 | 9961 | ||
| 10018 | category = (CONSP (bom) ? coding_category_utf_8_auto | 9962 | category = (CONSP (bom) ? coding_category_utf_8_auto |
| 10019 | : NILP (bom) ? coding_category_utf_8_nosig | 9963 | : NILP (bom) ? coding_category_utf_8_nosig |
| @@ -10025,14 +9969,15 @@ usage: (define-coding-system-internal ...) */) | |||
| 10025 | error ("Invalid coding system type: %s", | 9969 | error ("Invalid coding system type: %s", |
| 10026 | SDATA (SYMBOL_NAME (coding_type))); | 9970 | SDATA (SYMBOL_NAME (coding_type))); |
| 10027 | 9971 | ||
| 10028 | CODING_ATTR_CATEGORY (attrs) = make_number (category); | 9972 | ASET (attrs, coding_attr_category, make_number (category)); |
| 10029 | CODING_ATTR_PLIST (attrs) | 9973 | ASET (attrs, coding_attr_plist, |
| 10030 | = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), | 9974 | Fcons (QCcategory, |
| 10031 | CODING_ATTR_PLIST (attrs))); | 9975 | Fcons (AREF (Vcoding_category_table, category), |
| 10032 | CODING_ATTR_PLIST (attrs) | 9976 | CODING_ATTR_PLIST (attrs)))); |
| 10033 | = Fcons (QCascii_compatible_p, | 9977 | ASET (attrs, coding_attr_plist, |
| 10034 | Fcons (CODING_ATTR_ASCII_COMPAT (attrs), | 9978 | Fcons (QCascii_compatible_p, |
| 10035 | CODING_ATTR_PLIST (attrs))); | 9979 | Fcons (CODING_ATTR_ASCII_COMPAT (attrs), |
| 9980 | CODING_ATTR_PLIST (attrs)))); | ||
| 10036 | 9981 | ||
| 10037 | eol_type = args[coding_arg_eol_type]; | 9982 | eol_type = args[coding_arg_eol_type]; |
| 10038 | if (! NILP (eol_type) | 9983 | if (! NILP (eol_type) |
| @@ -10106,7 +10051,7 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, | |||
| 10106 | { | 10051 | { |
| 10107 | if (! STRINGP (val)) | 10052 | if (! STRINGP (val)) |
| 10108 | CHECK_CHARACTER (val); | 10053 | CHECK_CHARACTER (val); |
| 10109 | CODING_ATTR_MNEMONIC (attrs) = val; | 10054 | ASET (attrs, coding_attr_mnemonic, val); |
| 10110 | } | 10055 | } |
| 10111 | else if (EQ (prop, QCdefault_char)) | 10056 | else if (EQ (prop, QCdefault_char)) |
| 10112 | { | 10057 | { |
| @@ -10114,37 +10059,37 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, | |||
| 10114 | val = make_number (' '); | 10059 | val = make_number (' '); |
| 10115 | else | 10060 | else |
| 10116 | CHECK_CHARACTER (val); | 10061 | CHECK_CHARACTER (val); |
| 10117 | CODING_ATTR_DEFAULT_CHAR (attrs) = val; | 10062 | ASET (attrs, coding_attr_default_char, val); |
| 10118 | } | 10063 | } |
| 10119 | else if (EQ (prop, QCdecode_translation_table)) | 10064 | else if (EQ (prop, QCdecode_translation_table)) |
| 10120 | { | 10065 | { |
| 10121 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) | 10066 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
| 10122 | CHECK_SYMBOL (val); | 10067 | CHECK_SYMBOL (val); |
| 10123 | CODING_ATTR_DECODE_TBL (attrs) = val; | 10068 | ASET (attrs, coding_attr_decode_tbl, val); |
| 10124 | } | 10069 | } |
| 10125 | else if (EQ (prop, QCencode_translation_table)) | 10070 | else if (EQ (prop, QCencode_translation_table)) |
| 10126 | { | 10071 | { |
| 10127 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) | 10072 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
| 10128 | CHECK_SYMBOL (val); | 10073 | CHECK_SYMBOL (val); |
| 10129 | CODING_ATTR_ENCODE_TBL (attrs) = val; | 10074 | ASET (attrs, coding_attr_encode_tbl, val); |
| 10130 | } | 10075 | } |
| 10131 | else if (EQ (prop, QCpost_read_conversion)) | 10076 | else if (EQ (prop, QCpost_read_conversion)) |
| 10132 | { | 10077 | { |
| 10133 | CHECK_SYMBOL (val); | 10078 | CHECK_SYMBOL (val); |
| 10134 | CODING_ATTR_POST_READ (attrs) = val; | 10079 | ASET (attrs, coding_attr_post_read, val); |
| 10135 | } | 10080 | } |
| 10136 | else if (EQ (prop, QCpre_write_conversion)) | 10081 | else if (EQ (prop, QCpre_write_conversion)) |
| 10137 | { | 10082 | { |
| 10138 | CHECK_SYMBOL (val); | 10083 | CHECK_SYMBOL (val); |
| 10139 | CODING_ATTR_PRE_WRITE (attrs) = val; | 10084 | ASET (attrs, coding_attr_pre_write, val); |
| 10140 | } | 10085 | } |
| 10141 | else if (EQ (prop, QCascii_compatible_p)) | 10086 | else if (EQ (prop, QCascii_compatible_p)) |
| 10142 | { | 10087 | { |
| 10143 | CODING_ATTR_ASCII_COMPAT (attrs) = val; | 10088 | ASET (attrs, coding_attr_ascii_compat, val); |
| 10144 | } | 10089 | } |
| 10145 | 10090 | ||
| 10146 | CODING_ATTR_PLIST (attrs) | 10091 | ASET (attrs, coding_attr_plist, |
| 10147 | = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); | 10092 | Fplist_put (CODING_ATTR_PLIST (attrs), prop, val)); |
| 10148 | return val; | 10093 | return val; |
| 10149 | } | 10094 | } |
| 10150 | 10095 | ||
| @@ -10327,7 +10272,7 @@ syms_of_coding (void) | |||
| 10327 | Vcode_conversion_reused_workbuf = Qnil; | 10272 | Vcode_conversion_reused_workbuf = Qnil; |
| 10328 | 10273 | ||
| 10329 | staticpro (&Vcode_conversion_workbuf_name); | 10274 | staticpro (&Vcode_conversion_workbuf_name); |
| 10330 | Vcode_conversion_workbuf_name = make_pure_c_string (" *code-conversion-work*"); | 10275 | Vcode_conversion_workbuf_name = build_pure_c_string (" *code-conversion-work*"); |
| 10331 | 10276 | ||
| 10332 | reused_workbuf_in_use = 0; | 10277 | reused_workbuf_in_use = 0; |
| 10333 | 10278 | ||
| @@ -10377,6 +10322,11 @@ syms_of_coding (void) | |||
| 10377 | DEFSYM (Qutf_8, "utf-8"); | 10322 | DEFSYM (Qutf_8, "utf-8"); |
| 10378 | DEFSYM (Qutf_8_emacs, "utf-8-emacs"); | 10323 | DEFSYM (Qutf_8_emacs, "utf-8-emacs"); |
| 10379 | 10324 | ||
| 10325 | #if defined (WINDOWSNT) || defined (CYGWIN) | ||
| 10326 | /* No, not utf-16-le: that one has a BOM. */ | ||
| 10327 | DEFSYM (Qutf_16le, "utf-16le"); | ||
| 10328 | #endif | ||
| 10329 | |||
| 10380 | DEFSYM (Qutf_16, "utf-16"); | 10330 | DEFSYM (Qutf_16, "utf-16"); |
| 10381 | DEFSYM (Qbig, "big"); | 10331 | DEFSYM (Qbig, "big"); |
| 10382 | DEFSYM (Qlittle, "little"); | 10332 | DEFSYM (Qlittle, "little"); |
| @@ -10388,9 +10338,9 @@ syms_of_coding (void) | |||
| 10388 | 10338 | ||
| 10389 | DEFSYM (Qcoding_system_error, "coding-system-error"); | 10339 | DEFSYM (Qcoding_system_error, "coding-system-error"); |
| 10390 | Fput (Qcoding_system_error, Qerror_conditions, | 10340 | Fput (Qcoding_system_error, Qerror_conditions, |
| 10391 | pure_cons (Qcoding_system_error, pure_cons (Qerror, Qnil))); | 10341 | listn (CONSTYPE_PURE, 2, Qcoding_system_error, Qerror)); |
| 10392 | Fput (Qcoding_system_error, Qerror_message, | 10342 | Fput (Qcoding_system_error, Qerror_message, |
| 10393 | make_pure_c_string ("Invalid coding system")); | 10343 | build_pure_c_string ("Invalid coding system")); |
| 10394 | 10344 | ||
| 10395 | /* Intern this now in case it isn't already done. | 10345 | /* Intern this now in case it isn't already done. |
| 10396 | Setting this variable twice is harmless. | 10346 | Setting this variable twice is harmless. |
| @@ -10537,7 +10487,7 @@ Don't modify this variable directly, but use `set-coding-system-priority'. */); | |||
| 10537 | Vcoding_category_list = Qnil; | 10487 | Vcoding_category_list = Qnil; |
| 10538 | for (i = coding_category_max - 1; i >= 0; i--) | 10488 | for (i = coding_category_max - 1; i >= 0; i--) |
| 10539 | Vcoding_category_list | 10489 | Vcoding_category_list |
| 10540 | = Fcons (XVECTOR (Vcoding_category_table)->contents[i], | 10490 | = Fcons (AREF (Vcoding_category_table, i), |
| 10541 | Vcoding_category_list); | 10491 | Vcoding_category_list); |
| 10542 | } | 10492 | } |
| 10543 | 10493 | ||
| @@ -10663,22 +10613,22 @@ Also used for decoding keyboard input on X Window system. */); | |||
| 10663 | DEFVAR_LISP ("eol-mnemonic-unix", eol_mnemonic_unix, | 10613 | DEFVAR_LISP ("eol-mnemonic-unix", eol_mnemonic_unix, |
| 10664 | doc: /* | 10614 | doc: /* |
| 10665 | *String displayed in mode line for UNIX-like (LF) end-of-line format. */); | 10615 | *String displayed in mode line for UNIX-like (LF) end-of-line format. */); |
| 10666 | eol_mnemonic_unix = make_pure_c_string (":"); | 10616 | eol_mnemonic_unix = build_pure_c_string (":"); |
| 10667 | 10617 | ||
| 10668 | DEFVAR_LISP ("eol-mnemonic-dos", eol_mnemonic_dos, | 10618 | DEFVAR_LISP ("eol-mnemonic-dos", eol_mnemonic_dos, |
| 10669 | doc: /* | 10619 | doc: /* |
| 10670 | *String displayed in mode line for DOS-like (CRLF) end-of-line format. */); | 10620 | *String displayed in mode line for DOS-like (CRLF) end-of-line format. */); |
| 10671 | eol_mnemonic_dos = make_pure_c_string ("\\"); | 10621 | eol_mnemonic_dos = build_pure_c_string ("\\"); |
| 10672 | 10622 | ||
| 10673 | DEFVAR_LISP ("eol-mnemonic-mac", eol_mnemonic_mac, | 10623 | DEFVAR_LISP ("eol-mnemonic-mac", eol_mnemonic_mac, |
| 10674 | doc: /* | 10624 | doc: /* |
| 10675 | *String displayed in mode line for MAC-like (CR) end-of-line format. */); | 10625 | *String displayed in mode line for MAC-like (CR) end-of-line format. */); |
| 10676 | eol_mnemonic_mac = make_pure_c_string ("/"); | 10626 | eol_mnemonic_mac = build_pure_c_string ("/"); |
| 10677 | 10627 | ||
| 10678 | DEFVAR_LISP ("eol-mnemonic-undecided", eol_mnemonic_undecided, | 10628 | DEFVAR_LISP ("eol-mnemonic-undecided", eol_mnemonic_undecided, |
| 10679 | doc: /* | 10629 | doc: /* |
| 10680 | *String displayed in mode line when end-of-line format is not yet determined. */); | 10630 | *String displayed in mode line when end-of-line format is not yet determined. */); |
| 10681 | eol_mnemonic_undecided = make_pure_c_string (":"); | 10631 | eol_mnemonic_undecided = build_pure_c_string (":"); |
| 10682 | 10632 | ||
| 10683 | DEFVAR_LISP ("enable-character-translation", Venable_character_translation, | 10633 | DEFVAR_LISP ("enable-character-translation", Venable_character_translation, |
| 10684 | doc: /* | 10634 | doc: /* |
| @@ -10816,7 +10766,7 @@ internal character representation. */); | |||
| 10816 | plist[10] = intern_c_string (":for-unibyte"); | 10766 | plist[10] = intern_c_string (":for-unibyte"); |
| 10817 | plist[11] = args[coding_arg_for_unibyte] = Qt; | 10767 | plist[11] = args[coding_arg_for_unibyte] = Qt; |
| 10818 | plist[12] = intern_c_string (":docstring"); | 10768 | plist[12] = intern_c_string (":docstring"); |
| 10819 | plist[13] = make_pure_c_string ("Do no conversion.\n\ | 10769 | plist[13] = build_pure_c_string ("Do no conversion.\n\ |
| 10820 | \n\ | 10770 | \n\ |
| 10821 | When you visit a file with this coding, the file is read into a\n\ | 10771 | When you visit a file with this coding, the file is read into a\n\ |
| 10822 | unibyte buffer as is, thus each byte of a file is treated as a\n\ | 10772 | unibyte buffer as is, thus each byte of a file is treated as a\n\ |
| @@ -10834,7 +10784,7 @@ character."); | |||
| 10834 | plist[8] = intern_c_string (":charset-list"); | 10784 | plist[8] = intern_c_string (":charset-list"); |
| 10835 | plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); | 10785 | plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); |
| 10836 | plist[11] = args[coding_arg_for_unibyte] = Qnil; | 10786 | plist[11] = args[coding_arg_for_unibyte] = Qnil; |
| 10837 | plist[13] = make_pure_c_string ("No conversion on encoding, automatic conversion on decoding."); | 10787 | plist[13] = build_pure_c_string ("No conversion on encoding, automatic conversion on decoding."); |
| 10838 | plist[15] = args[coding_arg_eol_type] = Qnil; | 10788 | plist[15] = args[coding_arg_eol_type] = Qnil; |
| 10839 | args[coding_arg_plist] = Flist (16, plist); | 10789 | args[coding_arg_plist] = Flist (16, plist); |
| 10840 | Fdefine_coding_system_internal (coding_arg_max, args); | 10790 | Fdefine_coding_system_internal (coding_arg_max, args); |