mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-20 20:50:53 -08:00
(setup_coding_system): For invalid coding-system, set
coding->eol_type to CODING_EOL_UNDECIDED. (encode_coding): Cancel previous change. (shrink_encoding_region): Likewise. (code_convert_region1): Likewise. (code_convert_string1): Likewise. (code_convert_string_norecord): Likewise.
This commit is contained in:
parent
06ea6d57ca
commit
3f0b133f76
1 changed files with 8 additions and 11 deletions
19
src/coding.c
19
src/coding.c
|
|
@ -384,7 +384,9 @@ Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac;
|
|||
Lisp_Object eol_mnemonic_undecided;
|
||||
|
||||
/* Format of end-of-line decided by system. This is CODING_EOL_LF on
|
||||
Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. */
|
||||
Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac.
|
||||
This has an effect only for external encoding (i.e. for output to
|
||||
file and process), not for in-buffer or Lisp string encoding. */
|
||||
int system_eol_type;
|
||||
|
||||
#ifdef emacs
|
||||
|
|
@ -3924,10 +3926,7 @@ setup_coding_system (coding_system, coding)
|
|||
coding->type = coding_type_no_conversion;
|
||||
coding->category_idx = CODING_CATEGORY_IDX_BINARY;
|
||||
coding->common_flags = 0;
|
||||
coding->eol_type = NILP (coding_system) ? system_eol_type : CODING_EOL_LF;
|
||||
if (coding->eol_type != CODING_EOL_LF)
|
||||
coding->common_flags
|
||||
|= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK;
|
||||
coding->eol_type = CODING_EOL_UNDECIDED;
|
||||
coding->pre_write_conversion = coding->post_read_conversion = Qnil;
|
||||
return NILP (coding_system) ? 0 : -1;
|
||||
}
|
||||
|
|
@ -5004,7 +5003,7 @@ encode_coding (coding, source, destination, src_bytes, dst_bytes)
|
|||
coding->errors = 0;
|
||||
coding->result = CODING_FINISH_NORMAL;
|
||||
if (coding->eol_type == CODING_EOL_UNDECIDED)
|
||||
coding->eol_type = system_eol_type;
|
||||
coding->eol_type = CODING_EOL_LF;
|
||||
|
||||
switch (coding->type)
|
||||
{
|
||||
|
|
@ -5261,8 +5260,6 @@ shrink_encoding_region (beg, end, coding, str)
|
|||
if (coding->type == coding_type_ccl
|
||||
|| coding->eol_type == CODING_EOL_CRLF
|
||||
|| coding->eol_type == CODING_EOL_CR
|
||||
|| (coding->eol_type == CODING_EOL_UNDECIDED
|
||||
&& system_eol_type != CODING_EOL_LF)
|
||||
|| (coding->cmp_data && coding->cmp_data->used > 0))
|
||||
{
|
||||
/* We can't skip any data. */
|
||||
|
|
@ -7118,7 +7115,7 @@ code_convert_region1 (start, end, coding_system, encodep)
|
|||
from = XFASTINT (start);
|
||||
to = XFASTINT (end);
|
||||
|
||||
if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
|
||||
if (NILP (coding_system))
|
||||
return make_number (to - from);
|
||||
|
||||
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
|
||||
|
|
@ -7173,7 +7170,7 @@ code_convert_string1 (string, coding_system, nocopy, encodep)
|
|||
CHECK_STRING (string);
|
||||
CHECK_SYMBOL (coding_system);
|
||||
|
||||
if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
|
||||
if (NILP (coding_system))
|
||||
return (NILP (nocopy) ? Fcopy_sequence (string) : string);
|
||||
|
||||
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
|
||||
|
|
@ -7232,7 +7229,7 @@ code_convert_string_norecord (string, coding_system, encodep)
|
|||
CHECK_STRING (string);
|
||||
CHECK_SYMBOL (coding_system);
|
||||
|
||||
if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
|
||||
if (NILP (coding_system))
|
||||
return string;
|
||||
|
||||
if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue