src/*.c: Remove some additional unused parameters.
[bpt/emacs.git] / src / coding.c
index a5632ba..fd81214 100644 (file)
@@ -1,8 +1,7 @@
 /* Coding system handler (conversion, detection, etc).
-   Copyright (C) 2001, 2002, 2003, 2004, 2005,
-                 2006, 2007, 2008, 2009, 2010 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
+     2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H14PRO021
    Copyright (C) 2003
@@ -166,7 +165,7 @@ detect_coding_XXX (struct coding_system *coding,
 
   while (1)
     {
-      /* Get one byte from the source.  If the souce is exausted, jump
+      /* Get one byte from the source.  If the source is exhausted, jump
         to no_more_source:.  */
       ONE_MORE_BYTE (c);
 
@@ -180,7 +179,7 @@ detect_coding_XXX (struct coding_system *coding,
   return 0;
 
  no_more_source:
-  /* The source exausted successfully.  */
+  /* The source exhausted successfully.  */
   detect_info->found |= found;
   return 1;
 }
@@ -327,16 +326,6 @@ Lisp_Object Qinterrupted, Qinsufficient_memory;
    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
@@ -345,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
@@ -356,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;
@@ -455,8 +395,6 @@ Lisp_Object Vbig5_coding_system;
 
 /* Control characters of ISO2022.  */
                        /* code */      /* function */
-#define ISO_CODE_LF    0x0A            /* line-feed */
-#define ISO_CODE_CR    0x0D            /* carriage-return */
 #define ISO_CODE_SO    0x0E            /* shift-out */
 #define ISO_CODE_SI    0x0F            /* shift-in */
 #define ISO_CODE_SS2_7 0x19            /* single-shift-2 for 7-bit code */
@@ -530,7 +468,7 @@ enum iso_code_class_type
    on output.  */
 #define CODING_ISO_FLAG_DESIGNATE_AT_BOL 0x0400
 
-/* If set, do not encode unsafe charactes on output.  */
+/* If set, do not encode unsafe characters on output.  */
 #define CODING_ISO_FLAG_SAFE           0x0800
 
 /* If set, extra latin codes (128..159) are accepted as a valid code
@@ -539,7 +477,7 @@ enum iso_code_class_type
 
 #define CODING_ISO_FLAG_COMPOSITION    0x2000
 
-#define CODING_ISO_FLAG_EUC_TW_SHIFT   0x4000
+/* #define CODING_ISO_FLAG_EUC_TW_SHIFT        0x4000 */
 
 #define CODING_ISO_FLAG_USE_ROMAN      0x8000
 
@@ -681,12 +619,8 @@ 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 oly.  */
+   internal use only.  */
 static Lisp_Object Vcoding_category_table;
 
 /* Table of coding-categories ordered by priority.  */
@@ -785,25 +719,6 @@ static struct coding_system coding_categories[coding_category_max];
   } while (0)
 
 
-#define ONE_MORE_BYTE_NO_CHECK(c)                      \
-  do {                                                 \
-    c = *src++;                                                \
-    if (multibytep && (c & 0x80))                      \
-      {                                                        \
-       if ((c & 0xFE) == 0xC0)                         \
-         c = ((c & 1) << 6) | *src++;                  \
-       else                                            \
-         {                                             \
-           src--;                                      \
-           c = - string_char (src, &src, NULL);        \
-           record_conversion_result                    \
-             (coding, CODING_RESULT_INVALID_SRC);      \
-         }                                             \
-      }                                                        \
-    consumed_chars++;                                  \
-  } while (0)
-
-
 /* Store a byte C in the place pointed by DST and increment DST to the
    next free point, and increment PRODUCED_CHARS.  The caller should
    assure that C is 0..127, and declare and set the variable `dst'
@@ -818,7 +733,7 @@ static struct coding_system coding_categories[coding_category_max];
   } while (0)
 
 
-/* Like EMIT_ONE_ASCII_BYTE byt store two bytes; C1 and C2.  */
+/* Like EMIT_ONE_ASCII_BYTE but store two bytes; C1 and C2.  */
 
 #define EMIT_TWO_ASCII_BYTES(c1, c2)   \
   do {                                 \
@@ -938,8 +853,7 @@ 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 *);
+                                                 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);
@@ -1115,9 +1029,10 @@ coding_set_source (struct coding_system *coding)
       coding->source = SDATA (coding->src_object) + coding->src_pos_byte;
     }
   else
-    /* Otherwise, the source is C string and is never relocated
-       automatically.  Thus we don't have to update anything.  */
-    ;
+    {
+      /* Otherwise, the source is C string and is never relocated
+        automatically.  Thus we don't have to update anything.  */
+    }
 }
 
 static void
@@ -1143,9 +1058,10 @@ coding_set_destination (struct coding_system *coding)
        }
     }
   else
-    /* Otherwise, the destination is C string and is never relocated
-       automatically.  Thus we don't have to update anything.  */
-    ;
+    {
+      /* Otherwise, the destination is C string and is never relocated
+        automatically.  Thus we don't have to update anything.  */
+    }
 }
 
 
