diff options
| author | Kenichi Handa | 2006-05-08 05:25:02 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2006-05-08 05:25:02 +0000 |
| commit | 3f0b133f7662e6280b357b0fcf6031f953e16b58 (patch) | |
| tree | 95755b419b2f75c430801704884592e6896ea2f6 /src/coding.c | |
| parent | 06ea6d57ca6aa9c1709db7e239ea8a7cf7e65340 (diff) | |
| download | emacs-3f0b133f7662e6280b357b0fcf6031f953e16b58.tar.gz emacs-3f0b133f7662e6280b357b0fcf6031f953e16b58.zip | |
(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.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/coding.c b/src/coding.c index bd96b5cc068..155da568007 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -384,7 +384,9 @@ Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac; | |||
| 384 | Lisp_Object eol_mnemonic_undecided; | 384 | Lisp_Object eol_mnemonic_undecided; |
| 385 | 385 | ||
| 386 | /* Format of end-of-line decided by system. This is CODING_EOL_LF on | 386 | /* Format of end-of-line decided by system. This is CODING_EOL_LF on |
| 387 | Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. */ | 387 | Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. |
| 388 | This has an effect only for external encoding (i.e. for output to | ||
| 389 | file and process), not for in-buffer or Lisp string encoding. */ | ||
| 388 | int system_eol_type; | 390 | int system_eol_type; |
| 389 | 391 | ||
| 390 | #ifdef emacs | 392 | #ifdef emacs |
| @@ -3924,10 +3926,7 @@ setup_coding_system (coding_system, coding) | |||
| 3924 | coding->type = coding_type_no_conversion; | 3926 | coding->type = coding_type_no_conversion; |
| 3925 | coding->category_idx = CODING_CATEGORY_IDX_BINARY; | 3927 | coding->category_idx = CODING_CATEGORY_IDX_BINARY; |
| 3926 | coding->common_flags = 0; | 3928 | coding->common_flags = 0; |
| 3927 | coding->eol_type = NILP (coding_system) ? system_eol_type : CODING_EOL_LF; | 3929 | coding->eol_type = CODING_EOL_UNDECIDED; |
| 3928 | if (coding->eol_type != CODING_EOL_LF) | ||
| 3929 | coding->common_flags | ||
| 3930 | |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK; | ||
| 3931 | coding->pre_write_conversion = coding->post_read_conversion = Qnil; | 3930 | coding->pre_write_conversion = coding->post_read_conversion = Qnil; |
| 3932 | return NILP (coding_system) ? 0 : -1; | 3931 | return NILP (coding_system) ? 0 : -1; |
| 3933 | } | 3932 | } |
| @@ -5004,7 +5003,7 @@ encode_coding (coding, source, destination, src_bytes, dst_bytes) | |||
| 5004 | coding->errors = 0; | 5003 | coding->errors = 0; |
| 5005 | coding->result = CODING_FINISH_NORMAL; | 5004 | coding->result = CODING_FINISH_NORMAL; |
| 5006 | if (coding->eol_type == CODING_EOL_UNDECIDED) | 5005 | if (coding->eol_type == CODING_EOL_UNDECIDED) |
| 5007 | coding->eol_type = system_eol_type; | 5006 | coding->eol_type = CODING_EOL_LF; |
| 5008 | 5007 | ||
| 5009 | switch (coding->type) | 5008 | switch (coding->type) |
| 5010 | { | 5009 | { |
| @@ -5261,8 +5260,6 @@ shrink_encoding_region (beg, end, coding, str) | |||
| 5261 | if (coding->type == coding_type_ccl | 5260 | if (coding->type == coding_type_ccl |
| 5262 | || coding->eol_type == CODING_EOL_CRLF | 5261 | || coding->eol_type == CODING_EOL_CRLF |
| 5263 | || coding->eol_type == CODING_EOL_CR | 5262 | || coding->eol_type == CODING_EOL_CR |
| 5264 | || (coding->eol_type == CODING_EOL_UNDECIDED | ||
| 5265 | && system_eol_type != CODING_EOL_LF) | ||
| 5266 | || (coding->cmp_data && coding->cmp_data->used > 0)) | 5263 | || (coding->cmp_data && coding->cmp_data->used > 0)) |
| 5267 | { | 5264 | { |
| 5268 | /* We can't skip any data. */ | 5265 | /* We can't skip any data. */ |
| @@ -7118,7 +7115,7 @@ code_convert_region1 (start, end, coding_system, encodep) | |||
| 7118 | from = XFASTINT (start); | 7115 | from = XFASTINT (start); |
| 7119 | to = XFASTINT (end); | 7116 | to = XFASTINT (end); |
| 7120 | 7117 | ||
| 7121 | if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) | 7118 | if (NILP (coding_system)) |
| 7122 | return make_number (to - from); | 7119 | return make_number (to - from); |
| 7123 | 7120 | ||
| 7124 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 7121 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
| @@ -7173,7 +7170,7 @@ code_convert_string1 (string, coding_system, nocopy, encodep) | |||
| 7173 | CHECK_STRING (string); | 7170 | CHECK_STRING (string); |
| 7174 | CHECK_SYMBOL (coding_system); | 7171 | CHECK_SYMBOL (coding_system); |
| 7175 | 7172 | ||
| 7176 | if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) | 7173 | if (NILP (coding_system)) |
| 7177 | return (NILP (nocopy) ? Fcopy_sequence (string) : string); | 7174 | return (NILP (nocopy) ? Fcopy_sequence (string) : string); |
| 7178 | 7175 | ||
| 7179 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 7176 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |
| @@ -7232,7 +7229,7 @@ code_convert_string_norecord (string, coding_system, encodep) | |||
| 7232 | CHECK_STRING (string); | 7229 | CHECK_STRING (string); |
| 7233 | CHECK_SYMBOL (coding_system); | 7230 | CHECK_SYMBOL (coding_system); |
| 7234 | 7231 | ||
| 7235 | if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) | 7232 | if (NILP (coding_system)) |
| 7236 | return string; | 7233 | return string; |
| 7237 | 7234 | ||
| 7238 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) | 7235 | if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) |