* doc/lispref/variables.texi (Scope): Mention the availability of lexbind.
[bpt/emacs.git] / src / coding.c
index b20a72c..f631036 100644 (file)
@@ -1,6 +1,5 @@
 /* Coding system handler (conversion, detection, etc).
-   Copyright (C) 2001, 2002, 2003, 2004, 2005,
-                 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2011 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
@@ -154,9 +153,8 @@ STRUCT CODING_SYSTEM
 
 #if 0
 static int
-detect_coding_XXX (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_XXX (struct coding_system *coding,
+                  struct coding_detection_info *detect_info)
 {
   const unsigned char *src = coding->source;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -203,8 +201,7 @@ detect_coding_XXX (coding, detect_info)
 
 #if 0
 static void
-decode_coding_XXXX (coding)
-     struct coding_system *coding;
+decode_coding_XXXX (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -261,8 +258,7 @@ decode_coding_XXXX (coding)
   Below is a template of these functions.  */
 #if 0
 static void
-encode_coding_XXX (coding)
-     struct coding_system *coding;
+encode_coding_XXX (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -306,7 +302,6 @@ Lisp_Object Vcoding_system_hash_table;
 
 Lisp_Object Qcoding_system, Qcoding_aliases, Qeol_type;
 Lisp_Object Qunix, Qdos;
-extern Lisp_Object Qmac;       /* frame.c */
 Lisp_Object Qbuffer_file_coding_system;
 Lisp_Object Qpost_read_conversion, Qpre_write_conversion;
 Lisp_Object Qdefault_char;
@@ -320,7 +315,6 @@ Lisp_Object QCdecode_translation_table, QCencode_translation_table;
 Lisp_Object QCpost_read_conversion, QCpre_write_conversion;
 Lisp_Object QCascii_compatible_p;
 
-extern Lisp_Object Qinsert_file_contents, Qwrite_region;
 Lisp_Object Qcall_process, Qcall_process_region;
 Lisp_Object Qstart_process, Qopen_network_stream;
 Lisp_Object Qtarget_idx;
@@ -328,22 +322,10 @@ Lisp_Object Qtarget_idx;
 Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source;
 Lisp_Object Qinterrupted, Qinsufficient_memory;
 
-extern Lisp_Object Qcompletion_ignore_case;
-
 /* If a symbol has this property, evaluate the value to define the
    symbol as a coding system.  */
 static Lisp_Object Qcoding_system_define_form;
 
-int coding_system_require_warning;
-
-Lisp_Object Vselect_safe_coding_system_function;
-
-/* Mnemonic string for each format of end-of-line.  */
-Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac;
-/* Mnemonic string to indicate format of end-of-line is not yet
-   decided.  */
-Lisp_Object eol_mnemonic_undecided;
-
 /* Format of end-of-line decided by system.  This is Qunix on
    Unix and Mac, Qdos on DOS/Windows.
    This has an effect only for external encoding (i.e. for output to
@@ -352,8 +334,6 @@ static Lisp_Object system_eol_type;
 
 #ifdef emacs
 
-Lisp_Object Vcoding_system_list, Vcoding_system_alist;
-
 Lisp_Object Qcoding_system_p, Qcoding_system_error;
 
 /* Coding system emacs-mule and raw-text are for converting only
@@ -363,64 +343,17 @@ Lisp_Object Qutf_8_emacs;
 
 /* Coding-systems are handed between Emacs Lisp programs and C internal
    routines by the following three variables.  */
-/* Coding-system for reading files and receiving data from process.  */
-Lisp_Object Vcoding_system_for_read;
-/* Coding-system for writing files and sending data to process.  */
-Lisp_Object Vcoding_system_for_write;
-/* Coding-system actually used in the latest I/O.  */
-Lisp_Object Vlast_coding_system_used;
-/* Set to non-nil when an error is detected while code conversion.  */
-Lisp_Object Vlast_code_conversion_error;
-/* A vector of length 256 which contains information about special
-   Latin codes (especially for dealing with Microsoft codes).  */
-Lisp_Object Vlatin_extra_code_table;
-
-/* Flag to inhibit code conversion of end-of-line format.  */
-int inhibit_eol_conversion;
-
-/* Flag to inhibit ISO2022 escape sequence detection.  */
-int inhibit_iso_escape_detection;
-
-/* Flag to inhibit detection of binary files through null bytes.  */
-int inhibit_null_byte_detection;
-
-/* Flag to make buffer-file-coding-system inherit from process-coding.  */
-int inherit_process_coding_system;
-
 /* Coding system to be used to encode text for terminal display when
    terminal coding system is nil.  */
 struct coding_system safe_terminal_coding;
 
-Lisp_Object Vfile_coding_system_alist;
-Lisp_Object Vprocess_coding_system_alist;
-Lisp_Object Vnetwork_coding_system_alist;
-
-Lisp_Object Vlocale_coding_system;
-
 #endif /* emacs */
 
-/* Flag to tell if we look up translation table on character code
-   conversion.  */
-Lisp_Object Venable_character_translation;
-/* Standard translation table to look up on decoding (reading).  */
-Lisp_Object Vstandard_translation_table_for_decode;
-/* Standard translation table to look up on encoding (writing).  */
-Lisp_Object Vstandard_translation_table_for_encode;
-
 Lisp_Object Qtranslation_table;
 Lisp_Object Qtranslation_table_id;
 Lisp_Object Qtranslation_table_for_decode;
 Lisp_Object Qtranslation_table_for_encode;
 
-/* Alist of charsets vs revision number.  */
-static Lisp_Object Vcharset_revision_table;
-
-/* Default coding systems used for process I/O.  */
-Lisp_Object Vdefault_process_coding_system;
-
-/* Char table for translating Quail and self-inserting input.  */
-Lisp_Object Vtranslation_table_for_input;
-
 /* Two special coding systems.  */
 Lisp_Object Vsjis_coding_system;
 Lisp_Object Vbig5_coding_system;
@@ -688,10 +621,6 @@ enum coding_category
    | CATEGORY_MASK_UTF_8_NOSIG \
    | CATEGORY_MASK_UTF_8_SIG)
 
-/* List of symbols `coding-category-xxx' ordered by priority.  This
-   variable is exposed to Emacs Lisp.  */
-static Lisp_Object Vcoding_category_list;
-
 /* Table of coding categories (Lisp symbols).  This variable is for
    internal use only.  */
 static Lisp_Object Vcoding_category_table;
@@ -896,80 +825,80 @@ static struct coding_system coding_categories[coding_category_max];
 
 
 /* Prototypes for static functions.  */