@@ -1227,7 +1143,7 @@ alloc_destination (struct coding_system *coding, EMACS_INT nbytes,
 
    METHOD is one of enum composition_method.
 
-   Optionnal COMPOSITION-COMPONENTS are characters and composition
+   Optional COMPOSITION-COMPONENTS are characters and composition
    rules.
 
    In the case of CODING_ANNOTATE_CHARSET_MASK, one element CHARSET-ID
@@ -1281,7 +1197,6 @@ alloc_destination (struct coding_system *coding, EMACS_INT nbytes,
 #define UTF_8_4_OCTET_LEADING_P(c) (((c) & 0xF8) == 0xF0)
 #define UTF_8_5_OCTET_LEADING_P(c) (((c) & 0xFC) == 0xF8)
 
-#define UTF_BOM 0xFEFF
 #define UTF_8_BOM_1 0xEF
 #define UTF_8_BOM_2 0xBB
 #define UTF_8_BOM_3 0xBF
@@ -1382,7 +1297,7 @@ decode_coding_utf_8 (struct coding_system *coding)
   int multibytep = coding->src_multibyte;
   enum utf_bom_type bom = CODING_UTF_8_BOM (coding);
   Lisp_Object attr, charset_list;
-  int eol_crlf =
+  int eol_dos =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
   int byte_after_cr = -1;
 
@@ -1443,7 +1358,7 @@ decode_coding_utf_8 (struct coding_system *coding)
        }
       else if (UTF_8_1_OCTET_P (c1))
        {
-         if (eol_crlf && c1 == '\r')
+         if (eol_dos && c1 == '\r')
            ONE_MORE_BYTE (byte_after_cr);
          c = c1;
        }
@@ -1597,20 +1512,14 @@ encode_coding_utf_8 (struct coding_system *coding)
 #define UTF_16_LOW_SURROGATE_P(val) \
   (((val) & 0xFC00) == 0xDC00)
 
-#define UTF_16_INVALID_P(val)  \
-  (((val) == 0xFFFE)           \
-   || ((val) == 0xFFFF)                \
-   || UTF_16_LOW_SURROGATE_P (val))
-
 
 static int
 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;
@@ -1702,7 +1611,7 @@ decode_coding_utf_16 (struct coding_system *coding)
   enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
   int surrogate = CODING_UTF_16_SURROGATE (coding);
   Lisp_Object attr, charset_list;
-  int eol_crlf =
+  int eol_dos =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
   int byte_after_cr1 = -1, byte_after_cr2 = -1;
 
@@ -1799,7 +1708,7 @@ decode_coding_utf_16 (struct coding_system *coding)
            CODING_UTF_16_SURROGATE (coding) = surrogate = c;
          else
            {
-             if (eol_crlf && c == '\r')
+             if (eol_dos && c == '\r')
                {
                  ONE_MORE_BYTE (byte_after_cr1);
                  ONE_MORE_BYTE (byte_after_cr2);
@@ -1932,7 +1841,7 @@ encode_coding_utf_16 (struct coding_system *coding)
        CHARS is 0xA0 plus a number of characters composed by this
        data,
 
-       COMPONENTs are characters of multibye form or composition
+       COMPONENTs are characters of multibyte form or composition
        rules encoded by two-byte of ASCII codes.
 
    In addition, for backward compatibility, the following formats are
@@ -1983,17 +1892,17 @@ detect_coding_emacs_mule (struct coding_system *coding,
             it because analyzing it is too heavy for detecting.  But,
             at least, we check that the composite character
             constitutes of more than 4 bytes.  */
-         const unsigned char *src_base;
+         const unsigned char *src_start;
 
        repeat:
-         src_base = src;
+         src_start = src;
          do
            {
              ONE_MORE_BYTE (c);
            }
          while (c >= 0xA0);
 
-         if (src - src_base <= 4)
+         if (src - src_start <= 4)
            break;
          found = CATEGORY_MASK_EMACS_MULE;
          if (c == 0x80)
@@ -2008,7 +1917,7 @@ detect_coding_emacs_mule (struct coding_system *coding,
        }
       else
        {
-         int more_bytes = emacs_mule_bytes[*src_base] - 1;
+         int more_bytes = emacs_mule_bytes[c] - 1;
 
          while (more_bytes > 0)
            {
@@ -2045,7 +1954,7 @@ detect_coding_emacs_mule (struct coding_system *coding,
    the decoded character or rule.  If an invalid byte is found, return
    -1.  If SRC is too short, return -2.  */
 
-int
+static int
 emacs_mule_char (struct coding_system *coding, const unsigned char *src,
                 int *nbytes, int *nchars, int *id,
                 struct composition_status *cmp_status)
@@ -2053,7 +1962,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base = src;
   int multibytep = coding->src_multibyte;
-  struct charset *charset;
+  int charset_ID;
   unsigned code;
   int c;
   int consumed_chars = 0;
@@ -2063,7 +1972,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
   if (c < 0)
     {
       c = -c;
-      charset = emacs_mule_charset[0];
+      charset_ID = emacs_mule_charset[0];
     }
   else
     {
@@ -2099,7 +2008,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
       switch (emacs_mule_bytes[c])
        {
        case 2:
-         if (! (charset = emacs_mule_charset[c]))
+         if ((charset_ID = emacs_mule_charset[c]) < 0)
            goto invalid_code;
          ONE_MORE_BYTE (c);
          if (c < 0xA0)
@@ -2112,7 +2021,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
              || c == EMACS_MULE_LEADING_CODE_PRIVATE_12)
            {
              ONE_MORE_BYTE (c);
-             if (c < 0xA0 || ! (charset = emacs_mule_charset[c]))
+             if (c < 0xA0 || (charset_ID = emacs_mule_charset[c]) < 0)
                goto invalid_code;
              ONE_MORE_BYTE (c);
              if (c < 0xA0)
@@ -2121,7 +2030,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
            }
          else
            {
-             if (! (charset = emacs_mule_charset[c]))
+             if ((charset_ID = emacs_mule_charset[c]) < 0)
                goto invalid_code;
              ONE_MORE_BYTE (c);
              if (c < 0xA0)
@@ -2136,7 +2045,7 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
 
        case 4:
          ONE_MORE_BYTE (c);
-         if (c < 0 || ! (charset = emacs_mule_charset[c]))
+         if (c < 0 || (charset_ID = emacs_mule_charset[c]) < 0)
            goto invalid_code;
          ONE_MORE_BYTE (c);
          if (c < 0xA0)
@@ -2150,21 +2059,21 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
 
        case 1:
          code = c;
-         charset = CHARSET_FROM_ID (ASCII_BYTE_P (code)
-                                    ? charset_ascii : charset_eight_bit);
+         charset_ID = ASCII_BYTE_P (code) ? charset_ascii : charset_eight_bit;
          break;
 
        default:
          abort ();
        }
-      CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, code, c);
+      CODING_DECODE_CHAR (coding, src, src_base, src_end,
+                         CHARSET_FROM_ID (charset_ID), code, c);
       if (c < 0)
        goto invalid_code;
     }
   *nbytes = src - src_base;
   *nchars = consumed_chars;
   if (id)
-    *id = charset->id;
+    *id = charset_ID;
   return (mseq_found ? -c : c);
 
  no_more_source:
@@ -2277,7 +2186,6 @@ emacs_mule_char (struct coding_system *coding, const unsigned char *src,
 #define DECODE_EMACS_MULE_21_COMPOSITION()                             \
   do {                                                                 \
     enum composition_method method = c - 0xF2;                         \
-    int *charbuf_base = charbuf;                                       \
     int nbytes, nchars;                                                        \
                                                                        \
     ONE_MORE_BYTE (c);                                                 \
@@ -2428,8 +2336,8 @@ decode_coding_emacs_mule (struct coding_system *coding)
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce two annocations (charset and composition) in one
-     loop and one more charset annocation at the end.  */
+  /* We may produce two annotations (charset and composition) in one
+     loop and one more charset annotation at the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
   int consumed_chars = 0, consumed_chars_base;
@@ -2438,7 +2346,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
   int char_offset = coding->produced_char;
   int last_offset = char_offset;
   int last_id = charset_ascii;
-  int eol_crlf =
+  int eol_dos =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
   int byte_after_cr = -1;
   struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status;
@@ -2456,7 +2364,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
 
   while (1)
     {
-      int c, id;
+      int c, id IF_LINT (= 0);
 
       src_base = src;
       consumed_chars_base = consumed_chars;
@@ -2488,7 +2396,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
 
       if (c < 0x80)
        {
-         if (eol_crlf && c == '\r')
+         if (eol_dos && c == '\r')
            ONE_MORE_BYTE (byte_after_cr);
          id = charset_ascii;
          if (cmp_status->state != COMPOSING_NO)
@@ -2501,11 +2409,11 @@ decode_coding_emacs_mule (struct coding_system *coding)
        }
       else
        {
-         int nchars, nbytes;
+         int nchars IF_LINT (= 0), nbytes IF_LINT (= 0);
          /* emacs_mule_char can load a charset map from a file, which
             allocates a large structure and might cause buffer text
             to be relocated as result.  Thus, we need to remember the
-            original pointer to buffer text, and fixup all related
+            original pointer to buffer text, and fix up all related
             pointers after the call.  */
          const unsigned char *orig = coding->source;
          EMACS_INT offset;
@@ -2532,7 +2440,7 @@ decode_coding_emacs_mule (struct coding_system *coding)
            cmp_status->ncomps -= nchars;
        }
 
-      /* Now if C >= 0, we found a normally encoded characer, if C <
+      /* Now if C >= 0, we found a normally encoded character, if C <
         0, we found an old-style composition component character or
         rule.  */
 
@@ -2633,11 +2541,6 @@ decode_coding_emacs_mule (struct coding_system *coding)
        }
       continue;
 
-    retry:
-      src = src_base;
-      consumed_chars = consumed_chars_base;
-      continue;
-
     invalid_code:
       EMACS_MULE_MAYBE_FINISH_COMPOSITION ();
       src = src_base;
@@ -2974,10 +2877,6 @@ enum iso_code_class_type iso_code_class[256];
   ((id) <= (coding)->max_charset_id    \
    && (coding)->safe_charsets[id] != 255)
 
-
-#define SHIFT_OUT_OK(category) \
-  (CODING_ISO_INITIAL (&coding_categories[category], 1) >= 0)
-
 static void
 setup_iso_safe_charsets (Lisp_Object attrs)
 {
@@ -3043,7 +2942,7 @@ setup_iso_safe_charsets (Lisp_Object attrs)
 
 
 /* See the above "GENERAL NOTES on `detect_coding_XXX ()' functions".
-   Check if a text is encoded in one of ISO-2022 based codig systems.
+   Check if a text is encoded in one of ISO-2022 based coding systems.
    If it is, return 1, else return 0.  */
 
 static int
@@ -3094,40 +2993,11 @@ detect_coding_iso_2022 (struct coding_system *coding,
            break;
          single_shifting = 0;
          ONE_MORE_BYTE (c);
-         if (c >= '(' && c <= '/')
-           {
-             /* Designation sequence for a charset of dimension 1.  */
-             ONE_MORE_BYTE (c1);
-             if (c1 < ' ' || c1 >= 0x80
-                 || (id = iso_charset_table[0][c >= ','][c1]) < 0)
-               /* Invalid designation sequence.  Just ignore.  */
-               break;
-           }
-         else if (c == '$')
-           {
-             /* Designation sequence for a charset of dimension 2.  */
-             ONE_MORE_BYTE (c);
-             if (c >= '@' && c <= 'B')
-               /* Designation for JISX0208.1978, GB2312, or JISX0208.  */
-               id = iso_charset_table[1][0][c];
-             else if (c >= '(' && c <= '/')
-               {
-                 ONE_MORE_BYTE (c1);
-                 if (c1 < ' ' || c1 >= 0x80
-                     || (id = iso_charset_table[1][c >= ','][c1]) < 0)
-                   /* Invalid designation sequence.  Just ignore.  */
-                   break;
-               }
-             else
-               /* Invalid designation sequence.  Just ignore it.  */
-               break;
-           }
-         else if (c == 'N' || c == 'O')
+         if (c == 'N' || c == 'O')
            {
              /* ESC <Fe> for SS2 or SS3.  */
              single_shifting = 1;
              rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT;
-             break;
            }
          else if (c == '1')
            {
@@ -3143,36 +3013,66 @@ detect_coding_iso_2022 (struct coding_system *coding,
            {
              /* ESC <Fp> for start/end composition.  */
              composition_count = 0;
-             break;
            }
          else
            {
-             /* Invalid escape sequence.  Just ignore it.  */
-             break;
-           }
+             if (c >= '(' && c <= '/')
+               {
+                 /* Designation sequence for a charset of dimension 1.  */
+                 ONE_MORE_BYTE (c1);
+                 if (c1 < ' ' || c1 >= 0x80
+                     || (id = iso_charset_table[0][c >= ','][c1]) < 0)
+                   /* Invalid designation sequence.  Just ignore.  */
+                   break;
+               }
+             else if (c == '$')
+               {
+                 /* Designation sequence for a charset of dimension 2.  */
+                 ONE_MORE_BYTE (c);
+                 if (c >= '@' && c <= 'B')
+                   /* Designation for JISX0208.1978, GB2312, or JISX0208.  */
+                   id = iso_charset_table[1][0][c];
+                 else if (c >= '(' && c <= '/')
+                   {
+                     ONE_MORE_BYTE (c1);
+                     if (c1 < ' ' || c1 >= 0x80
+                         || (id = iso_charset_table[1][c >= ','][c1]) < 0)
+                       /* Invalid designation sequence.  Just ignore.  */
+                       break;
+                   }
+                 else
+                   /* Invalid designation sequence.  Just ignore it.  */
+                   break;
+               }
+             else
+               {
+                 /* Invalid escape sequence.  Just ignore it.  */
+                 break;
+               }
 
-         /* We found a valid designation sequence for CHARSET.  */
-         rejected |= CATEGORY_MASK_ISO_8BIT;
-         if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7],
-                             id))
-           found |= CATEGORY_MASK_ISO_7;
-         else
-           rejected |= CATEGORY_MASK_ISO_7;
-         if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight],
-                             id))
-           found |= CATEGORY_MASK_ISO_7_TIGHT;
-         else
-           rejected |= CATEGORY_MASK_ISO_7_TIGHT;
-         if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else],
-                             id))
-           found |= CATEGORY_MASK_ISO_7_ELSE;
-         else
-           rejected |= CATEGORY_MASK_ISO_7_ELSE;
-         if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else],
-                             id))
-           found |= CATEGORY_MASK_ISO_8_ELSE;
-         else
-           rejected |= CATEGORY_MASK_ISO_8_ELSE;
+             /* We found a valid designation sequence for CHARSET.  */
+             rejected |= CATEGORY_MASK_ISO_8BIT;
+             if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7],
+                                 id))
+               found |= CATEGORY_MASK_ISO_7;
+             else
+               rejected |= CATEGORY_MASK_ISO_7;
+             if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_tight],
+                                 id))
+               found |= CATEGORY_MASK_ISO_7_TIGHT;
+             else
+               rejected |= CATEGORY_MASK_ISO_7_TIGHT;
+             if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_7_else],
+                                 id))
+               found |= CATEGORY_MASK_ISO_7_ELSE;
+             else
+               rejected |= CATEGORY_MASK_ISO_7_ELSE;
+             if (SAFE_CHARSET_P (&coding_categories[coding_category_iso_8_else],
+                                 id))
+               found |= CATEGORY_MASK_ISO_8_ELSE;
+             else
+               rejected |= CATEGORY_MASK_ISO_8_ELSE;
+           }
          break;
 
        case ISO_CODE_SO:
@@ -3200,13 +3100,32 @@ detect_coding_iso_2022 (struct coding_system *coding,
          rejected |= CATEGORY_MASK_ISO_7BIT;
          if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
              & CODING_ISO_FLAG_SINGLE_SHIFT)
-           found |= CATEGORY_MASK_ISO_8_1, single_shifting = 1;
+           {
+             found |= CATEGORY_MASK_ISO_8_1;
+             single_shifting = 1;
+           }
          if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_2])
              & CODING_ISO_FLAG_SINGLE_SHIFT)
-           found |= CATEGORY_MASK_ISO_8_2, single_shifting = 1;
+           {
+             found |= CATEGORY_MASK_ISO_8_2;
+             single_shifting = 1;
+           }
          if (single_shifting)
            break;
-         goto check_extra_latin;
+       check_extra_latin:
+         if (! VECTORP (Vlatin_extra_code_table)
+             || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))
+           {
+             rejected = CATEGORY_MASK_ISO;
+             break;
+           }
+         if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
+             & CODING_ISO_FLAG_LATIN_EXTRA)
+           found |= CATEGORY_MASK_ISO_8_1;
+         else
+           rejected |= CATEGORY_MASK_ISO_8_1;
+         rejected |= CATEGORY_MASK_ISO_8_2;
+         break;
 
        default:
          if (c < 0)
