]> code.delx.au - gnu-emacs/blobdiff - src/coding.c
; Spelling fixes
[gnu-emacs] / src / coding.c
index f3f8dc1887521485e019f509b83bc88e30256692..9d75ef931021bacac25d1eba00fed9703a52f436 100644 (file)
@@ -1,5 +1,5 @@
 /* Coding system handler (conversion, detection, etc).
-   Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   Copyright (C) 2001-2016 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)
@@ -12,8 +12,8 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -297,41 +297,10 @@ encode_coding_XXX (struct coding_system *coding)
 #include "ccl.h"
 #include "composite.h"
 #include "coding.h"
-#include "window.h"
-#include "frame.h"
 #include "termhooks.h"
 
 Lisp_Object Vcoding_system_hash_table;
 
-static Lisp_Object Qcoding_system, Qeol_type;
-static Lisp_Object Qcoding_aliases;
-Lisp_Object Qunix, Qdos;
-static Lisp_Object Qmac;
-Lisp_Object Qbuffer_file_coding_system;
-static Lisp_Object Qpost_read_conversion, Qpre_write_conversion;
-static Lisp_Object Qdefault_char;
-Lisp_Object Qno_conversion, Qundecided;
-Lisp_Object Qcharset, Qutf_8;
-static Lisp_Object Qiso_2022;
-static Lisp_Object Qutf_16, Qshift_jis, Qbig5;
-static Lisp_Object Qbig, Qlittle;
-static Lisp_Object Qcoding_system_history;
-static Lisp_Object Qvalid_codes;
-static Lisp_Object QCcategory, QCmnemonic, QCdefault_char;
-static Lisp_Object QCdecode_translation_table, QCencode_translation_table;
-static Lisp_Object QCpost_read_conversion, QCpre_write_conversion;
-static Lisp_Object QCascii_compatible_p;
-
-Lisp_Object Qcall_process, Qcall_process_region;
-Lisp_Object Qstart_process, Qopen_network_stream;
-static Lisp_Object Qtarget_idx;
-
-static Lisp_Object Qinsufficient_source, Qinvalid_source, Qinterrupted;
-
-/* If a symbol has this property, evaluate the value to define the
-   symbol as a coding system.  */
-static Lisp_Object Qcoding_system_define_form;
-
 /* 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
@@ -340,17 +309,6 @@ static Lisp_Object system_eol_type;
 
 #ifdef emacs
 
-Lisp_Object Qcoding_system_p, Qcoding_system_error;
-
-/* Coding system emacs-mule and raw-text are for converting only
-   end-of-line format.  */
-Lisp_Object Qemacs_mule, Qraw_text;
-Lisp_Object Qutf_8_emacs;
-
-#if defined (WINDOWSNT) || defined (CYGWIN)
-static Lisp_Object Qutf_16le;
-#endif
-
 /* Coding-systems are handed between Emacs Lisp programs and C internal
    routines by the following three variables.  */
 /* Coding system to be used to encode text for terminal display when
@@ -359,11 +317,6 @@ struct coding_system safe_terminal_coding;
 
 #endif /* emacs */
 
-Lisp_Object Qtranslation_table;
-Lisp_Object Qtranslation_table_id;
-static Lisp_Object Qtranslation_table_for_decode;
-static Lisp_Object Qtranslation_table_for_encode;
-
 /* Two special coding systems.  */
 static Lisp_Object Vsjis_coding_system;
 static Lisp_Object Vbig5_coding_system;
@@ -395,7 +348,8 @@ static Lisp_Object Vbig5_coding_system;
 #define CODING_ISO_BOL(coding) \
   ((coding)->spec.iso_2022.bol)
 #define CODING_ISO_INVOKED_CHARSET(coding, plane)      \
-  CODING_ISO_DESIGNATION ((coding), CODING_ISO_INVOCATION ((coding), (plane)))
+  (CODING_ISO_INVOCATION (coding, plane) < 0 ? -1      \
+   : CODING_ISO_DESIGNATION (coding, CODING_ISO_INVOCATION (coding, plane)))
 #define CODING_ISO_CMP_STATUS(coding)  \
   (&(coding)->spec.iso_2022.cmp_status)
 #define CODING_ISO_EXTSEGMENT_LEN(coding)      \
