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.
This commit is contained in:
Andreas Schwab 2015-10-03 14:21:48 +02:00
parent 272ca09635
commit b235ceaaf6
2 changed files with 9 additions and 19 deletions

View 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;

View 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