aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c511
1 files changed, 207 insertions, 304 deletions
diff --git a/src/coding.c b/src/coding.c
index 6435fa1ddb1..989fd70b497 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -154,9 +154,8 @@ STRUCT CODING_SYSTEM
154 154
155#if 0 155#if 0
156static int 156static int
157detect_coding_XXX (coding, detect_info) 157detect_coding_XXX (struct coding_system *coding,
158 struct coding_system *coding; 158 struct coding_detection_info *detect_info)
159 struct coding_detection_info *detect_info;
160{ 159{
161 const unsigned char *src = coding->source; 160 const unsigned char *src = coding->source;
162 const unsigned char *src_end = coding->source + coding->src_bytes; 161 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -203,8 +202,7 @@ detect_coding_XXX (coding, detect_info)
203 202
204#if 0 203#if 0
205static void 204static void
206decode_coding_XXXX (coding) 205decode_coding_XXXX (struct coding_system *coding)
207 struct coding_system *coding;
208{ 206{
209 const unsigned char *src = coding->source + coding->consumed; 207 const unsigned char *src = coding->source + coding->consumed;
210 const unsigned char *src_end = coding->source + coding->src_bytes; 208 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -261,8 +259,7 @@ decode_coding_XXXX (coding)
261 Below is a template of these functions. */ 259 Below is a template of these functions. */
262#if 0 260#if 0
263static void 261static void
264encode_coding_XXX (coding) 262encode_coding_XXX (struct coding_system *coding)
265 struct coding_system *coding;
266{ 263{
267 int multibytep = coding->dst_multibyte; 264 int multibytep = coding->dst_multibyte;
268 int *charbuf = coding->charbuf; 265 int *charbuf = coding->charbuf;
@@ -896,80 +893,80 @@ static struct coding_system coding_categories[coding_category_max];
896 893
897 894
898/* Prototypes for static functions. */ 895/* Prototypes for static functions. */
899static void record_conversion_result P_ ((struct coding_system *coding, 896static void record_conversion_result (struct coding_system *coding,
900 enum coding_result_code result)); 897 enum coding_result_code result);
901static int detect_coding_utf_8 P_ ((struct coding_system *, 898static int detect_coding_utf_8 (struct coding_system *,
902 struct coding_detection_info *info)); 899 struct coding_detection_info *info);
903static void decode_coding_utf_8 P_ ((struct coding_system *)); 900static void decode_coding_utf_8 (struct coding_system *);
904static int encode_coding_utf_8 P_ ((struct coding_system *)); 901static int encode_coding_utf_8 (struct coding_system *);
905 902
906static int detect_coding_utf_16 P_ ((struct coding_system *, 903static int detect_coding_utf_16 (struct coding_system *,
907 struct coding_detection_info *info)); 904 struct coding_detection_info *info);
908static void decode_coding_utf_16 P_ ((struct coding_system *)); 905static void decode_coding_utf_16 (struct coding_system *);
909static int encode_coding_utf_16 P_ ((struct coding_system *)); 906static int encode_coding_utf_16 (struct coding_system *);
910 907
911static int detect_coding_iso_2022 P_ ((struct coding_system *, 908static int detect_coding_iso_2022 (struct coding_system *,
912 struct coding_detection_info *info)); 909 struct coding_detection_info *info);
913static void decode_coding_iso_2022 P_ ((struct coding_system *)); 910static void decode_coding_iso_2022 (struct coding_system *);
914static int encode_coding_iso_2022 P_ ((struct coding_system *)); 911static int encode_coding_iso_2022 (struct coding_system *);
915 912
916static int detect_coding_emacs_mule P_ ((struct coding_system *, 913static int detect_coding_emacs_mule (struct coding_system *,
917 struct coding_detection_info *info)); 914 struct coding_detection_info *info);
918static void decode_coding_emacs_mule P_ ((struct coding_system *)); 915static void decode_coding_emacs_mule (struct coding_system *);
919static int encode_coding_emacs_mule P_ ((struct coding_system *)); 916static int encode_coding_emacs_mule (struct coding_system *);
920 917
921static int detect_coding_sjis P_ ((struct coding_system *, 918static int detect_coding_sjis (struct coding_system *,
922 struct coding_detection_info *info)); 919 struct coding_detection_info *info);
923static void decode_coding_sjis P_ ((struct coding_system *)); 920static void decode_coding_sjis (struct coding_system *);
924static int encode_coding_sjis P_ ((struct coding_system *)); 921static int encode_coding_sjis (struct coding_system *);
925 922
926static int detect_coding_big5 P_ ((struct coding_system *, 923static int detect_coding_big5 (struct coding_system *,
927 struct coding_detection_info *info)); 924 struct coding_detection_info *info);
928static void decode_coding_big5 P_ ((struct coding_system *)); 925static void decode_coding_big5 (struct coding_system *);
929static int encode_coding_big5 P_ ((struct coding_system *)); 926static int encode_coding_big5 (struct coding_system *);
930 927
931static int detect_coding_ccl P_ ((struct coding_system *, 928static int detect_coding_ccl (struct coding_system *,
932 struct coding_detection_info *info)); 929 struct coding_detection_info *info);
933static void decode_coding_ccl P_ ((struct coding_system *)); 930static void decode_coding_ccl (struct coding_system *);
934static int encode_coding_ccl P_ ((struct coding_system *)); 931static int encode_coding_ccl (struct coding_system *);
935 932
936static void decode_coding_raw_text P_ ((struct coding_system *)); 933static void decode_coding_raw_text (struct coding_system *);
937static int encode_coding_raw_text P_ ((struct coding_system *)); 934static int encode_coding_raw_text (struct coding_system *);
938 935
939static void coding_set_source P_ ((struct coding_system *)); 936static void coding_set_source (struct coding_system *);
940static void coding_set_destination P_ ((struct coding_system *)); 937static void coding_set_destination (struct coding_system *);
941static void coding_alloc_by_realloc P_ ((struct coding_system *, EMACS_INT)); 938static void coding_alloc_by_realloc (struct coding_system *, EMACS_INT);
942static void coding_alloc_by_making_gap P_ ((struct coding_system *, 939static void coding_alloc_by_making_gap (struct coding_system *,
943 EMACS_INT, EMACS_INT)); 940 EMACS_INT, EMACS_INT);
944static unsigned char *alloc_destination P_ ((struct coding_system *, 941static unsigned char *alloc_destination (struct coding_system *,
945 EMACS_INT, unsigned char *)); 942 EMACS_INT, unsigned char *);
946static void setup_iso_safe_charsets P_ ((Lisp_Object)); 943static void setup_iso_safe_charsets (Lisp_Object);
947static unsigned char *encode_designation_at_bol P_ ((struct coding_system *, 944static unsigned char *encode_designation_at_bol (struct coding_system *,
948 int *, int *, 945 int *, int *,
949 unsigned char *)); 946 unsigned char *);
950static int detect_eol P_ ((const unsigned char *, 947static int detect_eol (const unsigned char *,
951 EMACS_INT, enum coding_category)); 948 EMACS_INT, enum coding_category);
952static Lisp_Object adjust_coding_eol_type P_ ((struct coding_system *, int)); 949static Lisp_Object adjust_coding_eol_type (struct coding_system *, int);
953static void decode_eol P_ ((struct coding_system *)); 950static void decode_eol (struct coding_system *);
954static Lisp_Object get_translation_table P_ ((Lisp_Object, int, int *)); 951static Lisp_Object get_translation_table (Lisp_Object, int, int *);
955static Lisp_Object get_translation P_ ((Lisp_Object, int *, int *)); 952static Lisp_Object get_translation (Lisp_Object, int *, int *);
956static int produce_chars P_ ((struct coding_system *, Lisp_Object, int)); 953static int produce_chars (struct coding_system *, Lisp_Object, int);
957static INLINE void produce_charset P_ ((struct coding_system *, int *, 954static INLINE void produce_charset (struct coding_system *, int *,
958 EMACS_INT)); 955 EMACS_INT);
959static void produce_annotation P_ ((struct coding_system *, EMACS_INT)); 956static void produce_annotation (struct coding_system *, EMACS_INT);
960static int decode_coding P_ ((struct coding_system *)); 957static int decode_coding (struct coding_system *);
961static INLINE int *handle_composition_annotation P_ ((EMACS_INT, EMACS_INT, 958static INLINE int *handle_composition_annotation (EMACS_INT, EMACS_INT,
962 struct coding_system *, 959 struct coding_system *,
963 int *, EMACS_INT *)); 960 int *, EMACS_INT *);
964static INLINE int *handle_charset_annotation P_ ((EMACS_INT, EMACS_INT, 961static INLINE int *handle_charset_annotation (EMACS_INT, EMACS_INT,
965 struct coding_system *, 962 struct coding_system *,
966 int *, EMACS_INT *)); 963 int *, EMACS_INT *);
967static void consume_chars P_ ((struct coding_system *, Lisp_Object, int)); 964static void consume_chars (struct coding_system *, Lisp_Object, int);
968static int encode_coding P_ ((struct coding_system *)); 965static int encode_coding (struct coding_system *);
969static Lisp_Object make_conversion_work_buffer P_ ((int)); 966static Lisp_Object make_conversion_work_buffer (int);
970static Lisp_Object code_conversion_restore P_ ((Lisp_Object)); 967static Lisp_Object code_conversion_restore (Lisp_Object);
971static INLINE int char_encodable_p P_ ((int, Lisp_Object)); 968static INLINE int char_encodable_p (int, Lisp_Object);
972static Lisp_Object make_subsidiaries P_ ((Lisp_Object)); 969static Lisp_Object make_subsidiaries (Lisp_Object);
973 970
974static void 971static void
975record_conversion_result (struct coding_system *coding, 972record_conversion_result (struct coding_system *coding,
@@ -1106,8 +1103,7 @@ record_conversion_result (struct coding_system *coding,
1106 1103
1107 1104
1108static void 1105static void
1109coding_set_source (coding) 1106coding_set_source (struct coding_system *coding)
1110 struct coding_system *coding;
1111{ 1107{
1112 if (BUFFERP (coding->src_object)) 1108 if (BUFFERP (coding->src_object))
1113 { 1109 {
@@ -1129,8 +1125,7 @@ coding_set_source (coding)
1129} 1125}
1130 1126
1131static void 1127static void
1132coding_set_destination (coding) 1128coding_set_destination (struct coding_system *coding)
1133 struct coding_system *coding;
1134{ 1129{
1135 if (BUFFERP (coding->dst_object)) 1130 if (BUFFERP (coding->dst_object))
1136 { 1131 {
@@ -1159,9 +1154,7 @@ coding_set_destination (coding)
1159 1154
1160 1155
1161static void 1156static void
1162coding_alloc_by_realloc (coding, bytes) 1157coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes)
1163 struct coding_system *coding;
1164 EMACS_INT bytes;
1165{ 1158{
1166 coding->destination = (unsigned char *) xrealloc (coding->destination, 1159 coding->destination = (unsigned char *) xrealloc (coding->destination,
1167 coding->dst_bytes + bytes); 1160 coding->dst_bytes + bytes);
@@ -1169,9 +1162,8 @@ coding_alloc_by_realloc (coding, bytes)
1169} 1162}
1170 1163
1171static void 1164static void
1172coding_alloc_by_making_gap (coding, gap_head_used, bytes) 1165coding_alloc_by_making_gap (struct coding_system *coding,
1173 struct coding_system *coding; 1166 EMACS_INT gap_head_used, EMACS_INT bytes)
1174 EMACS_INT gap_head_used, bytes;
1175{ 1167{
1176 if (EQ (coding->src_object, coding->dst_object)) 1168 if (EQ (coding->src_object, coding->dst_object))
1177 { 1169 {
@@ -1200,10 +1192,8 @@ coding_alloc_by_making_gap (coding, gap_head_used, bytes)
1200 1192
1201 1193
1202static unsigned char * 1194static unsigned char *
1203alloc_destination (coding, nbytes, dst) 1195alloc_destination (struct coding_system *coding, EMACS_INT nbytes,
1204 struct coding_system *coding; 1196 unsigned char *dst)
1205 EMACS_INT nbytes;
1206 unsigned char *dst;
1207{ 1197{
1208 EMACS_INT offset = dst - coding->destination; 1198 EMACS_INT offset = dst - coding->destination;
1209 1199
@@ -1301,9 +1291,8 @@ alloc_destination (coding, nbytes, dst)
1301#define UTF_8_BOM_3 0xBF 1291#define UTF_8_BOM_3 0xBF
1302 1292
1303static int 1293static int
1304detect_coding_utf_8 (coding, detect_info) 1294detect_coding_utf_8 (struct coding_system *coding,
1305 struct coding_system *coding; 1295 struct coding_detection_info *detect_info)
1306 struct coding_detection_info *detect_info;
1307{ 1296{
1308 const unsigned char *src = coding->source, *src_base; 1297 const unsigned char *src = coding->source, *src_base;
1309 const unsigned char *src_end = coding->source + coding->src_bytes; 1298 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1386,8 +1375,7 @@ detect_coding_utf_8 (coding, detect_info)
1386 1375
1387 1376
1388static void 1377static void
1389decode_coding_utf_8 (coding) 1378decode_coding_utf_8 (struct coding_system *coding)
1390 struct coding_system *coding;
1391{ 1379{
1392 const unsigned char *src = coding->source + coding->consumed; 1380 const unsigned char *src = coding->source + coding->consumed;
1393 const unsigned char *src_end = coding->source + coding->src_bytes; 1381 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1435,8 +1423,6 @@ decode_coding_utf_8 (coding)
1435 } 1423 }
1436 CODING_UTF_8_BOM (coding) = utf_without_bom; 1424 CODING_UTF_8_BOM (coding) = utf_without_bom;
1437 1425
1438
1439
1440 while (1) 1426 while (1)
1441 { 1427 {
1442 int c, c1, c2, c3, c4, c5; 1428 int c, c1, c2, c3, c4, c5;
@@ -1459,7 +1445,7 @@ decode_coding_utf_8 (coding)
1459 { 1445 {
1460 c = - c1; 1446 c = - c1;
1461 } 1447 }
1462 else if (UTF_8_1_OCTET_P(c1)) 1448 else if (UTF_8_1_OCTET_P (c1))
1463 { 1449 {
1464 if (eol_crlf && c1 == '\r') 1450 if (eol_crlf && c1 == '\r')
1465 ONE_MORE_BYTE (byte_after_cr); 1451 ONE_MORE_BYTE (byte_after_cr);
@@ -1543,8 +1529,7 @@ decode_coding_utf_8 (coding)
1543 1529
1544 1530
1545static int 1531static int
1546encode_coding_utf_8 (coding) 1532encode_coding_utf_8 (struct coding_system *coding)
1547 struct coding_system *coding;
1548{ 1533{
1549 int multibytep = coding->dst_multibyte; 1534 int multibytep = coding->dst_multibyte;
1550 int *charbuf = coding->charbuf; 1535 int *charbuf = coding->charbuf;
@@ -1623,9 +1608,8 @@ encode_coding_utf_8 (coding)
1623 1608
1624 1609
1625static int 1610static int
1626detect_coding_utf_16 (coding, detect_info) 1611detect_coding_utf_16 (struct coding_system *coding,
1627 struct coding_system *coding; 1612 struct coding_detection_info *detect_info)
1628 struct coding_detection_info *detect_info;
1629{ 1613{
1630 const unsigned char *src = coding->source, *src_base = src; 1614 const unsigned char *src = coding->source, *src_base = src;
1631 const unsigned char *src_end = coding->source + coding->src_bytes; 1615 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1708,8 +1692,7 @@ detect_coding_utf_16 (coding, detect_info)
1708} 1692}
1709 1693
1710static void 1694static void
1711decode_coding_utf_16 (coding) 1695decode_coding_utf_16 (struct coding_system *coding)
1712 struct coding_system *coding;
1713{ 1696{
1714 const unsigned char *src = coding->source + coding->consumed; 1697 const unsigned char *src = coding->source + coding->consumed;
1715 const unsigned char *src_end = coding->source + coding->src_bytes; 1698 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1837,8 +1820,7 @@ decode_coding_utf_16 (coding)
1837} 1820}
1838 1821
1839static int 1822static int
1840encode_coding_utf_16 (coding) 1823encode_coding_utf_16 (struct coding_system *coding)
1841 struct coding_system *coding;
1842{ 1824{
1843 int multibytep = coding->dst_multibyte; 1825 int multibytep = coding->dst_multibyte;
1844 int *charbuf = coding->charbuf; 1826 int *charbuf = coding->charbuf;
@@ -1979,9 +1961,8 @@ char emacs_mule_bytes[256];
1979 else return 0. */ 1961 else return 0. */
1980 1962
1981static int 1963static int
1982detect_coding_emacs_mule (coding, detect_info) 1964detect_coding_emacs_mule (struct coding_system *coding,
1983 struct coding_system *coding; 1965 struct coding_detection_info *detect_info)
1984 struct coding_detection_info *detect_info;
1985{ 1966{
1986 const unsigned char *src = coding->source, *src_base; 1967 const unsigned char *src = coding->source, *src_base;
1987 const unsigned char *src_end = coding->source + coding->src_bytes; 1968 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -2069,11 +2050,9 @@ detect_coding_emacs_mule (coding, detect_info)
2069 -1. If SRC is too short, return -2. */ 2050 -1. If SRC is too short, return -2. */
2070 2051
2071int 2052int
2072emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status) 2053emacs_mule_char (struct coding_system *coding, const unsigned char *src,
2073 struct coding_system *coding; 2054 int *nbytes, int *nchars, int *id,
2074 const unsigned char *src; 2055 struct composition_status *cmp_status)
2075 int *nbytes, *nchars, *id;
2076 struct composition_status *cmp_status;
2077{ 2056{
2078 const unsigned char *src_end = coding->source + coding->src_bytes; 2057 const unsigned char *src_end = coding->source + coding->src_bytes;
2079 const unsigned char *src_base = src; 2058 const unsigned char *src_base = src;
@@ -2210,7 +2189,7 @@ emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status)
2210 (3) alt&rule composition: 0x80 0xF5 BYTES CHARS | ALT RULE ... ALT CHAR ... 2189 (3) alt&rule composition: 0x80 0xF5 BYTES CHARS | ALT RULE ... ALT CHAR ...
2211 2190
2212 and these old form: 2191 and these old form:
2213 2192
2214 (4) relative composition: 0x80 | MSEQ ... MSEQ 2193 (4) relative composition: 0x80 | MSEQ ... MSEQ
2215 (5) rulebase composition: 0x80 0xFF | MSEQ MRULE ... MSEQ 2194 (5) rulebase composition: 0x80 0xFF | MSEQ MRULE ... MSEQ
2216 2195
@@ -2391,9 +2370,8 @@ emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status)
2391 2370
2392 2371
2393static int 2372static int
2394emacs_mule_finish_composition (charbuf, cmp_status) 2373emacs_mule_finish_composition (int *charbuf,
2395 int *charbuf; 2374 struct composition_status *cmp_status)
2396 struct composition_status *cmp_status;
2397{ 2375{
2398 int idx = - cmp_status->length; 2376 int idx = - cmp_status->length;
2399 int new_chars; 2377 int new_chars;
@@ -2448,8 +2426,7 @@ emacs_mule_finish_composition (charbuf, cmp_status)
2448 2426
2449 2427
2450static void 2428static void
2451decode_coding_emacs_mule (coding) 2429decode_coding_emacs_mule (struct coding_system *coding)
2452 struct coding_system *coding;
2453{ 2430{
2454 const unsigned char *src = coding->source + coding->consumed; 2431 const unsigned char *src = coding->source + coding->consumed;
2455 const unsigned char *src_end = coding->source + coding->src_bytes; 2432 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -2713,8 +2690,7 @@ decode_coding_emacs_mule (coding)
2713 2690
2714 2691
2715static int 2692static int
2716encode_coding_emacs_mule (coding) 2693encode_coding_emacs_mule (struct coding_system *coding)
2717 struct coding_system *coding;
2718{ 2694{
2719 int multibytep = coding->dst_multibyte; 2695 int multibytep = coding->dst_multibyte;
2720 int *charbuf = coding->charbuf; 2696 int *charbuf = coding->charbuf;
@@ -3007,8 +2983,7 @@ enum iso_code_class_type iso_code_class[256];
3007 (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0) 2983 (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0)
3008 2984
3009static void 2985static void
3010setup_iso_safe_charsets (attrs) 2986setup_iso_safe_charsets (Lisp_Object attrs)
3011 Lisp_Object attrs;
3012{ 2987{
3013 Lisp_Object charset_list, safe_charsets; 2988 Lisp_Object charset_list, safe_charsets;
3014 Lisp_Object request; 2989 Lisp_Object request;
@@ -3076,9 +3051,8 @@ setup_iso_safe_charsets (attrs)
3076 If it is, return 1, else return 0. */ 3051 If it is, return 1, else return 0. */
3077 3052
3078static int 3053static int
3079detect_coding_iso_2022 (coding, detect_info) 3054detect_coding_iso_2022 (struct coding_system *coding,
3080 struct coding_system *coding; 3055 struct coding_detection_info *detect_info)
3081 struct coding_detection_info *detect_info;
3082{ 3056{
3083 const unsigned char *src = coding->source, *src_base = src; 3057 const unsigned char *src = coding->source, *src_base = src;
3084 const unsigned char *src_end = coding->source + coding->src_bytes; 3058 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -3442,12 +3416,10 @@ detect_coding_iso_2022 (coding, detect_info)
3442 3416
3443/* Finish the current composition as invalid. */ 3417/* Finish the current composition as invalid. */
3444 3418
3445static int finish_composition P_ ((int *, struct composition_status *)); 3419static int finish_composition (int *, struct composition_status *);
3446 3420
3447static int 3421static int
3448finish_composition (charbuf, cmp_status) 3422finish_composition (int *charbuf, struct composition_status *cmp_status)
3449 int *charbuf;
3450 struct composition_status *cmp_status;
3451{ 3423{
3452 int idx = - cmp_status->length; 3424 int idx = - cmp_status->length;
3453 int new_chars; 3425 int new_chars;
@@ -3584,8 +3556,7 @@ finish_composition (charbuf, cmp_status)
3584/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ 3556/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */
3585 3557
3586static void 3558static void
3587decode_coding_iso_2022 (coding) 3559decode_coding_iso_2022 (struct coding_system *coding)
3588 struct coding_system *coding;
3589{ 3560{
3590 const unsigned char *src = coding->source + coding->consumed; 3561 const unsigned char *src = coding->source + coding->consumed;
3591 const unsigned char *src_end = coding->source + coding->src_bytes; 3562 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4317,7 +4288,7 @@ decode_coding_iso_2022 (coding)
4317 4288
4318#define ENCODE_ISO_CHARACTER(charset, c) \ 4289#define ENCODE_ISO_CHARACTER(charset, c) \
4319 do { \ 4290 do { \
4320 int code = ENCODE_CHAR ((charset),(c)); \ 4291 int code = ENCODE_CHAR ((charset), (c)); \
4321 \ 4292 \
4322 if (CHARSET_DIMENSION (charset) == 1) \ 4293 if (CHARSET_DIMENSION (charset) == 1) \
4323 ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ 4294 ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \
@@ -4331,11 +4302,9 @@ decode_coding_iso_2022 (coding)
4331 Return new DST. */ 4302 Return new DST. */
4332 4303
4333unsigned char * 4304unsigned char *
4334encode_invocation_designation (charset, coding, dst, p_nchars) 4305encode_invocation_designation (struct charset *charset,
4335 struct charset *charset; 4306 struct coding_system *coding,
4336 struct coding_system *coding; 4307 unsigned char *dst, int *p_nchars)
4337 unsigned char *dst;
4338 int *p_nchars;
4339{ 4308{
4340 int multibytep = coding->dst_multibyte; 4309 int multibytep = coding->dst_multibyte;
4341 int produced_chars = *p_nchars; 4310 int produced_chars = *p_nchars;
@@ -4447,10 +4416,8 @@ encode_invocation_designation (charset, coding, dst, p_nchars)
4447 find all the necessary designations. */ 4416 find all the necessary designations. */
4448 4417
4449static unsigned char * 4418static unsigned char *
4450encode_designation_at_bol (coding, charbuf, charbuf_end, dst) 4419encode_designation_at_bol (struct coding_system *coding, int *charbuf,
4451 struct coding_system *coding; 4420 int *charbuf_end, unsigned char *dst)
4452 int *charbuf, *charbuf_end;
4453 unsigned char *dst;
4454{ 4421{
4455 struct charset *charset; 4422 struct charset *charset;
4456 /* Table of charsets to be designated to each graphic register. */ 4423 /* Table of charsets to be designated to each graphic register. */
@@ -4500,8 +4467,7 @@ encode_designation_at_bol (coding, charbuf, charbuf_end, dst)
4500/* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ 4467/* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */
4501 4468
4502static int 4469static int
4503encode_coding_iso_2022 (coding) 4470encode_coding_iso_2022 (struct coding_system *coding)
4504 struct coding_system *coding;
4505{ 4471{
4506 int multibytep = coding->dst_multibyte; 4472 int multibytep = coding->dst_multibyte;
4507 int *charbuf = coding->charbuf; 4473 int *charbuf = coding->charbuf;
@@ -4691,9 +4657,8 @@ encode_coding_iso_2022 (coding)
4691 CATEGORY_MASK_SJIS, else return 0. */ 4657 CATEGORY_MASK_SJIS, else return 0. */
4692 4658
4693static int 4659static int
4694detect_coding_sjis (coding, detect_info) 4660detect_coding_sjis (struct coding_system *coding,
4695 struct coding_system *coding; 4661 struct coding_detection_info *detect_info)
4696 struct coding_detection_info *detect_info;
4697{ 4662{
4698 const unsigned char *src = coding->source, *src_base; 4663 const unsigned char *src = coding->source, *src_base;
4699 const unsigned char *src_end = coding->source + coding->src_bytes; 4664 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4749,9 +4714,8 @@ detect_coding_sjis (coding, detect_info)
4749 CATEGORY_MASK_BIG5, else return 0. */ 4714 CATEGORY_MASK_BIG5, else return 0. */
4750 4715
4751static int 4716static int
4752detect_coding_big5 (coding, detect_info) 4717detect_coding_big5 (struct coding_system *coding,
4753 struct coding_system *coding; 4718 struct coding_detection_info *detect_info)
4754 struct coding_detection_info *detect_info;
4755{ 4719{
4756 const unsigned char *src = coding->source, *src_base; 4720 const unsigned char *src = coding->source, *src_base;
4757 const unsigned char *src_end = coding->source + coding->src_bytes; 4721 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4797,8 +4761,7 @@ detect_coding_big5 (coding, detect_info)
4797 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */ 4761 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */
4798 4762
4799static void 4763static void
4800decode_coding_sjis (coding) 4764decode_coding_sjis (struct coding_system *coding)
4801 struct coding_system *coding;
4802{ 4765{
4803 const unsigned char *src = coding->source + coding->consumed; 4766 const unsigned char *src = coding->source + coding->consumed;
4804 const unsigned char *src_end = coding->source + coding->src_bytes; 4767 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4916,8 +4879,7 @@ decode_coding_sjis (coding)
4916} 4879}
4917 4880
4918static void 4881static void
4919decode_coding_big5 (coding) 4882decode_coding_big5 (struct coding_system *coding)
4920 struct coding_system *coding;
4921{ 4883{
4922 const unsigned char *src = coding->source + coding->consumed; 4884 const unsigned char *src = coding->source + coding->consumed;
4923 const unsigned char *src_end = coding->source + coding->src_bytes; 4885 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5021,8 +4983,7 @@ decode_coding_big5 (coding)
5021 SJIS text, else encode BIG5 text. */ 4983 SJIS text, else encode BIG5 text. */
5022 4984
5023static int 4985static int
5024encode_coding_sjis (coding) 4986encode_coding_sjis (struct coding_system *coding)
5025 struct coding_system *coding;
5026{ 4987{
5027 int multibytep = coding->dst_multibyte; 4988 int multibytep = coding->dst_multibyte;
5028 int *charbuf = coding->charbuf; 4989 int *charbuf = coding->charbuf;
@@ -5114,8 +5075,7 @@ encode_coding_sjis (coding)
5114} 5075}
5115 5076
5116static int 5077static int
5117encode_coding_big5 (coding) 5078encode_coding_big5 (struct coding_system *coding)
5118 struct coding_system *coding;
5119{ 5079{
5120 int multibytep = coding->dst_multibyte; 5080 int multibytep = coding->dst_multibyte;
5121 int *charbuf = coding->charbuf; 5081 int *charbuf = coding->charbuf;
@@ -5193,9 +5153,8 @@ encode_coding_big5 (coding)
5193 CATEGORY_MASK_CCL, else return 0. */ 5153 CATEGORY_MASK_CCL, else return 0. */
5194 5154
5195static int 5155static int
5196detect_coding_ccl (coding, detect_info) 5156detect_coding_ccl (struct coding_system *coding,
5197 struct coding_system *coding; 5157 struct coding_detection_info *detect_info)
5198 struct coding_detection_info *detect_info;
5199{ 5158{
5200 const unsigned char *src = coding->source, *src_base; 5159 const unsigned char *src = coding->source, *src_base;
5201 const unsigned char *src_end = coding->source + coding->src_bytes; 5160 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5234,8 +5193,7 @@ detect_coding_ccl (coding, detect_info)
5234} 5193}
5235 5194
5236static void 5195static void
5237decode_coding_ccl (coding) 5196decode_coding_ccl (struct coding_system *coding)
5238 struct coding_system *coding;
5239{ 5197{
5240 const unsigned char *src = coding->source + coding->consumed; 5198 const unsigned char *src = coding->source + coding->consumed;
5241 const unsigned char *src_end = coding->source + coding->src_bytes; 5199 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5304,8 +5262,7 @@ decode_coding_ccl (coding)
5304} 5262}
5305 5263
5306static int 5264static int
5307encode_coding_ccl (coding) 5265encode_coding_ccl (struct coding_system *coding)
5308 struct coding_system *coding;
5309{ 5266{
5310 struct ccl_program *ccl = &coding->spec.ccl->ccl; 5267 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5311 int multibytep = coding->dst_multibyte; 5268 int multibytep = coding->dst_multibyte;
@@ -5374,8 +5331,7 @@ encode_coding_ccl (coding)
5374/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */ 5331/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */
5375 5332
5376static void 5333static void
5377decode_coding_raw_text (coding) 5334decode_coding_raw_text (struct coding_system *coding)
5378 struct coding_system *coding;
5379{ 5335{
5380 int eol_crlf = 5336 int eol_crlf =
5381 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 5337 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
@@ -5394,8 +5350,7 @@ decode_coding_raw_text (coding)
5394} 5350}
5395 5351
5396static int 5352static int
5397encode_coding_raw_text (coding) 5353encode_coding_raw_text (struct coding_system *coding)
5398 struct coding_system *coding;
5399{ 5354{
5400 int multibytep = coding->dst_multibyte; 5355 int multibytep = coding->dst_multibyte;
5401 int *charbuf = coding->charbuf; 5356 int *charbuf = coding->charbuf;
@@ -5478,9 +5433,8 @@ encode_coding_raw_text (coding)
5478 is, return 1, else return 0. */ 5433 is, return 1, else return 0. */
5479 5434
5480static int 5435static int
5481detect_coding_charset (coding, detect_info) 5436detect_coding_charset (struct coding_system *coding,
5482 struct coding_system *coding; 5437 struct coding_detection_info *detect_info)
5483 struct coding_detection_info *detect_info;
5484{ 5438{
5485 const unsigned char *src = coding->source, *src_base; 5439 const unsigned char *src = coding->source, *src_base;
5486 const unsigned char *src_end = coding->source + coding->src_bytes; 5440 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5582,8 +5536,7 @@ detect_coding_charset (coding, detect_info)
5582} 5536}
5583 5537
5584static void 5538static void
5585decode_coding_charset (coding) 5539decode_coding_charset (struct coding_system *coding)
5586 struct coding_system *coding;
5587{ 5540{
5588 const unsigned char *src = coding->source + coding->consumed; 5541 const unsigned char *src = coding->source + coding->consumed;
5589 const unsigned char *src_end = coding->source + coding->src_bytes; 5542 const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5711,8 +5664,7 @@ decode_coding_charset (coding)
5711} 5664}
5712 5665
5713static int 5666static int
5714encode_coding_charset (coding) 5667encode_coding_charset (struct coding_system *coding)
5715 struct coding_system *coding;
5716{ 5668{
5717 int multibytep = coding->dst_multibyte; 5669 int multibytep = coding->dst_multibyte;
5718 int *charbuf = coding->charbuf; 5670 int *charbuf = coding->charbuf;
@@ -5782,9 +5734,7 @@ encode_coding_charset (coding)
5782 CODING_SYSTEM is invalid, signal an error. */ 5734 CODING_SYSTEM is invalid, signal an error. */
5783 5735
5784void 5736void
5785setup_coding_system (coding_system, coding) 5737setup_coding_system (Lisp_Object coding_system, struct coding_system *coding)
5786 Lisp_Object coding_system;
5787 struct coding_system *coding;
5788{ 5738{
5789 Lisp_Object attrs; 5739 Lisp_Object attrs;
5790 Lisp_Object eol_type; 5740 Lisp_Object eol_type;
@@ -5987,8 +5937,7 @@ setup_coding_system (coding_system, coding)
5987/* Return a list of charsets supported by CODING. */ 5937/* Return a list of charsets supported by CODING. */
5988 5938
5989Lisp_Object 5939Lisp_Object
5990coding_charset_list (coding) 5940coding_charset_list (struct coding_system *coding)
5991 struct coding_system *coding;
5992{ 5941{
5993 Lisp_Object attrs, charset_list; 5942 Lisp_Object attrs, charset_list;
5994 5943
@@ -6011,8 +5960,7 @@ coding_charset_list (coding)
6011/* Return a list of charsets supported by CODING-SYSTEM. */ 5960/* Return a list of charsets supported by CODING-SYSTEM. */
6012 5961
6013Lisp_Object 5962Lisp_Object
6014coding_system_charset_list (coding_system) 5963coding_system_charset_list (Lisp_Object coding_system)
6015 Lisp_Object coding_system;
6016{ 5964{
6017 int id; 5965 int id;
6018 Lisp_Object attrs, charset_list; 5966 Lisp_Object attrs, charset_list;
@@ -6045,8 +5993,7 @@ coding_system_charset_list (coding_system)
6045 eol_type as CODING-SYSTEM. */ 5993 eol_type as CODING-SYSTEM. */
6046 5994
6047Lisp_Object 5995Lisp_Object
6048raw_text_coding_system (coding_system) 5996raw_text_coding_system (Lisp_Object coding_system)
6049 Lisp_Object coding_system;
6050{ 5997{
6051 Lisp_Object spec, attrs; 5998 Lisp_Object spec, attrs;
6052 Lisp_Object eol_type, raw_text_eol_type; 5999 Lisp_Object eol_type, raw_text_eol_type;
@@ -6077,8 +6024,7 @@ raw_text_coding_system (coding_system)
6077 (system_eol_type). */ 6024 (system_eol_type). */
6078 6025
6079Lisp_Object 6026Lisp_Object
6080coding_inherit_eol_type (coding_system, parent) 6027coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
6081 Lisp_Object coding_system, parent;
6082{ 6028{
6083 Lisp_Object spec, eol_type; 6029 Lisp_Object spec, eol_type;
6084 6030
@@ -6233,10 +6179,8 @@ coding_inherit_eol_type (coding_system, parent)
6233#define MAX_EOL_CHECK_COUNT 3 6179#define MAX_EOL_CHECK_COUNT 3
6234 6180
6235static int 6181static int
6236detect_eol (source, src_bytes, category) 6182detect_eol (const unsigned char *source, EMACS_INT src_bytes,
6237 const unsigned char *source; 6183 enum coding_category category)
6238 EMACS_INT src_bytes;
6239 enum coding_category category;
6240{ 6184{
6241 const unsigned char *src = source, *src_end = src + src_bytes; 6185 const unsigned char *src = source, *src_end = src + src_bytes;
6242 unsigned char c; 6186 unsigned char c;
@@ -6334,9 +6278,7 @@ detect_eol (source, src_bytes, category)
6334 6278
6335 6279
6336static Lisp_Object 6280static Lisp_Object
6337adjust_coding_eol_type (coding, eol_seen) 6281adjust_coding_eol_type (struct coding_system *coding, int eol_seen)
6338 struct coding_system *coding;
6339 int eol_seen;
6340{ 6282{
6341 Lisp_Object eol_type; 6283 Lisp_Object eol_type;
6342 6284
@@ -6364,8 +6306,7 @@ adjust_coding_eol_type (coding, eol_seen)
6364 system. */ 6306 system. */
6365 6307
6366void 6308void
6367detect_coding (coding) 6309detect_coding (struct coding_system *coding)
6368 struct coding_system *coding;
6369{ 6310{
6370 const unsigned char *src, *src_end; 6311 const unsigned char *src, *src_end;
6371 int saved_mode = coding->mode; 6312 int saved_mode = coding->mode;
@@ -6544,8 +6485,7 @@ detect_coding (coding)
6544 6485
6545 6486
6546static void 6487static void
6547decode_eol (coding) 6488decode_eol (struct coding_system *coding)
6548 struct coding_system *coding;
6549{ 6489{
6550 Lisp_Object eol_type; 6490 Lisp_Object eol_type;
6551 unsigned char *p, *pbeg, *pend; 6491 unsigned char *p, *pbeg, *pend;
@@ -6610,7 +6550,7 @@ decode_eol (coding)
6610 for (p = pend - 2; p >= pbeg; p--) 6550 for (p = pend - 2; p >= pbeg; p--)
6611 if (*p == '\r') 6551 if (*p == '\r')
6612 { 6552 {
6613 safe_bcopy ((char *) (p + 1), (char *) p, pend-- - p - 1); 6553 memmove (p, p + 1, pend-- - p - 1);
6614 n++; 6554 n++;
6615 } 6555 }
6616 } 6556 }
@@ -6647,9 +6587,7 @@ decode_eol (coding)
6647 decoding (ENCODEP is zero). */ 6587 decoding (ENCODEP is zero). */
6648 6588
6649static Lisp_Object 6589static Lisp_Object
6650get_translation_table (attrs, encodep, max_lookup) 6590get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup)
6651 Lisp_Object attrs;
6652 int encodep, *max_lookup;
6653{ 6591{
6654 Lisp_Object standard, translation_table; 6592 Lisp_Object standard, translation_table;
6655 Lisp_Object val; 6593 Lisp_Object val;
@@ -6751,9 +6689,7 @@ get_translation_table (attrs, encodep, max_lookup)
6751 If BUF is too short to lookup characters in FROM, return Qt. */ 6689 If BUF is too short to lookup characters in FROM, return Qt. */
6752 6690
6753static Lisp_Object 6691static Lisp_Object
6754get_translation (trans, buf, buf_end) 6692get_translation (Lisp_Object trans, int *buf, int *buf_end)
6755 Lisp_Object trans;
6756 int *buf, *buf_end;
6757{ 6693{
6758 6694
6759 if (INTEGERP (trans)) 6695 if (INTEGERP (trans))
@@ -6780,10 +6716,8 @@ get_translation (trans, buf, buf_end)
6780 6716
6781 6717
6782static int 6718static int
6783produce_chars (coding, translation_table, last_block) 6719produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6784 struct coding_system *coding; 6720 int last_block)
6785 Lisp_Object translation_table;
6786 int last_block;
6787{ 6721{
6788 unsigned char *dst = coding->destination + coding->produced; 6722 unsigned char *dst = coding->destination + coding->produced;
6789 unsigned char *dst_end = coding->destination + coding->dst_bytes; 6723 unsigned char *dst_end = coding->destination + coding->dst_bytes;
@@ -6981,10 +6915,7 @@ produce_chars (coding, translation_table, last_block)
6981 */ 6915 */
6982 6916
6983static INLINE void 6917static INLINE void
6984produce_composition (coding, charbuf, pos) 6918produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos)
6985 struct coding_system *coding;
6986 int *charbuf;
6987 EMACS_INT pos;
6988{ 6919{
6989 int len; 6920 int len;
6990 EMACS_INT to; 6921 EMACS_INT to;
@@ -7028,10 +6959,7 @@ produce_composition (coding, charbuf, pos)
7028 */ 6959 */
7029 6960
7030static INLINE void 6961static INLINE void
7031produce_charset (coding, charbuf, pos) 6962produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos)
7032 struct coding_system *coding;
7033 int *charbuf;
7034 EMACS_INT pos;
7035{ 6963{
7036 EMACS_INT from = pos - charbuf[2]; 6964 EMACS_INT from = pos - charbuf[2];
7037 struct charset *charset = CHARSET_FROM_ID (charbuf[3]); 6965 struct charset *charset = CHARSET_FROM_ID (charbuf[3]);
@@ -7066,9 +6994,7 @@ produce_charset (coding, charbuf, pos)
7066 6994
7067 6995
7068static void 6996static void
7069produce_annotation (coding, pos) 6997produce_annotation (struct coding_system *coding, EMACS_INT pos)
7070 struct coding_system *coding;
7071 EMACS_INT pos;
7072{ 6998{
7073 int *charbuf = coding->charbuf; 6999 int *charbuf = coding->charbuf;
7074 int *charbuf_end = charbuf + coding->charbuf_used; 7000 int *charbuf_end = charbuf + coding->charbuf_used;
@@ -7123,8 +7049,7 @@ produce_annotation (coding, pos)
7123*/ 7049*/
7124 7050
7125static int 7051static int
7126decode_coding (coding) 7052decode_coding (struct coding_system *coding)
7127 struct coding_system *coding;
7128{ 7053{
7129 Lisp_Object attrs; 7054 Lisp_Object attrs;
7130 Lisp_Object undo_list; 7055 Lisp_Object undo_list;
@@ -7262,11 +7187,9 @@ decode_coding (coding)
7262 return BUF. */ 7187 return BUF. */
7263 7188
7264static INLINE int * 7189static INLINE int *
7265handle_composition_annotation (pos, limit, coding, buf, stop) 7190handle_composition_annotation (EMACS_INT pos, EMACS_INT limit,
7266 EMACS_INT pos, limit; 7191 struct coding_system *coding, int *buf,
7267 struct coding_system *coding; 7192 EMACS_INT *stop)
7268 int *buf;
7269 EMACS_INT *stop;
7270{ 7193{
7271 EMACS_INT start, end; 7194 EMACS_INT start, end;
7272 Lisp_Object prop; 7195 Lisp_Object prop;
@@ -7347,11 +7270,9 @@ handle_composition_annotation (pos, limit, coding, buf, stop)
7347 property value is non-nil (limiting by LIMIT), and return BUF. */ 7270 property value is non-nil (limiting by LIMIT), and return BUF. */
7348 7271
7349static INLINE int * 7272static INLINE int *
7350handle_charset_annotation (pos, limit, coding, buf, stop) 7273handle_charset_annotation (EMACS_INT pos, EMACS_INT limit,
7351 EMACS_INT pos, limit; 7274 struct coding_system *coding, int *buf,
7352 struct coding_system *coding; 7275 EMACS_INT *stop)
7353 int *buf;
7354 EMACS_INT *stop;
7355{ 7276{
7356 Lisp_Object val, next; 7277 Lisp_Object val, next;
7357 int id; 7278 int id;
@@ -7371,10 +7292,8 @@ handle_charset_annotation (pos, limit, coding, buf, stop)
7371 7292
7372 7293
7373static void 7294static void
7374consume_chars (coding, translation_table, max_lookup) 7295consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7375 struct coding_system *coding; 7296 int max_lookup)
7376 Lisp_Object translation_table;
7377 int max_lookup;
7378{ 7297{
7379 int *buf = coding->charbuf; 7298 int *buf = coding->charbuf;
7380 int *buf_end = coding->charbuf + coding->charbuf_size; 7299 int *buf_end = coding->charbuf + coding->charbuf_size;
@@ -7530,8 +7449,7 @@ consume_chars (coding, translation_table, max_lookup)
7530 memory area specified by CODING->destination. */ 7449 memory area specified by CODING->destination. */
7531 7450
7532static int 7451static int
7533encode_coding (coding) 7452encode_coding (struct coding_system *coding)
7534 struct coding_system *coding;
7535{ 7453{
7536 Lisp_Object attrs; 7454 Lisp_Object attrs;
7537 Lisp_Object translation_table; 7455 Lisp_Object translation_table;
@@ -7595,8 +7513,7 @@ static int reused_workbuf_in_use;
7595 multibyteness of returning buffer. */ 7513 multibyteness of returning buffer. */
7596 7514
7597static Lisp_Object 7515static Lisp_Object
7598make_conversion_work_buffer (multibyte) 7516make_conversion_work_buffer (int multibyte)
7599 int multibyte;
7600{ 7517{
7601 Lisp_Object name, workbuf; 7518 Lisp_Object name, workbuf;
7602 struct buffer *current; 7519 struct buffer *current;
@@ -7628,8 +7545,7 @@ make_conversion_work_buffer (multibyte)
7628 7545
7629 7546
7630static Lisp_Object 7547static Lisp_Object
7631code_conversion_restore (arg) 7548code_conversion_restore (Lisp_Object arg)
7632 Lisp_Object arg;
7633{ 7549{
7634 Lisp_Object current, workbuf; 7550 Lisp_Object current, workbuf;
7635 struct gcpro gcpro1; 7551 struct gcpro gcpro1;
@@ -7650,8 +7566,7 @@ code_conversion_restore (arg)
7650} 7566}
7651 7567
7652Lisp_Object 7568Lisp_Object
7653code_conversion_save (with_work_buf, multibyte) 7569code_conversion_save (int with_work_buf, int multibyte)
7654 int with_work_buf, multibyte;
7655{ 7570{
7656 Lisp_Object workbuf = Qnil; 7571 Lisp_Object workbuf = Qnil;
7657 7572
@@ -7663,11 +7578,10 @@ code_conversion_save (with_work_buf, multibyte)
7663} 7578}
7664 7579
7665int 7580int
7666decode_coding_gap (coding, chars, bytes) 7581decode_coding_gap (struct coding_system *coding,
7667 struct coding_system *coding; 7582 EMACS_INT chars, EMACS_INT bytes)
7668 EMACS_INT chars, bytes;
7669{ 7583{
7670 int count = specpdl_ptr - specpdl; 7584 int count = SPECPDL_INDEX ();
7671 Lisp_Object attrs; 7585 Lisp_Object attrs;
7672 7586
7673 code_conversion_save (0, 0); 7587 code_conversion_save (0, 0);
@@ -7710,11 +7624,10 @@ decode_coding_gap (coding, chars, bytes)
7710} 7624}
7711 7625
7712int 7626int
7713encode_coding_gap (coding, chars, bytes) 7627encode_coding_gap (struct coding_system *coding,
7714 struct coding_system *coding; 7628 EMACS_INT chars, EMACS_INT bytes)
7715 EMACS_INT chars, bytes;
7716{ 7629{
7717 int count = specpdl_ptr - specpdl; 7630 int count = SPECPDL_INDEX ();
7718 7631
7719 code_conversion_save (0, 0); 7632 code_conversion_save (0, 0);
7720 7633
@@ -7765,14 +7678,13 @@ encode_coding_gap (coding, chars, bytes)
7765 */ 7678 */
7766 7679
7767void 7680void
7768decode_coding_object (coding, src_object, from, from_byte, to, to_byte, 7681decode_coding_object (struct coding_system *coding,
7769 dst_object) 7682 Lisp_Object src_object,
7770 struct coding_system *coding; 7683 EMACS_INT from, EMACS_INT from_byte,
7771 Lisp_Object src_object; 7684 EMACS_INT to, EMACS_INT to_byte,
7772 EMACS_INT from, from_byte, to, to_byte; 7685 Lisp_Object dst_object)
7773 Lisp_Object dst_object;
7774{ 7686{
7775 int count = specpdl_ptr - specpdl; 7687 int count = SPECPDL_INDEX ();
7776 unsigned char *destination; 7688 unsigned char *destination;
7777 EMACS_INT dst_bytes; 7689 EMACS_INT dst_bytes;
7778 EMACS_INT chars = to - from; 7690 EMACS_INT chars = to - from;
@@ -7902,7 +7814,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
7902 } 7814 }
7903 if (BEGV < GPT && GPT < BEGV + coding->produced_char) 7815 if (BEGV < GPT && GPT < BEGV + coding->produced_char)
7904 move_gap_both (BEGV, BEGV_BYTE); 7816 move_gap_both (BEGV, BEGV_BYTE);
7905 bcopy (BEGV_ADDR, destination, coding->produced); 7817 memcpy (destination, BEGV_ADDR, coding->produced);
7906 coding->destination = destination; 7818 coding->destination = destination;
7907 } 7819 }
7908 } 7820 }
@@ -7956,14 +7868,13 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
7956 7868
7957 7869
7958void 7870void
7959encode_coding_object (coding, src_object, from, from_byte, to, to_byte, 7871encode_coding_object (struct coding_system *coding,
7960 dst_object) 7872 Lisp_Object src_object,
7961 struct coding_system *coding; 7873 EMACS_INT from, EMACS_INT from_byte,
7962 Lisp_Object src_object; 7874 EMACS_INT to, EMACS_INT to_byte,
7963 EMACS_INT from, from_byte, to, to_byte; 7875 Lisp_Object dst_object)
7964 Lisp_Object dst_object;
7965{ 7876{
7966 int count = specpdl_ptr - specpdl; 7877 int count = SPECPDL_INDEX ();
7967 EMACS_INT chars = to - from; 7878 EMACS_INT chars = to - from;
7968 EMACS_INT bytes = to_byte - from_byte; 7879 EMACS_INT bytes = to_byte - from_byte;
7969 Lisp_Object attrs; 7880 Lisp_Object attrs;
@@ -8165,7 +8076,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
8165 8076
8166 8077
8167Lisp_Object 8078Lisp_Object
8168preferred_coding_system () 8079preferred_coding_system (void)
8169{ 8080{
8170 int id = coding_categories[coding_priorities[0]].id; 8081 int id = coding_categories[coding_priorities[0]].id;
8171 8082
@@ -8269,13 +8180,10 @@ function `define-coding-system'. */)
8269 detect only text-format. */ 8180 detect only text-format. */
8270 8181
8271Lisp_Object 8182Lisp_Object
8272detect_coding_system (src, src_chars, src_bytes, highest, multibytep, 8183detect_coding_system (const unsigned char *src,
8273 coding_system) 8184 EMACS_INT src_chars, EMACS_INT src_bytes,
8274 const unsigned char *src; 8185 int highest, int multibytep,
8275 EMACS_INT src_chars, src_bytes; 8186 Lisp_Object coding_system)
8276 int highest;
8277 int multibytep;
8278 Lisp_Object coding_system;
8279{ 8187{
8280 const unsigned char *src_end = src + src_bytes; 8188 const unsigned char *src_end = src + src_bytes;
8281 Lisp_Object attrs, eol_type; 8189 Lisp_Object attrs, eol_type;
@@ -8643,9 +8551,7 @@ highest priority. */)
8643 8551
8644 8552
8645static INLINE int 8553static INLINE int
8646char_encodable_p (c, attrs) 8554char_encodable_p (int c, Lisp_Object attrs)
8647 int c;
8648 Lisp_Object attrs;
8649{ 8555{
8650 Lisp_Object tail; 8556 Lisp_Object tail;
8651 struct charset *charset; 8557 struct charset *charset;
@@ -9031,9 +8937,9 @@ is nil. */)
9031 8937
9032 8938
9033Lisp_Object 8939Lisp_Object
9034code_convert_region (start, end, coding_system, dst_object, encodep, norecord) 8940code_convert_region (Lisp_Object start, Lisp_Object end,
9035 Lisp_Object start, end, coding_system, dst_object; 8941 Lisp_Object coding_system, Lisp_Object dst_object,
9036 int encodep, norecord; 8942 int encodep, int norecord)
9037{ 8943{
9038 struct coding_system coding; 8944 struct coding_system coding;
9039 EMACS_INT from, from_byte, to, to_byte; 8945 EMACS_INT from, from_byte, to, to_byte;
@@ -9172,9 +9078,8 @@ code_convert_string (string, coding_system, dst_object,
9172 ENCODE_FILE, thus we ignore character composition. */ 9078 ENCODE_FILE, thus we ignore character composition. */
9173 9079
9174Lisp_Object 9080Lisp_Object
9175code_convert_string_norecord (string, coding_system, encodep) 9081code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system,
9176 Lisp_Object string, coding_system; 9082 int encodep)
9177 int encodep;
9178{ 9083{
9179 return code_convert_string (string, coding_system, Qt, encodep, 0, 1); 9084 return code_convert_string (string, coding_system, Qt, encodep, 0, 1);
9180} 9085}
@@ -9577,7 +9482,7 @@ usage: (set-coding-system-priority &rest coding-systems) */)
9577 int changed[coding_category_max]; 9482 int changed[coding_category_max];
9578 enum coding_category priorities[coding_category_max]; 9483 enum coding_category priorities[coding_category_max];
9579 9484
9580 bzero (changed, sizeof changed); 9485 memset (changed, 0, sizeof changed);
9581 9486
9582 for (i = j = 0; i < nargs; i++) 9487 for (i = j = 0; i < nargs; i++)
9583 { 9488 {
@@ -9612,7 +9517,7 @@ usage: (set-coding-system-priority &rest coding-systems) */)
9612 priorities[i] = coding_priorities[j]; 9517 priorities[i] = coding_priorities[j];
9613 } 9518 }
9614 9519
9615 bcopy (priorities, coding_priorities, sizeof priorities); 9520 memcpy (coding_priorities, priorities, sizeof priorities);
9616 9521
9617 /* Update `coding-category-list'. */ 9522 /* Update `coding-category-list'. */
9618 Vcoding_category_list = Qnil; 9523 Vcoding_category_list = Qnil;
@@ -9656,19 +9561,18 @@ HIGHESTP non-nil means just return the highest priority one. */)
9656static const char *const suffixes[] = { "-unix", "-dos", "-mac" }; 9561static const char *const suffixes[] = { "-unix", "-dos", "-mac" };
9657 9562
9658static Lisp_Object 9563static Lisp_Object
9659make_subsidiaries (base) 9564make_subsidiaries (Lisp_Object base)
9660 Lisp_Object base;
9661{ 9565{
9662 Lisp_Object subsidiaries; 9566 Lisp_Object subsidiaries;
9663 int base_name_len = SBYTES (SYMBOL_NAME (base)); 9567 int base_name_len = SBYTES (SYMBOL_NAME (base));
9664 char *buf = (char *) alloca (base_name_len + 6); 9568 char *buf = (char *) alloca (base_name_len + 6);
9665 int i; 9569 int i;
9666 9570
9667 bcopy (SDATA (SYMBOL_NAME (base)), buf, base_name_len); 9571 memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len);
9668 subsidiaries = Fmake_vector (make_number (3), Qnil); 9572 subsidiaries = Fmake_vector (make_number (3), Qnil);
9669 for (i = 0; i < 3; i++) 9573 for (i = 0; i < 3; i++)
9670 { 9574 {
9671 bcopy (suffixes[i], buf + base_name_len, strlen (suffixes[i]) + 1); 9575 memcpy (buf + base_name_len, suffixes[i], strlen (suffixes[i]) + 1);
9672 ASET (subsidiaries, i, intern (buf)); 9576 ASET (subsidiaries, i, intern (buf));
9673 } 9577 }
9674 return subsidiaries; 9578 return subsidiaries;
@@ -10210,7 +10114,7 @@ usage: (define-coding-system-internal ...) */)
10210DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, 10114DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put,
10211 3, 3, 0, 10115 3, 3, 0,
10212 doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */) 10116 doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */)
10213 (coding_system, prop, val) 10117 (coding_system, prop, val)
10214 Lisp_Object coding_system, prop, val; 10118 Lisp_Object coding_system, prop, val;
10215{ 10119{
10216 Lisp_Object spec, attrs; 10120 Lisp_Object spec, attrs;
@@ -10308,7 +10212,7 @@ DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base,
10308 1, 1, 0, 10212 1, 1, 0,
10309 doc: /* Return the base of CODING-SYSTEM. 10213 doc: /* Return the base of CODING-SYSTEM.
10310Any alias or subsidiary coding system is not a base coding system. */) 10214Any alias or subsidiary coding system is not a base coding system. */)
10311 (coding_system) 10215 (coding_system)
10312 Lisp_Object coding_system; 10216 Lisp_Object coding_system;
10313{ 10217{
10314 Lisp_Object spec, attrs; 10218 Lisp_Object spec, attrs;
@@ -10385,7 +10289,7 @@ coding system whose eol-type is N. */)
10385/*** 9. Post-amble ***/ 10289/*** 9. Post-amble ***/
10386 10290
10387void 10291void
10388init_coding_once () 10292init_coding_once (void)
10389{ 10293{
10390 int i; 10294 int i;
10391 10295
@@ -10427,7 +10331,7 @@ init_coding_once ()
10427#ifdef emacs 10331#ifdef emacs
10428 10332
10429void 10333void
10430syms_of_coding () 10334syms_of_coding (void)
10431{ 10335{
10432 staticpro (&Vcoding_system_hash_table); 10336 staticpro (&Vcoding_system_hash_table);
10433 { 10337 {
@@ -10968,7 +10872,7 @@ character.");
10968 for (i = 0; i < coding_category_max; i++) 10872 for (i = 0; i < coding_category_max; i++)
10969 Fset (AREF (Vcoding_category_table, i), Qno_conversion); 10873 Fset (AREF (Vcoding_category_table, i), Qno_conversion);
10970 } 10874 }
10971#if defined (MSDOS) || defined (WINDOWSNT) 10875#if defined (DOS_NT)
10972 system_eol_type = Qdos; 10876 system_eol_type = Qdos;
10973#else 10877#else
10974 system_eol_type = Qunix; 10878 system_eol_type = Qunix;
@@ -10977,8 +10881,7 @@ character.");
10977} 10881}
10978 10882
10979char * 10883char *
10980emacs_strerror (error_number) 10884emacs_strerror (int error_number)
10981 int error_number;
10982{ 10885{
10983 char *str; 10886 char *str;
10984 10887