@@ -1054,11 +1008,12 @@ coding_change_destination (struct coding_system *coding)
 static void
 coding_alloc_by_realloc (struct coding_system *coding, ptrdiff_t bytes)
 {
-  if (STRING_BYTES_BOUND - coding->dst_bytes < bytes)
+  ptrdiff_t newbytes;
+  if (INT_ADD_WRAPV (coding->dst_bytes, bytes, &newbytes)
+      || SIZE_MAX < newbytes)
     string_overflow ();
-  coding->destination = xrealloc (coding->destination,
-                                 coding->dst_bytes + bytes);
-  coding->dst_bytes += bytes;
+  coding->destination = xrealloc (coding->destination, newbytes);
+  coding->dst_bytes = newbytes;
 }
 
 static void
@@ -4339,6 +4294,9 @@ encode_invocation_designation (struct charset *charset,
          else
            ENCODE_LOCKING_SHIFT_3;
          break;
+
+       default:
+         break;
        }
     }
 
@@ -6023,6 +5981,15 @@ raw_text_coding_system (Lisp_Object coding_system)
          : AREF (raw_text_eol_type, 2));
 }
 
+/* Return true if CODING corresponds to raw-text coding-system.  */
+
+bool
+raw_text_coding_system_p (struct coding_system *coding)
+{
+  return (coding->decoder == decode_coding_raw_text
+         && coding->encoder == encode_coding_raw_text) ? true : false;
+}
+
 
 /* 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
@@ -6036,6 +6003,8 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
 
   if (NILP (coding_system))
     coding_system = Qraw_text;
+  else
+    CHECK_CODING_SYSTEM (coding_system);
   spec = CODING_SYSTEM_SPEC (coding_system);
   eol_type = AREF (spec, 2);
   if (VECTORP (eol_type))
@@ -6046,6 +6015,7 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
        {
          Lisp_Object parent_spec;
 
+         CHECK_CODING_SYSTEM (parent);
          parent_spec = CODING_SYSTEM_SPEC (parent);
          parent_eol_type = AREF (parent_spec, 2);
          if (VECTORP (parent_eol_type))
@@ -6844,39 +6814,29 @@ decode_eol (struct coding_system *coding)
   else if (EQ (eol_type, Qdos))
     {
       ptrdiff_t n = 0;
+      ptrdiff_t pos = coding->dst_pos;
+      ptrdiff_t pos_byte = coding->dst_pos_byte;
+      ptrdiff_t pos_end = pos_byte + coding->produced - 1;
 
-      if (NILP (coding->dst_object))
-       {
-         /* Start deleting '\r' from the tail to minimize the memory
-            movement.  */
-         for (p = pend - 2; p >= pbeg; p--)
-           if (*p == '\r')
-             {
-               memmove (p, p + 1, pend-- - p - 1);
-               n++;
-             }
-       }
-      else
-       {
-         ptrdiff_t pos_byte = coding->dst_pos_byte;
-         ptrdiff_t pos = coding->dst_pos;
-         ptrdiff_t pos_end = pos + coding->produced_char - 1;
+      /* This assertion is here instead of code, now deleted, that
+        handled the NILP case, which no longer happens with the
+        current codebase.  */
+      eassert (!NILP (coding->dst_object));
 
-         while (pos < pos_end)
+      while (pos_byte < pos_end)
+       {
+         p = BYTE_POS_ADDR (pos_byte);
+         if (*p == '\r' && p[1] == '\n')
            {
-             p = BYTE_POS_ADDR (pos_byte);
-             if (*p == '\r' && p[1] == '\n')
-               {
-                 del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0);
-                 n++;
-                 pos_end--;
-               }
-             pos++;
-             if (coding->dst_multibyte)
-               pos_byte += BYTES_BY_CHAR_HEAD (*p);
-             else
-               pos_byte++;
+             del_range_2 (pos, pos_byte, pos + 1, pos_byte + 1, 0);
+             n++;
+             pos_end--;
            }
+         pos++;
+         if (coding->dst_multibyte)
+           pos_byte += BYTES_BY_CHAR_HEAD (*p);
+         else
+           pos_byte++;
        }
       coding->produced -= n;
       coding->produced_char -= n;
