aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schwab2015-10-03 14:21:48 +0200
committerAndreas Schwab2015-10-03 14:50:50 +0200
commitb235ceaaf69345a5c79ec96ce0ca61b29fb232e1 (patch)
tree0b116e6b34ebbcf325e2a58e518260822d014faa /src
parent272ca096356e30c67ce337855da7531994040255 (diff)
downloademacs-b235ceaaf69345a5c79ec96ce0ca61b29fb232e1.tar.gz
emacs-b235ceaaf69345a5c79ec96ce0ca61b29fb232e1.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/coding.c4
-rw-r--r--src/fileio.c24
2 files changed, 9 insertions, 19 deletions
diff --git a/src/coding.c b/src/coding.c
index d2655310cd3..31bffeab5c9 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6004,7 +6004,8 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
6004 6004
6005 if (NILP (coding_system)) 6005 if (NILP (coding_system))
6006 coding_system = Qraw_text; 6006 coding_system = Qraw_text;
6007 CHECK_CODING_SYSTEM (coding_system); 6007 else
6008 CHECK_CODING_SYSTEM (coding_system);
6008 spec = CODING_SYSTEM_SPEC (coding_system); 6009 spec = CODING_SYSTEM_SPEC (coding_system);
6009 eol_type = AREF (spec, 2); 6010 eol_type = AREF (spec, 2);
6010 if (VECTORP (eol_type)) 6011 if (VECTORP (eol_type))
@@ -6051,6 +6052,7 @@ complement_process_encoding_system (Lisp_Object coding_system)
6051 coding_system = CDR_SAFE (Vdefault_process_coding_system); 6052 coding_system = CDR_SAFE (Vdefault_process_coding_system);
6052 else if (i == 2) 6053 else if (i == 2)
6053 coding_system = preferred_coding_system (); 6054 coding_system = preferred_coding_system ();
6055 CHECK_CODING_SYSTEM (coding_system);
6054 spec = CODING_SYSTEM_SPEC (coding_system); 6056 spec = CODING_SYSTEM_SPEC (coding_system);
6055 if (NILP (spec)) 6057 if (NILP (spec))
6056 continue; 6058 continue;
diff --git a/src/fileio.c b/src/fileio.c
index 15bebdf09fa..b82b7d360b5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3470,10 +3470,7 @@ by calling `format-decode', which see. */)
3470 mtime = time_error_value (save_errno); 3470 mtime = time_error_value (save_errno);
3471 st.st_size = -1; 3471 st.st_size = -1;
3472 if (!NILP (Vcoding_system_for_read)) 3472 if (!NILP (Vcoding_system_for_read))
3473 { 3473 Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
3474 CHECK_CODING_SYSTEM (Vcoding_system_for_read);
3475 Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
3476 }
3477 goto notfound; 3474 goto notfound;
3478 } 3475 }
3479 3476
@@ -4529,7 +4526,6 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
4529 else if (!NILP (Vcoding_system_for_write)) 4526 else if (!NILP (Vcoding_system_for_write))
4530 { 4527 {
4531 val = Vcoding_system_for_write; 4528 val = Vcoding_system_for_write;
4532 CHECK_CODING_SYSTEM (val);
4533 if (coding_system_require_warning 4529 if (coding_system_require_warning
4534 && !NILP (Ffboundp (Vselect_safe_coding_system_function))) 4530 && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
4535 /* Confirm that VAL can surely encode the current region. */ 4531 /* 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
4578 using_default_coding = 1; 4574 using_default_coding = 1;
4579 } 4575 }
4580 4576
4581 if (!NILP (val))
4582 CHECK_CODING_SYSTEM (val);
4583
4584 if (! NILP (val) && ! force_raw_text) 4577 if (! NILP (val) && ! force_raw_text)
4585 { 4578 {
4586 Lisp_Object spec, attrs; 4579 Lisp_Object spec, attrs;
4587 4580
4581 CHECK_CODING_SYSTEM (val);
4588 CHECK_CODING_SYSTEM_GET_SPEC (val, spec); 4582 CHECK_CODING_SYSTEM_GET_SPEC (val, spec);
4589 attrs = AREF (spec, 0); 4583 attrs = AREF (spec, 0);
4590 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) 4584 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
4593 4587
4594 if (!force_raw_text 4588 if (!force_raw_text
4595 && !NILP (Ffboundp (Vselect_safe_coding_system_function))) 4589 && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
4596 { 4590 /* Confirm that VAL can surely encode the current region. */
4597 /* Confirm that VAL can surely encode the current region. */ 4591 val = call5 (Vselect_safe_coding_system_function,
4598 val = call5 (Vselect_safe_coding_system_function, 4592 start, end, val, Qnil, filename);
4599 start, end, val, Qnil, filename);
4600 CHECK_CODING_SYSTEM (val);
4601 }
4602 4593
4603 /* If the decided coding-system doesn't specify end-of-line 4594 /* If the decided coding-system doesn't specify end-of-line
4604 format, we use that of 4595 format, we use that of
@@ -4608,10 +4599,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
4608 Lisp_Object dflt = BVAR (&buffer_defaults, buffer_file_coding_system); 4599 Lisp_Object dflt = BVAR (&buffer_defaults, buffer_file_coding_system);
4609 4600
4610 if (! NILP (dflt)) 4601 if (! NILP (dflt))
4611 { 4602 val = coding_inherit_eol_type (val, dflt);
4612 CHECK_CODING_SYSTEM (dflt);
4613 val = (coding_inherit_eol_type (val, dflt));
4614 }
4615 } 4603 }
4616 4604
4617 /* If we decide not to encode text, use `raw-text' or one of its 4605 /* If we decide not to encode text, use `raw-text' or one of its