]> git.eshelyaron.com Git - emacs.git/commitdiff
More validatation of coding systems
authorAndreas Schwab <schwab@linux-m68k.org>
Sat, 3 Oct 2015 12:21:48 +0000 (14:21 +0200)
committerAndreas Schwab <schwab@linux-m68k.org>
Sat, 3 Oct 2015 12:50:50 +0000 (14:50 +0200)
* src/fileio.c (Finsert_file_contents): Remove redundant
coding-system check.
(choose_write_coding_system): Likewise.
* src/coding.c (complement_process_encoding_system): Check
argument for valid coding system.

src/coding.c
src/fileio.c

index d2655310cd3e037d922c97ed26c389329e27ac20..31bffeab5c9966b2cb85fdad4c989757de4ba430 100644 (file)
@@ -6004,7 +6004,8 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
 
   if (NILP (coding_system))
     coding_system = Qraw_text;
-  CHECK_CODING_SYSTEM (coding_system);
+  else
+    CHECK_CODING_SYSTEM (coding_system);
   spec = CODING_SYSTEM_SPEC (coding_system);
   eol_type = AREF (spec, 2);
   if (VECTORP (eol_type))
@@ -6051,6 +6052,7 @@ complement_process_encoding_system (Lisp_Object coding_system)
        coding_system = CDR_SAFE (Vdefault_process_coding_system);
       else if (i == 2)
        coding_system = preferred_coding_system ();
+      CHECK_CODING_SYSTEM (coding_system);
       spec = CODING_SYSTEM_SPEC (coding_system);
       if (NILP (spec))
        continue;
index 15bebdf09facc212072d5bd84b316412082113c4..b82b7d360b52f4498937d92f3665454a60912a4b 100644 (file)
@@ -3470,10 +3470,7 @@ by calling `format-decode', which see.  */)
       mtime = time_error_value (save_errno);
       st.st_size = -1;
       if (!NILP (Vcoding_system_for_read))
-       {
-         CHECK_CODING_SYSTEM (Vcoding_system_for_read);
-         Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
-       }
+       Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
       goto notfound;
     }
 
@@ -4529,7 +4526,6 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
   else if (!NILP (Vcoding_system_for_write))
     {
       val = Vcoding_system_for_write;
-      CHECK_CODING_SYSTEM (val);
       if (coding_system_require_warning
          && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
        /* Confirm that VAL can surely encode the current region.  */
@@ -4578,13 +4574,11 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
          using_default_coding = 1;
        }
 
-      if (!NILP (val))
-       CHECK_CODING_SYSTEM (val);
-
       if (! NILP (val) && ! force_raw_text)
        {
          Lisp_Object spec, attrs;
 
+         CHECK_CODING_SYSTEM (val);
          CHECK_CODING_SYSTEM_GET_SPEC (val, spec);
          attrs = AREF (spec, 0);
          if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text))
@@ -4593,12 +4587,9 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
 
       if (!force_raw_text
          && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
-       {
-         /* Confirm that VAL can surely encode the current region.  */
-         val = call5 (Vselect_safe_coding_system_function,
-                      start, end, val, Qnil, filename);
-         CHECK_CODING_SYSTEM (val);
-       }
+       /* Confirm that VAL can surely encode the current region.  */
+       val = call5 (Vselect_safe_coding_system_function,
+                    start, end, val, Qnil, filename);
 
       /* If the decided coding-system doesn't specify end-of-line
         format, we use that of
@@ -4608,10 +4599,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
          Lisp_Object dflt = BVAR (&buffer_defaults, buffer_file_coding_system);
 
          if (! NILP (dflt))
-           {
-             CHECK_CODING_SYSTEM (dflt);
-             val = (coding_inherit_eol_type (val, dflt));
-           }
+           val = coding_inherit_eol_type (val, dflt);
        }
 
       /* If we decide not to encode text, use `raw-text' or one of its