emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master b235cea: More validatation of coding systems


From: Andreas Schwab
Subject: [Emacs-diffs] master b235cea: More validatation of coding systems
Date: Sat, 03 Oct 2015 12:52:43 +0000

branch: master
commit b235ceaaf69345a5c79ec96ce0ca61b29fb232e1
Author: Andreas Schwab <address@hidden>
Commit: Andreas Schwab <address@hidden>

    More validatation of coding systems
    
    * 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 |    4 +++-
 src/fileio.c |   24 ++++++------------------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/src/coding.c b/src/coding.c
index d265531..31bffea 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -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;
diff --git a/src/fileio.c b/src/fileio.c
index 15bebdf..b82b7d3 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]