@@ -7079,14 +7039,12 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
              if ((dst_end - dst) / MAX_MULTIBYTE_LENGTH < to_nchars)
                {
                  eassert (growable_destination (coding));
-                 if (((min (PTRDIFF_MAX, SIZE_MAX) - (buf_end - buf))
-                      / MAX_MULTIBYTE_LENGTH)
-                     < to_nchars)
+                 ptrdiff_t dst_size;
+                 if (INT_MULTIPLY_WRAPV (to_nchars, MAX_MULTIBYTE_LENGTH,
+                                         &dst_size)
+                     || INT_ADD_WRAPV (buf_end - buf, dst_size, &dst_size))
                    memory_full (SIZE_MAX);
-                 dst = alloc_destination (coding,
-                                          buf_end - buf
-                                          + MAX_MULTIBYTE_LENGTH * to_nchars,
-                                          dst);
+                 dst = alloc_destination (coding, dst_size, dst);
                  if (EQ (coding->src_object, coding->dst_object))
                    {
                      coding_set_source (coding);
@@ -7327,6 +7285,8 @@ produce_annotation (struct coding_system *coding, ptrdiff_t pos)
              case CODING_ANNOTATE_CHARSET_MASK:
                produce_charset (coding, charbuf, pos);
                break;
+             default:
+               break;
              }
          charbuf += len;
        }
@@ -7868,9 +7828,7 @@ static void
 code_conversion_restore (Lisp_Object arg)
 {
   Lisp_Object current, workbuf;
-  struct gcpro gcpro1;
 
-  GCPRO1 (arg);
   current = XCAR (arg);
   workbuf = XCDR (arg);
   if (! NILP (workbuf))
@@ -7881,7 +7839,6 @@ code_conversion_restore (Lisp_Object arg)
        Fkill_buffer (workbuf);
     }
   set_buffer_internal (XBUFFER (current));
-  UNGCPRO;
 }
 
 Lisp_Object
@@ -8058,12 +8015,12 @@ decode_coding_object (struct coding_system *coding,
                      Lisp_Object dst_object)
 {
   ptrdiff_t count = SPECPDL_INDEX ();
-  unsigned char *destination IF_LINT (= NULL);
-  ptrdiff_t dst_bytes IF_LINT (= 0);
+  unsigned char *destination;
+  ptrdiff_t dst_bytes;
   ptrdiff_t chars = to - from;
   ptrdiff_t bytes = to_byte - from_byte;
   Lisp_Object attrs;
-  ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0);
+  ptrdiff_t saved_pt = -1, saved_pt_byte;
   bool need_marker_adjustment = 0;
   Lisp_Object old_deactivate_mark;
 
@@ -8153,16 +8110,12 @@ decode_coding_object (struct coding_system *coding,
 
   if (! NILP (CODING_ATTR_POST_READ (attrs)))
     {
-      struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
       ptrdiff_t prev_Z = Z, prev_Z_BYTE = Z_BYTE;
       Lisp_Object val;
 
       TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte);
-      GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object,
-             old_deactivate_mark);
       val = safe_call1 (CODING_ATTR_POST_READ (attrs),
                        make_number (coding->produced_char));
-      UNGCPRO;
       CHECK_NATNUM (val);
       coding->produced_char += Z - prev_Z;
       coding->produced += Z_BYTE - prev_Z_BYTE;
@@ -8245,7 +8198,7 @@ encode_coding_object (struct coding_system *coding,
   ptrdiff_t chars = to - from;
   ptrdiff_t bytes = to_byte - from_byte;
   Lisp_Object attrs;
-  ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0);
+  ptrdiff_t saved_pt = -1, saved_pt_byte;
   bool need_marker_adjustment = 0;
   bool kill_src_buffer = 0;
   Lisp_Object old_deactivate_mark;
@@ -8290,15 +8243,8 @@ encode_coding_object (struct coding_system *coding,
          set_buffer_internal (XBUFFER (coding->src_object));
        }
 
-      {
-       struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
-
-       GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object,
-               old_deactivate_mark);
-       safe_call2 (CODING_ATTR_PRE_WRITE (attrs),
-                   make_number (BEG), make_number (Z));
-       UNGCPRO;
-      }
+      safe_call2 (CODING_ATTR_PRE_WRITE (attrs),
+                 make_number (BEG), make_number (Z));
       if (XBUFFER (coding->src_object) != current_buffer)
        kill_src_buffer = 1;
       coding->src_object = Fcurrent_buffer ();