@@ -3229,7 +3148,7 @@ detect_coding_iso_2022 (struct coding_system *coding,
              if (! single_shifting
                  && ! (rejected & CATEGORY_MASK_ISO_8_2))
                {
-                 int i = 1;
+                 int len = 1;
                  while (src < src_end)
                    {
                      src_base = src;
@@ -3239,38 +3158,24 @@ detect_coding_iso_2022 (struct coding_system *coding,
                          src = src_base;
                          break;
                        }
-                     i++;
+                     len++;
                    }
 
-                 if (i & 1 && src < src_end)
+                 if (len & 1 && src < src_end)
                    {
                      rejected |= CATEGORY_MASK_ISO_8_2;
                      if (composition_count >= 0)
-                       composition_count += i;
+                       composition_count += len;
                    }
                  else
                    {
                      found |= CATEGORY_MASK_ISO_8_2;
                      if (composition_count >= 0)
-                       composition_count += i / 2;
+                       composition_count += len / 2;
                    }
                }
              break;
            }
-       check_extra_latin:
-         single_shifting = 0;
-         if (! VECTORP (Vlatin_extra_code_table)
-             || NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))
-           {
-             rejected = CATEGORY_MASK_ISO;
-             break;
-           }
-         if (CODING_ISO_FLAGS (&coding_categories[coding_category_iso_8_1])
-             & CODING_ISO_FLAG_LATIN_EXTRA)
-           found |= CATEGORY_MASK_ISO_8_1;
-         else
-           rejected |= CATEGORY_MASK_ISO_8_1;
-         rejected |= CATEGORY_MASK_ISO_8_2;
        }
     }
   detect_info->rejected |= CATEGORY_MASK_ISO;
