aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
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/fileio.c
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/fileio.c')
-rw-r--r--src/fileio.c24
1 files changed, 6 insertions, 18 deletions
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