@@ -8336,7 +8282,11 @@ encode_coding_object (struct coding_system *coding,
        }
     }
   else
-    code_conversion_save (0, 0);
+    {
+      code_conversion_save (0, 0);
+      coding->src_pos = from;
+      coding->src_pos_byte = from_byte;
+    }
 
   if (BUFFERP (dst_object))
     {
@@ -8469,11 +8419,10 @@ from_unicode (Lisp_Object str)
 Lisp_Object
 from_unicode_buffer (const wchar_t *wstr)
 {
-    return from_unicode (
-        make_unibyte_string (
-            (char *) wstr,
-            /* we get one of the two final 0 bytes for free. */
-            1 + sizeof (wchar_t) * wcslen (wstr)));
+  /* We get one of the two final null bytes for free.  */
+  ptrdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr);
+  AUTO_STRING_WITH_LEN (str, (char *) wstr, len);
+  return from_unicode (str);
 }
 
 wchar_t *
@@ -9894,7 +9843,8 @@ usage: (find-operation-coding-system OPERATION ARGUMENTS...)  */)
   if (!(STRINGP (target)
        || (EQ (operation, Qinsert_file_contents) && CONSP (target)
            && STRINGP (XCAR (target)) && BUFFERP (XCDR (target)))
-       || (EQ (operation, Qopen_network_stream) && INTEGERP (target))))
+       || (EQ (operation, Qopen_network_stream)
+           && (INTEGERP (target) || EQ (target, Qt)))))
     error ("Invalid argument %"pI"d of operation `%s'",
           XFASTINT (target_idx) + 1, SDATA (SYMBOL_NAME (operation)));
   if (CONSP (target))