@@ -3380,10 +3285,10 @@ detect_coding_iso_2022 (struct coding_system *coding,
       }                                                                        \
     else                       /* new format (after ver.21) */         \
       {                                                                        \
-       int c;                                                          \
+       int b;                                                          \
                                                                        \
-       ONE_MORE_BYTE (c);                                              \
-       rule = COMPOSITION_ENCODE_RULE (rule - 81, c - 32);             \
+       ONE_MORE_BYTE (b);                                              \
+       rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32);             \
        if (rule >= 0)                                                  \
          rule += 0x100;   /* to destinguish it from the old format */  \
        nbytes = 2;                                                     \
@@ -3452,7 +3357,7 @@ finish_composition (int *charbuf, struct composition_status *cmp_status)
   return new_chars;
 }
 
-/* If characers are under composition, finish the composition.  */
+/* If characters are under composition, finish the composition.  */
 #define MAYBE_FINISH_COMPOSITION()                             \
   do {                                                         \
     if (cmp_status->state != COMPOSING_NO)                     \
@@ -3558,8 +3463,8 @@ decode_coding_iso_2022 (struct coding_system *coding)
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce two annocations (charset and composition) in one
-     loop and one more charset annocation at the end.  */
+  /* We may produce two annotations (charset and composition) in one
+     loop and one more charset annotation at the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
   int consumed_chars = 0, consumed_chars_base;
@@ -3575,7 +3480,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
   int char_offset = coding->produced_char;
   int last_offset = char_offset;
   int last_id = charset_ascii;
-  int eol_crlf =
+  int eol_dos =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
   int byte_after_cr = -1;
   int i;
@@ -3695,7 +3600,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
          break;
 
        case ISO_control_0:
-         if (eol_crlf && c1 == '\r')
+         if (eol_dos && c1 == '\r')
            ONE_MORE_BYTE (byte_after_cr);
          MAYBE_FINISH_COMPOSITION ();
          charset = CHARSET_FROM_ID (charset_ascii);
@@ -3861,7 +3766,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
                goto invalid_code;
              /* For the moment, nested direction is not supported.
                 So, `coding->mode & CODING_MODE_DIRECTION' zero means
-                left-to-right, and nozero means right-to-left.  */
+                left-to-right, and nonzero means right-to-left.  */
              ONE_MORE_BYTE (c1);
              switch (c1)
                {
@@ -3902,7 +3807,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
                  int size;
 
                  ONE_MORE_BYTE (dim);
-                 if (dim < 0 || dim > 4)
+                 if (dim < '0' || dim > '4')
                    goto invalid_code;
                  ONE_MORE_BYTE (M);
                  if (M < 128)
@@ -3968,6 +3873,10 @@ decode_coding_iso_2022 (struct coding_system *coding)
              }
              continue;
            }
