diff options
| author | Fabián Ezequiel Gallina | 2012-06-14 23:05:43 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-06-14 23:05:43 -0300 |
| commit | 315f675857250c2204d024748e9eafa57c68410f (patch) | |
| tree | 101bfee7ff075c2eb02fd4bd80af02ed1da979b5 /src/coding.c | |
| parent | c6a506fefd22cb1efde1935154e79b471b943c45 (diff) | |
| parent | 4302f5ba6e853d3f42ca21c536afd5a69b9e1774 (diff) | |
| download | emacs-315f675857250c2204d024748e9eafa57c68410f.tar.gz emacs-315f675857250c2204d024748e9eafa57c68410f.zip | |
Merge from trunk
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 346 |
1 files changed, 184 insertions, 162 deletions
diff --git a/src/coding.c b/src/coding.c index eb89563eef4..17e342298b9 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -159,7 +159,7 @@ detect_coding_XXX (struct coding_system *coding, | |||
| 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 | int 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 | ||
| @@ -266,7 +266,7 @@ encode_coding_XXX (struct coding_system *coding) | |||
| 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 | { |
| @@ -847,33 +847,35 @@ static int encode_coding_ccl (struct coding_system *); | |||
| 847 | static void decode_coding_raw_text (struct coding_system *); | 847 | static void decode_coding_raw_text (struct coding_system *); |
| 848 | static int encode_coding_raw_text (struct coding_system *); | 848 | static int encode_coding_raw_text (struct coding_system *); |
| 849 | 849 | ||
| 850 | static EMACS_INT coding_set_source (struct coding_system *); | 850 | static void coding_set_source (struct coding_system *); |
| 851 | static EMACS_INT coding_set_destination (struct coding_system *); | 851 | static ptrdiff_t coding_change_source (struct coding_system *); |
| 852 | static void coding_alloc_by_realloc (struct coding_system *, EMACS_INT); | 852 | static void coding_set_destination (struct coding_system *); |
| 853 | static ptrdiff_t coding_change_destination (struct coding_system *); | ||
| 854 | static void coding_alloc_by_realloc (struct coding_system *, ptrdiff_t); | ||
| 853 | static void coding_alloc_by_making_gap (struct coding_system *, | 855 | static void coding_alloc_by_making_gap (struct coding_system *, |
| 854 | EMACS_INT, EMACS_INT); | 856 | ptrdiff_t, ptrdiff_t); |
| 855 | static unsigned char *alloc_destination (struct coding_system *, | 857 | static unsigned char *alloc_destination (struct coding_system *, |
| 856 | EMACS_INT, unsigned char *); | 858 | ptrdiff_t, unsigned char *); |
| 857 | static void setup_iso_safe_charsets (Lisp_Object); | 859 | static void setup_iso_safe_charsets (Lisp_Object); |
| 858 | static EMACS_INT encode_designation_at_bol (struct coding_system *, | 860 | static ptrdiff_t encode_designation_at_bol (struct coding_system *, |
| 859 | int *, int *, unsigned char *); | 861 | int *, int *, unsigned char *); |
| 860 | static int detect_eol (const unsigned char *, | 862 | static int detect_eol (const unsigned char *, |
| 861 | EMACS_INT, enum coding_category); | 863 | ptrdiff_t, enum coding_category); |
| 862 | static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); | 864 | static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); |
| 863 | static void decode_eol (struct coding_system *); | 865 | static void decode_eol (struct coding_system *); |
| 864 | static Lisp_Object get_translation_table (Lisp_Object, int, int *); | 866 | static Lisp_Object get_translation_table (Lisp_Object, int, int *); |
| 865 | static Lisp_Object get_translation (Lisp_Object, int *, int *); | 867 | static Lisp_Object get_translation (Lisp_Object, int *, int *); |
| 866 | static int produce_chars (struct coding_system *, Lisp_Object, int); | 868 | static int produce_chars (struct coding_system *, Lisp_Object, int); |
| 867 | static inline void produce_charset (struct coding_system *, int *, | 869 | static inline void produce_charset (struct coding_system *, int *, |
| 868 | EMACS_INT); | 870 | ptrdiff_t); |
| 869 | static void produce_annotation (struct coding_system *, EMACS_INT); | 871 | static void produce_annotation (struct coding_system *, ptrdiff_t); |
| 870 | static int decode_coding (struct coding_system *); | 872 | static int decode_coding (struct coding_system *); |
| 871 | static inline int *handle_composition_annotation (EMACS_INT, EMACS_INT, | 873 | static inline int *handle_composition_annotation (ptrdiff_t, ptrdiff_t, |
| 872 | struct coding_system *, | 874 | struct coding_system *, |
| 873 | int *, EMACS_INT *); | 875 | int *, ptrdiff_t *); |
| 874 | static inline int *handle_charset_annotation (EMACS_INT, EMACS_INT, | 876 | static inline int *handle_charset_annotation (ptrdiff_t, ptrdiff_t, |
| 875 | struct coding_system *, | 877 | struct coding_system *, |
| 876 | int *, EMACS_INT *); | 878 | int *, ptrdiff_t *); |
| 877 | static void consume_chars (struct coding_system *, Lisp_Object, int); | 879 | static void consume_chars (struct coding_system *, Lisp_Object, int); |
| 878 | static int encode_coding (struct coding_system *); | 880 | static int encode_coding (struct coding_system *); |
| 879 | static Lisp_Object make_conversion_work_buffer (int); | 881 | static Lisp_Object make_conversion_work_buffer (int); |
| @@ -922,12 +924,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 922 | 924 | ||
| 923 | #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ | 925 | #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ |
| 924 | do { \ | 926 | do { \ |
| 925 | EMACS_INT offset; \ | 927 | ptrdiff_t offset; \ |
| 926 | \ | 928 | \ |
| 927 | charset_map_loaded = 0; \ | 929 | charset_map_loaded = 0; \ |
| 928 | c = DECODE_CHAR (charset, code); \ | 930 | c = DECODE_CHAR (charset, code); \ |
| 929 | if (charset_map_loaded \ | 931 | if (charset_map_loaded \ |
| 930 | && (offset = coding_set_source (coding))) \ | 932 | && (offset = coding_change_source (coding))) \ |
| 931 | { \ | 933 | { \ |
| 932 | src += offset; \ | 934 | src += offset; \ |
| 933 | src_base += offset; \ | 935 | src_base += offset; \ |
| @@ -937,12 +939,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 937 | 939 | ||
| 938 | #define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ | 940 | #define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ |
| 939 | do { \ | 941 | do { \ |
| 940 | EMACS_INT offset; \ | 942 | ptrdiff_t offset; \ |
| 941 | \ | 943 | \ |
| 942 | charset_map_loaded = 0; \ | 944 | charset_map_loaded = 0; \ |
| 943 | code = ENCODE_CHAR (charset, c); \ | 945 | code = ENCODE_CHAR (charset, c); \ |
| 944 | if (charset_map_loaded \ | 946 | if (charset_map_loaded \ |
| 945 | && (offset = coding_set_destination (coding))) \ | 947 | && (offset = coding_change_destination (coding))) \ |
| 946 | { \ | 948 | { \ |
| 947 | dst += offset; \ | 949 | dst += offset; \ |
| 948 | dst_end += offset; \ | 950 | dst_end += offset; \ |
| @@ -951,12 +953,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 951 | 953 | ||
| 952 | #define CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, code_return, charset) \ | 954 | #define CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, code_return, charset) \ |
| 953 | do { \ | 955 | do { \ |
| 954 | EMACS_INT offset; \ | 956 | ptrdiff_t offset; \ |
| 955 | \ | 957 | \ |
| 956 | charset_map_loaded = 0; \ | 958 | charset_map_loaded = 0; \ |
| 957 | charset = char_charset (c, charset_list, code_return); \ | 959 | charset = char_charset (c, charset_list, code_return); \ |
| 958 | if (charset_map_loaded \ | 960 | if (charset_map_loaded \ |
| 959 | && (offset = coding_set_destination (coding))) \ | 961 | && (offset = coding_change_destination (coding))) \ |
| 960 | { \ | 962 | { \ |
| 961 | dst += offset; \ | 963 | dst += offset; \ |
| 962 | dst_end += offset; \ | 964 | dst_end += offset; \ |
| @@ -965,12 +967,12 @@ record_conversion_result (struct coding_system *coding, | |||
| 965 | 967 | ||
| 966 | #define CODING_CHAR_CHARSET_P(coding, dst, dst_end, c, charset, result) \ | 968 | #define CODING_CHAR_CHARSET_P(coding, dst, dst_end, c, charset, result) \ |
| 967 | do { \ | 969 | do { \ |
| 968 | EMACS_INT offset; \ | 970 | ptrdiff_t offset; \ |
| 969 | \ | 971 | \ |
| 970 | charset_map_loaded = 0; \ | 972 | charset_map_loaded = 0; \ |
| 971 | result = CHAR_CHARSET_P (c, charset); \ | 973 | result = CHAR_CHARSET_P (c, charset); \ |
| 972 | if (charset_map_loaded \ | 974 | if (charset_map_loaded \ |
| 973 | && (offset = coding_set_destination (coding))) \ | 975 | && (offset = coding_change_destination (coding))) \ |
| 974 | { \ | 976 | { \ |
| 975 | dst += offset; \ | 977 | dst += offset; \ |
| 976 | dst_end += offset; \ | 978 | dst_end += offset; \ |
| @@ -987,7 +989,7 @@ record_conversion_result (struct coding_system *coding, | |||
| 987 | do { \ | 989 | do { \ |
| 988 | if (dst + (bytes) >= dst_end) \ | 990 | if (dst + (bytes) >= dst_end) \ |
| 989 | { \ | 991 | { \ |
| 990 | EMACS_INT more_bytes = charbuf_end - charbuf + (bytes); \ | 992 | ptrdiff_t more_bytes = charbuf_end - charbuf + (bytes); \ |
| 991 | \ | 993 | \ |
| 992 | dst = alloc_destination (coding, more_bytes, dst); \ | 994 | dst = alloc_destination (coding, more_bytes, dst); \ |
| 993 | dst_end = coding->destination + coding->dst_bytes; \ | 995 | dst_end = coding->destination + coding->dst_bytes; \ |
| @@ -1056,14 +1058,11 @@ record_conversion_result (struct coding_system *coding, | |||
| 1056 | | ((p)[-1] & 0x3F)))) | 1058 | | ((p)[-1] & 0x3F)))) |
| 1057 | 1059 | ||
| 1058 | 1060 | ||
| 1059 | /* Update coding->source from coding->src_object, and return how many | 1061 | /* Set coding->source from coding->src_object. */ |
| 1060 | bytes coding->source was changed. */ | ||
| 1061 | 1062 | ||
| 1062 | static EMACS_INT | 1063 | static void |
| 1063 | coding_set_source (struct coding_system *coding) | 1064 | coding_set_source (struct coding_system *coding) |
| 1064 | { | 1065 | { |
| 1065 | const unsigned char *orig = coding->source; | ||
| 1066 | |||
| 1067 | if (BUFFERP (coding->src_object)) | 1066 | if (BUFFERP (coding->src_object)) |
| 1068 | { | 1067 | { |
| 1069 | struct buffer *buf = XBUFFER (coding->src_object); | 1068 | struct buffer *buf = XBUFFER (coding->src_object); |
| @@ -1082,18 +1081,26 @@ coding_set_source (struct coding_system *coding) | |||
| 1082 | /* Otherwise, the source is C string and is never relocated | 1081 | /* Otherwise, the source is C string and is never relocated |
| 1083 | automatically. Thus we don't have to update anything. */ | 1082 | automatically. Thus we don't have to update anything. */ |
| 1084 | } | 1083 | } |
| 1084 | } | ||
| 1085 | |||
| 1086 | |||
| 1087 | /* Set coding->source from coding->src_object, and return how many | ||
| 1088 | bytes coding->source was changed. */ | ||
| 1089 | |||
| 1090 | static ptrdiff_t | ||
| 1091 | coding_change_source (struct coding_system *coding) | ||
| 1092 | { | ||
| 1093 | const unsigned char *orig = coding->source; | ||
| 1094 | coding_set_source (coding); | ||
| 1085 | return coding->source - orig; | 1095 | return coding->source - orig; |
| 1086 | } | 1096 | } |
| 1087 | 1097 | ||
| 1088 | 1098 | ||
| 1089 | /* Update coding->destination from coding->dst_object, and return how | 1099 | /* Set coding->destination from coding->dst_object. */ |
| 1090 | many bytes coding->destination was changed. */ | ||
| 1091 | 1100 | ||
| 1092 | static EMACS_INT | 1101 | static void |
| 1093 | coding_set_destination (struct coding_system *coding) | 1102 | coding_set_destination (struct coding_system *coding) |
| 1094 | { | 1103 | { |
| 1095 | const unsigned char *orig = coding->destination; | ||
| 1096 | |||
| 1097 | if (BUFFERP (coding->dst_object)) | 1104 | if (BUFFERP (coding->dst_object)) |
| 1098 | { | 1105 | { |
| 1099 | if (BUFFERP (coding->src_object) && coding->src_pos < 0) | 1106 | if (BUFFERP (coding->src_object) && coding->src_pos < 0) |
| @@ -1118,12 +1125,23 @@ coding_set_destination (struct coding_system *coding) | |||
| 1118 | /* Otherwise, the destination is C string and is never relocated | 1125 | /* Otherwise, the destination is C string and is never relocated |
| 1119 | automatically. Thus we don't have to update anything. */ | 1126 | automatically. Thus we don't have to update anything. */ |
| 1120 | } | 1127 | } |
| 1128 | } | ||
| 1129 | |||
| 1130 | |||
| 1131 | /* Set coding->destination from coding->dst_object, and return how | ||
| 1132 | many bytes coding->destination was changed. */ | ||
| 1133 | |||
| 1134 | static ptrdiff_t | ||
| 1135 | coding_change_destination (struct coding_system *coding) | ||
| 1136 | { | ||
| 1137 | const unsigned char *orig = coding->destination; | ||
| 1138 | coding_set_destination (coding); | ||
| 1121 | return coding->destination - orig; | 1139 | return coding->destination - orig; |
| 1122 | } | 1140 | } |
| 1123 | 1141 | ||
| 1124 | 1142 | ||
| 1125 | static void | 1143 | static void |
| 1126 | coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) | 1144 | coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes) |
| 1127 | { | 1145 | { |
| 1128 | if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) | 1146 | if (STRING_BYTES_BOUND - coding->dst_bytes < bytes) |
| 1129 | string_overflow (); | 1147 | string_overflow (); |
| @@ -1134,7 +1152,7 @@ coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes) | |||
| 1134 | 1152 | ||
| 1135 | static void | 1153 | static void |
| 1136 | coding_alloc_by_making_gap (struct coding_system *coding, | 1154 | coding_alloc_by_making_gap (struct coding_system *coding, |
| 1137 | EMACS_INT gap_head_used, EMACS_INT bytes) | 1155 | ptrdiff_t gap_head_used, ptrdiff_t bytes) |
| 1138 | { | 1156 | { |
| 1139 | if (EQ (coding->src_object, coding->dst_object)) | 1157 | if (EQ (coding->src_object, coding->dst_object)) |
| 1140 | { | 1158 | { |
| @@ -1142,7 +1160,7 @@ coding_alloc_by_making_gap (struct coding_system *coding, | |||
| 1142 | consumed data at the tail. To preserve those data, we at | 1160 | consumed data at the tail. To preserve those data, we at |
| 1143 | first make the gap size to zero, then increase the gap | 1161 | first make the gap size to zero, then increase the gap |
| 1144 | size. */ | 1162 | size. */ |
| 1145 | EMACS_INT add = GAP_SIZE; | 1163 | ptrdiff_t add = GAP_SIZE; |
| 1146 | 1164 | ||
| 1147 | GPT += gap_head_used, GPT_BYTE += gap_head_used; | 1165 | GPT += gap_head_used, GPT_BYTE += gap_head_used; |
| 1148 | GAP_SIZE = 0; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; | 1166 | GAP_SIZE = 0; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; |
| @@ -1163,10 +1181,10 @@ coding_alloc_by_making_gap (struct coding_system *coding, | |||
| 1163 | 1181 | ||
| 1164 | 1182 | ||
| 1165 | static unsigned char * | 1183 | static unsigned char * |
| 1166 | alloc_destination (struct coding_system *coding, EMACS_INT nbytes, | 1184 | alloc_destination (struct coding_system *coding, ptrdiff_t nbytes, |
| 1167 | unsigned char *dst) | 1185 | unsigned char *dst) |
| 1168 | { | 1186 | { |
| 1169 | EMACS_INT offset = dst - coding->destination; | 1187 | ptrdiff_t offset = dst - coding->destination; |
| 1170 | 1188 | ||
| 1171 | if (BUFFERP (coding->dst_object)) | 1189 | if (BUFFERP (coding->dst_object)) |
| 1172 | { | 1190 | { |
| @@ -1267,7 +1285,7 @@ detect_coding_utf_8 (struct coding_system *coding, | |||
| 1267 | const unsigned char *src = coding->source, *src_base; | 1285 | const unsigned char *src = coding->source, *src_base; |
| 1268 | const unsigned char *src_end = coding->source + coding->src_bytes; | 1286 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 1269 | int multibytep = coding->src_multibyte; | 1287 | int multibytep = coding->src_multibyte; |
| 1270 | EMACS_INT consumed_chars = 0; | 1288 | ptrdiff_t consumed_chars = 0; |
| 1271 | int bom_found = 0; | 1289 | int bom_found = 0; |
| 1272 | int found = 0; | 1290 | int found = 0; |
| 1273 | 1291 | ||
| @@ -1352,7 +1370,7 @@ decode_coding_utf_8 (struct coding_system *coding) | |||
| 1352 | const unsigned char *src_base; | 1370 | const unsigned char *src_base; |
| 1353 | int *charbuf = coding->charbuf + coding->charbuf_used; | 1371 | int *charbuf = coding->charbuf + coding->charbuf_used; |
| 1354 | int *charbuf_end = coding->charbuf + coding->charbuf_size; | 1372 | int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 1355 | EMACS_INT consumed_chars = 0, consumed_chars_base = 0; | 1373 | ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; |
| 1356 | int multibytep = coding->src_multibyte; | 1374 | int multibytep = coding->src_multibyte; |
| 1357 | enum utf_bom_type bom = CODING_UTF_8_BOM (coding); | 1375 | enum utf_bom_type bom = CODING_UTF_8_BOM (coding); |
| 1358 | int eol_dos = | 1376 | int eol_dos = |
| @@ -1503,7 +1521,7 @@ encode_coding_utf_8 (struct coding_system *coding) | |||
| 1503 | int *charbuf_end = charbuf + coding->charbuf_used; | 1521 | int *charbuf_end = charbuf + coding->charbuf_used; |
| 1504 | unsigned char *dst = coding->destination + coding->produced; | 1522 | unsigned char *dst = coding->destination + coding->produced; |
| 1505 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 1523 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 1506 | EMACS_INT produced_chars = 0; | 1524 | ptrdiff_t produced_chars = 0; |
| 1507 | int c; | 1525 | int c; |
| 1508 | 1526 | ||
| 1509 | if (CODING_UTF_8_BOM (coding) == utf_with_bom) | 1527 | if (CODING_UTF_8_BOM (coding) == utf_with_bom) |
| @@ -1661,7 +1679,7 @@ decode_coding_utf_16 (struct coding_system *coding) | |||
| 1661 | int *charbuf = coding->charbuf + coding->charbuf_used; | 1679 | int *charbuf = coding->charbuf + coding->charbuf_used; |
| 1662 | /* We may produces at most 3 chars in one loop. */ | 1680 | /* We may produces at most 3 chars in one loop. */ |
| 1663 | int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; | 1681 | int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; |
| 1664 | EMACS_INT consumed_chars = 0, consumed_chars_base = 0; | 1682 | ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; |
| 1665 | int multibytep = coding->src_multibyte; | 1683 | int multibytep = coding->src_multibyte; |
| 1666 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); | 1684 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
| 1667 | enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); | 1685 | enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); |
| @@ -1788,7 +1806,7 @@ encode_coding_utf_16 (struct coding_system *coding) | |||
| 1788 | int safe_room = 8; | 1806 | int safe_room = 8; |
| 1789 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); | 1807 | enum utf_bom_type bom = CODING_UTF_16_BOM (coding); |
| 1790 | int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; | 1808 | int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; |
| 1791 | EMACS_INT produced_chars = 0; | 1809 | ptrdiff_t produced_chars = 0; |
| 1792 | int c; | 1810 | int c; |
| 1793 | 1811 | ||
| 1794 | if (bom != utf_without_bom) | 1812 | if (bom != utf_without_bom) |
| @@ -1922,7 +1940,7 @@ detect_coding_emacs_mule (struct coding_system *coding, | |||
| 1922 | const unsigned char *src = coding->source, *src_base; | 1940 | const unsigned char *src = coding->source, *src_base; |
| 1923 | const unsigned char *src_end = coding->source + coding->src_bytes; | 1941 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 1924 | int multibytep = coding->src_multibyte; | 1942 | int multibytep = coding->src_multibyte; |
| 1925 | EMACS_INT consumed_chars = 0; | 1943 | ptrdiff_t consumed_chars = 0; |
| 1926 | int c; | 1944 | int c; |
| 1927 | int found = 0; | 1945 | int found = 0; |
| 1928 | 1946 | ||
| @@ -2392,10 +2410,10 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2392 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3) | 2410 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3) |
| 2393 | /* We can produce up to 2 characters in a loop. */ | 2411 | /* We can produce up to 2 characters in a loop. */ |
| 2394 | - 1; | 2412 | - 1; |
| 2395 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 2413 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 2396 | int multibytep = coding->src_multibyte; | 2414 | int multibytep = coding->src_multibyte; |
| 2397 | EMACS_INT char_offset = coding->produced_char; | 2415 | ptrdiff_t char_offset = coding->produced_char; |
| 2398 | EMACS_INT last_offset = char_offset; | 2416 | ptrdiff_t last_offset = char_offset; |
| 2399 | int last_id = charset_ascii; | 2417 | int last_id = charset_ascii; |
| 2400 | int eol_dos = | 2418 | int eol_dos = |
| 2401 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 2419 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| @@ -2467,7 +2485,7 @@ decode_coding_emacs_mule (struct coding_system *coding) | |||
| 2467 | original pointer to buffer text, and fix up all related | 2485 | original pointer to buffer text, and fix up all related |
| 2468 | pointers after the call. */ | 2486 | pointers after the call. */ |
| 2469 | const unsigned char *orig = coding->source; | 2487 | const unsigned char *orig = coding->source; |
| 2470 | EMACS_INT offset; | 2488 | ptrdiff_t offset; |
| 2471 | 2489 | ||
| 2472 | c = emacs_mule_char (coding, src_base, &nbytes, &nchars, &id, | 2490 | c = emacs_mule_char (coding, src_base, &nbytes, &nchars, &id, |
| 2473 | cmp_status); | 2491 | cmp_status); |
| @@ -2648,7 +2666,7 @@ encode_coding_emacs_mule (struct coding_system *coding) | |||
| 2648 | unsigned char *dst = coding->destination + coding->produced; | 2666 | unsigned char *dst = coding->destination + coding->produced; |
| 2649 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 2667 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 2650 | int safe_room = 8; | 2668 | int safe_room = 8; |
| 2651 | EMACS_INT produced_chars = 0; | 2669 | ptrdiff_t produced_chars = 0; |
| 2652 | Lisp_Object attrs, charset_list; | 2670 | Lisp_Object attrs, charset_list; |
| 2653 | int c; | 2671 | int c; |
| 2654 | int preferred_charset_id = -1; | 2672 | int preferred_charset_id = -1; |
| @@ -2941,7 +2959,7 @@ setup_iso_safe_charsets (Lisp_Object attrs) | |||
| 2941 | Lisp_Object request; | 2959 | Lisp_Object request; |
| 2942 | Lisp_Object reg_usage; | 2960 | Lisp_Object reg_usage; |
| 2943 | Lisp_Object tail; | 2961 | Lisp_Object tail; |
| 2944 | int reg94, reg96; | 2962 | EMACS_INT reg94, reg96; |
| 2945 | int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | 2963 | int flags = XINT (AREF (attrs, coding_attr_iso_flags)); |
| 2946 | int max_charset_id; | 2964 | int max_charset_id; |
| 2947 | 2965 | ||
| @@ -3012,7 +3030,7 @@ detect_coding_iso_2022 (struct coding_system *coding, | |||
| 3012 | int single_shifting = 0; | 3030 | int single_shifting = 0; |
| 3013 | int id; | 3031 | int id; |
| 3014 | int c, c1; | 3032 | int c, c1; |
| 3015 | EMACS_INT consumed_chars = 0; | 3033 | ptrdiff_t consumed_chars = 0; |
| 3016 | int i; | 3034 | int i; |
| 3017 | int rejected = 0; | 3035 | int rejected = 0; |
| 3018 | int found = 0; | 3036 | int found = 0; |
| @@ -3522,7 +3540,7 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3522 | loop and one more charset annotation at the end. */ | 3540 | loop and one more charset annotation at the end. */ |
| 3523 | int *charbuf_end | 3541 | int *charbuf_end |
| 3524 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); | 3542 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); |
| 3525 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 3543 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 3526 | int multibytep = coding->src_multibyte; | 3544 | int multibytep = coding->src_multibyte; |
| 3527 | /* Charsets invoked to graphic plane 0 and 1 respectively. */ | 3545 | /* Charsets invoked to graphic plane 0 and 1 respectively. */ |
| 3528 | int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); | 3546 | int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); |
| @@ -3532,8 +3550,8 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3532 | int c; | 3550 | int c; |
| 3533 | struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); | 3551 | struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); |
| 3534 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); | 3552 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); |
| 3535 | EMACS_INT char_offset = coding->produced_char; | 3553 | ptrdiff_t char_offset = coding->produced_char; |
| 3536 | EMACS_INT last_offset = char_offset; | 3554 | ptrdiff_t last_offset = char_offset; |
| 3537 | int last_id = charset_ascii; | 3555 | int last_id = charset_ascii; |
| 3538 | int eol_dos = | 3556 | int eol_dos = |
| 3539 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 3557 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| @@ -4245,7 +4263,7 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 4245 | 4263 | ||
| 4246 | #define ENCODE_ISO_CHARACTER(charset, c) \ | 4264 | #define ENCODE_ISO_CHARACTER(charset, c) \ |
| 4247 | do { \ | 4265 | do { \ |
| 4248 | int code; \ | 4266 | unsigned code; \ |
| 4249 | CODING_ENCODE_CHAR (coding, dst, dst_end, (charset), (c), code); \ | 4267 | CODING_ENCODE_CHAR (coding, dst, dst_end, (charset), (c), code); \ |
| 4250 | \ | 4268 | \ |
| 4251 | if (CHARSET_DIMENSION (charset) == 1) \ | 4269 | if (CHARSET_DIMENSION (charset) == 1) \ |
| @@ -4262,10 +4280,10 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 4262 | static unsigned char * | 4280 | static unsigned char * |
| 4263 | encode_invocation_designation (struct charset *charset, | 4281 | encode_invocation_designation (struct charset *charset, |
| 4264 | struct coding_system *coding, | 4282 | struct coding_system *coding, |
| 4265 | unsigned char *dst, EMACS_INT *p_nchars) | 4283 | unsigned char *dst, ptrdiff_t *p_nchars) |
| 4266 | { | 4284 | { |
| 4267 | int multibytep = coding->dst_multibyte; | 4285 | int multibytep = coding->dst_multibyte; |
| 4268 | EMACS_INT produced_chars = *p_nchars; | 4286 | ptrdiff_t produced_chars = *p_nchars; |
| 4269 | int reg; /* graphic register number */ | 4287 | int reg; /* graphic register number */ |
| 4270 | int id = CHARSET_ID (charset); | 4288 | int id = CHARSET_ID (charset); |
| 4271 | 4289 | ||
| @@ -4351,7 +4369,7 @@ encode_invocation_designation (struct charset *charset, | |||
| 4351 | If the current block ends before any end-of-line, we may fail to | 4369 | If the current block ends before any end-of-line, we may fail to |
| 4352 | find all the necessary designations. */ | 4370 | find all the necessary designations. */ |
| 4353 | 4371 | ||
| 4354 | static EMACS_INT | 4372 | static ptrdiff_t |
| 4355 | encode_designation_at_bol (struct coding_system *coding, | 4373 | encode_designation_at_bol (struct coding_system *coding, |
| 4356 | int *charbuf, int *charbuf_end, | 4374 | int *charbuf, int *charbuf_end, |
| 4357 | unsigned char *dst) | 4375 | unsigned char *dst) |
| @@ -4361,7 +4379,7 @@ encode_designation_at_bol (struct coding_system *coding, | |||
| 4361 | /* Table of charsets to be designated to each graphic register. */ | 4379 | /* Table of charsets to be designated to each graphic register. */ |
| 4362 | int r[4]; | 4380 | int r[4]; |
| 4363 | int c, found = 0, reg; | 4381 | int c, found = 0, reg; |
| 4364 | EMACS_INT produced_chars = 0; | 4382 | ptrdiff_t produced_chars = 0; |
| 4365 | int multibytep = coding->dst_multibyte; | 4383 | int multibytep = coding->dst_multibyte; |
| 4366 | Lisp_Object attrs; | 4384 | Lisp_Object attrs; |
| 4367 | Lisp_Object charset_list; | 4385 | Lisp_Object charset_list; |
| @@ -4416,7 +4434,7 @@ encode_coding_iso_2022 (struct coding_system *coding) | |||
| 4416 | int bol_designation | 4434 | int bol_designation |
| 4417 | = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL | 4435 | = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL |
| 4418 | && CODING_ISO_BOL (coding)); | 4436 | && CODING_ISO_BOL (coding)); |
| 4419 | EMACS_INT produced_chars = 0; | 4437 | ptrdiff_t produced_chars = 0; |
| 4420 | Lisp_Object attrs, eol_type, charset_list; | 4438 | Lisp_Object attrs, eol_type, charset_list; |
| 4421 | int ascii_compatible; | 4439 | int ascii_compatible; |
| 4422 | int c; | 4440 | int c; |
| @@ -4446,13 +4464,13 @@ encode_coding_iso_2022 (struct coding_system *coding) | |||
| 4446 | /* We have to produce designation sequences if any now. */ | 4464 | /* We have to produce designation sequences if any now. */ |
| 4447 | unsigned char desig_buf[16]; | 4465 | unsigned char desig_buf[16]; |
| 4448 | int nbytes; | 4466 | int nbytes; |
| 4449 | EMACS_INT offset; | 4467 | ptrdiff_t offset; |
| 4450 | 4468 | ||
| 4451 | charset_map_loaded = 0; | 4469 | charset_map_loaded = 0; |
| 4452 | nbytes = encode_designation_at_bol (coding, charbuf, charbuf_end, | 4470 | nbytes = encode_designation_at_bol (coding, charbuf, charbuf_end, |
| 4453 | desig_buf); | 4471 | desig_buf); |
| 4454 | if (charset_map_loaded | 4472 | if (charset_map_loaded |
| 4455 | && (offset = coding_set_destination (coding))) | 4473 | && (offset = coding_change_destination (coding))) |
| 4456 | { | 4474 | { |
| 4457 | dst += offset; | 4475 | dst += offset; |
| 4458 | dst_end += offset; | 4476 | dst_end += offset; |
| @@ -4623,7 +4641,7 @@ detect_coding_sjis (struct coding_system *coding, | |||
| 4623 | const unsigned char *src = coding->source, *src_base; | 4641 | const unsigned char *src = coding->source, *src_base; |
| 4624 | const unsigned char *src_end = coding->source + coding->src_bytes; | 4642 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 4625 | int multibytep = coding->src_multibyte; | 4643 | int multibytep = coding->src_multibyte; |
| 4626 | EMACS_INT consumed_chars = 0; | 4644 | ptrdiff_t consumed_chars = 0; |
| 4627 | int found = 0; | 4645 | int found = 0; |
| 4628 | int c; | 4646 | int c; |
| 4629 | Lisp_Object attrs, charset_list; | 4647 | Lisp_Object attrs, charset_list; |
| @@ -4680,7 +4698,7 @@ detect_coding_big5 (struct coding_system *coding, | |||
| 4680 | const unsigned char *src = coding->source, *src_base; | 4698 | const unsigned char *src = coding->source, *src_base; |
| 4681 | const unsigned char *src_end = coding->source + coding->src_bytes; | 4699 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 4682 | int multibytep = coding->src_multibyte; | 4700 | int multibytep = coding->src_multibyte; |
| 4683 | EMACS_INT consumed_chars = 0; | 4701 | ptrdiff_t consumed_chars = 0; |
| 4684 | int found = 0; | 4702 | int found = 0; |
| 4685 | int c; | 4703 | int c; |
| 4686 | 4704 | ||
| @@ -4731,13 +4749,13 @@ decode_coding_sjis (struct coding_system *coding) | |||
| 4731 | the end. */ | 4749 | the end. */ |
| 4732 | int *charbuf_end | 4750 | int *charbuf_end |
| 4733 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); | 4751 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
| 4734 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 4752 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 4735 | int multibytep = coding->src_multibyte; | 4753 | int multibytep = coding->src_multibyte; |
| 4736 | struct charset *charset_roman, *charset_kanji, *charset_kana; | 4754 | struct charset *charset_roman, *charset_kanji, *charset_kana; |
| 4737 | struct charset *charset_kanji2; | 4755 | struct charset *charset_kanji2; |
| 4738 | Lisp_Object attrs, charset_list, val; | 4756 | Lisp_Object attrs, charset_list, val; |
| 4739 | EMACS_INT char_offset = coding->produced_char; | 4757 | ptrdiff_t char_offset = coding->produced_char; |
| 4740 | EMACS_INT last_offset = char_offset; | 4758 | ptrdiff_t last_offset = char_offset; |
| 4741 | int last_id = charset_ascii; | 4759 | int last_id = charset_ascii; |
| 4742 | int eol_dos = | 4760 | int eol_dos = |
| 4743 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 4761 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| @@ -4849,12 +4867,12 @@ decode_coding_big5 (struct coding_system *coding) | |||
| 4849 | the end. */ | 4867 | the end. */ |
| 4850 | int *charbuf_end | 4868 | int *charbuf_end |
| 4851 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); | 4869 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
| 4852 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 4870 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 4853 | int multibytep = coding->src_multibyte; | 4871 | int multibytep = coding->src_multibyte; |
| 4854 | struct charset *charset_roman, *charset_big5; | 4872 | struct charset *charset_roman, *charset_big5; |
| 4855 | Lisp_Object attrs, charset_list, val; | 4873 | Lisp_Object attrs, charset_list, val; |
| 4856 | EMACS_INT char_offset = coding->produced_char; | 4874 | ptrdiff_t char_offset = coding->produced_char; |
| 4857 | EMACS_INT last_offset = char_offset; | 4875 | ptrdiff_t last_offset = char_offset; |
| 4858 | int last_id = charset_ascii; | 4876 | int last_id = charset_ascii; |
| 4859 | int eol_dos = | 4877 | int eol_dos = |
| 4860 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 4878 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| @@ -4951,7 +4969,7 @@ encode_coding_sjis (struct coding_system *coding) | |||
| 4951 | unsigned char *dst = coding->destination + coding->produced; | 4969 | unsigned char *dst = coding->destination + coding->produced; |
| 4952 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 4970 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 4953 | int safe_room = 4; | 4971 | int safe_room = 4; |
| 4954 | EMACS_INT produced_chars = 0; | 4972 | ptrdiff_t produced_chars = 0; |
| 4955 | Lisp_Object attrs, charset_list, val; | 4973 | Lisp_Object attrs, charset_list, val; |
| 4956 | int ascii_compatible; | 4974 | int ascii_compatible; |
| 4957 | struct charset *charset_kanji, *charset_kana; | 4975 | struct charset *charset_kanji, *charset_kana; |
| @@ -5045,7 +5063,7 @@ encode_coding_big5 (struct coding_system *coding) | |||
| 5045 | unsigned char *dst = coding->destination + coding->produced; | 5063 | unsigned char *dst = coding->destination + coding->produced; |
| 5046 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 5064 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 5047 | int safe_room = 4; | 5065 | int safe_room = 4; |
| 5048 | EMACS_INT produced_chars = 0; | 5066 | ptrdiff_t produced_chars = 0; |
| 5049 | Lisp_Object attrs, charset_list, val; | 5067 | Lisp_Object attrs, charset_list, val; |
| 5050 | int ascii_compatible; | 5068 | int ascii_compatible; |
| 5051 | struct charset *charset_big5; | 5069 | struct charset *charset_big5; |
| @@ -5123,10 +5141,10 @@ detect_coding_ccl (struct coding_system *coding, | |||
| 5123 | const unsigned char *src = coding->source, *src_base; | 5141 | const unsigned char *src = coding->source, *src_base; |
| 5124 | const unsigned char *src_end = coding->source + coding->src_bytes; | 5142 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 5125 | int multibytep = coding->src_multibyte; | 5143 | int multibytep = coding->src_multibyte; |
| 5126 | EMACS_INT consumed_chars = 0; | 5144 | ptrdiff_t consumed_chars = 0; |
| 5127 | int found = 0; | 5145 | int found = 0; |
| 5128 | unsigned char *valids; | 5146 | unsigned char *valids; |
| 5129 | EMACS_INT head_ascii = coding->head_ascii; | 5147 | ptrdiff_t head_ascii = coding->head_ascii; |
| 5130 | Lisp_Object attrs; | 5148 | Lisp_Object attrs; |
| 5131 | 5149 | ||
| 5132 | detect_info->checked |= CATEGORY_MASK_CCL; | 5150 | detect_info->checked |= CATEGORY_MASK_CCL; |
| @@ -5163,7 +5181,7 @@ decode_coding_ccl (struct coding_system *coding) | |||
| 5163 | const unsigned char *src_end = coding->source + coding->src_bytes; | 5181 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 5164 | int *charbuf = coding->charbuf + coding->charbuf_used; | 5182 | int *charbuf = coding->charbuf + coding->charbuf_used; |
| 5165 | int *charbuf_end = coding->charbuf + coding->charbuf_size; | 5183 | int *charbuf_end = coding->charbuf + coding->charbuf_size; |
| 5166 | EMACS_INT consumed_chars = 0; | 5184 | ptrdiff_t consumed_chars = 0; |
| 5167 | int multibytep = coding->src_multibyte; | 5185 | int multibytep = coding->src_multibyte; |
| 5168 | struct ccl_program *ccl = &coding->spec.ccl->ccl; | 5186 | struct ccl_program *ccl = &coding->spec.ccl->ccl; |
| 5169 | int source_charbuf[1024]; | 5187 | int source_charbuf[1024]; |
| @@ -5235,7 +5253,7 @@ encode_coding_ccl (struct coding_system *coding) | |||
| 5235 | unsigned char *dst = coding->destination + coding->produced; | 5253 | unsigned char *dst = coding->destination + coding->produced; |
| 5236 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 5254 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 5237 | int destination_charbuf[1024]; | 5255 | int destination_charbuf[1024]; |
| 5238 | EMACS_INT produced_chars = 0; | 5256 | ptrdiff_t produced_chars = 0; |
| 5239 | int i; | 5257 | int i; |
| 5240 | Lisp_Object attrs, charset_list; | 5258 | Lisp_Object attrs, charset_list; |
| 5241 | 5259 | ||
| @@ -5323,7 +5341,7 @@ encode_coding_raw_text (struct coding_system *coding) | |||
| 5323 | int *charbuf_end = coding->charbuf + coding->charbuf_used; | 5341 | int *charbuf_end = coding->charbuf + coding->charbuf_used; |
| 5324 | unsigned char *dst = coding->destination + coding->produced; | 5342 | unsigned char *dst = coding->destination + coding->produced; |
| 5325 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 5343 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 5326 | EMACS_INT produced_chars = 0; | 5344 | ptrdiff_t produced_chars = 0; |
| 5327 | int c; | 5345 | int c; |
| 5328 | 5346 | ||
| 5329 | if (multibytep) | 5347 | if (multibytep) |
| @@ -5406,10 +5424,10 @@ detect_coding_charset (struct coding_system *coding, | |||
| 5406 | const unsigned char *src = coding->source, *src_base; | 5424 | const unsigned char *src = coding->source, *src_base; |
| 5407 | const unsigned char *src_end = coding->source + coding->src_bytes; | 5425 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 5408 | int multibytep = coding->src_multibyte; | 5426 | int multibytep = coding->src_multibyte; |
| 5409 | EMACS_INT consumed_chars = 0; | 5427 | ptrdiff_t consumed_chars = 0; |
| 5410 | Lisp_Object attrs, valids, name; | 5428 | Lisp_Object attrs, valids, name; |
| 5411 | int found = 0; | 5429 | int found = 0; |
| 5412 | EMACS_INT head_ascii = coding->head_ascii; | 5430 | ptrdiff_t head_ascii = coding->head_ascii; |
| 5413 | int check_latin_extra = 0; | 5431 | int check_latin_extra = 0; |
| 5414 | 5432 | ||
| 5415 | detect_info->checked |= CATEGORY_MASK_CHARSET; | 5433 | detect_info->checked |= CATEGORY_MASK_CHARSET; |
| @@ -5513,12 +5531,12 @@ decode_coding_charset (struct coding_system *coding) | |||
| 5513 | the end. */ | 5531 | the end. */ |
| 5514 | int *charbuf_end | 5532 | int *charbuf_end |
| 5515 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); | 5533 | = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); |
| 5516 | EMACS_INT consumed_chars = 0, consumed_chars_base; | 5534 | ptrdiff_t consumed_chars = 0, consumed_chars_base; |
| 5517 | int multibytep = coding->src_multibyte; | 5535 | int multibytep = coding->src_multibyte; |
| 5518 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); | 5536 | Lisp_Object attrs = CODING_ID_ATTRS (coding->id); |
| 5519 | Lisp_Object valids; | 5537 | Lisp_Object valids; |
| 5520 | EMACS_INT char_offset = coding->produced_char; | 5538 | ptrdiff_t char_offset = coding->produced_char; |
| 5521 | EMACS_INT last_offset = char_offset; | 5539 | ptrdiff_t last_offset = char_offset; |
| 5522 | int last_id = charset_ascii; | 5540 | int last_id = charset_ascii; |
| 5523 | int eol_dos = | 5541 | int eol_dos = |
| 5524 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); | 5542 | !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); |
| @@ -5639,7 +5657,7 @@ encode_coding_charset (struct coding_system *coding) | |||
| 5639 | unsigned char *dst = coding->destination + coding->produced; | 5657 | unsigned char *dst = coding->destination + coding->produced; |
| 5640 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 5658 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 5641 | int safe_room = MAX_MULTIBYTE_LENGTH; | 5659 | int safe_room = MAX_MULTIBYTE_LENGTH; |
| 5642 | EMACS_INT produced_chars = 0; | 5660 | ptrdiff_t produced_chars = 0; |
| 5643 | Lisp_Object attrs, charset_list; | 5661 | Lisp_Object attrs, charset_list; |
| 5644 | int ascii_compatible; | 5662 | int ascii_compatible; |
| 5645 | int c; | 5663 | int c; |
| @@ -6188,7 +6206,7 @@ complement_process_encoding_system (Lisp_Object coding_system) | |||
| 6188 | #define MAX_EOL_CHECK_COUNT 3 | 6206 | #define MAX_EOL_CHECK_COUNT 3 |
| 6189 | 6207 | ||
| 6190 | static int | 6208 | static int |
| 6191 | detect_eol (const unsigned char *source, EMACS_INT src_bytes, | 6209 | detect_eol (const unsigned char *source, ptrdiff_t src_bytes, |
| 6192 | enum coding_category category) | 6210 | enum coding_category category) |
| 6193 | { | 6211 | { |
| 6194 | const unsigned char *src = source, *src_end = src + src_bytes; | 6212 | const unsigned char *src = source, *src_end = src + src_bytes; |
| @@ -6549,7 +6567,7 @@ decode_eol (struct coding_system *coding) | |||
| 6549 | } | 6567 | } |
| 6550 | else if (EQ (eol_type, Qdos)) | 6568 | else if (EQ (eol_type, Qdos)) |
| 6551 | { | 6569 | { |
| 6552 | EMACS_INT n = 0; | 6570 | ptrdiff_t n = 0; |
| 6553 | 6571 | ||
| 6554 | if (NILP (coding->dst_object)) | 6572 | if (NILP (coding->dst_object)) |
| 6555 | { | 6573 | { |
| @@ -6564,9 +6582,9 @@ decode_eol (struct coding_system *coding) | |||
| 6564 | } | 6582 | } |
| 6565 | else | 6583 | else |
| 6566 | { | 6584 | { |
| 6567 | EMACS_INT pos_byte = coding->dst_pos_byte; | 6585 | ptrdiff_t pos_byte = coding->dst_pos_byte; |
| 6568 | EMACS_INT pos = coding->dst_pos; | 6586 | ptrdiff_t pos = coding->dst_pos; |
| 6569 | EMACS_INT pos_end = pos + coding->produced_char - 1; | 6587 | ptrdiff_t pos_end = pos + coding->produced_char - 1; |
| 6570 | 6588 | ||
| 6571 | while (pos < pos_end) | 6589 | while (pos < pos_end) |
| 6572 | { | 6590 | { |
| @@ -6706,8 +6724,8 @@ get_translation (Lisp_Object trans, int *buf, int *buf_end) | |||
| 6706 | { | 6724 | { |
| 6707 | Lisp_Object val = XCAR (trans); | 6725 | Lisp_Object val = XCAR (trans); |
| 6708 | Lisp_Object from = XCAR (val); | 6726 | Lisp_Object from = XCAR (val); |
| 6709 | int len = ASIZE (from); | 6727 | ptrdiff_t len = ASIZE (from); |
| 6710 | int i; | 6728 | ptrdiff_t i; |
| 6711 | 6729 | ||
| 6712 | for (i = 0; i < len; i++) | 6730 | for (i = 0; i < len; i++) |
| 6713 | { | 6731 | { |
| @@ -6729,8 +6747,8 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6729 | { | 6747 | { |
| 6730 | unsigned char *dst = coding->destination + coding->produced; | 6748 | unsigned char *dst = coding->destination + coding->produced; |
| 6731 | unsigned char *dst_end = coding->destination + coding->dst_bytes; | 6749 | unsigned char *dst_end = coding->destination + coding->dst_bytes; |
| 6732 | EMACS_INT produced; | 6750 | ptrdiff_t produced; |
| 6733 | EMACS_INT produced_chars = 0; | 6751 | ptrdiff_t produced_chars = 0; |
| 6734 | int carryover = 0; | 6752 | int carryover = 0; |
| 6735 | 6753 | ||
| 6736 | if (! coding->chars_at_source) | 6754 | if (! coding->chars_at_source) |
| @@ -6751,7 +6769,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6751 | 6769 | ||
| 6752 | if (c >= 0) | 6770 | if (c >= 0) |
| 6753 | { | 6771 | { |
| 6754 | EMACS_INT from_nchars = 1, to_nchars = 1; | 6772 | ptrdiff_t from_nchars = 1, to_nchars = 1; |
| 6755 | Lisp_Object trans = Qnil; | 6773 | Lisp_Object trans = Qnil; |
| 6756 | 6774 | ||
| 6757 | LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); | 6775 | LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); |
| @@ -6828,7 +6846,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6828 | if (coding->src_multibyte) | 6846 | if (coding->src_multibyte) |
| 6829 | { | 6847 | { |
| 6830 | int multibytep = 1; | 6848 | int multibytep = 1; |
| 6831 | EMACS_INT consumed_chars = 0; | 6849 | ptrdiff_t consumed_chars = 0; |
| 6832 | 6850 | ||
| 6833 | while (1) | 6851 | while (1) |
| 6834 | { | 6852 | { |
| @@ -6842,7 +6860,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6842 | dst_end = (unsigned char *) src; | 6860 | dst_end = (unsigned char *) src; |
| 6843 | if (dst == dst_end) | 6861 | if (dst == dst_end) |
| 6844 | { | 6862 | { |
| 6845 | EMACS_INT offset = src - coding->source; | 6863 | ptrdiff_t offset = src - coding->source; |
| 6846 | 6864 | ||
| 6847 | dst = alloc_destination (coding, src_end - src + 1, | 6865 | dst = alloc_destination (coding, src_end - src + 1, |
| 6848 | dst); | 6866 | dst); |
| @@ -6872,8 +6890,8 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6872 | dst_end = (unsigned char *) src; | 6890 | dst_end = (unsigned char *) src; |
| 6873 | if (dst >= dst_end - 1) | 6891 | if (dst >= dst_end - 1) |
| 6874 | { | 6892 | { |
| 6875 | EMACS_INT offset = src - coding->source; | 6893 | ptrdiff_t offset = src - coding->source; |
| 6876 | EMACS_INT more_bytes; | 6894 | ptrdiff_t more_bytes; |
| 6877 | 6895 | ||
| 6878 | if (EQ (coding->src_object, coding->dst_object)) | 6896 | if (EQ (coding->src_object, coding->dst_object)) |
| 6879 | more_bytes = ((src_end - src) / 2) + 2; | 6897 | more_bytes = ((src_end - src) / 2) + 2; |
| @@ -6895,11 +6913,11 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6895 | { | 6913 | { |
| 6896 | if (!EQ (coding->src_object, coding->dst_object)) | 6914 | if (!EQ (coding->src_object, coding->dst_object)) |
| 6897 | { | 6915 | { |
| 6898 | EMACS_INT require = coding->src_bytes - coding->dst_bytes; | 6916 | ptrdiff_t require = coding->src_bytes - coding->dst_bytes; |
| 6899 | 6917 | ||
| 6900 | if (require > 0) | 6918 | if (require > 0) |
| 6901 | { | 6919 | { |
| 6902 | EMACS_INT offset = src - coding->source; | 6920 | ptrdiff_t offset = src - coding->source; |
| 6903 | 6921 | ||
| 6904 | dst = alloc_destination (coding, require, dst); | 6922 | dst = alloc_destination (coding, require, dst); |
| 6905 | coding_set_source (coding); | 6923 | coding_set_source (coding); |
| @@ -6927,10 +6945,10 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 6927 | */ | 6945 | */ |
| 6928 | 6946 | ||
| 6929 | static inline void | 6947 | static inline void |
| 6930 | produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) | 6948 | produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos) |
| 6931 | { | 6949 | { |
| 6932 | int len; | 6950 | int len; |
| 6933 | EMACS_INT to; | 6951 | ptrdiff_t to; |
| 6934 | enum composition_method method; | 6952 | enum composition_method method; |
| 6935 | Lisp_Object components; | 6953 | Lisp_Object components; |
| 6936 | 6954 | ||
| @@ -6971,9 +6989,9 @@ produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos) | |||
| 6971 | */ | 6989 | */ |
| 6972 | 6990 | ||
| 6973 | static inline void | 6991 | static inline void |
| 6974 | produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) | 6992 | produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos) |
| 6975 | { | 6993 | { |
| 6976 | EMACS_INT from = pos - charbuf[2]; | 6994 | ptrdiff_t from = pos - charbuf[2]; |
| 6977 | struct charset *charset = CHARSET_FROM_ID (charbuf[3]); | 6995 | struct charset *charset = CHARSET_FROM_ID (charbuf[3]); |
| 6978 | 6996 | ||
| 6979 | Fput_text_property (make_number (from), make_number (pos), | 6997 | Fput_text_property (make_number (from), make_number (pos), |
| @@ -7006,7 +7024,7 @@ produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos) | |||
| 7006 | 7024 | ||
| 7007 | 7025 | ||
| 7008 | static void | 7026 | static void |
| 7009 | produce_annotation (struct coding_system *coding, EMACS_INT pos) | 7027 | produce_annotation (struct coding_system *coding, ptrdiff_t pos) |
| 7010 | { | 7028 | { |
| 7011 | int *charbuf = coding->charbuf; | 7029 | int *charbuf = coding->charbuf; |
| 7012 | int *charbuf_end = charbuf + coding->charbuf_used; | 7030 | int *charbuf_end = charbuf + coding->charbuf_used; |
| @@ -7106,7 +7124,7 @@ decode_coding (struct coding_system *coding) | |||
| 7106 | } | 7124 | } |
| 7107 | do | 7125 | do |
| 7108 | { | 7126 | { |
| 7109 | EMACS_INT pos = coding->dst_pos + coding->produced_char; | 7127 | ptrdiff_t pos = coding->dst_pos + coding->produced_char; |
| 7110 | 7128 | ||
| 7111 | coding_set_source (coding); | 7129 | coding_set_source (coding); |
| 7112 | coding->annotated = 0; | 7130 | coding->annotated = 0; |
| @@ -7199,11 +7217,11 @@ decode_coding (struct coding_system *coding) | |||
| 7199 | return BUF. */ | 7217 | return BUF. */ |
| 7200 | 7218 | ||
| 7201 | static inline int * | 7219 | static inline int * |
| 7202 | handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, | 7220 | handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit, |
| 7203 | struct coding_system *coding, int *buf, | 7221 | struct coding_system *coding, int *buf, |
| 7204 | EMACS_INT *stop) | 7222 | ptrdiff_t *stop) |
| 7205 | { | 7223 | { |
| 7206 | EMACS_INT start, end; | 7224 | ptrdiff_t start, end; |
| 7207 | Lisp_Object prop; | 7225 | Lisp_Object prop; |
| 7208 | 7226 | ||
| 7209 | if (! find_composition (pos, limit, &start, &end, &prop, coding->src_object) | 7227 | if (! find_composition (pos, limit, &start, &end, &prop, coding->src_object) |
| @@ -7225,7 +7243,7 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, | |||
| 7225 | if (method != COMPOSITION_RELATIVE) | 7243 | if (method != COMPOSITION_RELATIVE) |
| 7226 | { | 7244 | { |
| 7227 | Lisp_Object components; | 7245 | Lisp_Object components; |
| 7228 | int len, i, i_byte; | 7246 | ptrdiff_t i, len, i_byte; |
| 7229 | 7247 | ||
| 7230 | components = COMPOSITION_COMPONENTS (prop); | 7248 | components = COMPOSITION_COMPONENTS (prop); |
| 7231 | if (VECTORP (components)) | 7249 | if (VECTORP (components)) |
| @@ -7282,9 +7300,9 @@ handle_composition_annotation (EMACS_INT pos, EMACS_INT limit, | |||
| 7282 | property value is non-nil (limiting by LIMIT), and return BUF. */ | 7300 | property value is non-nil (limiting by LIMIT), and return BUF. */ |
| 7283 | 7301 | ||
| 7284 | static inline int * | 7302 | static inline int * |
| 7285 | handle_charset_annotation (EMACS_INT pos, EMACS_INT limit, | 7303 | handle_charset_annotation (ptrdiff_t pos, ptrdiff_t limit, |
| 7286 | struct coding_system *coding, int *buf, | 7304 | struct coding_system *coding, int *buf, |
| 7287 | EMACS_INT *stop) | 7305 | ptrdiff_t *stop) |
| 7288 | { | 7306 | { |
| 7289 | Lisp_Object val, next; | 7307 | Lisp_Object val, next; |
| 7290 | int id; | 7308 | int id; |
| @@ -7311,12 +7329,12 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7311 | int *buf_end = coding->charbuf + coding->charbuf_size; | 7329 | int *buf_end = coding->charbuf + coding->charbuf_size; |
| 7312 | const unsigned char *src = coding->source + coding->consumed; | 7330 | const unsigned char *src = coding->source + coding->consumed; |
| 7313 | const unsigned char *src_end = coding->source + coding->src_bytes; | 7331 | const unsigned char *src_end = coding->source + coding->src_bytes; |
| 7314 | EMACS_INT pos = coding->src_pos + coding->consumed_char; | 7332 | ptrdiff_t pos = coding->src_pos + coding->consumed_char; |
| 7315 | EMACS_INT end_pos = coding->src_pos + coding->src_chars; | 7333 | ptrdiff_t end_pos = coding->src_pos + coding->src_chars; |
| 7316 | int multibytep = coding->src_multibyte; | 7334 | int multibytep = coding->src_multibyte; |
| 7317 | Lisp_Object eol_type; | 7335 | Lisp_Object eol_type; |
| 7318 | int c; | 7336 | int c; |
| 7319 | EMACS_INT stop, stop_composition, stop_charset; | 7337 | ptrdiff_t stop, stop_composition, stop_charset; |
| 7320 | int *lookup_buf = NULL; | 7338 | int *lookup_buf = NULL; |
| 7321 | 7339 | ||
| 7322 | if (! NILP (translation_table)) | 7340 | if (! NILP (translation_table)) |
| @@ -7365,7 +7383,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7365 | 7383 | ||
| 7366 | if (! multibytep) | 7384 | if (! multibytep) |
| 7367 | { | 7385 | { |
| 7368 | EMACS_INT bytes; | 7386 | int bytes; |
| 7369 | 7387 | ||
| 7370 | if (coding->encoder == encode_coding_raw_text | 7388 | if (coding->encoder == encode_coding_raw_text |
| 7371 | || coding->encoder == encode_coding_ccl) | 7389 | || coding->encoder == encode_coding_ccl) |
| @@ -7396,7 +7414,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7396 | *buf++ = c; | 7414 | *buf++ = c; |
| 7397 | else | 7415 | else |
| 7398 | { | 7416 | { |
| 7399 | int from_nchars = 1, to_nchars = 1; | 7417 | ptrdiff_t from_nchars = 1, to_nchars = 1; |
| 7400 | int *lookup_buf_end; | 7418 | int *lookup_buf_end; |
| 7401 | const unsigned char *p = src; | 7419 | const unsigned char *p = src; |
| 7402 | int i; | 7420 | int i; |
| @@ -7417,7 +7435,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table, | |||
| 7417 | else | 7435 | else |
| 7418 | { | 7436 | { |
| 7419 | to_nchars = ASIZE (trans); | 7437 | to_nchars = ASIZE (trans); |
| 7420 | if (buf + to_nchars > buf_end) | 7438 | if (buf_end - buf < to_nchars) |
| 7421 | break; | 7439 | break; |
| 7422 | c = XINT (AREF (trans, 0)); | 7440 | c = XINT (AREF (trans, 0)); |
| 7423 | } | 7441 | } |
| @@ -7591,9 +7609,9 @@ code_conversion_save (int with_work_buf, int multibyte) | |||
| 7591 | 7609 | ||
| 7592 | int | 7610 | int |
| 7593 | decode_coding_gap (struct coding_system *coding, | 7611 | decode_coding_gap (struct coding_system *coding, |
| 7594 | EMACS_INT chars, EMACS_INT bytes) | 7612 | ptrdiff_t chars, ptrdiff_t bytes) |
| 7595 | { | 7613 | { |
| 7596 | int count = SPECPDL_INDEX (); | 7614 | ptrdiff_t count = SPECPDL_INDEX (); |
| 7597 | Lisp_Object attrs; | 7615 | Lisp_Object attrs; |
| 7598 | 7616 | ||
| 7599 | code_conversion_save (0, 0); | 7617 | code_conversion_save (0, 0); |
| @@ -7620,7 +7638,7 @@ decode_coding_gap (struct coding_system *coding, | |||
| 7620 | attrs = CODING_ID_ATTRS (coding->id); | 7638 | attrs = CODING_ID_ATTRS (coding->id); |
| 7621 | if (! NILP (CODING_ATTR_POST_READ (attrs))) | 7639 | if (! NILP (CODING_ATTR_POST_READ (attrs))) |
| 7622 | { | 7640 | { |
| 7623 | EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; | 7641 | ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
| 7624 | Lisp_Object val; | 7642 | Lisp_Object val; |
| 7625 | 7643 | ||
| 7626 | TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); | 7644 | TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
| @@ -7668,15 +7686,15 @@ decode_coding_gap (struct coding_system *coding, | |||
| 7668 | void | 7686 | void |
| 7669 | decode_coding_object (struct coding_system *coding, | 7687 | decode_coding_object (struct coding_system *coding, |
| 7670 | Lisp_Object src_object, | 7688 | Lisp_Object src_object, |
| 7671 | EMACS_INT from, EMACS_INT from_byte, | 7689 | ptrdiff_t from, ptrdiff_t from_byte, |
| 7672 | EMACS_INT to, EMACS_INT to_byte, | 7690 | ptrdiff_t to, ptrdiff_t to_byte, |
| 7673 | Lisp_Object dst_object) | 7691 | Lisp_Object dst_object) |
| 7674 | { | 7692 | { |
| 7675 | int count = SPECPDL_INDEX (); | 7693 | ptrdiff_t count = SPECPDL_INDEX (); |
| 7676 | unsigned char *destination IF_LINT (= NULL); | 7694 | unsigned char *destination IF_LINT (= NULL); |
| 7677 | EMACS_INT dst_bytes IF_LINT (= 0); | 7695 | ptrdiff_t dst_bytes IF_LINT (= 0); |
| 7678 | EMACS_INT chars = to - from; | 7696 | ptrdiff_t chars = to - from; |
| 7679 | EMACS_INT bytes = to_byte - from_byte; | 7697 | ptrdiff_t bytes = to_byte - from_byte; |
| 7680 | Lisp_Object attrs; | 7698 | Lisp_Object attrs; |
| 7681 | int saved_pt = -1, saved_pt_byte IF_LINT (= 0); | 7699 | int saved_pt = -1, saved_pt_byte IF_LINT (= 0); |
| 7682 | int need_marker_adjustment = 0; | 7700 | int need_marker_adjustment = 0; |
| @@ -7769,7 +7787,7 @@ decode_coding_object (struct coding_system *coding, | |||
| 7769 | if (! NILP (CODING_ATTR_POST_READ (attrs))) | 7787 | if (! NILP (CODING_ATTR_POST_READ (attrs))) |
| 7770 | { | 7788 | { |
| 7771 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 7789 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 7772 | EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; | 7790 | ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE; |
| 7773 | Lisp_Object val; | 7791 | Lisp_Object val; |
| 7774 | 7792 | ||
| 7775 | TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); | 7793 | TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); |
| @@ -7858,13 +7876,13 @@ decode_coding_object (struct coding_system *coding, | |||
| 7858 | void | 7876 | void |
| 7859 | encode_coding_object (struct coding_system *coding, | 7877 | encode_coding_object (struct coding_system *coding, |
| 7860 | Lisp_Object src_object, | 7878 | Lisp_Object src_object, |
| 7861 | EMACS_INT from, EMACS_INT from_byte, | 7879 | ptrdiff_t from, ptrdiff_t from_byte, |
| 7862 | EMACS_INT to, EMACS_INT to_byte, | 7880 | ptrdiff_t to, ptrdiff_t to_byte, |
| 7863 | Lisp_Object dst_object) | 7881 | Lisp_Object dst_object) |
| 7864 | { | 7882 | { |
| 7865 | int count = SPECPDL_INDEX (); | 7883 | ptrdiff_t count = SPECPDL_INDEX (); |
| 7866 | EMACS_INT chars = to - from; | 7884 | ptrdiff_t chars = to - from; |
| 7867 | EMACS_INT bytes = to_byte - from_byte; | 7885 | ptrdiff_t bytes = to_byte - from_byte; |
| 7868 | Lisp_Object attrs; | 7886 | Lisp_Object attrs; |
| 7869 | int saved_pt = -1, saved_pt_byte IF_LINT (= 0); | 7887 | int saved_pt = -1, saved_pt_byte IF_LINT (= 0); |
| 7870 | int need_marker_adjustment = 0; | 7888 | int need_marker_adjustment = 0; |
| @@ -8112,7 +8130,7 @@ are lower-case). */) | |||
| 8112 | (Lisp_Object prompt, Lisp_Object default_coding_system) | 8130 | (Lisp_Object prompt, Lisp_Object default_coding_system) |
| 8113 | { | 8131 | { |
| 8114 | Lisp_Object val; | 8132 | Lisp_Object val; |
| 8115 | int count = SPECPDL_INDEX (); | 8133 | ptrdiff_t count = SPECPDL_INDEX (); |
| 8116 | 8134 | ||
| 8117 | if (SYMBOLP (default_coding_system)) | 8135 | if (SYMBOLP (default_coding_system)) |
| 8118 | default_coding_system = SYMBOL_NAME (default_coding_system); | 8136 | default_coding_system = SYMBOL_NAME (default_coding_system); |
| @@ -8164,7 +8182,7 @@ function `define-coding-system'. */) | |||
| 8164 | 8182 | ||
| 8165 | Lisp_Object | 8183 | Lisp_Object |
| 8166 | detect_coding_system (const unsigned char *src, | 8184 | detect_coding_system (const unsigned char *src, |
| 8167 | EMACS_INT src_chars, EMACS_INT src_bytes, | 8185 | ptrdiff_t src_chars, ptrdiff_t src_bytes, |
| 8168 | int highest, int multibytep, | 8186 | int highest, int multibytep, |
| 8169 | Lisp_Object coding_system) | 8187 | Lisp_Object coding_system) |
| 8170 | { | 8188 | { |
| @@ -8484,8 +8502,8 @@ If optional argument HIGHEST is non-nil, return the coding system of | |||
| 8484 | highest priority. */) | 8502 | highest priority. */) |
| 8485 | (Lisp_Object start, Lisp_Object end, Lisp_Object highest) | 8503 | (Lisp_Object start, Lisp_Object end, Lisp_Object highest) |
| 8486 | { | 8504 | { |
| 8487 | int from, to; | 8505 | ptrdiff_t from, to; |
| 8488 | int from_byte, to_byte; | 8506 | ptrdiff_t from_byte, to_byte; |
| 8489 | 8507 | ||
| 8490 | CHECK_NUMBER_COERCE_MARKER (start); | 8508 | CHECK_NUMBER_COERCE_MARKER (start); |
| 8491 | CHECK_NUMBER_COERCE_MARKER (end); | 8509 | CHECK_NUMBER_COERCE_MARKER (end); |
| @@ -8565,7 +8583,7 @@ DEFUN ("find-coding-systems-region-internal", | |||
| 8565 | (Lisp_Object start, Lisp_Object end, Lisp_Object exclude) | 8583 | (Lisp_Object start, Lisp_Object end, Lisp_Object exclude) |
| 8566 | { | 8584 | { |
| 8567 | Lisp_Object coding_attrs_list, safe_codings; | 8585 | Lisp_Object coding_attrs_list, safe_codings; |
| 8568 | EMACS_INT start_byte, end_byte; | 8586 | ptrdiff_t start_byte, end_byte; |
| 8569 | const unsigned char *p, *pbeg, *pend; | 8587 | const unsigned char *p, *pbeg, *pend; |
| 8570 | int c; | 8588 | int c; |
| 8571 | Lisp_Object tail, elt, work_table; | 8589 | Lisp_Object tail, elt, work_table; |
| @@ -8659,7 +8677,7 @@ DEFUN ("find-coding-systems-region-internal", | |||
| 8659 | } | 8677 | } |
| 8660 | if (charset_map_loaded) | 8678 | if (charset_map_loaded) |
| 8661 | { | 8679 | { |
| 8662 | EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | 8680 | ptrdiff_t p_offset = p - pbeg, pend_offset = pend - pbeg; |
| 8663 | 8681 | ||
| 8664 | if (STRINGP (start)) | 8682 | if (STRINGP (start)) |
| 8665 | pbeg = SDATA (start); | 8683 | pbeg = SDATA (start); |
| @@ -8697,11 +8715,11 @@ for un-encodable characters. In that case, START and END are indexes | |||
| 8697 | to the string. */) | 8715 | to the string. */) |
| 8698 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) | 8716 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) |
| 8699 | { | 8717 | { |
| 8700 | int n; | 8718 | EMACS_INT n; |
| 8701 | struct coding_system coding; | 8719 | struct coding_system coding; |
| 8702 | Lisp_Object attrs, charset_list, translation_table; | 8720 | Lisp_Object attrs, charset_list, translation_table; |
| 8703 | Lisp_Object positions; | 8721 | Lisp_Object positions; |
| 8704 | int from, to; | 8722 | ptrdiff_t from, to; |
| 8705 | const unsigned char *p, *stop, *pend; | 8723 | const unsigned char *p, *stop, *pend; |
| 8706 | int ascii_compatible; | 8724 | int ascii_compatible; |
| 8707 | 8725 | ||
| @@ -8734,11 +8752,10 @@ to the string. */) | |||
| 8734 | CHECK_STRING (string); | 8752 | CHECK_STRING (string); |
| 8735 | CHECK_NATNUM (start); | 8753 | CHECK_NATNUM (start); |
| 8736 | CHECK_NATNUM (end); | 8754 | CHECK_NATNUM (end); |
| 8755 | if (! (XINT (start) <= XINT (end) && XINT (end) <= SCHARS (string))) | ||
| 8756 | args_out_of_range_3 (string, start, end); | ||
| 8737 | from = XINT (start); | 8757 | from = XINT (start); |
| 8738 | to = XINT (end); | 8758 | 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)) | 8759 | if (! STRING_MULTIBYTE (string)) |
| 8743 | return Qnil; | 8760 | return Qnil; |
| 8744 | p = SDATA (string) + string_char_to_byte (string, from); | 8761 | p = SDATA (string) + string_char_to_byte (string, from); |
| @@ -8824,8 +8841,8 @@ is nil. */) | |||
| 8824 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list) | 8841 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list) |
| 8825 | { | 8842 | { |
| 8826 | Lisp_Object list; | 8843 | Lisp_Object list; |
| 8827 | EMACS_INT start_byte, end_byte; | 8844 | ptrdiff_t start_byte, end_byte; |
| 8828 | int pos; | 8845 | ptrdiff_t pos; |
| 8829 | const unsigned char *p, *pbeg, *pend; | 8846 | const unsigned char *p, *pbeg, *pend; |
| 8830 | int c; | 8847 | int c; |
| 8831 | Lisp_Object tail, elt, attrs; | 8848 | Lisp_Object tail, elt, attrs; |
| @@ -8898,7 +8915,7 @@ is nil. */) | |||
| 8898 | } | 8915 | } |
| 8899 | if (charset_map_loaded) | 8916 | if (charset_map_loaded) |
| 8900 | { | 8917 | { |
| 8901 | EMACS_INT p_offset = p - pbeg, pend_offset = pend - pbeg; | 8918 | ptrdiff_t p_offset = p - pbeg, pend_offset = pend - pbeg; |
| 8902 | 8919 | ||
| 8903 | if (STRINGP (start)) | 8920 | if (STRINGP (start)) |
| 8904 | pbeg = SDATA (start); | 8921 | pbeg = SDATA (start); |
| @@ -8931,7 +8948,7 @@ code_convert_region (Lisp_Object start, Lisp_Object end, | |||
| 8931 | int encodep, int norecord) | 8948 | int encodep, int norecord) |
| 8932 | { | 8949 | { |
| 8933 | struct coding_system coding; | 8950 | struct coding_system coding; |
| 8934 | EMACS_INT from, from_byte, to, to_byte; | 8951 | ptrdiff_t from, from_byte, to, to_byte; |
| 8935 | Lisp_Object src_object; | 8952 | Lisp_Object src_object; |
| 8936 | 8953 | ||
| 8937 | CHECK_NUMBER_COERCE_MARKER (start); | 8954 | CHECK_NUMBER_COERCE_MARKER (start); |
| @@ -9019,7 +9036,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system, | |||
| 9019 | Lisp_Object dst_object, int encodep, int nocopy, int norecord) | 9036 | Lisp_Object dst_object, int encodep, int nocopy, int norecord) |
| 9020 | { | 9037 | { |
| 9021 | struct coding_system coding; | 9038 | struct coding_system coding; |
| 9022 | EMACS_INT chars, bytes; | 9039 | ptrdiff_t chars, bytes; |
| 9023 | 9040 | ||
| 9024 | CHECK_STRING (string); | 9041 | CHECK_STRING (string); |
| 9025 | if (NILP (coding_system)) | 9042 | if (NILP (coding_system)) |
| @@ -9394,9 +9411,9 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...) */) | |||
| 9394 | error ("Too few arguments"); | 9411 | error ("Too few arguments"); |
| 9395 | operation = args[0]; | 9412 | operation = args[0]; |
| 9396 | if (!SYMBOLP (operation) | 9413 | if (!SYMBOLP (operation) |
| 9397 | || !NATNUMP (target_idx = Fget (operation, Qtarget_idx))) | 9414 | || (target_idx = Fget (operation, Qtarget_idx), !NATNUMP (target_idx))) |
| 9398 | error ("Invalid first argument"); | 9415 | error ("Invalid first argument"); |
| 9399 | if (nargs < 1 + XFASTINT (target_idx)) | 9416 | if (nargs <= 1 + XFASTINT (target_idx)) |
| 9400 | error ("Too few arguments for operation `%s'", | 9417 | error ("Too few arguments for operation `%s'", |
| 9401 | SDATA (SYMBOL_NAME (operation))); | 9418 | SDATA (SYMBOL_NAME (operation))); |
| 9402 | target = args[XFASTINT (target_idx) + 1]; | 9419 | target = args[XFASTINT (target_idx) + 1]; |
| @@ -9615,8 +9632,12 @@ usage: (define-coding-system-internal ...) */) | |||
| 9615 | charset_list = Vemacs_mule_charset_list; | 9632 | charset_list = Vemacs_mule_charset_list; |
| 9616 | } | 9633 | } |
| 9617 | for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) | 9634 | for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) |
| 9618 | if (max_charset_id < XFASTINT (XCAR (tail))) | 9635 | { |
| 9619 | max_charset_id = XFASTINT (XCAR (tail)); | 9636 | if (! RANGED_INTEGERP (0, XCAR (tail), INT_MAX - 1)) |
| 9637 | error ("Invalid charset-list"); | ||
| 9638 | if (max_charset_id < XFASTINT (XCAR (tail))) | ||
| 9639 | max_charset_id = XFASTINT (XCAR (tail)); | ||
| 9640 | } | ||
| 9620 | } | 9641 | } |
| 9621 | else | 9642 | else |
| 9622 | { | 9643 | { |
| @@ -9776,23 +9797,23 @@ usage: (define-coding-system-internal ...) */) | |||
| 9776 | val = Fcar (tail); | 9797 | val = Fcar (tail); |
| 9777 | if (INTEGERP (val)) | 9798 | if (INTEGERP (val)) |
| 9778 | { | 9799 | { |
| 9779 | from = to = XINT (val); | 9800 | 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)); | 9801 | args_out_of_range_3 (val, make_number (0), make_number (255)); |
| 9802 | from = to = XINT (val); | ||
| 9782 | } | 9803 | } |
| 9783 | else | 9804 | else |
| 9784 | { | 9805 | { |
| 9785 | CHECK_CONS (val); | 9806 | CHECK_CONS (val); |
| 9786 | CHECK_NATNUM_CAR (val); | 9807 | CHECK_NATNUM_CAR (val); |
| 9787 | CHECK_NATNUM_CDR (val); | 9808 | CHECK_NUMBER_CDR (val); |
| 9788 | from = XINT (XCAR (val)); | 9809 | if (XINT (XCAR (val)) > 255) |
| 9789 | if (from > 255) | ||
| 9790 | args_out_of_range_3 (XCAR (val), | 9810 | args_out_of_range_3 (XCAR (val), |
| 9791 | make_number (0), make_number (255)); | 9811 | make_number (0), make_number (255)); |
| 9792 | to = XINT (XCDR (val)); | 9812 | from = XINT (XCAR (val)); |
| 9793 | if (to < from || to > 255) | 9813 | if (! (from <= XINT (XCDR (val)) && XINT (XCDR (val)) <= 255)) |
| 9794 | args_out_of_range_3 (XCDR (val), | 9814 | args_out_of_range_3 (XCDR (val), |
| 9795 | XCAR (val), make_number (255)); | 9815 | XCAR (val), make_number (255)); |
| 9816 | to = XINT (XCDR (val)); | ||
| 9796 | } | 9817 | } |
| 9797 | for (i = from; i <= to; i++) | 9818 | for (i = from; i <= to; i++) |
| 9798 | SSET (valids, i, 1); | 9819 | SSET (valids, i, 1); |
| @@ -9887,9 +9908,10 @@ usage: (define-coding-system-internal ...) */) | |||
| 9887 | 9908 | ||
| 9888 | flags = args[coding_arg_iso2022_flags]; | 9909 | flags = args[coding_arg_iso2022_flags]; |
| 9889 | CHECK_NATNUM (flags); | 9910 | CHECK_NATNUM (flags); |
| 9890 | i = XINT (flags); | 9911 | i = XINT (flags) & INT_MAX; |
| 9891 | if (EQ (args[coding_arg_charset_list], Qiso_2022)) | 9912 | if (EQ (args[coding_arg_charset_list], Qiso_2022)) |
| 9892 | flags = make_number (i | CODING_ISO_FLAG_FULL_SUPPORT); | 9913 | i |= CODING_ISO_FLAG_FULL_SUPPORT; |
| 9914 | flags = make_number (i); | ||
| 9893 | 9915 | ||
| 9894 | ASET (attrs, coding_attr_iso_initial, initial); | 9916 | ASET (attrs, coding_attr_iso_initial, initial); |
| 9895 | ASET (attrs, coding_attr_iso_usage, reg_usage); | 9917 | ASET (attrs, coding_attr_iso_usage, reg_usage); |