@@ -10716,7 +10666,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.")
+       doc: /* Return the property list of CODING-SYSTEM.  */)
   (Lisp_Object coding_system)
 {
   Lisp_Object spec, attrs;
@@ -10821,12 +10771,7 @@ void
 syms_of_coding (void)
 {
   staticpro (&Vcoding_system_hash_table);
-  {
-    Lisp_Object args[2];
-    args[0] = QCtest;
-    args[1] = Qeq;
-    Vcoding_system_hash_table = Fmake_hash_table (2, args);
-  }
+  Vcoding_system_hash_table = CALLN (Fmake_hash_table, QCtest, Qeq);
 
   staticpro (&Vsjis_coding_system);
   Vsjis_coding_system = Qnil;
@@ -10868,18 +10813,11 @@ syms_of_coding (void)
   /* Target SERVICE is the fourth argument.  */
   Fput (Qopen_network_stream, Qtarget_idx, make_number (3));
 
-  DEFSYM (Qcoding_system, "coding-system");
-  DEFSYM (Qcoding_aliases, "coding-aliases");
-
-  DEFSYM (Qeol_type, "eol-type");
   DEFSYM (Qunix, "unix");
   DEFSYM (Qdos, "dos");
   DEFSYM (Qmac, "mac");
 
   DEFSYM (Qbuffer_file_coding_system, "buffer-file-coding-system");
-  DEFSYM (Qpost_read_conversion, "post-read-conversion");
-  DEFSYM (Qpre_write_conversion, "pre-write-conversion");
-  DEFSYM (Qdefault_char, "default-char");
   DEFSYM (Qundecided, "undecided");
   DEFSYM (Qno_conversion, "no-conversion");
   DEFSYM (Qraw_text, "raw-text");
@@ -10903,6 +10841,7 @@ syms_of_coding (void)
 
   DEFSYM (Qcoding_system_p, "coding-system-p");
 
+  /* Error signaled when there's a problem with detecting a coding system.  */
   DEFSYM (Qcoding_system_error, "coding-system-error");
   Fput (Qcoding_system_error, Qerror_conditions,
        listn (CONSTYPE_PURE, 2, Qcoding_system_error, Qerror));
@@ -10912,11 +10851,9 @@ syms_of_coding (void)
   DEFSYM (Qtranslation_table, "translation-table");
   Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (2));
   DEFSYM (Qtranslation_table_id, "translation-table-id");
-  DEFSYM (Qtranslation_table_for_decode, "translation-table-for-decode");
-  DEFSYM (Qtranslation_table_for_encode, "translation-table-for-encode");
-
-  DEFSYM (Qvalid_codes, "valid-codes");
 
+  /* Coding system emacs-mule and raw-text are for converting only
+     end-of-line format.  */
   DEFSYM (Qemacs_mule, "emacs-mule");
 
   DEFSYM (QCcategory, ":category");
@@ -10979,6 +10916,9 @@ syms_of_coding (void)
   DEFSYM (Qinsufficient_source, "insufficient-source");
   DEFSYM (Qinvalid_source, "invalid-source");
   DEFSYM (Qinterrupted, "interrupted");
+
+  /* If a symbol has this property, evaluate the value to define the
+     symbol as a coding system.  */
   DEFSYM (Qcoding_system_define_form, "coding-system-define-form");
 
   defsubr (&Scoding_system_p);
@@ -11098,7 +11038,7 @@ conversion.  */);
 
   DEFVAR_BOOL ("inhibit-eol-conversion", inhibit_eol_conversion,
               doc: /*
-*Non-nil means always inhibit code conversion of end-of-line format.
+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;
@@ -11166,33 +11106,34 @@ See also the function `find-operation-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.  */);
+Also used for decoding keyboard input on X Window system, and for
+encoding standard output and error streams.  */);
   Vlocale_coding_system = Qnil;
 
   /* The eol mnemonics are reset in startup.el system-dependently.  */
   DEFVAR_LISP ("eol-mnemonic-unix", eol_mnemonic_unix,
               doc: /*
-*String displayed in mode line for UNIX-like (LF) end-of-line format.  */);
+String displayed in mode line for UNIX-like (LF) end-of-line format.  */);
   eol_mnemonic_unix = build_pure_c_string (":");
 
   DEFVAR_LISP ("eol-mnemonic-dos", eol_mnemonic_dos,
               doc: /*
-*String displayed in mode line for DOS-like (CRLF) end-of-line format.  */);
+String displayed in mode line for DOS-like (CRLF) end-of-line format.  */);
   eol_mnemonic_dos = build_pure_c_string ("\\");
 
   DEFVAR_LISP ("eol-mnemonic-mac", eol_mnemonic_mac,
               doc: /*
-*String displayed in mode line for MAC-like (CR) end-of-line format.  */);
+String displayed in mode line for MAC-like (CR) end-of-line format.  */);
   eol_mnemonic_mac = build_pure_c_string ("/");
 
   DEFVAR_LISP ("eol-mnemonic-undecided", eol_mnemonic_undecided,
               doc: /*
-*String displayed in mode line when end-of-line format is not yet determined.  */);
+String displayed in mode line when end-of-line format is not yet determined.  */);
   eol_mnemonic_undecided = build_pure_c_string (":");
 
   DEFVAR_LISP ("enable-character-translation", Venable_character_translation,
               doc: /*
-*Non-nil enables character translation while encoding and decoding.  */);
+Non-nil enables character translation while encoding and decoding.  */);
   Venable_character_translation = Qt;
 
   DEFVAR_LISP ("standard-translation-table-for-decode",
@@ -11308,63 +11249,59 @@ See also `keyboard-translate-table'.
 Use of this variable for character code unification was rendered
 obsolete in Emacs 23.1 and later, since Unicode is now the basis of
 internal character representation.  */);
-    Vtranslation_table_for_input = Qnil;
-
-  {
-    Lisp_Object args[coding_arg_undecided_max];
-    Lisp_Object plist[16];
-    int i;
-
-    for (i = 0; i < coding_arg_undecided_max; i++)
-      args[i] = Qnil;
-
-    plist[0] = intern_c_string (":name");
-    plist[1] = args[coding_arg_name] = Qno_conversion;
-    plist[2] = intern_c_string (":mnemonic");
-    plist[3] = args[coding_arg_mnemonic] = make_number ('=');
-    plist[4] = intern_c_string (":coding-type");
-    plist[5] = args[coding_arg_coding_type] = Qraw_text;
-    plist[6] = intern_c_string (":ascii-compatible-p");
-    plist[7] = args[coding_arg_ascii_compatible_p] = Qt;
-    plist[8] = intern_c_string (":default-char");
-    plist[9] = args[coding_arg_default_char] = make_number (0);
-    plist[10] = intern_c_string (":for-unibyte");
-    plist[11] = args[coding_arg_for_unibyte] = Qt;
-    plist[12] = intern_c_string (":docstring");
-    plist[13] = build_pure_c_string ("Do no conversion.\n\
-\n\
-When you visit a file with this coding, the file is read into a\n\
-unibyte buffer as is, thus each byte of a file is treated as a\n\
-character.");
-    plist[14] = intern_c_string (":eol-type");
-    plist[15] = args[coding_arg_eol_type] = Qunix;
-    args[coding_arg_plist] = Flist (16, plist);
-    Fdefine_coding_system_internal (coding_arg_max, args);
-
-    plist[1] = args[coding_arg_name] = Qundecided;
-    plist[3] = args[coding_arg_mnemonic] = make_number ('-');
-    plist[5] = args[coding_arg_coding_type] = Qundecided;
-    /* This is already set.
-       plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */
-    plist[8] = intern_c_string (":charset-list");
-    plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil);
-    plist[11] = args[coding_arg_for_unibyte] = Qnil;
-    plist[13] = build_pure_c_string ("No conversion on encoding, automatic conversion on decoding.");
-    plist[15] = args[coding_arg_eol_type] = Qnil;
-    args[coding_arg_plist] = Flist (16, plist);
-    args[coding_arg_undecided_inhibit_null_byte_detection] = make_number (0);
-    args[coding_arg_undecided_inhibit_iso_escape_detection] = make_number (0);
-    Fdefine_coding_system_internal (coding_arg_undecided_max, args);
-  }
+  Vtranslation_table_for_input = Qnil;
+
+  Lisp_Object args[coding_arg_undecided_max];
+  memclear (args, sizeof args);
+
+  Lisp_Object plist[] =
+    {
+      QCname,
+      args[coding_arg_name] = Qno_conversion,
+      QCmnemonic,
+      args[coding_arg_mnemonic] = make_number ('='),
+      intern_c_string (":coding-type"),
+      args[coding_arg_coding_type] = Qraw_text,
+      QCascii_compatible_p,
+      args[coding_arg_ascii_compatible_p] = Qt,
+      QCdefault_char,
+      args[coding_arg_default_char] = make_number (0),
+      intern_c_string (":for-unibyte"),
+      args[coding_arg_for_unibyte] = Qt,
+      intern_c_string (":docstring"),
+      (build_pure_c_string
+       ("Do no conversion.\n"
+       "\n"
+       "When you visit a file with this coding, the file is read into a\n"
+       "unibyte buffer as is, thus each byte of a file is treated as a\n"
+       "character.")),
+      intern_c_string (":eol-type"),
+      args[coding_arg_eol_type] = Qunix,
+    };
+  args[coding_arg_plist] = CALLMANY (Flist, plist);
+  Fdefine_coding_system_internal (coding_arg_max, args);
+
+  plist[1] = args[coding_arg_name] = Qundecided;
+  plist[3] = args[coding_arg_mnemonic] = make_number ('-');
+  plist[5] = args[coding_arg_coding_type] = Qundecided;
+  /* This is already set.
+     plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */
+  plist[8] = intern_c_string (":charset-list");
+  plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil);
+  plist[11] = args[coding_arg_for_unibyte] = Qnil;
+  plist[13] = build_pure_c_string ("No conversion on encoding, "
+                                  "automatic conversion on decoding.");
+  plist[15] = args[coding_arg_eol_type] = Qnil;
+  args[coding_arg_plist] = CALLMANY (Flist, plist);
+  args[coding_arg_undecided_inhibit_null_byte_detection] = make_number (0);
+  args[coding_arg_undecided_inhibit_iso_escape_detection] = make_number (0);
+  Fdefine_coding_system_internal (coding_arg_undecided_max, args);
 
   setup_coding_system (Qno_conversion, &safe_terminal_coding);
 
-  {
-    int i;
+  for (int i = 0; i < coding_category_max; i++)
+    Fset (AREF (Vcoding_category_table, i), Qno_conversion);
 
-    for (i = 0; i < coding_category_max; i++)
-      Fset (AREF (Vcoding_category_table, i), Qno_conversion);
-  }
 #if defined (DOS_NT)
   system_eol_type = Qdos;
 #else