+         break;
+
+       default:
+         abort ();
        }
 
       if (cmp_status->state == COMPOSING_NO
@@ -4100,7 +4009,6 @@ decode_coding_iso_2022 (struct coding_system *coding)
     const char *intermediate_char_94 = "()*+";                         \
     const char *intermediate_char_96 = ",-./";                         \
     int revision = -1;                                                 \
-    int c;                                                             \
                                                                        \
     if (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_REVISION)          \
       revision = CHARSET_ISO_REVISION (charset);                       \
@@ -4113,11 +4021,12 @@ decode_coding_iso_2022 (struct coding_system *coding)
     EMIT_ONE_ASCII_BYTE (ISO_CODE_ESC);                                        \
     if (CHARSET_DIMENSION (charset) == 1)                              \
       {                                                                        \
+       int b;                                                          \
        if (! CHARSET_ISO_CHARS_96 (charset))                           \
-         c = intermediate_char_94[reg];                                \
+         b = intermediate_char_94[reg];                                \
        else                                                            \
-         c = intermediate_char_96[reg];                                \
-       EMIT_ONE_ASCII_BYTE (c);                                        \
+         b = intermediate_char_96[reg];                                \
+       EMIT_ONE_ASCII_BYTE (b);                                        \
       }                                                                        \
     else                                                               \
       {                                                                        \
@@ -4297,7 +4206,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
    to use CHARSET.  The element `spec.iso_2022' of *CODING is updated.
    Return new DST.  */
 
-unsigned char *
+static unsigned char *
 encode_invocation_designation (struct charset *charset,
                               struct coding_system *coding,
                               unsigned char *dst, int *p_nchars)
@@ -4360,30 +4269,6 @@ encode_invocation_designation (struct charset *charset,
   return dst;
 }
 
-/* The following three macros produce codes for indicating direction
-   of text.  */
-#define ENCODE_CONTROL_SEQUENCE_INTRODUCER                             \
-  do {                                                                 \
-    if (CODING_ISO_FLAGS (coding) == CODING_ISO_FLAG_SEVEN_BITS)       \
-      EMIT_TWO_ASCII_BYTES (ISO_CODE_ESC, '[');                                \
-    else                                                               \
-      EMIT_ONE_BYTE (ISO_CODE_CSI);                                    \
-  } while (0)
-
-
-#define ENCODE_DIRECTION_R2L()                 \
-  do {                                         \
-    ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst);  \
-    EMIT_TWO_ASCII_BYTES ('2', ']');           \
-  } while (0)
-
-
-#define ENCODE_DIRECTION_L2R()                 \
-  do {                                         \
-    ENCODE_CONTROL_SEQUENCE_INTRODUCER (dst);  \
-    EMIT_TWO_ASCII_BYTES ('0', ']');           \
-  } while (0)
-
 
 /* Produce codes for designation and invocation to reset the graphic
    planes and registers to initial state.  */
@@ -4413,7 +4298,7 @@ encode_invocation_designation (struct charset *charset,
 
 static unsigned char *
 encode_designation_at_bol (struct coding_system *coding, int *charbuf,
-                          int *charbuf_end, unsigned char *dst)
+                          unsigned char *dst)
 {
   struct charset *charset;
   /* Table of charsets to be designated to each graphic register.  */
@@ -4490,7 +4375,10 @@ encode_coding_iso_2022 (struct coding_system *coding)
   charset_list = CODING_ATTR_CHARSET_LIST (attrs);
   coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs));
 
-  ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs));
+  ascii_compatible
+    = (! NILP (CODING_ATTR_ASCII_COMPAT (attrs))
+       && ! (CODING_ISO_FLAGS (coding) & (CODING_ISO_FLAG_DESIGNATION
+                                         | CODING_ISO_FLAG_LOCKING_SHIFT)));
 
   while (charbuf < charbuf_end)
     {
@@ -4501,7 +4389,7 @@ encode_coding_iso_2022 (struct coding_system *coding)
          unsigned char *dst_prev = dst;
 
          /* We have to produce designation sequences if any now.  */
-         dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst);
+         dst = encode_designation_at_bol (coding, charbuf, dst);
          bol_designation = 0;
          /* We are sure that designation sequences are all ASCII bytes.  */
          produced_chars += dst - dst_prev;
@@ -4763,7 +4651,7 @@ decode_coding_sjis (struct coding_system *coding)
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce one charset annocation in one loop and one more at
+  /* We may produce one charset annotation in one loop and one more at
      the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
@@ -4775,7 +4663,7 @@ decode_coding_sjis (struct coding_system *coding)
   int char_offset = coding->produced_char;
   int last_offset = char_offset;
   int last_id = charset_ascii;
-  int eol_crlf =
+  int eol_dos =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
   int byte_after_cr = -1;
 
@@ -4810,7 +4698,7 @@ decode_coding_sjis (struct coding_system *coding)
        goto invalid_code;
       if (c < 0x80)
        {
-         if (eol_crlf && c == '\r')
+         if (eol_dos && c == '\r')
            ONE_MORE_BYTE (byte_after_cr);
          charset = charset_roman;
        }
@@ -4881,7 +4769,7 @@ decode_coding_big5 (struct coding_system *coding)
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce one charset annocation in one loop and one more at
+  /* We may produce one charset annotation in one loop and one more at
      the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
@@ -4892,7 +4780,7 @@ decode_coding_big5 (struct coding_system *coding)
   int char_offset = coding->produced_char;
   int last_offset = char_offset;
   int last_id = charset_ascii;
-  int eol_crlf =
+  int eol_dos =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
   int byte_after_cr = -1;
 
@@ -4925,7 +4813,7 @@ decode_coding_big5 (struct coding_system *coding)
        goto invalid_code;
       if (c < 0x80)
        {
-         if (eol_crlf && c == '\r')
+         if (eol_dos && c == '\r')
            ONE_MORE_BYTE (byte_after_cr);
          charset = charset_roman;
        }
@@ -5329,13 +5217,13 @@ encode_coding_ccl (struct coding_system *coding)
 static void
 decode_coding_raw_text (struct coding_system *coding)
 {
-  int eol_crlf =
+  int eol_dos =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
 
   coding->chars_at_source = 1;
   coding->consumed_char = coding->src_chars;
   coding->consumed = coding->src_bytes;
-  if (eol_crlf && coding->source[coding->src_bytes - 1] == '\r')
+  if (eol_dos && coding->source[coding->src_bytes - 1] == '\r')
     {
       coding->consumed_char--;
       coding->consumed--;
@@ -5377,11 +5265,12 @@ encode_coding_raw_text (struct coding_system *coding)
                unsigned char str[MAX_MULTIBYTE_LENGTH], *p0 = str, *p1 = str;
 
                CHAR_STRING_ADVANCE (c, p1);
-               while (p0 < p1)
+               do
                  {
                    EMIT_ONE_BYTE (*p0);
                    p0++;
                  }
+               while (p0 < p1);
              }
          }
       else
@@ -5447,9 +5336,9 @@ detect_coding_charset (struct coding_system *coding,
   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;
 
@@ -5538,7 +5427,7 @@ decode_coding_charset (struct coding_system *coding)
   const unsigned char *src_end = coding->source + coding->src_bytes;
   const unsigned char *src_base;
   int *charbuf = coding->charbuf + coding->charbuf_used;
-  /* We may produce one charset annocation in one loop and one more at
+  /* We may produce one charset annotation in one loop and one more at
      the end.  */
   int *charbuf_end
     = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
@@ -5548,7 +5437,7 @@ decode_coding_charset (struct coding_system *coding)
   int char_offset = coding->produced_char;
   int last_offset = char_offset;
   int last_id = charset_ascii;
-  int eol_crlf =
+  int eol_dos =
     !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
   int byte_after_cr = -1;
 
@@ -5582,7 +5471,7 @@ decode_coding_charset (struct coding_system *coding)
       else
        {
          ONE_MORE_BYTE (c);
-         if (eol_crlf && c == '\r')
+         if (eol_dos && c == '\r')
            ONE_MORE_BYTE (byte_after_cr);
        }
       if (c < 0)
@@ -6013,10 +5902,9 @@ raw_text_coding_system (Lisp_Object coding_system)
 }
 
 
-/* If CODING_SYSTEM doesn't specify end-of-line format but PARENT
-   does, return one of the subsidiary that has the same eol-spec as
-   PARENT.  Otherwise, return CODING_SYSTEM.  If PARENT is nil,
-   inherit end-of-line format from the system's setting
+/* If CODING_SYSTEM doesn't specify end-of-line format, return one of
+   the subsidiary that has the same eol-spec as PARENT (if it is not
+   nil and specifies end-of-line format) or the system's setting
    (system_eol_type).  */
 
 Lisp_Object
@@ -6038,6 +5926,8 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object 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;
        }
       else
        parent_eol_type = system_eol_type;
@@ -6051,6 +5941,45 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
   return coding_system;
 }
 
+
+/* Check if text-conversion and eol-conversion of CODING_SYSTEM are
+   decided for writing to a process.  If not, complement them, and
+   return a new coding system.  */
+
+Lisp_Object
+complement_process_encoding_system (Lisp_Object coding_system)
+{
+  Lisp_Object coding_base = Qnil, eol_base = Qnil;
+  Lisp_Object spec, attrs;
+  int i;
+
+  for (i = 0; i < 3; i++)
+    {
+      if (i == 1)
+       coding_system = CDR_SAFE (Vdefault_process_coding_system);
+      else if (i == 2)
+       coding_system = preferred_coding_system ();
+      spec = CODING_SYSTEM_SPEC (coding_system);
+      if (NILP (spec))
+       continue;
+      attrs = AREF (spec, 0);
+      if (NILP (coding_base) && ! EQ (CODING_ATTR_TYPE (attrs), Qundecided))
+       coding_base = CODING_ATTR_BASE_NAME (attrs);
+      if (NILP (eol_base) && ! VECTORP (AREF (spec, 2)))
+       eol_base = coding_system;
+      if (! NILP (coding_base) && ! NILP (eol_base))
+       break;
+    }
+
+  if (i > 0)
+    /* The original CODING_SYSTEM didn't specify text-conversion or
+       eol-conversion.  Be sure that we return a fully complemented
+       coding system.  */
+    coding_system = coding_inherit_eol_type (coding_base, eol_base);
+  return coding_system;
+}
+
+
 /* Emacs has a mechanism to automatically detect a coding system if it
    is one of Emacs' internal format, ISO2022, SJIS, and BIG5.  But,
    it's impossible to distinguish some coding systems accurately
@@ -6101,14 +6030,14 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
    o coding-category-iso-7-else
 
        The category for a coding system which has the same code range
-       as ISO2022 of 7-bit environemnt but uses locking shift or
+       as ISO2022 of 7-bit environment but uses locking shift or
        single shift functions.  Assigned the coding-system (Lisp
        symbol) `iso-2022-7bit-lock' by default.
 
    o coding-category-iso-8-else
 
        The category for a coding system which has the same code range
-       as ISO2022 of 8-bit environemnt but uses locking shift or
+       as ISO2022 of 8-bit environment but uses locking shift or
        single shift functions.  Assigned the coding-system (Lisp
        symbol) `iso-2022-8bit-ss2' by default.
 
@@ -6217,8 +6146,9 @@ detect_eol (const unsigned char *source, EMACS_INT src_bytes,
                {
                  /* 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
                    {
@@ -6233,42 +6163,40 @@ detect_eol (const unsigned char *source, EMACS_INT src_bytes,
        }
     }
   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;
 }
 
@@ -6636,15 +6564,15 @@ get_translation_table (Lisp_Object attrs, int encodep, int *max_lookup)
        }
       else if (CONSP (translation_table))
        {
-         Lisp_Object tail, val;
+         Lisp_Object tail;
 
          for (tail = translation_table; CONSP (tail); tail = XCDR (tail))
            if (CHAR_TABLE_P (XCAR (tail))
                && CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (XCAR (tail))) > 1)
              {
-               val = XCHAR_TABLE (XCAR (tail))->extras[1];
-               if (NATNUMP (val) && *max_lookup < XFASTINT (val))
-                 *max_lookup = XFASTINT (val);
+               Lisp_Object tailval = XCHAR_TABLE (XCAR (tail))->extras[1];
+               if (NATNUMP (tailval) && *max_lookup < XFASTINT (tailval))
+                 *max_lookup = XFASTINT (tailval);
              }
        }
     }
@@ -7067,8 +6995,8 @@ decode_coding (struct coding_system *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;
@@ -7165,7 +7093,7 @@ decode_coding (struct coding_system *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;
@@ -7462,7 +7390,7 @@ encode_coding (struct coding_system *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;
@@ -7505,7 +7433,7 @@ static Lisp_Object Vcode_conversion_reused_workbuf;
 static int reused_workbuf_in_use;
 
 
-/* Return a working buffer of code convesion.  MULTIBYTE specifies the
+/* Return a working buffer of code conversion.  MULTIBYTE specifies the
    multibyteness of returning buffer.  */
 
 static Lisp_Object
@@ -7533,8 +7461,8 @@ make_conversion_work_buffer (int 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;
 }
@@ -7591,7 +7519,7 @@ decode_coding_gap (struct coding_system *coding,
   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);
@@ -7681,12 +7609,12 @@ decode_coding_object (struct coding_system *coding,
                      Lisp_Object dst_object)
 {
   int count = SPECPDL_INDEX ();
-  unsigned char *destination;
-  EMACS_INT dst_bytes;
+  unsigned char *destination IF_LINT (= NULL);
+  EMACS_INT dst_bytes IF_LINT (= 0);
   EMACS_INT chars = to - from;
   EMACS_INT bytes = to_byte - from_byte;
   Lisp_Object attrs;
-  int saved_pt = -1, saved_pt_byte;
+  int saved_pt = -1, saved_pt_byte IF_LINT (= 0);
   int need_marker_adjustment = 0;
   Lisp_Object old_deactivate_mark;
 
@@ -7757,7 +7685,7 @@ decode_coding_object (struct coding_system *coding,
       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
     {
@@ -7827,7 +7755,7 @@ decode_coding_object (struct coding_system *coding,
        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
@@ -7851,7 +7779,7 @@ decode_coding_object (struct coding_system *coding,
                  {
                    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);
                  }
              }
@@ -7874,7 +7802,7 @@ encode_coding_object (struct coding_system *coding,
   EMACS_INT chars = to - from;
   EMACS_INT bytes = to_byte - from_byte;
   Lisp_Object attrs;
-  int saved_pt = -1, saved_pt_byte;
+  int saved_pt = -1, saved_pt_byte IF_LINT (= 0);
   int need_marker_adjustment = 0;
   int kill_src_buffer = 0;
   Lisp_Object old_deactivate_mark;
@@ -7909,7 +7837,7 @@ encode_coding_object (struct coding_system *coding,
       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))
        {
@@ -7989,7 +7917,7 @@ encode_coding_object (struct coding_system *coding,
          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))
     {
@@ -8032,7 +7960,7 @@ encode_coding_object (struct coding_system *coding,
        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
@@ -8056,7 +7984,7 @@ encode_coding_object (struct coding_system *coding,
                  {
                    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);
                  }
              }
@@ -8157,7 +8085,7 @@ function `define-coding-system'.  */)
 \f
 /* Detect how the bytes at SRC of length SRC_BYTES are encoded.  If
    HIGHEST is nonzero, return the coding system of the highest
-   priority among the detected coding systems.  Otherwize return a
+   priority among the detected coding systems.  Otherwise return a
    list of detected coding systems sorted by their priorities.  If
    MULTIBYTEP is nonzero, it is assumed that the bytes are in correct
    multibyte form but contains only ASCII and eight-bit chars.
@@ -8207,8 +8135,8 @@ detect_coding_system (const unsigned char *src,
   base_category = XINT (CODING_ATTR_CATEGORY (attrs));
   if (base_category == coding_category_undecided)
     {
-      enum coding_category category;
-      struct coding_system *this;
+      enum coding_category category IF_LINT (= 0);
+      struct coding_system *this IF_LINT (= NULL);
       int c, i;
 
       /* Skip all ASCII bytes except for a few ISO2022 controls.  */
@@ -8510,8 +8438,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);
 }
 
