aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-08-27 09:19:34 -0700
committerPaul Eggert2012-08-27 09:19:34 -0700
commitf10fe38f772c29031a23ef7aa92d2de1b3675461 (patch)
tree5e45fef267903dafb4d2a92bd464ff851b3e3835 /src
parent5474c384641da64d402e4d135dbf4697a60a70d3 (diff)
downloademacs-f10fe38f772c29031a23ef7aa92d2de1b3675461.tar.gz
emacs-f10fe38f772c29031a23ef7aa92d2de1b3675461.zip
* cmds.c, coding.c: Use bool for booleans.
* cmds.c (move_point, Fself_insert_command): * coding.h (struct composition status, struct coding_system): * coding.c (detect_coding_utf_8, encode_coding_utf_8) (detect_coding_utf_16, encode_coding_utf_16, detect_coding_emacs_mule) (emacs_mule_char, decode_coding_emacs_mule) (encode_coding_emacs_mule, detect_coding_iso_2022) (decode_coding_iso_2022, encode_invocation_designation) (encode_designation_at_bol, encode_coding_iso_2022) (detect_coding_sjis, detect_coding_big5, decode_coding_sjis) (decode_coding_big5, encode_coding_sjis, encode_coding_big5) (detect_coding_ccl, encode_coding_ccl, decode_coding_raw_text) (encode_coding_raw_text, detect_coding_charset) (decode_coding_charset, encode_coding_charset, detect_eol) (detect_coding, get_translation_table, produce_chars) (consume_chars, reused_workbuf_in_use) (make_conversion_work_buffer, code_conversion_save) (decode_coding_object, encode_coding_object) (detect_coding_system, char_encodable_p) (Funencodable_char_position, code_convert_region) (code_convert_string, code_convert_string_norecord) (Fset_coding_system_priority): * fileio.c (Finsert_file_contents): Use bool for booleans. * coding.h, lisp.h: Reflect above API changes. * coding.c: Remove unnecessary static function decls. (detect_coding): Use unsigned, not signed, to copy an unsigned field. (decode_coding, encode_coding, decode_coding_gap): Return 'void', not a boolean 'int', since callers never look at the return value. (ALLOC_CONVERSION_WORK_AREA): Assume caller returns 'void', not 'int'. * coding.h (decoding_buffer_size, encoding_buffer_size) (emacs_mule_string_char): Remove unused extern decls. (struct iso_2022_spec, struct coding_system): Use 'unsigned int : 1' for boolean fields, since there's more than one. (struct emacs_mule_spec): Remove unused field 'full_support'. All initializations removed. * cmds.c (internal_self_insert): Don't assume EMACS_INT fits in 'int'.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog42
-rw-r--r--src/charset.h2
-rw-r--r--src/cmds.c8
-rw-r--r--src/coding.c368
-rw-r--r--src/coding.h49
-rw-r--r--src/fileio.c3
-rw-r--r--src/lisp.h2
7 files changed, 208 insertions, 266 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2a5afcaa310..7be88c568e2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,6 +1,46 @@
12012-08-27 Paul Eggert <eggert@cs.ucla.edu>
2
3 * cmds.c, coding.c: Use bool for booleans.
4 * cmds.c (move_point, Fself_insert_command):
5 * coding.h (struct composition status, struct coding_system):
6 * coding.c (detect_coding_utf_8, encode_coding_utf_8)
7 (detect_coding_utf_16, encode_coding_utf_16, detect_coding_emacs_mule)
8 (emacs_mule_char, decode_coding_emacs_mule)
9 (encode_coding_emacs_mule, detect_coding_iso_2022)
10 (decode_coding_iso_2022, encode_invocation_designation)
11 (encode_designation_at_bol, encode_coding_iso_2022)
12 (detect_coding_sjis, detect_coding_big5, decode_coding_sjis)
13 (decode_coding_big5, encode_coding_sjis, encode_coding_big5)
14 (detect_coding_ccl, encode_coding_ccl, decode_coding_raw_text)
15 (encode_coding_raw_text, detect_coding_charset)
16 (decode_coding_charset, encode_coding_charset, detect_eol)
17 (detect_coding, get_translation_table, produce_chars)
18 (consume_chars, reused_workbuf_in_use)
19 (make_conversion_work_buffer, code_conversion_save)
20 (decode_coding_object, encode_coding_object)
21 (detect_coding_system, char_encodable_p)
22 (Funencodable_char_position, code_convert_region)
23 (code_convert_string, code_convert_string_norecord)
24 (Fset_coding_system_priority):
25 * fileio.c (Finsert_file_contents):
26 Use bool for booleans.
27 * coding.h, lisp.h: Reflect above API changes.
28 * coding.c: Remove unnecessary static function decls.
29 (detect_coding): Use unsigned, not signed, to copy an unsigned field.
30 (decode_coding, encode_coding, decode_coding_gap): Return 'void',
31 not a boolean 'int', since callers never look at the return value.
32 (ALLOC_CONVERSION_WORK_AREA): Assume caller returns 'void', not 'int'.
33 * coding.h (decoding_buffer_size, encoding_buffer_size)
34 (emacs_mule_string_char): Remove unused extern decls.
35 (struct iso_2022_spec, struct coding_system):
36 Use 'unsigned int : 1' for boolean fields, since there's more than one.
37 (struct emacs_mule_spec): Remove unused field 'full_support'.
38 All initializations removed.
39 * cmds.c (internal_self_insert): Don't assume EMACS_INT fits in 'int'.
40
12012-08-27 Dmitry Antipov <dmantipov@yandex.ru> 412012-08-27 Dmitry Antipov <dmantipov@yandex.ru>
2 42
3 Fix spare memory change. 43 Fix spare memory change (Bug#12286).
4 * alloc.c (mark_maybe_pointer): Handle MEM_TYPE_SPARE. 44 * alloc.c (mark_maybe_pointer): Handle MEM_TYPE_SPARE.
5 (valid_lisp_object_p): Likewise. 45 (valid_lisp_object_p): Likewise.
6 46
diff --git a/src/charset.h b/src/charset.h
index 6e6d0ec2701..50d230489fe 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -496,7 +496,7 @@ extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
496 496
497 497
498 498
499/* 1 if CHARSET may contain the character C. */ 499/* True if CHARSET may contain the character C. */
500#define CHAR_CHARSET_P(c, charset) \ 500#define CHAR_CHARSET_P(c, charset) \
501 ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p) \ 501 ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p) \
502 || ((CHARSET_UNIFIED_P (charset) \ 502 || ((CHARSET_UNIFIED_P (charset) \
diff --git a/src/cmds.c b/src/cmds.c
index b416135ee9e..90d3cd6dced 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -47,10 +47,10 @@ DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0,
47 return make_number (PT + XINT (n)); 47 return make_number (PT + XINT (n));
48} 48}
49 49
50/* Add N to point; or subtract N if FORWARD is zero. N defaults to 1. 50/* Add N to point; or subtract N if FORWARD is false. N defaults to 1.
51 Validate the new location. Return nil. */ 51 Validate the new location. Return nil. */
52static Lisp_Object 52static Lisp_Object
53move_point (Lisp_Object n, int forward) 53move_point (Lisp_Object n, bool forward)
54{ 54{
55 /* This used to just set point to point + XINT (n), and then check 55 /* This used to just set point to point + XINT (n), and then check
56 to see if it was within boundaries. But now that SET_PT can 56 to see if it was within boundaries. But now that SET_PT can
@@ -277,7 +277,7 @@ After insertion, the value of `auto-fill-function' is called if the
277At the end, it runs `post-self-insert-hook'. */) 277At the end, it runs `post-self-insert-hook'. */)
278 (Lisp_Object n) 278 (Lisp_Object n)
279{ 279{
280 int remove_boundary = 1; 280 bool remove_boundary = 1;
281 CHECK_NATNUM (n); 281 CHECK_NATNUM (n);
282 282
283 if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command))) 283 if (!EQ (Vthis_command, KVAR (current_kboard, Vlast_command)))
@@ -438,7 +438,7 @@ internal_self_insert (int c, EMACS_INT n)
438 : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) 438 : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ())))
439 == Sword)) 439 == Sword))
440 { 440 {
441 int modiff = MODIFF; 441 EMACS_INT modiff = MODIFF;
442 Lisp_Object sym; 442 Lisp_Object sym;
443 443
444 sym = call0 (Qexpand_abbrev); 444 sym = call0 (Qexpand_abbrev);
diff --git a/src/coding.c b/src/coding.c
index 971686dc180..5bfd42c7272 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -147,18 +147,18 @@ STRUCT CODING_SYSTEM
147 CODING conforms to the format of XXX, and update the members of 147 CODING conforms to the format of XXX, and update the members of
148 DETECT_INFO. 148 DETECT_INFO.
149 149
150 Return 1 if the byte sequence conforms to XXX, otherwise return 0. 150 Return true if the byte sequence conforms to XXX.
151 151
152 Below is the template of these functions. */ 152 Below is the template of these functions. */
153 153
154#if 0 154#if 0
155static int 155static bool
156detect_coding_XXX (struct coding_system *coding, 156detect_coding_XXX (struct coding_system *coding,
157 struct coding_detection_info *detect_info) 157 struct coding_detection_info *detect_info)
158{ 158{
159 const unsigned char *src = coding->source; 159 const unsigned char *src = coding->source;
160 const unsigned char *src_end = coding->source + coding->src_bytes; 160 const unsigned char *src_end = coding->source + coding->src_bytes;
161 int multibytep = coding->src_multibyte; 161 bool multibytep = coding->src_multibyte;
162 ptrdiff_t consumed_chars = 0; 162 ptrdiff_t consumed_chars = 0;
163 int found = 0; 163 int found = 0;
164 ...; 164 ...;
@@ -212,7 +212,7 @@ decode_coding_XXXX (struct coding_system *coding)
212 /* A buffer to produce decoded characters. */ 212 /* A buffer to produce decoded characters. */
213 int *charbuf = coding->charbuf + coding->charbuf_used; 213 int *charbuf = coding->charbuf + coding->charbuf_used;
214 int *charbuf_end = coding->charbuf + coding->charbuf_size; 214 int *charbuf_end = coding->charbuf + coding->charbuf_size;
215 int multibytep = coding->src_multibyte; 215 bool multibytep = coding->src_multibyte;
216 216
217 while (1) 217 while (1)
218 { 218 {
@@ -260,7 +260,7 @@ decode_coding_XXXX (struct coding_system *coding)
260static void 260static void
261encode_coding_XXX (struct coding_system *coding) 261encode_coding_XXX (struct coding_system *coding)
262{ 262{
263 int multibytep = coding->dst_multibyte; 263 bool multibytep = coding->dst_multibyte;
264 int *charbuf = coding->charbuf; 264 int *charbuf = coding->charbuf;
265 int *charbuf_end = charbuf->charbuf + coding->charbuf_used; 265 int *charbuf_end = charbuf->charbuf + coding->charbuf_used;
266 unsigned char *dst = coding->destination + coding->produced; 266 unsigned char *dst = coding->destination + coding->produced;
@@ -651,8 +651,8 @@ static struct coding_system coding_categories[coding_category_max];
651 651
652/* Safely get one byte from the source text pointed by SRC which ends 652/* Safely get one byte from the source text pointed by SRC which ends
653 at SRC_END, and set C to that byte. If there are not enough bytes 653 at SRC_END, and set C to that byte. If there are not enough bytes
654 in the source, it jumps to `no_more_source'. If multibytep is 654 in the source, it jumps to 'no_more_source'. If MULTIBYTEP,
655 nonzero, and a multibyte character is found at SRC, set C to the 655 and a multibyte character is found at SRC, set C to the
656 negative value of the character code. The caller should declare 656 negative value of the character code. The caller should declare
657 and set these variables appropriately in advance: 657 and set these variables appropriately in advance:
658 src, src_end, multibytep */ 658 src, src_end, multibytep */
@@ -685,7 +685,7 @@ static struct coding_system coding_categories[coding_category_max];
685/* Safely get two bytes from the source text pointed by SRC which ends 685/* Safely get two bytes from the source text pointed by SRC which ends
686 at SRC_END, and set C1 and C2 to those bytes while skipping the 686 at SRC_END, and set C1 and C2 to those bytes while skipping the
687 heading multibyte characters. If there are not enough bytes in the 687 heading multibyte characters. If there are not enough bytes in the
688 source, it jumps to `no_more_source'. If multibytep is nonzero and 688 source, it jumps to 'no_more_source'. If MULTIBYTEP and
689 a multibyte character is found for C2, set C2 to the negative value 689 a multibyte character is found for C2, set C2 to the negative value
690 of the character code. The caller should declare and set these 690 of the character code. The caller should declare and set these
691 variables appropriately in advance: 691 variables appropriately in advance:
@@ -746,8 +746,8 @@ static struct coding_system coding_categories[coding_category_max];
746 746
747 747
748/* Store a byte C in the place pointed by DST and increment DST to the 748/* Store a byte C in the place pointed by DST and increment DST to the
749 next free point, and increment PRODUCED_CHARS. If MULTIBYTEP is 749 next free point, and increment PRODUCED_CHARS. If MULTIBYTEP,
750 nonzero, store in an appropriate multibyte from. The caller should 750 store in an appropriate multibyte form. The caller should
751 declare and set the variables `dst' and `multibytep' appropriately 751 declare and set the variables `dst' and `multibytep' appropriately
752 in advance. */ 752 in advance. */
753 753
@@ -806,83 +806,6 @@ static struct coding_system coding_categories[coding_category_max];
806 } while (0) 806 } while (0)
807 807
808 808
809/* Prototypes for static functions. */
810static void record_conversion_result (struct coding_system *coding,
811 enum coding_result_code result);
812static int detect_coding_utf_8 (struct coding_system *,
813 struct coding_detection_info *info);
814static void decode_coding_utf_8 (struct coding_system *);
815static int encode_coding_utf_8 (struct coding_system *);
816
817static int detect_coding_utf_16 (struct coding_system *,
818 struct coding_detection_info *info);
819static void decode_coding_utf_16 (struct coding_system *);
820static int encode_coding_utf_16 (struct coding_system *);
821
822static int detect_coding_iso_2022 (struct coding_system *,
823 struct coding_detection_info *info);
824static void decode_coding_iso_2022 (struct coding_system *);
825static int encode_coding_iso_2022 (struct coding_system *);
826
827static int detect_coding_emacs_mule (struct coding_system *,
828 struct coding_detection_info *info);
829static void decode_coding_emacs_mule (struct coding_system *);
830static int encode_coding_emacs_mule (struct coding_system *);
831
832static int detect_coding_sjis (struct coding_system *,
833 struct coding_detection_info *info);
834static void decode_coding_sjis (struct coding_system *);
835static int encode_coding_sjis (struct coding_system *);
836
837static int detect_coding_big5 (struct coding_system *,
838 struct coding_detection_info *info);
839static void decode_coding_big5 (struct coding_system *);
840static int encode_coding_big5 (struct coding_system *);
841
842static int detect_coding_ccl (struct coding_system *,
843 struct coding_detection_info *info);
844static void decode_coding_ccl (struct coding_system *);
845static int encode_coding_ccl (struct coding_system *);
846
847static void decode_coding_raw_text (struct coding_system *);
848static int encode_coding_raw_text (struct coding_system *);
849
850static void coding_set_source (struct coding_system *);
851static ptrdiff_t coding_change_source (struct coding_system *);
852static void coding_set_destination (struct coding_system *);
853static ptrdiff_t coding_change_destination (struct coding_system *);
854static void coding_alloc_by_realloc (struct coding_system *, ptrdiff_t);
855static void coding_alloc_by_making_gap (struct coding_system *,
856 ptrdiff_t, ptrdiff_t);
857static unsigned char *alloc_destination (struct coding_system *,
858 ptrdiff_t, unsigned char *);
859static void setup_iso_safe_charsets (Lisp_Object);
860static ptrdiff_t encode_designation_at_bol (struct coding_system *,
861 int *, int *, unsigned char *);
862static int detect_eol (const unsigned char *,
863 ptrdiff_t, enum coding_category);
864static Lisp_Object adjust_coding_eol_type (struct coding_system *, int);
865static void decode_eol (struct coding_system *);
866static Lisp_Object get_translation_table (Lisp_Object, int, int *);
867static Lisp_Object get_translation (Lisp_Object, int *, int *);
868static int produce_chars (struct coding_system *, Lisp_Object, int);
869static inline void produce_charset (struct coding_system *, int *,
870 ptrdiff_t);
871static void produce_annotation (struct coding_system *, ptrdiff_t);
872static int decode_coding (struct coding_system *);
873static inline int *handle_composition_annotation (ptrdiff_t, ptrdiff_t,
874 struct coding_system *,
875 int *, ptrdiff_t *);
876static inline int *handle_charset_annotation (ptrdiff_t, ptrdiff_t,
877 struct coding_system *,
878 int *, ptrdiff_t *);
879static void consume_chars (struct coding_system *, Lisp_Object, int);
880static int encode_coding (struct coding_system *);
881static Lisp_Object make_conversion_work_buffer (int);
882static Lisp_Object code_conversion_restore (Lisp_Object);
883static inline int char_encodable_p (int, Lisp_Object);
884static Lisp_Object make_subsidiaries (Lisp_Object);
885
886static void 809static void
887record_conversion_result (struct coding_system *coding, 810record_conversion_result (struct coding_system *coding,
888 enum coding_result_code result) 811 enum coding_result_code result)
@@ -1264,8 +1187,7 @@ alloc_destination (struct coding_system *coding, ptrdiff_t nbytes,
1264/*** 3. UTF-8 ***/ 1187/*** 3. UTF-8 ***/
1265 1188
1266/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 1189/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
1267 Check if a text is encoded in UTF-8. If it is, return 1, else 1190 Return true if a text is encoded in UTF-8. */
1268 return 0. */
1269 1191
1270#define UTF_8_1_OCTET_P(c) ((c) < 0x80) 1192#define UTF_8_1_OCTET_P(c) ((c) < 0x80)
1271#define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80) 1193#define UTF_8_EXTRA_OCTET_P(c) (((c) & 0xC0) == 0x80)
@@ -1278,16 +1200,16 @@ alloc_destination (struct coding_system *coding, ptrdiff_t nbytes,
1278#define UTF_8_BOM_2 0xBB 1200#define UTF_8_BOM_2 0xBB
1279#define UTF_8_BOM_3 0xBF 1201#define UTF_8_BOM_3 0xBF
1280 1202
1281static int 1203static bool
1282detect_coding_utf_8 (struct coding_system *coding, 1204detect_coding_utf_8 (struct coding_system *coding,
1283 struct coding_detection_info *detect_info) 1205 struct coding_detection_info *detect_info)
1284{ 1206{
1285 const unsigned char *src = coding->source, *src_base; 1207 const unsigned char *src = coding->source, *src_base;
1286 const unsigned char *src_end = coding->source + coding->src_bytes; 1208 const unsigned char *src_end = coding->source + coding->src_bytes;
1287 int multibytep = coding->src_multibyte; 1209 bool multibytep = coding->src_multibyte;
1288 ptrdiff_t consumed_chars = 0; 1210 ptrdiff_t consumed_chars = 0;
1289 int bom_found = 0; 1211 bool bom_found = 0;
1290 int found = 0; 1212 bool found = 0;
1291 1213
1292 detect_info->checked |= CATEGORY_MASK_UTF_8; 1214 detect_info->checked |= CATEGORY_MASK_UTF_8;
1293 /* A coding system of this category is always ASCII compatible. */ 1215 /* A coding system of this category is always ASCII compatible. */
@@ -1371,10 +1293,10 @@ decode_coding_utf_8 (struct coding_system *coding)
1371 int *charbuf = coding->charbuf + coding->charbuf_used; 1293 int *charbuf = coding->charbuf + coding->charbuf_used;
1372 int *charbuf_end = coding->charbuf + coding->charbuf_size; 1294 int *charbuf_end = coding->charbuf + coding->charbuf_size;
1373 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; 1295 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0;
1374 int multibytep = coding->src_multibyte; 1296 bool multibytep = coding->src_multibyte;
1375 enum utf_bom_type bom = CODING_UTF_8_BOM (coding); 1297 enum utf_bom_type bom = CODING_UTF_8_BOM (coding);
1376 int eol_dos = 1298 bool eol_dos
1377 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 1299 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
1378 int byte_after_cr = -1; 1300 int byte_after_cr = -1;
1379 1301
1380 if (bom != utf_without_bom) 1302 if (bom != utf_without_bom)
@@ -1513,10 +1435,10 @@ decode_coding_utf_8 (struct coding_system *coding)
1513} 1435}
1514 1436
1515 1437
1516static int 1438static bool
1517encode_coding_utf_8 (struct coding_system *coding) 1439encode_coding_utf_8 (struct coding_system *coding)
1518{ 1440{
1519 int multibytep = coding->dst_multibyte; 1441 bool multibytep = coding->dst_multibyte;
1520 int *charbuf = coding->charbuf; 1442 int *charbuf = coding->charbuf;
1521 int *charbuf_end = charbuf + coding->charbuf_used; 1443 int *charbuf_end = charbuf + coding->charbuf_used;
1522 unsigned char *dst = coding->destination + coding->produced; 1444 unsigned char *dst = coding->destination + coding->produced;
@@ -1577,8 +1499,7 @@ encode_coding_utf_8 (struct coding_system *coding)
1577 1499
1578 1500
1579/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 1501/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
1580 Check if a text is encoded in one of UTF-16 based coding systems. 1502 Return true if a text is encoded in one of UTF-16 based coding systems. */
1581 If it is, return 1, else return 0. */
1582 1503
1583#define UTF_16_HIGH_SURROGATE_P(val) \ 1504#define UTF_16_HIGH_SURROGATE_P(val) \
1584 (((val) & 0xFC00) == 0xD800) 1505 (((val) & 0xFC00) == 0xD800)
@@ -1587,13 +1508,13 @@ encode_coding_utf_8 (struct coding_system *coding)
1587 (((val) & 0xFC00) == 0xDC00) 1508 (((val) & 0xFC00) == 0xDC00)
1588 1509
1589 1510
1590static int 1511static bool
1591detect_coding_utf_16 (struct coding_system *coding, 1512detect_coding_utf_16 (struct coding_system *coding,
1592 struct coding_detection_info *detect_info) 1513 struct coding_detection_info *detect_info)
1593{ 1514{
1594 const unsigned char *src = coding->source; 1515 const unsigned char *src = coding->source;
1595 const unsigned char *src_end = coding->source + coding->src_bytes; 1516 const unsigned char *src_end = coding->source + coding->src_bytes;
1596 int multibytep = coding->src_multibyte; 1517 bool multibytep = coding->src_multibyte;
1597 int c1, c2; 1518 int c1, c2;
1598 1519
1599 detect_info->checked |= CATEGORY_MASK_UTF_16; 1520 detect_info->checked |= CATEGORY_MASK_UTF_16;
@@ -1680,12 +1601,12 @@ decode_coding_utf_16 (struct coding_system *coding)
1680 /* We may produces at most 3 chars in one loop. */ 1601 /* We may produces at most 3 chars in one loop. */
1681 int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; 1602 int *charbuf_end = coding->charbuf + coding->charbuf_size - 2;
1682 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0; 1603 ptrdiff_t consumed_chars = 0, consumed_chars_base = 0;
1683 int multibytep = coding->src_multibyte; 1604 bool multibytep = coding->src_multibyte;
1684 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); 1605 enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1685 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); 1606 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
1686 int surrogate = CODING_UTF_16_SURROGATE (coding); 1607 int surrogate = CODING_UTF_16_SURROGATE (coding);
1687 int eol_dos = 1608 bool eol_dos
1688 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 1609 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
1689 int byte_after_cr1 = -1, byte_after_cr2 = -1; 1610 int byte_after_cr1 = -1, byte_after_cr2 = -1;
1690 1611
1691 if (bom == utf_with_bom) 1612 if (bom == utf_with_bom)
@@ -1795,17 +1716,17 @@ decode_coding_utf_16 (struct coding_system *coding)
1795 coding->charbuf_used = charbuf - coding->charbuf; 1716 coding->charbuf_used = charbuf - coding->charbuf;
1796} 1717}
1797 1718
1798static int 1719static bool
1799encode_coding_utf_16 (struct coding_system *coding) 1720encode_coding_utf_16 (struct coding_system *coding)
1800{ 1721{
1801 int multibytep = coding->dst_multibyte; 1722 bool multibytep = coding->dst_multibyte;
1802 int *charbuf = coding->charbuf; 1723 int *charbuf = coding->charbuf;
1803 int *charbuf_end = charbuf + coding->charbuf_used; 1724 int *charbuf_end = charbuf + coding->charbuf_used;
1804 unsigned char *dst = coding->destination + coding->produced; 1725 unsigned char *dst = coding->destination + coding->produced;
1805 unsigned char *dst_end = coding->destination + coding->dst_bytes; 1726 unsigned char *dst_end = coding->destination + coding->dst_bytes;
1806 int safe_room = 8; 1727 int safe_room = 8;
1807 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); 1728 enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1808 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; 1729 bool big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian;
1809 ptrdiff_t produced_chars = 0; 1730 ptrdiff_t produced_chars = 0;
1810 int c; 1731 int c;
1811 1732
@@ -1930,16 +1851,15 @@ char emacs_mule_bytes[256];
1930 1851
1931 1852
1932/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 1853/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
1933 Check if a text is encoded in `emacs-mule'. If it is, return 1, 1854 Return true if a text is encoded in 'emacs-mule'. */
1934 else return 0. */
1935 1855
1936static int 1856static bool
1937detect_coding_emacs_mule (struct coding_system *coding, 1857detect_coding_emacs_mule (struct coding_system *coding,
1938 struct coding_detection_info *detect_info) 1858 struct coding_detection_info *detect_info)
1939{ 1859{
1940 const unsigned char *src = coding->source, *src_base; 1860 const unsigned char *src = coding->source, *src_base;
1941 const unsigned char *src_end = coding->source + coding->src_bytes; 1861 const unsigned char *src_end = coding->source + coding->src_bytes;
1942 int multibytep = coding->src_multibyte; 1862 bool multibytep = coding->src_multibyte;
1943 ptrdiff_t consumed_chars = 0; 1863 ptrdiff_t consumed_chars = 0;
1944 int c; 1864 int c;
1945 int found = 0; 1865 int found = 0;
@@ -2029,12 +1949,12 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
2029{ 1949{
2030 const unsigned char *src_end = coding->source + coding->src_bytes; 1950 const unsigned char *src_end = coding->source + coding->src_bytes;
2031 const unsigned char *src_base = src; 1951 const unsigned char *src_base = src;
2032 int multibytep = coding->src_multibyte; 1952 bool multibytep = coding->src_multibyte;
2033 int charset_ID; 1953 int charset_ID;
2034 unsigned code; 1954 unsigned code;
2035 int c; 1955 int c;
2036 int consumed_chars = 0; 1956 int consumed_chars = 0;
2037 int mseq_found = 0; 1957 bool mseq_found = 0;
2038 1958
2039 ONE_MORE_BYTE (c); 1959 ONE_MORE_BYTE (c);
2040 if (c < 0) 1960 if (c < 0)
@@ -2411,12 +2331,12 @@ decode_coding_emacs_mule (struct coding_system *coding)
2411 /* We can produce up to 2 characters in a loop. */ 2331 /* We can produce up to 2 characters in a loop. */
2412 - 1; 2332 - 1;
2413 ptrdiff_t consumed_chars = 0, consumed_chars_base; 2333 ptrdiff_t consumed_chars = 0, consumed_chars_base;
2414 int multibytep = coding->src_multibyte; 2334 bool multibytep = coding->src_multibyte;
2415 ptrdiff_t char_offset = coding->produced_char; 2335 ptrdiff_t char_offset = coding->produced_char;
2416 ptrdiff_t last_offset = char_offset; 2336 ptrdiff_t last_offset = char_offset;
2417 int last_id = charset_ascii; 2337 int last_id = charset_ascii;
2418 int eol_dos = 2338 bool eol_dos
2419 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 2339 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
2420 int byte_after_cr = -1; 2340 int byte_after_cr = -1;
2421 struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; 2341 struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status;
2422 2342
@@ -2657,10 +2577,10 @@ decode_coding_emacs_mule (struct coding_system *coding)
2657 } while (0); 2577 } while (0);
2658 2578
2659 2579
2660static int 2580static bool
2661encode_coding_emacs_mule (struct coding_system *coding) 2581encode_coding_emacs_mule (struct coding_system *coding)
2662{ 2582{
2663 int multibytep = coding->dst_multibyte; 2583 bool multibytep = coding->dst_multibyte;
2664 int *charbuf = coding->charbuf; 2584 int *charbuf = coding->charbuf;
2665 int *charbuf_end = charbuf + coding->charbuf_used; 2585 int *charbuf_end = charbuf + coding->charbuf_used;
2666 unsigned char *dst = coding->destination + coding->produced; 2586 unsigned char *dst = coding->destination + coding->produced;
@@ -2722,7 +2642,7 @@ encode_coding_emacs_mule (struct coding_system *coding)
2722 2642
2723 if (preferred_charset_id >= 0) 2643 if (preferred_charset_id >= 0)
2724 { 2644 {
2725 int result; 2645 bool result;
2726 2646
2727 charset = CHARSET_FROM_ID (preferred_charset_id); 2647 charset = CHARSET_FROM_ID (preferred_charset_id);
2728 CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); 2648 CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result);
@@ -3017,17 +2937,17 @@ setup_iso_safe_charsets (Lisp_Object attrs)
3017 2937
3018 2938
3019/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 2939/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
3020 Check if a text is encoded in one of ISO-2022 based coding systems. 2940 Return true if a text is encoded in one of ISO-2022 based coding
3021 If it is, return 1, else return 0. */ 2941 systems. */
3022 2942
3023static int 2943static bool
3024detect_coding_iso_2022 (struct coding_system *coding, 2944detect_coding_iso_2022 (struct coding_system *coding,
3025 struct coding_detection_info *detect_info) 2945 struct coding_detection_info *detect_info)
3026{ 2946{
3027 const unsigned char *src = coding->source, *src_base = src; 2947 const unsigned char *src = coding->source, *src_base = src;
3028 const unsigned char *src_end = coding->source + coding->src_bytes; 2948 const unsigned char *src_end = coding->source + coding->src_bytes;
3029 int multibytep = coding->src_multibyte; 2949 bool multibytep = coding->src_multibyte;
3030 int single_shifting = 0; 2950 bool single_shifting = 0;
3031 int id; 2951 int id;
3032 int c, c1; 2952 int c, c1;
3033 ptrdiff_t consumed_chars = 0; 2953 ptrdiff_t consumed_chars = 0;
@@ -3390,8 +3310,6 @@ detect_coding_iso_2022 (struct coding_system *coding,
3390 3310
3391/* Finish the current composition as invalid. */ 3311/* Finish the current composition as invalid. */
3392 3312
3393static int finish_composition (int *, struct composition_status *);
3394
3395static int 3313static int
3396finish_composition (int *charbuf, struct composition_status *cmp_status) 3314finish_composition (int *charbuf, struct composition_status *cmp_status)
3397{ 3315{
@@ -3541,7 +3459,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3541 int *charbuf_end 3459 int *charbuf_end
3542 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); 3460 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
3543 ptrdiff_t consumed_chars = 0, consumed_chars_base; 3461 ptrdiff_t consumed_chars = 0, consumed_chars_base;
3544 int multibytep = coding->src_multibyte; 3462 bool multibytep = coding->src_multibyte;
3545 /* Charsets invoked to graphic plane 0 and 1 respectively. */ 3463 /* Charsets invoked to graphic plane 0 and 1 respectively. */
3546 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); 3464 int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0);
3547 int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1); 3465 int charset_id_1 = CODING_ISO_INVOKED_CHARSET (coding, 1);
@@ -3553,8 +3471,8 @@ decode_coding_iso_2022 (struct coding_system *coding)
3553 ptrdiff_t char_offset = coding->produced_char; 3471 ptrdiff_t char_offset = coding->produced_char;
3554 ptrdiff_t last_offset = char_offset; 3472 ptrdiff_t last_offset = char_offset;
3555 int last_id = charset_ascii; 3473 int last_id = charset_ascii;
3556 int eol_dos = 3474 bool eol_dos
3557 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 3475 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
3558 int byte_after_cr = -1; 3476 int byte_after_cr = -1;
3559 int i; 3477 int i;
3560 3478
@@ -4282,7 +4200,7 @@ encode_invocation_designation (struct charset *charset,
4282 struct coding_system *coding, 4200 struct coding_system *coding,
4283 unsigned char *dst, ptrdiff_t *p_nchars) 4201 unsigned char *dst, ptrdiff_t *p_nchars)
4284{ 4202{
4285 int multibytep = coding->dst_multibyte; 4203 bool multibytep = coding->dst_multibyte;
4286 ptrdiff_t produced_chars = *p_nchars; 4204 ptrdiff_t produced_chars = *p_nchars;
4287 int reg; /* graphic register number */ 4205 int reg; /* graphic register number */
4288 int id = CHARSET_ID (charset); 4206 int id = CHARSET_ID (charset);
@@ -4380,7 +4298,7 @@ encode_designation_at_bol (struct coding_system *coding,
4380 int r[4]; 4298 int r[4];
4381 int c, found = 0, reg; 4299 int c, found = 0, reg;
4382 ptrdiff_t produced_chars = 0; 4300 ptrdiff_t produced_chars = 0;
4383 int multibytep = coding->dst_multibyte; 4301 bool multibytep = coding->dst_multibyte;
4384 Lisp_Object attrs; 4302 Lisp_Object attrs;
4385 Lisp_Object charset_list; 4303 Lisp_Object charset_list;
4386 4304
@@ -4422,21 +4340,21 @@ encode_designation_at_bol (struct coding_system *coding,
4422 4340
4423/* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ 4341/* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */
4424 4342
4425static int 4343static bool
4426encode_coding_iso_2022 (struct coding_system *coding) 4344encode_coding_iso_2022 (struct coding_system *coding)
4427{ 4345{
4428 int multibytep = coding->dst_multibyte; 4346 bool multibytep = coding->dst_multibyte;
4429 int *charbuf = coding->charbuf; 4347 int *charbuf = coding->charbuf;
4430 int *charbuf_end = charbuf + coding->charbuf_used; 4348 int *charbuf_end = charbuf + coding->charbuf_used;
4431 unsigned char *dst = coding->destination + coding->produced; 4349 unsigned char *dst = coding->destination + coding->produced;
4432 unsigned char *dst_end = coding->destination + coding->dst_bytes; 4350 unsigned char *dst_end = coding->destination + coding->dst_bytes;
4433 int safe_room = 16; 4351 int safe_room = 16;
4434 int bol_designation 4352 bool bol_designation
4435 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL 4353 = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL
4436 && CODING_ISO_BOL (coding)); 4354 && CODING_ISO_BOL (coding));
4437 ptrdiff_t produced_chars = 0; 4355 ptrdiff_t produced_chars = 0;
4438 Lisp_Object attrs, eol_type, charset_list; 4356 Lisp_Object attrs, eol_type, charset_list;
4439 int ascii_compatible; 4357 bool ascii_compatible;
4440 int c; 4358 int c;
4441 int preferred_charset_id = -1; 4359 int preferred_charset_id = -1;
4442 4360
@@ -4523,8 +4441,9 @@ encode_coding_iso_2022 (struct coding_system *coding)
4523 CODING_ISO_DESIGNATION (coding, i) 4441 CODING_ISO_DESIGNATION (coding, i)
4524 = CODING_ISO_INITIAL (coding, i); 4442 = CODING_ISO_INITIAL (coding, i);
4525 } 4443 }
4526 bol_designation 4444 bol_designation = ((CODING_ISO_FLAGS (coding)
4527 = CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL; 4445 & CODING_ISO_FLAG_DESIGNATE_AT_BOL)
4446 != 0);
4528 } 4447 }
4529 else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL) 4448 else if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_RESET_AT_CNTL)
4530 ENCODE_RESET_PLANE_AND_REGISTER (); 4449 ENCODE_RESET_PLANE_AND_REGISTER ();
@@ -4551,7 +4470,7 @@ encode_coding_iso_2022 (struct coding_system *coding)
4551 4470
4552 if (preferred_charset_id >= 0) 4471 if (preferred_charset_id >= 0)
4553 { 4472 {
4554 int result; 4473 bool result;
4555 4474
4556 charset = CHARSET_FROM_ID (preferred_charset_id); 4475 charset = CHARSET_FROM_ID (preferred_charset_id);
4557 CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); 4476 CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result);
@@ -4631,16 +4550,15 @@ encode_coding_iso_2022 (struct coding_system *coding)
4631 */ 4550 */
4632 4551
4633/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 4552/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
4634 Check if a text is encoded in SJIS. If it is, return 4553 Return true if a text is encoded in SJIS. */
4635 CATEGORY_MASK_SJIS, else return 0. */
4636 4554
4637static int 4555static bool
4638detect_coding_sjis (struct coding_system *coding, 4556detect_coding_sjis (struct coding_system *coding,
4639 struct coding_detection_info *detect_info) 4557 struct coding_detection_info *detect_info)
4640{ 4558{
4641 const unsigned char *src = coding->source, *src_base; 4559 const unsigned char *src = coding->source, *src_base;
4642 const unsigned char *src_end = coding->source + coding->src_bytes; 4560 const unsigned char *src_end = coding->source + coding->src_bytes;
4643 int multibytep = coding->src_multibyte; 4561 bool multibytep = coding->src_multibyte;
4644 ptrdiff_t consumed_chars = 0; 4562 ptrdiff_t consumed_chars = 0;
4645 int found = 0; 4563 int found = 0;
4646 int c; 4564 int c;
@@ -4688,16 +4606,15 @@ detect_coding_sjis (struct coding_system *coding,
4688} 4606}
4689 4607
4690/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 4608/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
4691 Check if a text is encoded in BIG5. If it is, return 4609 Return true if a text is encoded in BIG5. */
4692 CATEGORY_MASK_BIG5, else return 0. */
4693 4610
4694static int 4611static bool
4695detect_coding_big5 (struct coding_system *coding, 4612detect_coding_big5 (struct coding_system *coding,
4696 struct coding_detection_info *detect_info) 4613 struct coding_detection_info *detect_info)
4697{ 4614{
4698 const unsigned char *src = coding->source, *src_base; 4615 const unsigned char *src = coding->source, *src_base;
4699 const unsigned char *src_end = coding->source + coding->src_bytes; 4616 const unsigned char *src_end = coding->source + coding->src_bytes;
4700 int multibytep = coding->src_multibyte; 4617 bool multibytep = coding->src_multibyte;
4701 ptrdiff_t consumed_chars = 0; 4618 ptrdiff_t consumed_chars = 0;
4702 int found = 0; 4619 int found = 0;
4703 int c; 4620 int c;
@@ -4735,8 +4652,7 @@ detect_coding_big5 (struct coding_system *coding,
4735 return 1; 4652 return 1;
4736} 4653}
4737 4654
4738/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". 4655/* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions". */
4739 If SJIS_P is 1, decode SJIS text, else decode BIG5 test. */
4740 4656
4741static void 4657static void
4742decode_coding_sjis (struct coding_system *coding) 4658decode_coding_sjis (struct coding_system *coding)
@@ -4750,15 +4666,15 @@ decode_coding_sjis (struct coding_system *coding)
4750 int *charbuf_end 4666 int *charbuf_end
4751 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 4667 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
4752 ptrdiff_t consumed_chars = 0, consumed_chars_base; 4668 ptrdiff_t consumed_chars = 0, consumed_chars_base;
4753 int multibytep = coding->src_multibyte; 4669 bool multibytep = coding->src_multibyte;
4754 struct charset *charset_roman, *charset_kanji, *charset_kana; 4670 struct charset *charset_roman, *charset_kanji, *charset_kana;
4755 struct charset *charset_kanji2; 4671 struct charset *charset_kanji2;
4756 Lisp_Object attrs, charset_list, val; 4672 Lisp_Object attrs, charset_list, val;
4757 ptrdiff_t char_offset = coding->produced_char; 4673 ptrdiff_t char_offset = coding->produced_char;
4758 ptrdiff_t last_offset = char_offset; 4674 ptrdiff_t last_offset = char_offset;
4759 int last_id = charset_ascii; 4675 int last_id = charset_ascii;
4760 int eol_dos = 4676 bool eol_dos
4761 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 4677 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
4762 int byte_after_cr = -1; 4678 int byte_after_cr = -1;
4763 4679
4764 CODING_GET_INFO (coding, attrs, charset_list); 4680 CODING_GET_INFO (coding, attrs, charset_list);
@@ -4868,14 +4784,14 @@ decode_coding_big5 (struct coding_system *coding)
4868 int *charbuf_end 4784 int *charbuf_end
4869 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 4785 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
4870 ptrdiff_t consumed_chars = 0, consumed_chars_base; 4786 ptrdiff_t consumed_chars = 0, consumed_chars_base;
4871 int multibytep = coding->src_multibyte; 4787 bool multibytep = coding->src_multibyte;
4872 struct charset *charset_roman, *charset_big5; 4788 struct charset *charset_roman, *charset_big5;
4873 Lisp_Object attrs, charset_list, val; 4789 Lisp_Object attrs, charset_list, val;
4874 ptrdiff_t char_offset = coding->produced_char; 4790 ptrdiff_t char_offset = coding->produced_char;
4875 ptrdiff_t last_offset = char_offset; 4791 ptrdiff_t last_offset = char_offset;
4876 int last_id = charset_ascii; 4792 int last_id = charset_ascii;
4877 int eol_dos = 4793 bool eol_dos
4878 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 4794 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
4879 int byte_after_cr = -1; 4795 int byte_after_cr = -1;
4880 4796
4881 CODING_GET_INFO (coding, attrs, charset_list); 4797 CODING_GET_INFO (coding, attrs, charset_list);
@@ -4957,13 +4873,12 @@ decode_coding_big5 (struct coding_system *coding)
4957 `japanese-jisx0208', `chinese-big5-1', and `chinese-big5-2'. We 4873 `japanese-jisx0208', `chinese-big5-1', and `chinese-big5-2'. We
4958 are sure that all these charsets are registered as official charset 4874 are sure that all these charsets are registered as official charset
4959 (i.e. do not have extended leading-codes). Characters of other 4875 (i.e. do not have extended leading-codes). Characters of other
4960 charsets are produced without any encoding. If SJIS_P is 1, encode 4876 charsets are produced without any encoding. */
4961 SJIS text, else encode BIG5 text. */
4962 4877
4963static int 4878static bool
4964encode_coding_sjis (struct coding_system *coding) 4879encode_coding_sjis (struct coding_system *coding)
4965{ 4880{
4966 int multibytep = coding->dst_multibyte; 4881 bool multibytep = coding->dst_multibyte;
4967 int *charbuf = coding->charbuf; 4882 int *charbuf = coding->charbuf;
4968 int *charbuf_end = charbuf + coding->charbuf_used; 4883 int *charbuf_end = charbuf + coding->charbuf_used;
4969 unsigned char *dst = coding->destination + coding->produced; 4884 unsigned char *dst = coding->destination + coding->produced;
@@ -4971,7 +4886,7 @@ encode_coding_sjis (struct coding_system *coding)
4971 int safe_room = 4; 4886 int safe_room = 4;
4972 ptrdiff_t produced_chars = 0; 4887 ptrdiff_t produced_chars = 0;
4973 Lisp_Object attrs, charset_list, val; 4888 Lisp_Object attrs, charset_list, val;
4974 int ascii_compatible; 4889 bool ascii_compatible;
4975 struct charset *charset_kanji, *charset_kana; 4890 struct charset *charset_kanji, *charset_kana;
4976 struct charset *charset_kanji2; 4891 struct charset *charset_kanji2;
4977 int c; 4892 int c;
@@ -5054,10 +4969,10 @@ encode_coding_sjis (struct coding_system *coding)
5054 return 0; 4969 return 0;
5055} 4970}
5056 4971
5057static int 4972static bool
5058encode_coding_big5 (struct coding_system *coding) 4973encode_coding_big5 (struct coding_system *coding)
5059{ 4974{
5060 int multibytep = coding->dst_multibyte; 4975 bool multibytep = coding->dst_multibyte;
5061 int *charbuf = coding->charbuf; 4976 int *charbuf = coding->charbuf;
5062 int *charbuf_end = charbuf + coding->charbuf_used; 4977 int *charbuf_end = charbuf + coding->charbuf_used;
5063 unsigned char *dst = coding->destination + coding->produced; 4978 unsigned char *dst = coding->destination + coding->produced;
@@ -5065,7 +4980,7 @@ encode_coding_big5 (struct coding_system *coding)
5065 int safe_room = 4; 4980 int safe_room = 4;
5066 ptrdiff_t produced_chars = 0; 4981 ptrdiff_t produced_chars = 0;
5067 Lisp_Object attrs, charset_list, val; 4982 Lisp_Object attrs, charset_list, val;
5068 int ascii_compatible; 4983 bool ascii_compatible;
5069 struct charset *charset_big5; 4984 struct charset *charset_big5;
5070 int c; 4985 int c;
5071 4986
@@ -5130,17 +5045,16 @@ encode_coding_big5 (struct coding_system *coding)
5130/*** 10. CCL handlers ***/ 5045/*** 10. CCL handlers ***/
5131 5046
5132/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 5047/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
5133 Check if a text is encoded in a coding system of which 5048 Return true if a text is encoded in a coding system of which
5134 encoder/decoder are written in CCL program. If it is, return 5049 encoder/decoder are written in CCL program. */
5135 CATEGORY_MASK_CCL, else return 0. */
5136 5050
5137static int 5051static bool
5138detect_coding_ccl (struct coding_system *coding, 5052detect_coding_ccl (struct coding_system *coding,
5139 struct coding_detection_info *detect_info) 5053 struct coding_detection_info *detect_info)
5140{ 5054{
5141 const unsigned char *src = coding->source, *src_base; 5055 const unsigned char *src = coding->source, *src_base;
5142 const unsigned char *src_end = coding->source + coding->src_bytes; 5056 const unsigned char *src_end = coding->source + coding->src_bytes;
5143 int multibytep = coding->src_multibyte; 5057 bool multibytep = coding->src_multibyte;
5144 ptrdiff_t consumed_chars = 0; 5058 ptrdiff_t consumed_chars = 0;
5145 int found = 0; 5059 int found = 0;
5146 unsigned char *valids; 5060 unsigned char *valids;
@@ -5182,7 +5096,7 @@ decode_coding_ccl (struct coding_system *coding)
5182 int *charbuf = coding->charbuf + coding->charbuf_used; 5096 int *charbuf = coding->charbuf + coding->charbuf_used;
5183 int *charbuf_end = coding->charbuf + coding->charbuf_size; 5097 int *charbuf_end = coding->charbuf + coding->charbuf_size;
5184 ptrdiff_t consumed_chars = 0; 5098 ptrdiff_t consumed_chars = 0;
5185 int multibytep = coding->src_multibyte; 5099 bool multibytep = coding->src_multibyte;
5186 struct ccl_program *ccl = &coding->spec.ccl->ccl; 5100 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5187 int source_charbuf[1024]; 5101 int source_charbuf[1024];
5188 int source_byteidx[1025]; 5102 int source_byteidx[1025];
@@ -5243,11 +5157,11 @@ decode_coding_ccl (struct coding_system *coding)
5243 coding->charbuf_used = charbuf - coding->charbuf; 5157 coding->charbuf_used = charbuf - coding->charbuf;
5244} 5158}
5245 5159
5246static int 5160static bool
5247encode_coding_ccl (struct coding_system *coding) 5161encode_coding_ccl (struct coding_system *coding)
5248{ 5162{
5249 struct ccl_program *ccl = &coding->spec.ccl->ccl; 5163 struct ccl_program *ccl = &coding->spec.ccl->ccl;
5250 int multibytep = coding->dst_multibyte; 5164 bool multibytep = coding->dst_multibyte;
5251 int *charbuf = coding->charbuf; 5165 int *charbuf = coding->charbuf;
5252 int *charbuf_end = charbuf + coding->charbuf_used; 5166 int *charbuf_end = charbuf + coding->charbuf_used;
5253 unsigned char *dst = coding->destination + coding->produced; 5167 unsigned char *dst = coding->destination + coding->produced;
@@ -5308,7 +5222,6 @@ encode_coding_ccl (struct coding_system *coding)
5308 return 0; 5222 return 0;
5309} 5223}
5310 5224
5311
5312 5225
5313/*** 10, 11. no-conversion handlers ***/ 5226/*** 10, 11. no-conversion handlers ***/
5314 5227
@@ -5317,8 +5230,8 @@ encode_coding_ccl (struct coding_system *coding)
5317static void 5230static void
5318decode_coding_raw_text (struct coding_system *coding) 5231decode_coding_raw_text (struct coding_system *coding)
5319{ 5232{
5320 int eol_dos = 5233 bool eol_dos
5321 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 5234 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
5322 5235
5323 coding->chars_at_source = 1; 5236 coding->chars_at_source = 1;
5324 coding->consumed_char = coding->src_chars; 5237 coding->consumed_char = coding->src_chars;
@@ -5333,10 +5246,10 @@ decode_coding_raw_text (struct coding_system *coding)
5333 record_conversion_result (coding, CODING_RESULT_SUCCESS); 5246 record_conversion_result (coding, CODING_RESULT_SUCCESS);
5334} 5247}
5335 5248
5336static int 5249static bool
5337encode_coding_raw_text (struct coding_system *coding) 5250encode_coding_raw_text (struct coding_system *coding)
5338{ 5251{
5339 int multibytep = coding->dst_multibyte; 5252 bool multibytep = coding->dst_multibyte;
5340 int *charbuf = coding->charbuf; 5253 int *charbuf = coding->charbuf;
5341 int *charbuf_end = coding->charbuf + coding->charbuf_used; 5254 int *charbuf_end = coding->charbuf + coding->charbuf_used;
5342 unsigned char *dst = coding->destination + coding->produced; 5255 unsigned char *dst = coding->destination + coding->produced;
@@ -5414,21 +5327,20 @@ encode_coding_raw_text (struct coding_system *coding)
5414} 5327}
5415 5328
5416/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions". 5329/* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
5417 Check if a text is encoded in a charset-based coding system. If it 5330 Return true if a text is encoded in a charset-based coding system. */
5418 is, return 1, else return 0. */
5419 5331
5420static int 5332static bool
5421detect_coding_charset (struct coding_system *coding, 5333detect_coding_charset (struct coding_system *coding,
5422 struct coding_detection_info *detect_info) 5334 struct coding_detection_info *detect_info)
5423{ 5335{
5424 const unsigned char *src = coding->source, *src_base; 5336 const unsigned char *src = coding->source, *src_base;
5425 const unsigned char *src_end = coding->source + coding->src_bytes; 5337 const unsigned char *src_end = coding->source + coding->src_bytes;
5426 int multibytep = coding->src_multibyte; 5338 bool multibytep = coding->src_multibyte;
5427 ptrdiff_t consumed_chars = 0; 5339 ptrdiff_t consumed_chars = 0;
5428 Lisp_Object attrs, valids, name; 5340 Lisp_Object attrs, valids, name;
5429 int found = 0; 5341 int found = 0;
5430 ptrdiff_t head_ascii = coding->head_ascii; 5342 ptrdiff_t head_ascii = coding->head_ascii;
5431 int check_latin_extra = 0; 5343 bool check_latin_extra = 0;
5432 5344
5433 detect_info->checked |= CATEGORY_MASK_CHARSET; 5345 detect_info->checked |= CATEGORY_MASK_CHARSET;
5434 5346
@@ -5532,14 +5444,14 @@ decode_coding_charset (struct coding_system *coding)
5532 int *charbuf_end 5444 int *charbuf_end
5533 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 5445 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
5534 ptrdiff_t consumed_chars = 0, consumed_chars_base; 5446 ptrdiff_t consumed_chars = 0, consumed_chars_base;
5535 int multibytep = coding->src_multibyte; 5447 bool multibytep = coding->src_multibyte;
5536 Lisp_Object attrs = CODING_ID_ATTRS (coding->id); 5448 Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
5537 Lisp_Object valids; 5449 Lisp_Object valids;
5538 ptrdiff_t char_offset = coding->produced_char; 5450 ptrdiff_t char_offset = coding->produced_char;
5539 ptrdiff_t last_offset = char_offset; 5451 ptrdiff_t last_offset = char_offset;
5540 int last_id = charset_ascii; 5452 int last_id = charset_ascii;
5541 int eol_dos = 5453 bool eol_dos
5542 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 5454 = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
5543 int byte_after_cr = -1; 5455 int byte_after_cr = -1;
5544 5456
5545 valids = AREF (attrs, coding_attr_charset_valids); 5457 valids = AREF (attrs, coding_attr_charset_valids);
@@ -5648,10 +5560,10 @@ decode_coding_charset (struct coding_system *coding)
5648 coding->charbuf_used = charbuf - coding->charbuf; 5560 coding->charbuf_used = charbuf - coding->charbuf;
5649} 5561}
5650 5562
5651static int 5563static bool
5652encode_coding_charset (struct coding_system *coding) 5564encode_coding_charset (struct coding_system *coding)
5653{ 5565{
5654 int multibytep = coding->dst_multibyte; 5566 bool multibytep = coding->dst_multibyte;
5655 int *charbuf = coding->charbuf; 5567 int *charbuf = coding->charbuf;
5656 int *charbuf_end = charbuf + coding->charbuf_used; 5568 int *charbuf_end = charbuf + coding->charbuf_used;
5657 unsigned char *dst = coding->destination + coding->produced; 5569 unsigned char *dst = coding->destination + coding->produced;
@@ -5659,7 +5571,7 @@ encode_coding_charset (struct coding_system *coding)
5659 int safe_room = MAX_MULTIBYTE_LENGTH; 5571 int safe_room = MAX_MULTIBYTE_LENGTH;
5660 ptrdiff_t produced_chars = 0; 5572 ptrdiff_t produced_chars = 0;
5661 Lisp_Object attrs, charset_list; 5573 Lisp_Object attrs, charset_list;
5662 int ascii_compatible; 5574 bool ascii_compatible;
5663 int c; 5575 int c;
5664 5576
5665 CODING_GET_INFO (coding, attrs, charset_list); 5577 CODING_GET_INFO (coding, attrs, charset_list);
@@ -5865,7 +5777,6 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding)
5865 coding->encoder = encode_coding_emacs_mule; 5777 coding->encoder = encode_coding_emacs_mule;
5866 coding->common_flags 5778 coding->common_flags
5867 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK); 5779 |= (CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK);
5868 coding->spec.emacs_mule.full_support = 1;
5869 if (! NILP (AREF (attrs, coding_attr_emacs_mule_full)) 5780 if (! NILP (AREF (attrs, coding_attr_emacs_mule_full))
5870 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list)) 5781 && ! EQ (CODING_ATTR_CHARSET_LIST (attrs), Vemacs_mule_charset_list))
5871 { 5782 {
@@ -5883,7 +5794,6 @@ setup_coding_system (Lisp_Object coding_system, struct coding_system *coding)
5883 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); 5794 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0);
5884 coding->max_charset_id = max_charset_id; 5795 coding->max_charset_id = max_charset_id;
5885 coding->safe_charsets = SDATA (safe_charsets); 5796 coding->safe_charsets = SDATA (safe_charsets);
5886 coding->spec.emacs_mule.full_support = 1;
5887 } 5797 }
5888 coding->spec.emacs_mule.cmp_status.state = COMPOSING_NO; 5798 coding->spec.emacs_mule.cmp_status.state = COMPOSING_NO;
5889 coding->spec.emacs_mule.cmp_status.method = COMPOSITION_NO; 5799 coding->spec.emacs_mule.cmp_status.method = COMPOSITION_NO;
@@ -6216,11 +6126,9 @@ detect_eol (const unsigned char *source, ptrdiff_t src_bytes,
6216 6126
6217 if ((1 << category) & CATEGORY_MASK_UTF_16) 6127 if ((1 << category) & CATEGORY_MASK_UTF_16)
6218 { 6128 {
6219 int msb, lsb; 6129 bool msb = category == (coding_category_utf_16_le
6220 6130 | coding_category_utf_16_le_nosig);
6221 msb = category == (coding_category_utf_16_le 6131 bool lsb = !msb;
6222 | coding_category_utf_16_le_nosig);
6223 lsb = 1 - msb;
6224 6132
6225 while (src + 1 < src_end) 6133 while (src + 1 < src_end)
6226 { 6134 {
@@ -6335,7 +6243,7 @@ static void
6335detect_coding (struct coding_system *coding) 6243detect_coding (struct coding_system *coding)
6336{ 6244{
6337 const unsigned char *src, *src_end; 6245 const unsigned char *src, *src_end;
6338 int saved_mode = coding->mode; 6246 unsigned int saved_mode = coding->mode;
6339 6247
6340 coding->consumed = coding->consumed_char = 0; 6248 coding->consumed = coding->consumed_char = 0;
6341 coding->produced = coding->produced_char = 0; 6249 coding->produced = coding->produced_char = 0;
@@ -6350,7 +6258,7 @@ detect_coding (struct coding_system *coding)
6350 { 6258 {
6351 int c, i; 6259 int c, i;
6352 struct coding_detection_info detect_info; 6260 struct coding_detection_info detect_info;
6353 int null_byte_found = 0, eight_bit_found = 0; 6261 bool null_byte_found = 0, eight_bit_found = 0;
6354 6262
6355 detect_info.checked = detect_info.found = detect_info.rejected = 0; 6263 detect_info.checked = detect_info.found = detect_info.rejected = 0;
6356 for (src = coding->source; src < src_end; src++) 6264 for (src = coding->source; src < src_end; src++)
@@ -6609,11 +6517,11 @@ decode_eol (struct coding_system *coding)
6609 6517
6610 6518
6611/* Return a translation table (or list of them) from coding system 6519/* Return a translation table (or list of them) from coding system
6612 attribute vector ATTRS for encoding (ENCODEP is nonzero) or 6520 attribute vector ATTRS for encoding (if ENCODEP) or decoding (if
6613 decoding (ENCODEP is zero). */ 6521 not ENCODEP). */
6614 6522
6615static Lisp_Object 6523static Lisp_Object
6616get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup) 6524get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup)
6617{ 6525{
6618 Lisp_Object standard, translation_table; 6526 Lisp_Object standard, translation_table;
6619 Lisp_Object val; 6527 Lisp_Object val;
@@ -6743,7 +6651,7 @@ get_translation (Lisp_Object trans, int *buf, int *buf_end)
6743 6651
6744static int 6652static int
6745produce_chars (struct coding_system *coding, Lisp_Object translation_table, 6653produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6746 int last_block) 6654 bool last_block)
6747{ 6655{
6748 unsigned char *dst = coding->destination + coding->produced; 6656 unsigned char *dst = coding->destination + coding->produced;
6749 unsigned char *dst_end = coding->destination + coding->dst_bytes; 6657 unsigned char *dst_end = coding->destination + coding->dst_bytes;
@@ -6846,7 +6754,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6846 { 6754 {
6847 if (coding->src_multibyte) 6755 if (coding->src_multibyte)
6848 { 6756 {
6849 int multibytep = 1; 6757 bool multibytep = 1;
6850 ptrdiff_t consumed_chars = 0; 6758 ptrdiff_t consumed_chars = 0;
6851 6759
6852 while (1) 6760 while (1)
@@ -6882,7 +6790,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6882 else 6790 else
6883 while (src < src_end) 6791 while (src < src_end)
6884 { 6792 {
6885 int multibytep = 1; 6793 bool multibytep = 1;
6886 int c = *src++; 6794 int c = *src++;
6887 6795
6888 if (dst >= dst_end - 1) 6796 if (dst >= dst_end - 1)
@@ -7018,7 +6926,7 @@ produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
7018 if (! coding->charbuf) \ 6926 if (! coding->charbuf) \
7019 { \ 6927 { \
7020 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \ 6928 record_conversion_result (coding, CODING_RESULT_INSUFFICIENT_MEM); \
7021 return coding->result; \ 6929 return; \
7022 } \ 6930 } \
7023 coding->charbuf_size = size; \ 6931 coding->charbuf_size = size; \
7024 } while (0) 6932 } while (0)
@@ -7079,7 +6987,7 @@ produce_annotation (struct coding_system *coding, ptrdiff_t pos)
7079 CODING->dst_object. 6987 CODING->dst_object.
7080*/ 6988*/
7081 6989
7082static int 6990static void
7083decode_coding (struct coding_system *coding) 6991decode_coding (struct coding_system *coding)
7084{ 6992{
7085 Lisp_Object attrs; 6993 Lisp_Object attrs;
@@ -7212,7 +7120,6 @@ decode_coding (struct coding_system *coding)
7212 bset_undo_list (current_buffer, undo_list); 7120 bset_undo_list (current_buffer, undo_list);
7213 record_insert (coding->dst_pos, coding->produced_char); 7121 record_insert (coding->dst_pos, coding->produced_char);
7214 } 7122 }
7215 return coding->result;
7216} 7123}
7217 7124
7218 7125
@@ -7341,7 +7248,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7341 const unsigned char *src_end = coding->source + coding->src_bytes; 7248 const unsigned char *src_end = coding->source + coding->src_bytes;
7342 ptrdiff_t pos = coding->src_pos + coding->consumed_char; 7249 ptrdiff_t pos = coding->src_pos + coding->consumed_char;
7343 ptrdiff_t end_pos = coding->src_pos + coding->src_chars; 7250 ptrdiff_t end_pos = coding->src_pos + coding->src_chars;
7344 int multibytep = coding->src_multibyte; 7251 bool multibytep = coding->src_multibyte;
7345 Lisp_Object eol_type; 7252 Lisp_Object eol_type;
7346 int c; 7253 int c;
7347 ptrdiff_t stop, stop_composition, stop_charset; 7254 ptrdiff_t stop, stop_composition, stop_charset;
@@ -7488,7 +7395,7 @@ consume_chars (struct coding_system *coding, Lisp_Object translation_table,
7488 If CODING->dst_object is nil, the encoded data is placed at the 7395 If CODING->dst_object is nil, the encoded data is placed at the
7489 memory area specified by CODING->destination. */ 7396 memory area specified by CODING->destination. */
7490 7397
7491static int 7398static void
7492encode_coding (struct coding_system *coding) 7399encode_coding (struct coding_system *coding)
7493{ 7400{
7494 Lisp_Object attrs; 7401 Lisp_Object attrs;
@@ -7530,8 +7437,6 @@ encode_coding (struct coding_system *coding)
7530 7437
7531 if (BUFFERP (coding->dst_object) && coding->produced_char > 0) 7438 if (BUFFERP (coding->dst_object) && coding->produced_char > 0)
7532 insert_from_gap (coding->produced_char, coding->produced); 7439 insert_from_gap (coding->produced_char, coding->produced);
7533
7534 return (coding->result);
7535} 7440}
7536 7441
7537 7442
@@ -7545,26 +7450,27 @@ static Lisp_Object Vcode_conversion_workbuf_name;
7545 versions of Vcode_conversion_workbuf_name. */ 7450 versions of Vcode_conversion_workbuf_name. */
7546static Lisp_Object Vcode_conversion_reused_workbuf; 7451static Lisp_Object Vcode_conversion_reused_workbuf;
7547 7452
7548/* 1 iff Vcode_conversion_reused_workbuf is already in use. */ 7453/* True iff Vcode_conversion_reused_workbuf is already in use. */
7549static int reused_workbuf_in_use; 7454static bool reused_workbuf_in_use;
7550 7455
7551 7456
7552/* Return a working buffer of code conversion. MULTIBYTE specifies the 7457/* Return a working buffer of code conversion. MULTIBYTE specifies the
7553 multibyteness of returning buffer. */ 7458 multibyteness of returning buffer. */
7554 7459
7555static Lisp_Object 7460static Lisp_Object
7556make_conversion_work_buffer (int multibyte) 7461make_conversion_work_buffer (bool multibyte)
7557{ 7462{
7558 Lisp_Object name, workbuf; 7463 Lisp_Object name, workbuf;
7559 struct buffer *current; 7464 struct buffer *current;
7560 7465
7561 if (reused_workbuf_in_use++) 7466 if (reused_workbuf_in_use)
7562 { 7467 {
7563 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); 7468 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
7564 workbuf = Fget_buffer_create (name); 7469 workbuf = Fget_buffer_create (name);
7565 } 7470 }
7566 else 7471 else
7567 { 7472 {
7473 reused_workbuf_in_use = 1;
7568 if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf))) 7474 if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf)))
7569 Vcode_conversion_reused_workbuf 7475 Vcode_conversion_reused_workbuf
7570 = Fget_buffer_create (Vcode_conversion_workbuf_name); 7476 = Fget_buffer_create (Vcode_conversion_workbuf_name);
@@ -7606,7 +7512,7 @@ code_conversion_restore (Lisp_Object arg)
7606} 7512}
7607 7513
7608Lisp_Object 7514Lisp_Object
7609code_conversion_save (int with_work_buf, int multibyte) 7515code_conversion_save (bool with_work_buf, bool multibyte)
7610{ 7516{
7611 Lisp_Object workbuf = Qnil; 7517 Lisp_Object workbuf = Qnil;
7612 7518
@@ -7617,7 +7523,7 @@ code_conversion_save (int with_work_buf, int multibyte)
7617 return workbuf; 7523 return workbuf;
7618} 7524}
7619 7525
7620int 7526void
7621decode_coding_gap (struct coding_system *coding, 7527decode_coding_gap (struct coding_system *coding,
7622 ptrdiff_t chars, ptrdiff_t bytes) 7528 ptrdiff_t chars, ptrdiff_t bytes)
7623{ 7529{
@@ -7660,7 +7566,6 @@ decode_coding_gap (struct coding_system *coding,
7660 } 7566 }
7661 7567
7662 unbind_to (count, Qnil); 7568 unbind_to (count, Qnil);
7663 return coding->result;
7664} 7569}
7665 7570
7666 7571
@@ -7706,8 +7611,8 @@ decode_coding_object (struct coding_system *coding,
7706 ptrdiff_t chars = to - from; 7611 ptrdiff_t chars = to - from;
7707 ptrdiff_t bytes = to_byte - from_byte; 7612 ptrdiff_t bytes = to_byte - from_byte;
7708 Lisp_Object attrs; 7613 Lisp_Object attrs;
7709 int saved_pt = -1, saved_pt_byte IF_LINT (= 0); 7614 ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0);
7710 int need_marker_adjustment = 0; 7615 bool need_marker_adjustment = 0;
7711 Lisp_Object old_deactivate_mark; 7616 Lisp_Object old_deactivate_mark;
7712 7617
7713 old_deactivate_mark = Vdeactivate_mark; 7618 old_deactivate_mark = Vdeactivate_mark;
@@ -7894,9 +7799,9 @@ encode_coding_object (struct coding_system *coding,
7894 ptrdiff_t chars = to - from; 7799 ptrdiff_t chars = to - from;
7895 ptrdiff_t bytes = to_byte - from_byte; 7800 ptrdiff_t bytes = to_byte - from_byte;
7896 Lisp_Object attrs; 7801 Lisp_Object attrs;
7897 int saved_pt = -1, saved_pt_byte IF_LINT (= 0); 7802 ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0);
7898 int need_marker_adjustment = 0; 7803 bool need_marker_adjustment = 0;
7899 int kill_src_buffer = 0; 7804 bool kill_src_buffer = 0;
7900 Lisp_Object old_deactivate_mark; 7805 Lisp_Object old_deactivate_mark;
7901 7806
7902 old_deactivate_mark = Vdeactivate_mark; 7807 old_deactivate_mark = Vdeactivate_mark;
@@ -8172,10 +8077,10 @@ function `define-coding-system'. */)
8172 8077
8173 8078
8174/* Detect how the bytes at SRC of length SRC_BYTES are encoded. If 8079/* Detect how the bytes at SRC of length SRC_BYTES are encoded. If
8175 HIGHEST is nonzero, return the coding system of the highest 8080 HIGHEST, return the coding system of the highest
8176 priority among the detected coding systems. Otherwise return a 8081 priority among the detected coding systems. Otherwise return a
8177 list of detected coding systems sorted by their priorities. If 8082 list of detected coding systems sorted by their priorities. If
8178 MULTIBYTEP is nonzero, it is assumed that the bytes are in correct 8083 MULTIBYTEP, it is assumed that the bytes are in correct
8179 multibyte form but contains only ASCII and eight-bit chars. 8084 multibyte form but contains only ASCII and eight-bit chars.
8180 Otherwise, the bytes are raw bytes. 8085 Otherwise, the bytes are raw bytes.
8181 8086
@@ -8190,7 +8095,7 @@ function `define-coding-system'. */)
8190Lisp_Object 8095Lisp_Object
8191detect_coding_system (const unsigned char *src, 8096detect_coding_system (const unsigned char *src,
8192 ptrdiff_t src_chars, ptrdiff_t src_bytes, 8097 ptrdiff_t src_chars, ptrdiff_t src_bytes,
8193 int highest, int multibytep, 8098 bool highest, bool multibytep,
8194 Lisp_Object coding_system) 8099 Lisp_Object coding_system)
8195{ 8100{
8196 const unsigned char *src_end = src + src_bytes; 8101 const unsigned char *src_end = src + src_bytes;
@@ -8200,7 +8105,7 @@ detect_coding_system (const unsigned char *src,
8200 ptrdiff_t id; 8105 ptrdiff_t id;
8201 struct coding_detection_info detect_info; 8106 struct coding_detection_info detect_info;
8202 enum coding_category base_category; 8107 enum coding_category base_category;
8203 int null_byte_found = 0, eight_bit_found = 0; 8108 bool null_byte_found = 0, eight_bit_found = 0;
8204 8109
8205 if (NILP (coding_system)) 8110 if (NILP (coding_system))
8206 coding_system = Qundecided; 8111 coding_system = Qundecided;
@@ -8556,7 +8461,7 @@ highest priority. */)
8556} 8461}
8557 8462
8558 8463
8559static inline int 8464static inline bool
8560char_encodable_p (int c, Lisp_Object attrs) 8465char_encodable_p (int c, Lisp_Object attrs)
8561{ 8466{
8562 Lisp_Object tail; 8467 Lisp_Object tail;
@@ -8728,7 +8633,7 @@ to the string. */)
8728 Lisp_Object positions; 8633 Lisp_Object positions;
8729 ptrdiff_t from, to; 8634 ptrdiff_t from, to;
8730 const unsigned char *p, *stop, *pend; 8635 const unsigned char *p, *stop, *pend;
8731 int ascii_compatible; 8636 bool ascii_compatible;
8732 8637
8733 setup_coding_system (Fcheck_coding_system (coding_system), &coding); 8638 setup_coding_system (Fcheck_coding_system (coding_system), &coding);
8734 attrs = CODING_ID_ATTRS (coding.id); 8639 attrs = CODING_ID_ATTRS (coding.id);
@@ -8952,7 +8857,7 @@ is nil. */)
8952static Lisp_Object 8857static Lisp_Object
8953code_convert_region (Lisp_Object start, Lisp_Object end, 8858code_convert_region (Lisp_Object start, Lisp_Object end,
8954 Lisp_Object coding_system, Lisp_Object dst_object, 8859 Lisp_Object coding_system, Lisp_Object dst_object,
8955 int encodep, int norecord) 8860 bool encodep, bool norecord)
8956{ 8861{
8957 struct coding_system coding; 8862 struct coding_system coding;
8958 ptrdiff_t from, from_byte, to, to_byte; 8863 ptrdiff_t from, from_byte, to, to_byte;
@@ -9040,7 +8945,8 @@ not fully specified.) */)
9040 8945
9041Lisp_Object 8946Lisp_Object
9042code_convert_string (Lisp_Object string, Lisp_Object coding_system, 8947code_convert_string (Lisp_Object string, Lisp_Object coding_system,
9043 Lisp_Object dst_object, int encodep, int nocopy, int norecord) 8948 Lisp_Object dst_object, bool encodep, bool nocopy,
8949 bool norecord)
9044{ 8950{
9045 struct coding_system coding; 8951 struct coding_system coding;
9046 ptrdiff_t chars, bytes; 8952 ptrdiff_t chars, bytes;
@@ -9088,7 +8994,7 @@ code_convert_string (Lisp_Object string, Lisp_Object coding_system,
9088 8994
9089Lisp_Object 8995Lisp_Object
9090code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system, 8996code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system,
9091 int encodep) 8997 bool encodep)
9092{ 8998{
9093 return code_convert_string (string, coding_system, Qt, encodep, 0, 1); 8999 return code_convert_string (string, coding_system, Qt, encodep, 0, 1);
9094} 9000}
@@ -9489,7 +9395,7 @@ usage: (set-coding-system-priority &rest coding-systems) */)
9489 (ptrdiff_t nargs, Lisp_Object *args) 9395 (ptrdiff_t nargs, Lisp_Object *args)
9490{ 9396{
9491 ptrdiff_t i, j; 9397 ptrdiff_t i, j;
9492 int changed[coding_category_max]; 9398 bool changed[coding_category_max];
9493 enum coding_category priorities[coding_category_max]; 9399 enum coding_category priorities[coding_category_max];
9494 9400
9495 memset (changed, 0, sizeof changed); 9401 memset (changed, 0, sizeof changed);
diff --git a/src/coding.h b/src/coding.h
index 2987f19607b..c45d2ef86e2 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -321,7 +321,7 @@ struct composition_status
321{ 321{
322 enum composition_state state; 322 enum composition_state state;
323 enum composition_method method; 323 enum composition_method method;
324 int old_form; /* 0:pre-21 form, 1:post-21 form */ 324 bool old_form; /* true if pre-21 form */
325 int length; /* number of elements produced in charbuf */ 325 int length; /* number of elements produced in charbuf */
326 int nchars; /* number of characters composed */ 326 int nchars; /* number of characters composed */
327 int ncomps; /* number of composition components */ 327 int ncomps; /* number of composition components */
@@ -350,18 +350,18 @@ struct iso_2022_spec
350 there was an invalid designation previously. */ 350 there was an invalid designation previously. */
351 int current_designation[4]; 351 int current_designation[4];
352 352
353 /* Set to 1 temporarily only when graphic register 2 or 3 is invoked
354 by single-shift while encoding. */
355 int single_shifting;
356
357 /* Set to 1 temporarily only when processing at beginning of line. */
358 int bol;
359
360 /* If positive, we are now scanning CTEXT extended segment. */ 353 /* If positive, we are now scanning CTEXT extended segment. */
361 int ctext_extended_segment_len; 354 int ctext_extended_segment_len;
362 355
363 /* If nonzero, we are now scanning embedded UTF-8 sequence. */ 356 /* True temporarily only when graphic register 2 or 3 is invoked by
364 int embedded_utf_8; 357 single-shift while encoding. */
358 unsigned single_shifting : 1;
359
360 /* True temporarily only when processing at beginning of line. */
361 unsigned bol : 1;
362
363 /* If true, we are now scanning embedded UTF-8 sequence. */
364 unsigned embedded_utf_8 : 1;
365 365
366 /* The current composition. */ 366 /* The current composition. */
367 struct composition_status cmp_status; 367 struct composition_status cmp_status;
@@ -369,7 +369,6 @@ struct iso_2022_spec
369 369
370struct emacs_mule_spec 370struct emacs_mule_spec
371{ 371{
372 int full_support;
373 struct composition_status cmp_status; 372 struct composition_status cmp_status;
374}; 373};
375 374
@@ -470,10 +469,6 @@ struct coding_system
470 Lisp_Object dst_object; 469 Lisp_Object dst_object;
471 unsigned char *destination; 470 unsigned char *destination;
472 471
473 /* Set to 1 if the source of conversion is not in the member
474 `charbuf', but at `src_object'. */
475 int chars_at_source;
476
477 /* If an element is non-negative, it is a character code. 472 /* If an element is non-negative, it is a character code.
478 473
479 If it is in the range -128..-1, it is a 8-bit character code 474 If it is in the range -128..-1, it is a 8-bit character code
@@ -489,18 +484,21 @@ struct coding_system
489 int *charbuf; 484 int *charbuf;
490 int charbuf_size, charbuf_used; 485 int charbuf_size, charbuf_used;
491 486
487 /* True if the source of conversion is not in the member
488 `charbuf', but at `src_object'. */
489 unsigned chars_at_source : 1;
490
492 /* Set to 1 if charbuf contains an annotation. */ 491 /* Set to 1 if charbuf contains an annotation. */
493 int annotated; 492 unsigned annotated : 1;
494 493
495 unsigned char carryover[64]; 494 unsigned char carryover[64];
496 int carryover_bytes; 495 int carryover_bytes;
497 496
498 int default_char; 497 int default_char;
499 498
500 int (*detector) (struct coding_system *, 499 bool (*detector) (struct coding_system *, struct coding_detection_info *);
501 struct coding_detection_info *);
502 void (*decoder) (struct coding_system *); 500 void (*decoder) (struct coding_system *);
503 int (*encoder) (struct coding_system *); 501 bool (*encoder) (struct coding_system *);
504}; 502};
505 503
506/* Meanings of bits in the member `common_flags' of the structure 504/* Meanings of bits in the member `common_flags' of the structure
@@ -688,22 +686,20 @@ struct coding_system
688#define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1) 686#define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1)
689 687
690/* Extern declarations. */ 688/* Extern declarations. */
691extern Lisp_Object code_conversion_save (int, int); 689extern Lisp_Object code_conversion_save (bool, bool);
692extern int decoding_buffer_size (struct coding_system *, int);
693extern int encoding_buffer_size (struct coding_system *, int);
694extern void setup_coding_system (Lisp_Object, struct coding_system *); 690extern void setup_coding_system (Lisp_Object, struct coding_system *);
695extern Lisp_Object coding_charset_list (struct coding_system *); 691extern Lisp_Object coding_charset_list (struct coding_system *);
696extern Lisp_Object coding_system_charset_list (Lisp_Object); 692extern Lisp_Object coding_system_charset_list (Lisp_Object);
697extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object, 693extern Lisp_Object code_convert_string (Lisp_Object, Lisp_Object,
698 Lisp_Object, int, int, int); 694 Lisp_Object, bool, bool, bool);
699extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object, 695extern Lisp_Object code_convert_string_norecord (Lisp_Object, Lisp_Object,
700 int); 696 bool);
701extern Lisp_Object raw_text_coding_system (Lisp_Object); 697extern Lisp_Object raw_text_coding_system (Lisp_Object);
702extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); 698extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object);
703extern Lisp_Object complement_process_encoding_system (Lisp_Object); 699extern Lisp_Object complement_process_encoding_system (Lisp_Object);
704 700
705extern int decode_coding_gap (struct coding_system *, 701extern void decode_coding_gap (struct coding_system *,
706 ptrdiff_t, ptrdiff_t); 702 ptrdiff_t, ptrdiff_t);
707extern void decode_coding_object (struct coding_system *, 703extern void decode_coding_object (struct coding_system *,
708 Lisp_Object, ptrdiff_t, ptrdiff_t, 704 Lisp_Object, ptrdiff_t, ptrdiff_t,
709 ptrdiff_t, ptrdiff_t, Lisp_Object); 705 ptrdiff_t, ptrdiff_t, Lisp_Object);
@@ -778,6 +774,5 @@ extern struct coding_system safe_terminal_coding;
778extern Lisp_Object Qcoding_system_error; 774extern Lisp_Object Qcoding_system_error;
779 775
780extern char emacs_mule_bytes[256]; 776extern char emacs_mule_bytes[256];
781extern int emacs_mule_string_char (unsigned char *);
782 777
783#endif /* EMACS_CODING_H */ 778#endif /* EMACS_CODING_H */
diff --git a/src/fileio.c b/src/fileio.c
index 6deca0bf1e1..6906af7e74f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3760,7 +3760,8 @@ variable `last-coding-system-used' to the coding system actually used. */)
3760 ptrdiff_t temp; 3760 ptrdiff_t temp;
3761 ptrdiff_t this = 0; 3761 ptrdiff_t this = 0;
3762 ptrdiff_t this_count = SPECPDL_INDEX (); 3762 ptrdiff_t this_count = SPECPDL_INDEX ();
3763 int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 3763 bool multibyte
3764 = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
3764 Lisp_Object conversion_buffer; 3765 Lisp_Object conversion_buffer;
3765 struct gcpro gcpro1; 3766 struct gcpro gcpro1;
3766 3767
diff --git a/src/lisp.h b/src/lisp.h
index 5b842d371a2..9ae24998aa2 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2632,7 +2632,7 @@ extern void keys_of_cmds (void);
2632/* Defined in coding.c */ 2632/* Defined in coding.c */
2633extern Lisp_Object Qcharset; 2633extern Lisp_Object Qcharset;
2634extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, 2634extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t,
2635 ptrdiff_t, int, int, Lisp_Object); 2635 ptrdiff_t, bool, bool, Lisp_Object);
2636extern void init_coding (void); 2636extern void init_coding (void);
2637extern void init_coding_once (void); 2637extern void init_coding_once (void);
2638extern void syms_of_coding (void); 2638extern void syms_of_coding (void);