-static void record_conversion_result P_ ((struct coding_system *coding,
-                                         enum coding_result_code result));
-static int detect_coding_utf_8 P_ ((struct coding_system *,
-                                   struct coding_detection_info *info));
-static void decode_coding_utf_8 P_ ((struct coding_system *));
-static int encode_coding_utf_8 P_ ((struct coding_system *));
-
-static int detect_coding_utf_16 P_ ((struct coding_system *,
-                                    struct coding_detection_info *info));
-static void decode_coding_utf_16 P_ ((struct coding_system *));
-static int encode_coding_utf_16 P_ ((struct coding_system *));
-
-static int detect_coding_iso_2022 P_ ((struct coding_system *,
-                                      struct coding_detection_info *info));
-static void decode_coding_iso_2022 P_ ((struct coding_system *));
-static int encode_coding_iso_2022 P_ ((struct coding_system *));
-
-static int detect_coding_emacs_mule P_ ((struct coding_system *,
-                                        struct coding_detection_info *info));
-static void decode_coding_emacs_mule P_ ((struct coding_system *));
-static int encode_coding_emacs_mule P_ ((struct coding_system *));
-
-static int detect_coding_sjis P_ ((struct coding_system *,
-                                  struct coding_detection_info *info));
-static void decode_coding_sjis P_ ((struct coding_system *));
-static int encode_coding_sjis P_ ((struct coding_system *));
-
-static int detect_coding_big5 P_ ((struct coding_system *,
-                                  struct coding_detection_info *info));
-static void decode_coding_big5 P_ ((struct coding_system *));
-static int encode_coding_big5 P_ ((struct coding_system *));
-
-static int detect_coding_ccl P_ ((struct coding_system *,
-                                 struct coding_detection_info *info));
-static void decode_coding_ccl P_ ((struct coding_system *));
-static int encode_coding_ccl P_ ((struct coding_system *));
-
-static void decode_coding_raw_text P_ ((struct coding_system *));
-static int encode_coding_raw_text P_ ((struct coding_system *));
-
-static void coding_set_source P_ ((struct coding_system *));
-static void coding_set_destination P_ ((struct coding_system *));
-static void coding_alloc_by_realloc P_ ((struct coding_system *, EMACS_INT));
-static void coding_alloc_by_making_gap P_ ((struct coding_system *,
-                                           EMACS_INT, EMACS_INT));
-static unsigned char *alloc_destination P_ ((struct coding_system *,
-                                            EMACS_INT, unsigned char *));
-static void setup_iso_safe_charsets P_ ((Lisp_Object));
-static unsigned char *encode_designation_at_bol P_ ((struct coding_system *,
-                                                    int *, int *,
-                                                    unsigned char *));
-static int detect_eol P_ ((const unsigned char *,
-                          EMACS_INT, enum coding_category));
-static Lisp_Object adjust_coding_eol_type P_ ((struct coding_system *, int));
-static void decode_eol P_ ((struct coding_system *));
-static Lisp_Object get_translation_table P_ ((Lisp_Object, int, int *));
-static Lisp_Object get_translation P_ ((Lisp_Object, int *, int *));
-static int produce_chars P_ ((struct coding_system *, Lisp_Object, int));
-static INLINE void produce_charset P_ ((struct coding_system *, int *,
-                                       EMACS_INT));
-static void produce_annotation P_ ((struct coding_system *, EMACS_INT));
-static int decode_coding P_ ((struct coding_system *));
-static INLINE int *handle_composition_annotation P_ ((EMACS_INT, EMACS_INT,
-                                                     struct coding_system *,
-                                                     int *, EMACS_INT *));
-static INLINE int *handle_charset_annotation P_ ((EMACS_INT, EMACS_INT,
-                                                 struct coding_system *,
-                                                 int *, EMACS_INT *));
-static void consume_chars P_ ((struct coding_system *, Lisp_Object, int));
-static int encode_coding P_ ((struct coding_system *));
-static Lisp_Object make_conversion_work_buffer P_ ((int));
-static Lisp_Object code_conversion_restore P_ ((Lisp_Object));
-static INLINE int char_encodable_p P_ ((int, Lisp_Object));
-static Lisp_Object make_subsidiaries P_ ((Lisp_Object));
+static void record_conversion_result (struct coding_system *coding,
+                                      enum coding_result_code result);
+static int detect_coding_utf_8 (struct coding_system *,
+                                struct coding_detection_info *info);
+static void decode_coding_utf_8 (struct coding_system *);
+static int encode_coding_utf_8 (struct coding_system *);
+
+static int detect_coding_utf_16 (struct coding_system *,
+                                 struct coding_detection_info *info);
+static void decode_coding_utf_16 (struct coding_system *);
+static int encode_coding_utf_16 (struct coding_system *);
+
+static int detect_coding_iso_2022 (struct coding_system *,
+                                   struct coding_detection_info *info);
+static void decode_coding_iso_2022 (struct coding_system *);
+static int encode_coding_iso_2022 (struct coding_system *);
+
+static int detect_coding_emacs_mule (struct coding_system *,
+                                     struct coding_detection_info *info);
+static void decode_coding_emacs_mule (struct coding_system *);
+static int encode_coding_emacs_mule (struct coding_system *);
+
+static int detect_coding_sjis (struct coding_system *,
+                               struct coding_detection_info *info);
+static void decode_coding_sjis (struct coding_system *);
+static int encode_coding_sjis (struct coding_system *);
+
+static int detect_coding_big5 (struct coding_system *,
+                               struct coding_detection_info *info);
+static void decode_coding_big5 (struct coding_system *);
+static int encode_coding_big5 (struct coding_system *);
+
+static int detect_coding_ccl (struct coding_system *,
+                              struct coding_detection_info *info);
+static void decode_coding_ccl (struct coding_system *);
+static int encode_coding_ccl (struct coding_system *);
+
+static void decode_coding_raw_text (struct coding_system *);
+static int encode_coding_raw_text (struct coding_system *);
+
+static void coding_set_source (struct coding_system *);
+static void coding_set_destination (struct coding_system *);
+static void coding_alloc_by_realloc (struct coding_system *, EMACS_INT);
+static void coding_alloc_by_making_gap (struct coding_system *,
+                                        EMACS_INT, EMACS_INT);
+static unsigned char *alloc_destination (struct coding_system *,
+                                         EMACS_INT, unsigned char *);
+static void setup_iso_safe_charsets (Lisp_Object);
+static unsigned char *encode_designation_at_bol (struct coding_system *,
+                                                 int *, int *,
+                                                 unsigned char *);
+static int detect_eol (const unsigned char *,
+                       EMACS_INT, enum coding_category);
+static Lisp_Object adjust_coding_eol_type (struct coding_system *, int);
+static void decode_eol (struct coding_system *);
+static Lisp_Object get_translation_table (Lisp_Object, int, int *);
+static Lisp_Object get_translation (Lisp_Object, int *, int *);
+static int produce_chars (struct coding_system *, Lisp_Object, int);
+static INLINE void produce_charset (struct coding_system *, int *,
+                                    EMACS_INT);
+static void produce_annotation (struct coding_system *, EMACS_INT);
+static int decode_coding (struct coding_system *);
+static INLINE int *handle_composition_annotation (EMACS_INT, EMACS_INT,
+                                                  struct coding_system *,
+                                                  int *, EMACS_INT *);
+static INLINE int *handle_charset_annotation (EMACS_INT, EMACS_INT,
+                                              struct coding_system *,
+                                              int *, EMACS_INT *);
+static void consume_chars (struct coding_system *, Lisp_Object, int);
+static int encode_coding (struct coding_system *);
+static Lisp_Object make_conversion_work_buffer (int);
+static Lisp_Object code_conversion_restore (Lisp_Object);
+static INLINE int char_encodable_p (int, Lisp_Object);
+static Lisp_Object make_subsidiaries (Lisp_Object);
 
 static void
 record_conversion_result (struct coding_system *coding,
@@ -1106,8 +1035,7 @@ record_conversion_result (struct coding_system *coding,
 
 
 static void
-coding_set_source (coding)
-     struct coding_system *coding;
+coding_set_source (struct coding_system *coding)
 {
   if (BUFFERP (coding->src_object))
     {
@@ -1129,8 +1057,7 @@ coding_set_source (coding)
 }
 
 static void
-coding_set_destination (coding)
-     struct coding_system *coding;
+coding_set_destination (struct coding_system *coding)
 {
   if (BUFFERP (coding->dst_object))
     {
@@ -1159,9 +1086,7 @@ coding_set_destination (coding)
 
 
 static void
-coding_alloc_by_realloc (coding, bytes)
-     struct coding_system *coding;
-     EMACS_INT bytes;
+coding_alloc_by_realloc (struct coding_system *coding, EMACS_INT bytes)
 {
   coding->destination = (unsigned char *) xrealloc (coding->destination,
                                                    coding->dst_bytes + bytes);
@@ -1169,9 +1094,8 @@ coding_alloc_by_realloc (coding, bytes)
 }
 
 static void
-coding_alloc_by_making_gap (coding, gap_head_used, bytes)
-     struct coding_system *coding;
-     EMACS_INT gap_head_used, bytes;
+coding_alloc_by_making_gap (struct coding_system *coding,
+                           EMACS_INT gap_head_used, EMACS_INT bytes)
 {
   if (EQ (coding->src_object, coding->dst_object))
     {
@@ -1200,10 +1124,8 @@ coding_alloc_by_making_gap (coding, gap_head_used, bytes)
 
 
 static unsigned char *
-alloc_destination (coding, nbytes, dst)
-     struct coding_system *coding;
-     EMACS_INT nbytes;
-     unsigned char *dst;
+alloc_destination (struct coding_system *coding, EMACS_INT nbytes,
+                  unsigned char *dst)
 {
   EMACS_INT offset = dst - coding->destination;
 
@@ -1301,9 +1223,8 @@ alloc_destination (coding, nbytes, dst)
 #define UTF_8_BOM_3 0xBF
 
 static int
-detect_coding_utf_8 (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_utf_8 (struct coding_system *coding,
+                    struct coding_detection_info *detect_info)
 {
   const unsigned char *src = coding->source, *src_base;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1386,8 +1307,7 @@ detect_coding_utf_8 (coding, detect_info)
 
 
 static void
-decode_coding_utf_8 (coding)
-     struct coding_system *coding;
+decode_coding_utf_8 (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1435,8 +1355,6 @@ decode_coding_utf_8 (coding)
     }
   CODING_UTF_8_BOM (coding) = utf_without_bom;
 
-
-
   while (1)
     {
       int c, c1, c2, c3, c4, c5;
@@ -1459,7 +1377,7 @@ decode_coding_utf_8 (coding)
        {
          c = - c1;
        }
-      else if (UTF_8_1_OCTET_P(c1))
+      else if (UTF_8_1_OCTET_P (c1))
        {
          if (eol_crlf && c1 == '\r')
            ONE_MORE_BYTE (byte_after_cr);
@@ -1543,8 +1461,7 @@ decode_coding_utf_8 (coding)
 
 
 static int
-encode_coding_utf_8 (coding)
-     struct coding_system *coding;
+encode_coding_utf_8 (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -1623,14 +1540,12 @@ encode_coding_utf_8 (coding)
 
 
 static int
-detect_coding_utf_16 (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_utf_16 (struct coding_system *coding,
+                     struct coding_detection_info *detect_info)
 {
-  const unsigned char *src = coding->source, *src_base = src;
+  const unsigned char *src = coding->source;
   const unsigned char *src_end = coding->source + coding->src_bytes;
   int multibytep = coding->src_multibyte;
-  int consumed_chars = 0;
   int c1, c2;
 
   detect_info->checked |= CATEGORY_MASK_UTF_16;
@@ -1708,8 +1623,7 @@ detect_coding_utf_16 (coding, detect_info)
 }
 
 static void
-decode_coding_utf_16 (coding)
-     struct coding_system *coding;
+decode_coding_utf_16 (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -1837,8 +1751,7 @@ decode_coding_utf_16 (coding)
 }
 
 static int
-encode_coding_utf_16 (coding)
-     struct coding_system *coding;
+encode_coding_utf_16 (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -1979,9 +1892,8 @@ char emacs_mule_bytes[256];
    else return 0.  */
 
 static int
-detect_coding_emacs_mule (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_emacs_mule (struct coding_system *coding,
+                         struct coding_detection_info *detect_info)
 {
   const unsigned char *src = coding->source, *src_base;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -2069,11 +1981,9 @@ detect_coding_emacs_mule (coding, detect_info)
    -1.  If SRC is too short, return -2.  */
 
 int
-emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status)
-     struct coding_system *coding;
-     const unsigned char *src;
-     int *nbytes, *nchars, *id;
-     struct composition_status *cmp_status;
+emacs_mule_char (struct coding_system *coding, const unsigned char *src,
+                int *nbytes, int *nchars, int *id,
+                struct composition_status *cmp_status)
 {
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base = src;
@@ -2210,7 +2120,7 @@ emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status)
    (3) alt&rule composition: 0x80 0xF5 BYTES CHARS | ALT RULE ... ALT CHAR ...
 
    and these old form:
-  
+
    (4) relative composition: 0x80 | MSEQ ... MSEQ
    (5) rulebase composition: 0x80 0xFF | MSEQ MRULE ... MSEQ
 
@@ -2302,7 +2212,6 @@ emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status)
 #define DECODE_EMACS_MULE_21_COMPOSITION()                             \
   do {                                                                 \
     enum composition_method method = c - 0xF2;                         \
-    int *charbuf_base = charbuf;                                       \
     int nbytes, nchars;                                                        \
                                                                        \
     ONE_MORE_BYTE (c);                                                 \
@@ -2391,9 +2300,8 @@ emacs_mule_char (coding, src, nbytes, nchars, id, cmp_status)
 
 
 static int
-emacs_mule_finish_composition (charbuf, cmp_status)
-     int *charbuf;
-     struct composition_status *cmp_status;
+emacs_mule_finish_composition (int *charbuf,
+                              struct composition_status *cmp_status)
 {
   int idx = - cmp_status->length;
   int new_chars;
@@ -2448,8 +2356,7 @@ emacs_mule_finish_composition (charbuf, cmp_status)
 
 
 static void
-decode_coding_emacs_mule (coding)
-     struct coding_system *coding;
+decode_coding_emacs_mule (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -2660,11 +2567,6 @@ decode_coding_emacs_mule (coding)
        }
       continue;
 
-    retry:
-      src = src_base;
-      consumed_chars = consumed_chars_base;
-      continue;
-
     invalid_code:
       EMACS_MULE_MAYBE_FINISH_COMPOSITION ();
       src = src_base;
@@ -2713,8 +2615,7 @@ decode_coding_emacs_mule (coding)
 
 
 static int
-encode_coding_emacs_mule (coding)
-     struct coding_system *coding;
+encode_coding_emacs_mule (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -3007,8 +2908,7 @@ enum iso_code_class_type iso_code_class[256];
   (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0)
 
 static void
-setup_iso_safe_charsets (attrs)
-     Lisp_Object attrs;
+setup_iso_safe_charsets (Lisp_Object attrs)
 {
   Lisp_Object charset_list, safe_charsets;
   Lisp_Object request;
@@ -3076,9 +2976,8 @@ setup_iso_safe_charsets (attrs)
    If it is, return 1, else return 0.  */
 
 static int
-detect_coding_iso_2022 (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_iso_2022 (struct coding_system *coding,
+                       struct coding_detection_info *detect_info)
 {
   const unsigned char *src = coding->source, *src_base = src;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -3442,12 +3341,10 @@ detect_coding_iso_2022 (coding, detect_info)
 
 /* Finish the current composition as invalid.  */
 
-static int finish_composition P_ ((int *, struct composition_status *));
+static int finish_composition (int *, struct composition_status *);
 
 static int
-finish_composition (charbuf, cmp_status)
-     int *charbuf;
-     struct composition_status *cmp_status;
+finish_composition (int *charbuf, struct composition_status *cmp_status)
 {
   int idx = - cmp_status->length;
   int new_chars;
@@ -3584,8 +3481,7 @@ finish_composition (charbuf, cmp_status)
 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions".  */
 
 static void
-decode_coding_iso_2022 (coding)
-     struct coding_system *coding;
+decode_coding_iso_2022 (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4130,8 +4026,8 @@ decode_coding_iso_2022 (coding)
 #define ENCODE_DESIGNATION(charset, reg, coding)                       \
   do {                                                                 \
     unsigned char final_char = CHARSET_ISO_FINAL (charset);            \
-    char *intermediate_char_94 = "()*+";                               \
-    char *intermediate_char_96 = ",-./";                               \
+    const char *intermediate_char_94 = "()*+";                         \
+    const char *intermediate_char_96 = ",-./";                         \
     int revision = -1;                                                 \
     int c;                                                             \
                                                                        \
@@ -4317,7 +4213,7 @@ decode_coding_iso_2022 (coding)
 
 #define ENCODE_ISO_CHARACTER(charset, c)                                  \
   do {                                                                    \
-    int code = ENCODE_CHAR ((charset),(c));                               \
+    int code = ENCODE_CHAR ((charset), (c));                              \
                                                                           \
     if (CHARSET_DIMENSION (charset) == 1)                                 \
       ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code);                  \
@@ -4331,11 +4227,9 @@ decode_coding_iso_2022 (coding)
    Return new DST.  */
 
 unsigned char *
-encode_invocation_designation (charset, coding, dst, p_nchars)
-     struct charset *charset;
-     struct coding_system *coding;
-     unsigned char *dst;
-     int *p_nchars;
+encode_invocation_designation (struct charset *charset,
+                              struct coding_system *coding,
+                              unsigned char *dst, int *p_nchars)
 {
   int multibytep = coding->dst_multibyte;
   int produced_chars = *p_nchars;
@@ -4447,10 +4341,8 @@ encode_invocation_designation (charset, coding, dst, p_nchars)
    find all the necessary designations.  */
 
 static unsigned char *
-encode_designation_at_bol (coding, charbuf, charbuf_end, dst)
-     struct coding_system *coding;
-     int *charbuf, *charbuf_end;
-     unsigned char *dst;
+encode_designation_at_bol (struct coding_system *coding, int *charbuf,
+                          int *charbuf_end, unsigned char *dst)
 {
   struct charset *charset;
   /* Table of charsets to be designated to each graphic register.  */
@@ -4500,8 +4392,7 @@ encode_designation_at_bol (coding, charbuf, charbuf_end, dst)
 /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions".  */
 
 static int
-encode_coding_iso_2022 (coding)
-     struct coding_system *coding;
+encode_coding_iso_2022 (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -4694,9 +4585,8 @@ encode_coding_iso_2022 (coding)
    CATEGORY_MASK_SJIS, else return 0.  */
 
 static int
-detect_coding_sjis (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_sjis (struct coding_system *coding,
+                   struct coding_detection_info *detect_info)
 {
   const unsigned char *src = coding->source, *src_base;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4752,9 +4642,8 @@ detect_coding_sjis (coding, detect_info)
    CATEGORY_MASK_BIG5, else return 0.  */
 
 static int
-detect_coding_big5 (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_big5 (struct coding_system *coding,
+                   struct coding_detection_info *detect_info)
 {
   const unsigned char *src = coding->source, *src_base;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4800,8 +4689,7 @@ detect_coding_big5 (coding, detect_info)
    If SJIS_P is 1, decode SJIS text, else decode BIG5 test.  */
 
 static void
-decode_coding_sjis (coding)
-     struct coding_system *coding;
+decode_coding_sjis (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -4919,8 +4807,7 @@ decode_coding_sjis (coding)
 }
 
 static void
-decode_coding_big5 (coding)
-     struct coding_system *coding;
+decode_coding_big5 (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5024,8 +4911,7 @@ decode_coding_big5 (coding)
    SJIS text, else encode BIG5 text.  */
 
 static int
-encode_coding_sjis (coding)
-     struct coding_system *coding;
+encode_coding_sjis (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -5117,8 +5003,7 @@ encode_coding_sjis (coding)
 }
 
 static int
-encode_coding_big5 (coding)
-     struct coding_system *coding;
+encode_coding_big5 (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -5196,9 +5081,8 @@ encode_coding_big5 (coding)
    CATEGORY_MASK_CCL, else return 0.  */
 
 static int
-detect_coding_ccl (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_ccl (struct coding_system *coding,
+                  struct coding_detection_info *detect_info)
 {
   const unsigned char *src = coding->source, *src_base;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5237,8 +5121,7 @@ detect_coding_ccl (coding, detect_info)
 }
 
 static void
-decode_coding_ccl (coding)
-     struct coding_system *coding;
+decode_coding_ccl (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5307,8 +5190,7 @@ decode_coding_ccl (coding)
 }
 
 static int
-encode_coding_ccl (coding)
-     struct coding_system *coding;
+encode_coding_ccl (struct coding_system *coding)
 {
   struct ccl_program *ccl = &coding->spec.ccl->ccl;
   int multibytep = coding->dst_multibyte;
@@ -5377,8 +5259,7 @@ encode_coding_ccl (coding)
 /* See the above "GENERAL NOTES on `decode_coding_XXX ()' functions".  */
 
 static void
-decode_coding_raw_text (coding)
-     struct coding_system *coding;
+decode_coding_raw_text (struct coding_system *coding)
 {
   int eol_crlf =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
@@ -5397,8 +5278,7 @@ decode_coding_raw_text (coding)
 }
 
 static int
-encode_coding_raw_text (coding)
-     struct coding_system *coding;
+encode_coding_raw_text (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -5481,9 +5361,8 @@ encode_coding_raw_text (coding)
    is, return 1, else return 0.  */
 
 static int
-detect_coding_charset (coding, detect_info)
-     struct coding_system *coding;
-     struct coding_detection_info *detect_info;
+detect_coding_charset (struct coding_system *coding,
+                      struct coding_detection_info *detect_info)
 {
   const unsigned char *src = coding->source, *src_base;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5500,9 +5379,9 @@ detect_coding_charset (coding, detect_info)
   attrs = CODING_ID_ATTRS (coding->id);
   valids = AREF (attrs, coding_attr_charset_valids);
   name = CODING_ID_NAME (coding->id);
-  if (strncmp ((char *) SDATA (SYMBOL_NAME (name)),
+  if (strncmp (SSDATA (SYMBOL_NAME (name)),
               "iso-8859-", sizeof ("iso-8859-") - 1) == 0
-      || strncmp ((char *) SDATA (SYMBOL_NAME (name)),
+      || strncmp (SSDATA (SYMBOL_NAME (name)),
                  "iso-latin-", sizeof ("iso-latin-") - 1) == 0)
     check_latin_extra = 1;
 
@@ -5585,8 +5464,7 @@ detect_coding_charset (coding, detect_info)
 }
 
 static void
-decode_coding_charset (coding)
-     struct coding_system *coding;
+decode_coding_charset (struct coding_system *coding)
 {
   const unsigned char *src = coding->source + coding->consumed;
   const unsigned char *src_end = coding->source + coding->src_bytes;
@@ -5714,8 +5592,7 @@ decode_coding_charset (coding)
 }
 
 static int
-encode_coding_charset (coding)
-     struct coding_system *coding;
+encode_coding_charset (struct coding_system *coding)
 {
   int multibytep = coding->dst_multibyte;
   int *charbuf = coding->charbuf;
@@ -5785,9 +5662,7 @@ encode_coding_charset (coding)
    CODING_SYSTEM is invalid, signal an error.  */
 
 void
-setup_coding_system (coding_system, coding)
-     Lisp_Object coding_system;
-     struct coding_system *coding;
+setup_coding_system (Lisp_Object coding_system, struct coding_system *coding)
 {
   Lisp_Object attrs;
   Lisp_Object eol_type;
@@ -5990,8 +5865,7 @@ setup_coding_system (coding_system, coding)
 /* Return a list of charsets supported by CODING.  */
 
 Lisp_Object
-coding_charset_list (coding)
-     struct coding_system *coding;
+coding_charset_list (struct coding_system *coding)
 {
   Lisp_Object attrs, charset_list;
 
@@ -6014,8 +5888,7 @@ coding_charset_list (coding)
 /* Return a list of charsets supported by CODING-SYSTEM.  */
 
 Lisp_Object
-coding_system_charset_list (coding_system)
-     Lisp_Object coding_system;
+coding_system_charset_list (Lisp_Object coding_system)
 {
   int id;
   Lisp_Object attrs, charset_list;
@@ -6048,8 +5921,7 @@ coding_system_charset_list (coding_system)
    eol_type as CODING-SYSTEM.  */
 
 Lisp_Object
-raw_text_coding_system (coding_system)
-     Lisp_Object coding_system;
+raw_text_coding_system (Lisp_Object coding_system)
 {
   Lisp_Object spec, attrs;
   Lisp_Object eol_type, raw_text_eol_type;
@@ -6079,8 +5951,7 @@ raw_text_coding_system (coding_system)
    (system_eol_type).  */
 
 Lisp_Object
-coding_inherit_eol_type (coding_system, parent)
-     Lisp_Object coding_system, parent;
+coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
 {
   Lisp_Object spec, eol_type;
 
@@ -6099,7 +5970,7 @@ coding_inherit_eol_type (coding_system, parent)
          parent_spec = CODING_SYSTEM_SPEC (parent);
          parent_eol_type = AREF (parent_spec, 2);
          if (VECTORP (parent_eol_type))
-           parent_eol_type = system_eol_type;      
+           parent_eol_type = system_eol_type;
        }
       else
        parent_eol_type = system_eol_type;
@@ -6119,8 +5990,7 @@ coding_inherit_eol_type (coding_system, parent)
    return a new coding system.  */
 
 Lisp_Object
-complement_process_encoding_system (coding_system)
-     Lisp_Object coding_system;
+complement_process_encoding_system (Lisp_Object coding_system)
 {
   Lisp_Object coding_base = Qnil, eol_base = Qnil;
   Lisp_Object spec, attrs;
@@ -6277,10 +6147,8 @@ complement_process_encoding_system (coding_system)
 #define MAX_EOL_CHECK_COUNT 3
 
 static int
-detect_eol (source, src_bytes, category)
-     const unsigned char *source;
-     EMACS_INT src_bytes;
-     enum coding_category category;
+detect_eol (const unsigned char *source, EMACS_INT src_bytes,
+           enum coding_category category)
 {
   const unsigned char *src = source, *src_end = src + src_bytes;
   unsigned char c;
@@ -6321,8 +6189,9 @@ detect_eol (source, src_bytes, category)
                {
                  /* The found type is different from what found before.
                     Allow for stray ^M characters in DOS EOL files.  */
-                 if (eol_seen == EOL_SEEN_CR && this_eol == EOL_SEEN_CRLF
-                     || eol_seen == EOL_SEEN_CRLF && this_eol == EOL_SEEN_CR)
+                 if ((eol_seen == EOL_SEEN_CR && this_eol == EOL_SEEN_CRLF)
+                     || (eol_seen == EOL_SEEN_CRLF
+                         && this_eol == EOL_SEEN_CR))
                    eol_seen = EOL_SEEN_CRLF;
                  else
                    {
@@ -6337,50 +6206,46 @@ detect_eol (source, src_bytes, category)
        }
     }
   else
-    {
-      while (src < src_end)
-       {
-         c = *src++;
-         if (c == '\n' || c == '\r')
-           {
-             int this_eol;
+    while (src < src_end)
+      {
+       c = *src++;
+       if (c == '\n' || c == '\r')
+         {
+           int this_eol;
 
-             if (c == '\n')
-               this_eol = EOL_SEEN_LF;
-             else if (src >= src_end || *src != '\n')
-               this_eol = EOL_SEEN_CR;
-             else
-               this_eol = EOL_SEEN_CRLF, src++;
+           if (c == '\n')
+             this_eol = EOL_SEEN_LF;
+           else if (src >= src_end || *src != '\n')
+             this_eol = EOL_SEEN_CR;
+           else
+             this_eol = EOL_SEEN_CRLF, src++;
 
-             if (eol_seen == EOL_SEEN_NONE)
-               /* This is the first end-of-line.  */
-               eol_seen = this_eol;
-             else if (eol_seen != this_eol)
-               {
-                 /* The found type is different from what found before.
-                    Allow for stray ^M characters in DOS EOL files.  */
-                 if (eol_seen == EOL_SEEN_CR && this_eol == EOL_SEEN_CRLF
-                     || eol_seen == EOL_SEEN_CRLF && this_eol == EOL_SEEN_CR)
-                   eol_seen = EOL_SEEN_CRLF;
-                 else
-                   {
-                     eol_seen = EOL_SEEN_LF;
-                     break;
-                   }
-               }
-             if (++total == MAX_EOL_CHECK_COUNT)
-               break;
-           }
-       }
-    }
+           if (eol_seen == EOL_SEEN_NONE)
+             /* This is the first end-of-line.  */
+             eol_seen = this_eol;
+           else if (eol_seen != this_eol)
+             {
+               /* The found type is different from what found before.
+                  Allow for stray ^M characters in DOS EOL files.  */
+               if ((eol_seen == EOL_SEEN_CR && this_eol == EOL_SEEN_CRLF)
+                   || (eol_seen == EOL_SEEN_CRLF && this_eol == EOL_SEEN_CR))
+                 eol_seen = EOL_SEEN_CRLF;
+               else
+                 {
+                   eol_seen = EOL_SEEN_LF;
+                   break;
+                 }
+             }
+           if (++total == MAX_EOL_CHECK_COUNT)
+             break;
+         }
+      }
   return eol_seen;
 }
 
 
 static Lisp_Object
-adjust_coding_eol_type (coding, eol_seen)
-     struct coding_system *coding;
-     int eol_seen;
+adjust_coding_eol_type (struct coding_system *coding, int eol_seen)
 {
   Lisp_Object eol_type;
 
@@ -6408,8 +6273,7 @@ adjust_coding_eol_type (coding, eol_seen)
    system.  */
 
 void
-detect_coding (coding)
-     struct coding_system *coding;
+detect_coding (struct coding_system *coding)
 {
   const unsigned char *src, *src_end;
   int saved_mode = coding->mode;
@@ -6452,7 +6316,7 @@ detect_coding (coding)
                        {
                          /* We didn't find an 8-bit code.  We may
                             have found a null-byte, but it's very
-                            rare that a binary file confirm to
+                            rare that a binary file conforms to
                             ISO-2022.  */
                          src = src_end;
                          coding->head_ascii = src - coding->source;
@@ -6588,8 +6452,7 @@ detect_coding (coding)
 
 
 static void
-decode_eol (coding)
-     struct coding_system *coding;
+decode_eol (struct coding_system *coding)
 {
   Lisp_Object eol_type;
   unsigned char *p, *pbeg, *pend;
@@ -6654,7 +6517,7 @@ decode_eol (coding)
          for (p = pend - 2; p >= pbeg; p--)
            if (*p == '\r')
              {
-               safe_bcopy ((char *) (p + 1), (char *) p, pend-- - p - 1);
+               memmove (p, p + 1, pend-- - p - 1);
                n++;
              }
        }
@@ -6691,9 +6554,7 @@ decode_eol (coding)
    decoding (ENCODEP is zero). */
 
 static Lisp_Object
-get_translation_table (attrs, encodep, max_lookup)
-     Lisp_Object attrs;
-     int encodep, *max_lookup;
+get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup)
 {
   Lisp_Object standard, translation_table;
   Lisp_Object val;
@@ -6795,9 +6656,7 @@ get_translation_table (attrs, encodep, max_lookup)
    If BUF is too short to lookup characters in FROM, return Qt.  */
 
 static Lisp_Object
-get_translation (trans, buf, buf_end)
-     Lisp_Object trans;
-     int *buf, *buf_end;
+get_translation (Lisp_Object trans, int *buf, int *buf_end)
 {
 
   if (INTEGERP (trans))
@@ -6824,10 +6683,8 @@ get_translation (trans, buf, buf_end)
 
 
 static int
-produce_chars (coding, translation_table, last_block)
-     struct coding_system *coding;
-     Lisp_Object translation_table;
-     int last_block;
+produce_chars (struct coding_system *coding, Lisp_Object translation_table,
+              int last_block)
 {
   unsigned char *dst = coding->destination + coding->produced;
   unsigned char *dst_end = coding->destination + coding->dst_bytes;
@@ -7025,10 +6882,7 @@ produce_chars (coding, translation_table, last_block)
  */
 
 static INLINE void
-produce_composition (coding, charbuf, pos)
-     struct coding_system *coding;
-     int *charbuf;
-     EMACS_INT pos;
+produce_composition (struct coding_system *coding, int *charbuf, EMACS_INT pos)
 {
   int len;
   EMACS_INT to;
@@ -7072,10 +6926,7 @@ produce_composition (coding, charbuf, pos)
  */
 
 static INLINE void
-produce_charset (coding, charbuf, pos)
-     struct coding_system *coding;
-     int *charbuf;
-     EMACS_INT pos;
+produce_charset (struct coding_system *coding, int *charbuf, EMACS_INT pos)
 {
   EMACS_INT from = pos - charbuf[2];
   struct charset *charset = CHARSET_FROM_ID (charbuf[3]);
@@ -7110,9 +6961,7 @@ produce_charset (coding, charbuf, pos)
 
 
 static void
-produce_annotation (coding, pos)
-     struct coding_system *coding;
-     EMACS_INT pos;
+produce_annotation (struct coding_system *coding, EMACS_INT pos)
 {
   int *charbuf = coding->charbuf;
   int *charbuf_end = charbuf + coding->charbuf_used;
@@ -7167,8 +7016,7 @@ produce_annotation (coding, pos)
 */
 
 static int
-decode_coding (coding)
-     struct coding_system *coding;
+decode_coding (struct coding_system *coding)
 {
   Lisp_Object attrs;
   Lisp_Object undo_list;
@@ -7190,8 +7038,8 @@ decode_coding (coding)
        set_buffer_internal (XBUFFER (coding->dst_object));
       if (GPT != PT)
        move_gap_both (PT, PT_BYTE);
-      undo_list = current_buffer->undo_list;
-      current_buffer->undo_list = Qt;
+      undo_list = BVAR (current_buffer, undo_list);
+      BVAR (current_buffer, undo_list) = Qt;
     }
 
   coding->consumed = coding->consumed_char = 0;
@@ -7288,7 +7136,7 @@ decode_coding (coding)
     decode_eol (coding);
   if (BUFFERP (coding->dst_object))
     {
-      current_buffer->undo_list = undo_list;
+      BVAR (current_buffer, undo_list) = undo_list;
       record_insert (coding->dst_pos, coding->produced_char);
     }
   return coding->result;
@@ -7306,11 +7154,9 @@ decode_coding (coding)
    return BUF.  */
 
 static INLINE int *
-handle_composition_annotation (pos, limit, coding, buf, stop)
-     EMACS_INT pos, limit;
-     struct coding_system *coding;
-     int *buf;
-     EMACS_INT *stop;
+handle_composition_annotation (EMACS_INT pos, EMACS_INT limit,
+                              struct coding_system *coding, int *buf,
+                              EMACS_INT *stop)
 {
   EMACS_INT start, end;
   Lisp_Object prop;
@@ -7391,11 +7237,9 @@ handle_composition_annotation (pos, limit, coding, buf, stop)
    property value is non-nil (limiting by LIMIT), and return BUF.  */
 
 static INLINE int *
-handle_charset_annotation (pos, limit, coding, buf, stop)
-     EMACS_INT pos, limit;
-     struct coding_system *coding;
-     int *buf;
-     EMACS_INT *stop;
+handle_charset_annotation (EMACS_INT pos, EMACS_INT limit,
+                          struct coding_system *coding, int *buf,
+                          EMACS_INT *stop)
 {
   Lisp_Object val, next;
   int id;
@@ -7415,10 +7259,8 @@ handle_charset_annotation (pos, limit, coding, buf, stop)
 
 
 static void
-consume_chars (coding, translation_table, max_lookup)
-     struct coding_system *coding;
-     Lisp_Object translation_table;
-     int max_lookup;
+consume_chars (struct coding_system *coding, Lisp_Object translation_table,
+              int max_lookup)
 {
   int *buf = coding->charbuf;
   int *buf_end = coding->charbuf + coding->charbuf_size;
@@ -7574,8 +7416,7 @@ consume_chars (coding, translation_table, max_lookup)
    memory area specified by CODING->destination.  */
 
 static int
-encode_coding (coding)
-     struct coding_system *coding;
+encode_coding (struct coding_system *coding)
 {
   Lisp_Object attrs;
   Lisp_Object translation_table;
@@ -7592,7 +7433,7 @@ encode_coding (coding)
     {
       set_buffer_internal (XBUFFER (coding->dst_object));
       coding->dst_multibyte
-       = ! NILP (current_buffer->enable_multibyte_characters);
+       = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
     }
 
   coding->consumed = coding->consumed_char = 0;
@@ -7639,8 +7480,7 @@ static int reused_workbuf_in_use;
    multibyteness of returning buffer.  */
 
 static Lisp_Object
-make_conversion_work_buffer (multibyte)
-     int multibyte;
+make_conversion_work_buffer (int multibyte)
 {
   Lisp_Object name, workbuf;
   struct buffer *current;
@@ -7664,16 +7504,15 @@ make_conversion_work_buffer (multibyte)
      doesn't compile new regexps.  */
   Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt);
   Ferase_buffer ();
-  current_buffer->undo_list = Qt;
-  current_buffer->enable_multibyte_characters = multibyte ? Qt : Qnil;
+  BVAR (current_buffer, undo_list) = Qt;
+  BVAR (current_buffer, enable_multibyte_characters) = multibyte ? Qt : Qnil;
   set_buffer_internal (current);
   return workbuf;
 }
 
 
 static Lisp_Object
-code_conversion_restore (arg)
-     Lisp_Object arg;
+code_conversion_restore (Lisp_Object arg)
 {
   Lisp_Object current, workbuf;
   struct gcpro gcpro1;
@@ -7694,8 +7533,7 @@ code_conversion_restore (arg)
 }
 
 Lisp_Object
-code_conversion_save (with_work_buf, multibyte)
-     int with_work_buf, multibyte;
+code_conversion_save (int with_work_buf, int multibyte)
 {
   Lisp_Object workbuf = Qnil;
 
@@ -7707,11 +7545,10 @@ code_conversion_save (with_work_buf, multibyte)
 }
 
 int
-decode_coding_gap (coding, chars, bytes)
-     struct coding_system *coding;
-     EMACS_INT chars, bytes;
+decode_coding_gap (struct coding_system *coding,
+                  EMACS_INT chars, EMACS_INT bytes)
 {
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   Lisp_Object attrs;
 
   code_conversion_save (0, 0);
@@ -7725,7 +7562,7 @@ decode_coding_gap (coding, chars, bytes)
   coding->dst_object = coding->src_object;
   coding->dst_pos = PT;
   coding->dst_pos_byte = PT_BYTE;
-  coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters);
+  coding->dst_multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
 
   if (CODING_REQUIRE_DETECTION (coding))
     detect_coding (coding);
@@ -7754,11 +7591,10 @@ decode_coding_gap (coding, chars, bytes)
 }
 
 int
-encode_coding_gap (coding, chars, bytes)
-     struct coding_system *coding;
-     EMACS_INT chars, bytes;
+encode_coding_gap (struct coding_system *coding,
+                  EMACS_INT chars, EMACS_INT bytes)
 {
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
 
   code_conversion_save (0, 0);
 
@@ -7809,14 +7645,13 @@ encode_coding_gap (coding, chars, bytes)
  */
 
 void
-decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
-                     dst_object)
-     struct coding_system *coding;
-     Lisp_Object src_object;
-     EMACS_INT from, from_byte, to, to_byte;
-     Lisp_Object dst_object;
+decode_coding_object (struct coding_system *coding,
+                     Lisp_Object src_object,
+                     EMACS_INT from, EMACS_INT from_byte,
+                     EMACS_INT to, EMACS_INT to_byte,
+                     Lisp_Object dst_object)
 {
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   unsigned char *destination;
   EMACS_INT dst_bytes;
   EMACS_INT chars = to - from;
@@ -7893,7 +7728,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
       coding->dst_pos = BUF_PT (XBUFFER (dst_object));
       coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object));
       coding->dst_multibyte
-       = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters);
+       = ! NILP (BVAR (XBUFFER (dst_object), enable_multibyte_characters));
     }
   else
     {
@@ -7946,7 +7781,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
            }
          if (BEGV < GPT && GPT < BEGV + coding->produced_char)
            move_gap_both (BEGV, BEGV_BYTE);
-         bcopy (BEGV_ADDR, destination, coding->produced);
+         memcpy (destination, BEGV_ADDR, coding->produced);
          coding->destination = destination;
        }
     }
@@ -7963,7 +7798,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
        TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte);
       else if (saved_pt < from + chars)
        TEMP_SET_PT_BOTH (from, from_byte);
-      else if (! NILP (current_buffer->enable_multibyte_characters))
+      else if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
        TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars),
                          saved_pt_byte + (coding->produced - bytes));
       else
@@ -7987,7 +7822,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
                  {
                    tail->bytepos = from_byte + coding->produced;
                    tail->charpos
-                     = (NILP (current_buffer->enable_multibyte_characters)
+                     = (NILP (BVAR (current_buffer, enable_multibyte_characters))
                         ? tail->bytepos : from + coding->produced_char);
                  }
              }
@@ -8000,14 +7835,13 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
 
 
 void
-encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
-                     dst_object)
-     struct coding_system *coding;
-     Lisp_Object src_object;
-     EMACS_INT from, from_byte, to, to_byte;
-     Lisp_Object dst_object;
+encode_coding_object (struct coding_system *coding,
+                     Lisp_Object src_object,
+                     EMACS_INT from, EMACS_INT from_byte,
+                     EMACS_INT to, EMACS_INT to_byte,
+                     Lisp_Object dst_object)
 {
-  int count = specpdl_ptr - specpdl;
+  int count = SPECPDL_INDEX ();
   EMACS_INT chars = to - from;
   EMACS_INT bytes = to_byte - from_byte;
   Lisp_Object attrs;
@@ -8046,7 +7880,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
       else if (BUFFERP (src_object))
        insert_from_buffer (XBUFFER (src_object), from, chars, 0);
       else
-       insert_1_both (coding->source + from, chars, bytes, 0, 0, 0);
+       insert_1_both ((char *) coding->source + from, chars, bytes, 0, 0, 0);
 
       if (EQ (src_object, dst_object))
        {
@@ -8126,7 +7960,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
          set_buffer_temp (current);
        }
       coding->dst_multibyte
-       = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters);
+       = ! NILP (BVAR (XBUFFER (dst_object), enable_multibyte_characters));
     }
   else if (EQ (dst_object, Qt))
     {
@@ -8169,7 +8003,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
        TEMP_SET_PT_BOTH (saved_pt, saved_pt_byte);
       else if (saved_pt < from + chars)
        TEMP_SET_PT_BOTH (from, from_byte);
-      else if (! NILP (current_buffer->enable_multibyte_characters))
+      else if (! NILP (BVAR (current_buffer, enable_multibyte_characters)))
        TEMP_SET_PT_BOTH (saved_pt + (coding->produced_char - chars),
                          saved_pt_byte + (coding->produced - bytes));
       else
@@ -8193,7 +8027,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
                  {
                    tail->bytepos = from_byte + coding->produced;
                    tail->charpos
-                     = (NILP (current_buffer->enable_multibyte_characters)
+                     = (NILP (BVAR (current_buffer, enable_multibyte_characters))
                         ? tail->bytepos : from + coding->produced_char);
                  }
              }
@@ -8209,7 +8043,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
 
 
 Lisp_Object
-preferred_coding_system ()
+preferred_coding_system (void)
 {
   int id = coding_categories[coding_priorities[0]].id;
 
@@ -8224,8 +8058,7 @@ DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0,
        doc: /* Return t if OBJECT is nil or a coding-system.
 See the documentation of `define-coding-system' for information
 about coding-system objects.  */)
-     (object)
-     Lisp_Object object;
+  (Lisp_Object object)
 {
   if (NILP (object)
       || CODING_SYSTEM_ID (object) >= 0)
@@ -8239,8 +8072,7 @@ about coding-system objects.  */)
 DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system,
        Sread_non_nil_coding_system, 1, 1, 0,
        doc: /* Read a coding system from the minibuffer, prompting with string PROMPT.  */)
-     (prompt)
-     Lisp_Object prompt;
+  (Lisp_Object prompt)
 {
   Lisp_Object val;
   do
@@ -8257,8 +8089,7 @@ DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0,
 If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.
 Ignores case when completing coding systems (all Emacs coding systems
 are lower-case).  */)
-     (prompt, default_coding_system)
-     Lisp_Object prompt, default_coding_system;
+  (Lisp_Object prompt, Lisp_Object default_coding_system)
 {
   Lisp_Object val;
   int count = SPECPDL_INDEX ();
@@ -8279,8 +8110,7 @@ DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system,
 If valid, return CODING-SYSTEM, else signal a `coding-system-error' error.
 It is valid if it is nil or a symbol defined as a coding system by the
 function `define-coding-system'.  */)
-  (coding_system)
-     Lisp_Object coding_system;
+  (Lisp_Object coding_system)
 {
   Lisp_Object define_form;
 
@@ -8313,13 +8143,10 @@ function `define-coding-system'.  */)
    detect only text-format.  */
 
 Lisp_Object
-detect_coding_system (src, src_chars, src_bytes, highest, multibytep,
-                     coding_system)
-     const unsigned char *src;
-     EMACS_INT src_chars, src_bytes;
-     int highest;
-     int multibytep;
-     Lisp_Object coding_system;
+detect_coding_system (const unsigned char *src,
+                     EMACS_INT src_chars, EMACS_INT src_bytes,
+                     int highest, int multibytep,
+                     Lisp_Object coding_system)
 {
   const unsigned char *src_end = src + src_bytes;
   Lisp_Object attrs, eol_type;
@@ -8635,8 +8462,7 @@ format.
 
 If optional argument HIGHEST is non-nil, return the coding system of
 highest priority.  */)
-     (start, end, highest)
-     Lisp_Object start, end, highest;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object highest)
 {
   int from, to;
   int from_byte, to_byte;
@@ -8655,8 +8481,8 @@ highest priority.  */)
   return detect_coding_system (BYTE_POS_ADDR (from_byte),
                               to - from, to_byte - from_byte,
                               !NILP (highest),
-                              !NILP (current_buffer
-                                     ->enable_multibyte_characters),
+                              !NILP (BVAR (current_buffer
+                                     , enable_multibyte_characters)),
                               Qnil);
 }
 
@@ -8674,8 +8500,7 @@ format.
 
 If optional argument HIGHEST is non-nil, return the coding system of
 highest priority.  */)
-     (string, highest)
-     Lisp_Object string, highest;
+  (Lisp_Object string, Lisp_Object highest)
 {
   CHECK_STRING (string);
 
@@ -8687,9 +8512,7 @@ highest priority.  */)
 
 
 static INLINE int
-char_encodable_p (c, attrs)
-     int c;
-     Lisp_Object attrs;
+char_encodable_p (int c, Lisp_Object attrs)
 {
   Lisp_Object tail;
   struct charset *charset;
@@ -8719,8 +8542,7 @@ DEFUN ("find-coding-systems-region-internal",
        Ffind_coding_systems_region_internal,
        Sfind_coding_systems_region_internal, 2, 3, 0,
        doc: /* Internal use only.  */)
-     (start, end, exclude)
-     Lisp_Object start, end, exclude;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object exclude)
 {
   Lisp_Object coding_attrs_list, safe_codings;
   EMACS_INT start_byte, end_byte;
@@ -8742,7 +8564,7 @@ DEFUN ("find-coding-systems-region-internal",
       CHECK_NUMBER_COERCE_MARKER (end);
       if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end))
        args_out_of_range (start, end);
-      if (NILP (current_buffer->enable_multibyte_characters))
+      if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
        return Qt;
       start_byte = CHAR_TO_BYTE (XINT (start));
       end_byte = CHAR_TO_BYTE (XINT (end));
@@ -8853,8 +8675,7 @@ list of positions.
 If optional 5th argument STRING is non-nil, it is a string to search
 for un-encodable characters.  In that case, START and END are indexes
 to the string.  */)
-     (start, end, coding_system, count, string)
-     Lisp_Object start, end, coding_system, count, string;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string)
 {
   int n;
   struct coding_system coding;
@@ -8877,7 +8698,7 @@ to the string.  */)
       validate_region (&start, &end);
       from = XINT (start);
       to = XINT (end);
-      if (NILP (current_buffer->enable_multibyte_characters)
+      if (NILP (BVAR (current_buffer, enable_multibyte_characters))
          || (ascii_compatible
              && (to - from) == (CHAR_TO_BYTE (to) - (CHAR_TO_BYTE (from)))))
        return Qnil;
@@ -8969,8 +8790,7 @@ buffer positions.  END is ignored.
 
 If the current buffer (or START if it is a string) is unibyte, the value
 is nil.  */)
-     (start, end, coding_system_list)
-     Lisp_Object start, end, coding_system_list;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system_list)
 {
   Lisp_Object list;
   EMACS_INT start_byte, end_byte;
@@ -8994,7 +8814,7 @@ is nil.  */)
       CHECK_NUMBER_COERCE_MARKER (end);
       if (XINT (start) < BEG || XINT (end) > Z || XINT (start) > XINT (end))
        args_out_of_range (start, end);
-      if (NILP (current_buffer->enable_multibyte_characters))
+      if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
        return Qnil;
       start_byte = CHAR_TO_BYTE (XINT (start));
       end_byte = CHAR_TO_BYTE (XINT (end));
@@ -9075,9 +8895,9 @@ is nil.  */)
 
 
 Lisp_Object
-code_convert_region (start, end, coding_system, dst_object, encodep, norecord)
-     Lisp_Object start, end, coding_system, dst_object;
-     int encodep, norecord;
+code_convert_region (Lisp_Object start, Lisp_Object end,
+                    Lisp_Object coding_system, Lisp_Object dst_object,
+                    int encodep, int norecord)
 {
   struct coding_system coding;
   EMACS_INT from, from_byte, to, to_byte;
@@ -9136,8 +8956,7 @@ If DESTINATION is t, the decoded text is returned.
 This function sets `last-coding-system-used' to the precise coding system
 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is
 not fully specified.)  */)
-     (start, end, coding_system, destination)
-     Lisp_Object start, end, coding_system, destination;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object destination)
 {
   return code_convert_region (start, end, coding_system, destination, 0, 0);
 }
@@ -9159,17 +8978,14 @@ If DESTINATION is t, the encoded text is returned.
 This function sets `last-coding-system-used' to the precise coding system
 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is
 not fully specified.)  */)
-  (start, end, coding_system, destination)
-     Lisp_Object start, end, coding_system, destination;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object destination)
 {
   return code_convert_region (start, end, coding_system, destination, 1, 0);
 }
 
 Lisp_Object
-code_convert_string (string, coding_system, dst_object,
-                    encodep, nocopy, norecord)
-     Lisp_Object string, coding_system, dst_object;
-     int encodep, nocopy, norecord;
+code_convert_string (Lisp_Object string, Lisp_Object coding_system,
+                    Lisp_Object dst_object, int encodep, int nocopy, int norecord)
 {
   struct coding_system coding;
   EMACS_INT chars, bytes;
@@ -9216,9 +9032,8 @@ code_convert_string (string, coding_system, dst_object,
    ENCODE_FILE, thus we ignore character composition.  */
 
 Lisp_Object
-code_convert_string_norecord (string, coding_system, encodep)
-     Lisp_Object string, coding_system;
-     int encodep;
+code_convert_string_norecord (Lisp_Object string, Lisp_Object coding_system,
+                             int encodep)
 {
   return code_convert_string (string, coding_system, Qt, encodep, 0, 1);
 }
@@ -9238,8 +9053,7 @@ case, the return value is the length of the decoded text.
 This function sets `last-coding-system-used' to the precise coding system
 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is
 not fully specified.)  */)
-  (string, coding_system, nocopy, buffer)
-     Lisp_Object string, coding_system, nocopy, buffer;
+  (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer)
 {
   return code_convert_string (string, coding_system, buffer,
                              0, ! NILP (nocopy), 0);
@@ -9259,8 +9073,7 @@ case, the return value is the length of the encoded text.
 This function sets `last-coding-system-used' to the precise coding system
 used (which may be different from CODING-SYSTEM if CODING-SYSTEM is
 not fully specified.)  */)
-     (string, coding_system, nocopy, buffer)
-     Lisp_Object string, coding_system, nocopy, buffer;
+  (Lisp_Object string, Lisp_Object coding_system, Lisp_Object nocopy, Lisp_Object buffer)
 {
   return code_convert_string (string, coding_system, buffer,
                              1, ! NILP (nocopy), 1);
@@ -9270,8 +9083,7 @@ not fully specified.)  */)
 DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0,
        doc: /* Decode a Japanese character which has CODE in shift_jis encoding.
 Return the corresponding character.  */)
-     (code)
-     Lisp_Object code;
+  (Lisp_Object code)
 {
   Lisp_Object spec, attrs, val;
   struct charset *charset_roman, *charset_kanji, *charset_kana, *charset;
@@ -9318,8 +9130,7 @@ Return the corresponding character.  */)
 DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_sjis_char, 1, 1, 0,
        doc: /* Encode a Japanese character CH to shift_jis encoding.
 Return the corresponding code in SJIS.  */)
-     (ch)
-    Lisp_Object ch;
+  (Lisp_Object ch)
 {
   Lisp_Object spec, attrs, charset_list;
   int c;
@@ -9347,8 +9158,7 @@ Return the corresponding code in SJIS.  */)
 DEFUN ("decode-big5-char", Fdecode_big5_char, Sdecode_big5_char, 1, 1, 0,
        doc: /* Decode a Big5 character which has CODE in BIG5 coding system.
 Return the corresponding character.  */)
-     (code)
-     Lisp_Object code;
+  (Lisp_Object code)
 {
   Lisp_Object spec, attrs, val;
   struct charset *charset_roman, *charset_big5, *charset;
@@ -9386,8 +9196,7 @@ Return the corresponding character.  */)
 DEFUN ("encode-big5-char", Fencode_big5_char, Sencode_big5_char, 1, 1, 0,
        doc: /* Encode the Big5 character CH to BIG5 coding system.
 Return the corresponding character code in Big5.  */)
-     (ch)
-     Lisp_Object ch;
+  (Lisp_Object ch)
 {
   Lisp_Object spec, attrs, charset_list;
   struct charset *charset;
@@ -9414,11 +9223,10 @@ Return the corresponding character code in Big5.  */)
 DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal,
        Sset_terminal_coding_system_internal, 1, 2, 0,
        doc: /* Internal use only.  */)
-     (coding_system, terminal)
-     Lisp_Object coding_system;
-     Lisp_Object terminal;
+  (Lisp_Object coding_system, Lisp_Object terminal)
 {
-  struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1));
+  struct terminal *term = get_terminal (terminal, 1);
+  struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (term);
   CHECK_SYMBOL (coding_system);
   setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding);
   /* We had better not send unsafe characters to terminal.  */
@@ -9427,6 +9235,10 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern
   terminal_coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK;
   terminal_coding->src_multibyte = 1;
   terminal_coding->dst_multibyte = 0;
+  if (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK)
+    term->charset_list = coding_charset_list (terminal_coding);
+  else
+    term->charset_list = Fcons (make_number (charset_ascii), Qnil);
   return Qnil;
 }
 
@@ -9434,8 +9246,7 @@ DEFUN ("set-safe-terminal-coding-system-internal",
        Fset_safe_terminal_coding_system_internal,
        Sset_safe_terminal_coding_system_internal, 1, 1, 0,
        doc: /* Internal use only.  */)
-     (coding_system)
-     Lisp_Object coding_system;
+  (Lisp_Object coding_system)
 {
   CHECK_SYMBOL (coding_system);
   setup_coding_system (Fcheck_coding_system (coding_system),
@@ -9452,8 +9263,7 @@ DEFUN ("terminal-coding-system", Fterminal_coding_system,
        doc: /* Return coding system specified for terminal output on the given terminal.
 TERMINAL may be a terminal object, a frame, or nil for the selected
 frame's terminal device.  */)
-     (terminal)
-     Lisp_Object terminal;
+  (Lisp_Object terminal)
 {
   struct coding_system *terminal_coding
     = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1));
@@ -9466,9 +9276,7 @@ frame's terminal device.  */)
 DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal,
        Sset_keyboard_coding_system_internal, 1, 2, 0,
        doc: /* Internal use only.  */)
-     (coding_system, terminal)
-     Lisp_Object coding_system;
-     Lisp_Object terminal;
+  (Lisp_Object coding_system, Lisp_Object terminal)
 {
   struct terminal *t = get_terminal (terminal, 1);
   CHECK_SYMBOL (coding_system);
@@ -9486,8 +9294,7 @@ DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_intern
 DEFUN ("keyboard-coding-system",
        Fkeyboard_coding_system, Skeyboard_coding_system, 0, 1, 0,
        doc: /* Return coding system specified for decoding keyboard input.  */)
-     (terminal)
-     Lisp_Object terminal;
+  (Lisp_Object terminal)
 {
   return CODING_ID_NAME (TERMINAL_KEYBOARD_CODING
                         (get_terminal (terminal, 1))->id);
@@ -9535,9 +9342,7 @@ function to call for FILENAME, that function should examine the
 contents of BUFFER instead of reading the file.
 
 usage: (find-operation-coding-system OPERATION ARGUMENTS...)  */)
-     (nargs, args)
-     int nargs;
-     Lisp_Object *args;
+  (int nargs, Lisp_Object *args)
 {
   Lisp_Object operation, target_idx, target, val;
   register Lisp_Object chain;
@@ -9613,15 +9418,13 @@ If multiple coding systems belong to the same category,
 all but the first one are ignored.
 
 usage: (set-coding-system-priority &rest coding-systems)  */)
-     (nargs, args)
-     int nargs;
-     Lisp_Object *args;
+  (int nargs, Lisp_Object *args)
 {
   int i, j;
   int changed[coding_category_max];
   enum coding_category priorities[coding_category_max];
 
-  bzero (changed, sizeof changed);
+  memset (changed, 0, sizeof changed);
 
   for (i = j = 0; i < nargs; i++)
     {
@@ -9656,7 +9459,7 @@ usage: (set-coding-system-priority &rest coding-systems)  */)
       priorities[i] = coding_priorities[j];
     }
 
-  bcopy (priorities, coding_priorities, sizeof priorities);
+  memcpy (coding_priorities, priorities, sizeof priorities);
 
   /* Update `coding-category-list'.  */
   Vcoding_category_list = Qnil;
@@ -9675,8 +9478,7 @@ The list contains a subset of coding systems; i.e. coding systems
 assigned to each coding category (see `coding-category-list').
 
 HIGHESTP non-nil means just return the highest priority one.  */)
-     (highestp)
-     Lisp_Object highestp;
+  (Lisp_Object highestp)
 {
   int i;
   Lisp_Object val;
@@ -9700,19 +9502,18 @@ HIGHESTP non-nil means just return the highest priority one.  */)
 static const char *const suffixes[] = { "-unix", "-dos", "-mac" };
 
 static Lisp_Object
-make_subsidiaries (base)
-     Lisp_Object base;
+make_subsidiaries (Lisp_Object base)
 {
   Lisp_Object subsidiaries;
   int base_name_len = SBYTES (SYMBOL_NAME (base));
   char *buf = (char *) alloca (base_name_len + 6);
   int i;
 
-  bcopy (SDATA (SYMBOL_NAME (base)), buf, base_name_len);
+  memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len);
   subsidiaries = Fmake_vector (make_number (3), Qnil);
   for (i = 0; i < 3; i++)
     {
-      bcopy (suffixes[i], buf + base_name_len, strlen (suffixes[i]) + 1);
+      memcpy (buf + base_name_len, suffixes[i], strlen (suffixes[i]) + 1);
       ASET (subsidiaries, i, intern (buf));
     }
   return subsidiaries;
@@ -9723,9 +9524,7 @@ DEFUN ("define-coding-system-internal", Fdefine_coding_system_internal,
        Sdefine_coding_system_internal, coding_arg_max, MANY, 0,
        doc: /* For internal use only.
 usage: (define-coding-system-internal ...)  */)
-     (nargs, args)
-     int nargs;
-     Lisp_Object *args;
+  (int nargs, Lisp_Object *args)
 {
   Lisp_Object name;
   Lisp_Object spec_vec;                /* [ ATTRS ALIASE EOL_TYPE ] */
@@ -10254,8 +10053,7 @@ usage: (define-coding-system-internal ...)  */)
 DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put,
        3, 3, 0,
        doc: /* Change value in CODING-SYSTEM's property list PROP to VAL.  */)
-  (coding_system, prop, val)
-     Lisp_Object coding_system, prop, val;
+  (Lisp_Object coding_system, Lisp_Object prop, Lisp_Object val)
 {
   Lisp_Object spec, attrs;
 
@@ -10311,8 +10109,7 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put,
 DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
        Sdefine_coding_system_alias, 2, 2, 0,
        doc: /* Define ALIAS as an alias for CODING-SYSTEM.  */)
-     (alias, coding_system)
-     Lisp_Object alias, coding_system;
+  (Lisp_Object alias, Lisp_Object coding_system)
 {
   Lisp_Object spec, aliases, eol_type, val;
 
@@ -10352,8 +10149,7 @@ DEFUN ("coding-system-base", Fcoding_system_base, Scoding_system_base,
        1, 1, 0,
        doc: /* Return the base of CODING-SYSTEM.
 Any alias or subsidiary coding system is not a base coding system.  */)
-  (coding_system)
-     Lisp_Object coding_system;
+  (Lisp_Object coding_system)
 {
   Lisp_Object spec, attrs;
 
@@ -10367,8 +10163,7 @@ Any alias or subsidiary coding system is not a base coding system.  */)
 DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist,
        1, 1, 0,
        doc: "Return the property list of CODING-SYSTEM.")
-     (coding_system)
-     Lisp_Object coding_system;
+  (Lisp_Object coding_system)
 {
   Lisp_Object spec, attrs;
 
@@ -10383,8 +10178,7 @@ DEFUN ("coding-system-plist", Fcoding_system_plist, Scoding_system_plist,
 DEFUN ("coding-system-aliases", Fcoding_system_aliases, Scoding_system_aliases,
        1, 1, 0,
        doc: /* Return the list of aliases of CODING-SYSTEM.  */)
-     (coding_system)
-     Lisp_Object coding_system;
+  (Lisp_Object coding_system)
 {
   Lisp_Object spec;
 
@@ -10405,8 +10199,7 @@ and CR respectively.
 A vector value indicates that a format of end-of-line should be
 detected automatically.  Nth element of the vector is the subsidiary
 coding system whose eol-type is N.  */)
-     (coding_system)
-     Lisp_Object coding_system;
+  (Lisp_Object coding_system)
 {
   Lisp_Object spec, eol_type;
   int n;
@@ -10429,7 +10222,7 @@ coding system whose eol-type is N.  */)
 /*** 9. Post-amble ***/
 
 void
-init_coding_once ()
+init_coding_once (void)
 {
   int i;
 
@@ -10471,7 +10264,7 @@ init_coding_once ()
 #ifdef emacs
 
 void
-syms_of_coding ()
+syms_of_coding (void)
 {
   staticpro (&Vcoding_system_hash_table);
   {
@@ -10668,7 +10461,7 @@ syms_of_coding ()
   defsubr (&Scoding_system_eol_type);
   defsubr (&Scoding_system_priority_list);
 
-  DEFVAR_LISP ("coding-system-list", &Vcoding_system_list,
+  DEFVAR_LISP ("coding-system-list", Vcoding_system_list,
               doc: /* List of coding systems.
 
 Do not alter the value of this variable manually.  This variable should be
@@ -10676,7 +10469,7 @@ updated by the functions `define-coding-system' and
 `define-coding-system-alias'.  */);
   Vcoding_system_list = Qnil;
 
-  DEFVAR_LISP ("coding-system-alist", &Vcoding_system_alist,
+  DEFVAR_LISP ("coding-system-alist", Vcoding_system_alist,
               doc: /* Alist of coding system names.
 Each element is one element list of coding system name.
 This variable is given to `completing-read' as COLLECTION argument.
@@ -10686,7 +10479,7 @@ updated by the functions `make-coding-system' and
 `define-coding-system-alias'.  */);
   Vcoding_system_alist = Qnil;
 
-  DEFVAR_LISP ("coding-category-list", &Vcoding_category_list,
+  DEFVAR_LISP ("coding-category-list", Vcoding_category_list,
               doc: /* List of coding-categories (symbols) ordered by priority.
 
 On detecting a coding system, Emacs tries code detection algorithms
@@ -10694,7 +10487,7 @@ associated with each coding-category one by one in this order.  When
 one algorithm agrees with a byte sequence of source text, the coding
 system bound to the corresponding coding-category is selected.
 
-Don't modify this variable directly, but use `set-coding-priority'.  */);
+Don't modify this variable directly, but use `set-coding-system-priority'.  */);
   {
     int i;
 
@@ -10705,7 +10498,7 @@ Don't modify this variable directly, but use `set-coding-priority'.  */);
                 Vcoding_category_list);
   }
 
-  DEFVAR_LISP ("coding-system-for-read", &Vcoding_system_for_read,
+  DEFVAR_LISP ("coding-system-for-read", Vcoding_system_for_read,
               doc: /* Specify the coding system for read operations.
 It is useful to bind this variable with `let', but do not set it globally.
 If the value is a coding system, it is used for decoding on read operation.
@@ -10714,7 +10507,7 @@ There are three such tables: `file-coding-system-alist',
 `process-coding-system-alist', and `network-coding-system-alist'.  */);
   Vcoding_system_for_read = Qnil;
 
-  DEFVAR_LISP ("coding-system-for-write", &Vcoding_system_for_write,
+  DEFVAR_LISP ("coding-system-for-write", Vcoding_system_for_write,
               doc: /* Specify the coding system for write operations.
 Programs bind this variable with `let', but you should not set it globally.
 If the value is a coding system, it is used for encoding of output,
@@ -10728,12 +10521,12 @@ For output to files, if the above procedure does not specify a coding system,
 the value of `buffer-file-coding-system' is used.  */);
   Vcoding_system_for_write = Qnil;
 
-  DEFVAR_LISP ("last-coding-system-used", &Vlast_coding_system_used,
+  DEFVAR_LISP ("last-coding-system-used", Vlast_coding_system_used,
               doc: /*
 Coding system used in the latest file or process I/O.  */);
   Vlast_coding_system_used = Qnil;
 
-  DEFVAR_LISP ("last-code-conversion-error", &Vlast_code_conversion_error,
+  DEFVAR_LISP ("last-code-conversion-error", Vlast_code_conversion_error,
               doc: /*
 Error status of the last code conversion.
 
@@ -10750,21 +10543,21 @@ explicitly set this variable to nil before performing code
 conversion.  */);
   Vlast_code_conversion_error = Qnil;
 
-  DEFVAR_BOOL ("inhibit-eol-conversion", &inhibit_eol_conversion,
+  DEFVAR_BOOL ("inhibit-eol-conversion", inhibit_eol_conversion,
               doc: /*
 *Non-nil means always inhibit code conversion of end-of-line format.
 See info node `Coding Systems' and info node `Text and Binary' concerning
 such conversion.  */);
   inhibit_eol_conversion = 0;
 
-  DEFVAR_BOOL ("inherit-process-coding-system", &inherit_process_coding_system,
+  DEFVAR_BOOL ("inherit-process-coding-system", inherit_process_coding_system,
               doc: /*
 Non-nil means process buffer inherits coding system of process output.
 Bind it to t if the process output is to be treated as if it were a file
 read from some filesystem.  */);
   inherit_process_coding_system = 0;
 
-  DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist,
+  DEFVAR_LISP ("file-coding-system-alist", Vfile_coding_system_alist,
               doc: /*
 Alist to decide a coding system to use for a file I/O operation.
 The format is ((PATTERN . VAL) ...),
@@ -10785,7 +10578,7 @@ See also the function `find-operation-coding-system'
 and the variable `auto-coding-alist'.  */);
   Vfile_coding_system_alist = Qnil;
 
-  DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist,
+  DEFVAR_LISP ("process-coding-system-alist", Vprocess_coding_system_alist,
               doc: /*
 Alist to decide a coding system to use for a process I/O operation.
 The format is ((PATTERN . VAL) ...),
@@ -10801,7 +10594,7 @@ or a cons of coding systems which are used as above.
 See also the function `find-operation-coding-system'.  */);
   Vprocess_coding_system_alist = Qnil;
 
-  DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist,
+  DEFVAR_LISP ("network-coding-system-alist", Vnetwork_coding_system_alist,
               doc: /*
 Alist to decide a coding system to use for a network I/O operation.
 The format is ((PATTERN . VAL) ...),
@@ -10818,48 +10611,48 @@ or a cons of coding systems which are used as above.
 See also the function `find-operation-coding-system'.  */);
   Vnetwork_coding_system_alist = Qnil;
 
-  DEFVAR_LISP ("locale-coding-system", &Vlocale_coding_system,
+  DEFVAR_LISP ("locale-coding-system", Vlocale_coding_system,
               doc: /* Coding system to use with system messages.
 Also used for decoding keyboard input on X Window system.  */);
   Vlocale_coding_system = Qnil;
 
   /* The eol mnemonics are reset in startup.el system-dependently.  */
-  DEFVAR_LISP ("eol-mnemonic-unix", &eol_mnemonic_unix,
+  DEFVAR_LISP ("eol-mnemonic-unix", eol_mnemonic_unix,
               doc: /*
 *String displayed in mode line for UNIX-like (LF) end-of-line format.  */);
   eol_mnemonic_unix = make_pure_c_string (":");
 
-  DEFVAR_LISP ("eol-mnemonic-dos", &eol_mnemonic_dos,
+  DEFVAR_LISP ("eol-mnemonic-dos", eol_mnemonic_dos,
               doc: /*
 *String displayed in mode line for DOS-like (CRLF) end-of-line format.  */);
   eol_mnemonic_dos = make_pure_c_string ("\\");
 
-  DEFVAR_LISP ("eol-mnemonic-mac", &eol_mnemonic_mac,
+  DEFVAR_LISP ("eol-mnemonic-mac", eol_mnemonic_mac,
               doc: /*
 *String displayed in mode line for MAC-like (CR) end-of-line format.  */);
   eol_mnemonic_mac = make_pure_c_string ("/");
 
-  DEFVAR_LISP ("eol-mnemonic-undecided", &eol_mnemonic_undecided,
+  DEFVAR_LISP ("eol-mnemonic-undecided", eol_mnemonic_undecided,
               doc: /*
 *String displayed in mode line when end-of-line format is not yet determined.  */);
   eol_mnemonic_undecided = make_pure_c_string (":");
 
-  DEFVAR_LISP ("enable-character-translation", &Venable_character_translation,
+  DEFVAR_LISP ("enable-character-translation", Venable_character_translation,
               doc: /*
 *Non-nil enables character translation while encoding and decoding.  */);
   Venable_character_translation = Qt;
 
   DEFVAR_LISP ("standard-translation-table-for-decode",
-              &Vstandard_translation_table_for_decode,
+              Vstandard_translation_table_for_decode,
               doc: /* Table for translating characters while decoding.  */);
   Vstandard_translation_table_for_decode = Qnil;
 
   DEFVAR_LISP ("standard-translation-table-for-encode",
-              &Vstandard_translation_table_for_encode,
+              Vstandard_translation_table_for_encode,
               doc: /* Table for translating characters while encoding.  */);
   Vstandard_translation_table_for_encode = Qnil;
 
-  DEFVAR_LISP ("charset-revision-table", &Vcharset_revision_table,
+  DEFVAR_LISP ("charset-revision-table", Vcharset_revision_table,
               doc: /* Alist of charsets vs revision numbers.
 While encoding, if a charset (car part of an element) is found,
 designate it with the escape sequence identifying revision (cdr part
@@ -10867,13 +10660,13 @@ of the element).  */);
   Vcharset_revision_table = Qnil;
 
   DEFVAR_LISP ("default-process-coding-system",
-              &Vdefault_process_coding_system,
+              Vdefault_process_coding_system,
               doc: /* Cons of coding systems used for process I/O by default.
 The car part is used for decoding a process output,
 the cdr part is used for encoding a text to be sent to a process.  */);
   Vdefault_process_coding_system = Qnil;
 
-  DEFVAR_LISP ("latin-extra-code-table", &Vlatin_extra_code_table,
+  DEFVAR_LISP ("latin-extra-code-table", Vlatin_extra_code_table,
               doc: /*
 Table of extra Latin codes in the range 128..159 (inclusive).
 This is a vector of length 256.
@@ -10886,7 +10679,7 @@ Only 128th through 159th elements have a meaning.  */);
   Vlatin_extra_code_table = Fmake_vector (make_number (256), Qnil);
 
   DEFVAR_LISP ("select-safe-coding-system-function",
-              &Vselect_safe_coding_system_function,
+              Vselect_safe_coding_system_function,
               doc: /*
 Function to call to select safe coding system for encoding a text.
 
@@ -10900,7 +10693,7 @@ The default value is `select-safe-coding-system' (which see).  */);
   Vselect_safe_coding_system_function = Qnil;
 
   DEFVAR_BOOL ("coding-system-require-warning",
-              &coding_system_require_warning,
+              coding_system_require_warning,
               doc: /* Internal use only.
 If non-nil, on writing a file, `select-safe-coding-system-function' is
 called even if `coding-system-for-write' is non-nil.  The command
@@ -10909,7 +10702,7 @@ called even if `coding-system-for-write' is non-nil.  The command
 
 
   DEFVAR_BOOL ("inhibit-iso-escape-detection",
-              &inhibit_iso_escape_detection,
+              inhibit_iso_escape_detection,
               doc: /*
 If non-nil, Emacs ignores ISO-2022 escape sequences during code detection.
 
@@ -10937,7 +10730,7 @@ escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argumen
   inhibit_iso_escape_detection = 0;
 
   DEFVAR_BOOL ("inhibit-null-byte-detection",
-              &inhibit_null_byte_detection,
+              inhibit_null_byte_detection,
               doc: /* If non-nil, Emacs ignores null bytes on code detection.
 By default, Emacs treats it as binary data, and does not attempt to
 decode it.  The effect is as if you specified `no-conversion' for
@@ -10949,7 +10742,7 @@ from GNU Find and GNU Grep.  Emacs will then ignore the null bytes and
 decode text as usual.  */);
   inhibit_null_byte_detection = 0;
 
-  DEFVAR_LISP ("translation-table-for-input", &Vtranslation_table_for_input,
+  DEFVAR_LISP ("translation-table-for-input", Vtranslation_table_for_input,
               doc: /* Char table for translating self-inserting characters.
 This is applied to the result of input methods, not their input.
 See also `keyboard-translate-table'.
@@ -11012,7 +10805,7 @@ character.");
     for (i = 0; i < coding_category_max; i++)
       Fset (AREF (Vcoding_category_table, i), Qno_conversion);
   }
-#if defined (MSDOS) || defined (WINDOWSNT)
+#if defined (DOS_NT)
   system_eol_type = Qdos;
 #else
   system_eol_type = Qunix;
@@ -11021,8 +10814,7 @@ character.");
 }
 
 char *
-emacs_strerror (error_number)
-     int error_number;
+emacs_strerror (int error_number)
 {
   char *str;
 
@@ -11034,13 +10826,10 @@ emacs_strerror (error_number)
       Lisp_Object dec = code_convert_string_norecord (build_string (str),
                                                      Vlocale_coding_system,
                                                      0);
-      str = (char *) SDATA (dec);
+      str = SSDATA (dec);
     }
 
   return str;
 }
 
 #endif /* emacs */
-
-/* arch-tag: 3a3a2b01-5ff6-4071-9afe-f5b808d9229d
-   (do not change this comment) */