@@ -8593,7 +8521,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));
@@ -8727,7 +8655,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;
@@ -8843,7 +8771,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));
@@ -9141,10 +9069,10 @@ Return the corresponding character.  */)
     }
   else
     {
-      int s1 = c >> 8, s2 = c & 0xFF;
+      int c1 = c >> 8, c2 = c & 0xFF;
 
-      if (s1 < 0x81 || (s1 > 0x9F && s1 < 0xE0) || s1 > 0xEF
-         || s2 < 0x40 || s2 == 0x7F || s2 > 0xFC)
+      if (c1 < 0x81 || (c1 > 0x9F && c1 < 0xE0) || c1 > 0xEF
+         || c2 < 0x40 || c2 == 0x7F || c2 > 0xFC)
        error ("Invalid code: %d", code);
       SJIS_TO_JIS (c);
       charset = charset_kanji;
@@ -9254,15 +9182,20 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern
        doc: /* Internal use only.  */)
   (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.  */
   terminal_coding->mode |= CODING_MODE_SAFE_ENCODING;
-  /* Characer composition should be disabled.  */
+  /* Character composition should be disabled.  */
   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;
 }
 
@@ -9275,7 +9208,7 @@ DEFUN ("set-safe-terminal-coding-system-internal",
   CHECK_SYMBOL (coding_system);
   setup_coding_system (Fcheck_coding_system (coding_system),
                       &safe_terminal_coding);
-  /* Characer composition should be disabled.  */
+  /* Character composition should be disabled.  */
   safe_terminal_coding.common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK;
   safe_terminal_coding.src_multibyte = 1;
   safe_terminal_coding.dst_multibyte = 0;
@@ -9309,7 +9242,7 @@ DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_intern
   else
     Fcheck_coding_system (coding_system);
   setup_coding_system (coding_system, TERMINAL_KEYBOARD_CODING (t));
-  /* Characer composition should be disabled.  */
+  /* Character composition should be disabled.  */
   TERMINAL_KEYBOARD_CODING (t)->common_flags
     &= ~CODING_ANNOTATE_COMPOSITION_MASK;
   return Qnil;
@@ -9677,7 +9610,7 @@ usage: (define-coding-system-internal ...)  */)
 
         If Nth element is a list of charset IDs, N is the first byte
         of one of them.  The list is sorted by dimensions of the
-        charsets.  A charset of smaller dimension comes firtst. */
+        charsets.  A charset of smaller dimension comes first. */
       val = Fmake_vector (make_number (256), Qnil);
 
       for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
@@ -9822,7 +9755,6 @@ usage: (define-coding-system-internal ...)  */)
   else if (EQ (coding_type, Qiso_2022))
     {
       Lisp_Object initial, reg_usage, request, flags;
-      int i;
 
       if (nargs < coding_arg_iso2022_max)
        goto short_args;
@@ -9854,12 +9786,12 @@ usage: (define-coding-system-internal ...)  */)
       for (tail = request; ! NILP (tail); tail = Fcdr (tail))
        {
          int id;
-         Lisp_Object tmp;
+         Lisp_Object tmp1;
 
          val = Fcar (tail);
          CHECK_CONS (val);
-         tmp = XCAR (val);
-         CHECK_CHARSET_GET_ID (tmp, id);
+         tmp1 = XCAR (val);
+         CHECK_CHARSET_GET_ID (tmp1, id);
          CHECK_NATNUM_CDR (val);
          if (XINT (XCDR (val)) >= 4)
            error ("Invalid graphic register number: %d", XINT (XCDR (val)));
@@ -10485,7 +10417,7 @@ syms_of_coding (void)
   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
@@ -10493,7 +10425,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.
@@ -10503,7 +10435,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
@@ -10511,7 +10443,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;
 
@@ -10522,7 +10454,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.
@@ -10531,7 +10463,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,
@@ -10545,12 +10477,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.
 
@@ -10567,21 +10499,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) ...),
@@ -10602,7 +10534,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) ...),
@@ -10618,7 +10550,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) ...),
@@ -10635,48 +10567,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
@@ -10684,13 +10616,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.
@@ -10703,7 +10635,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.
 
@@ -10717,7 +10649,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
@@ -10726,7 +10658,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.
 
@@ -10754,7 +10686,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
@@ -10766,7 +10698,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'.
@@ -10850,13 +10782,10 @@ emacs_strerror (int 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) */