diff options
| author | Kenichi Handa | 1997-07-25 07:46:51 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-07-25 07:46:51 +0000 |
| commit | 70ec4328682c6c69dfa8e379b5e7bc22fef830fa (patch) | |
| tree | 210a93887f7fb833ea4498bd2e30c8057f479581 | |
| parent | b34fe182272b235962435d71cfb37f4bc5cfff5d (diff) | |
| download | emacs-70ec4328682c6c69dfa8e379b5e7bc22fef830fa.tar.gz emacs-70ec4328682c6c69dfa8e379b5e7bc22fef830fa.zip | |
(Finsert_file_contents): Use new macros
CODING_MAY_REQUIRE_NO_CONVERSION and
CODING_MAY_REQUIRE_NO_CONVERSION.
(Fwrite_region): Correct the logic for deciding coding system.
| -rw-r--r-- | src/fileio.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/fileio.c b/src/fileio.c index b8d7de46f67..119c6d1b200 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -3179,11 +3179,7 @@ This does code conversion according to the value of\n\ | |||
| 3179 | But if we discover the need for conversion, we give up on this method | 3179 | But if we discover the need for conversion, we give up on this method |
| 3180 | and let the following if-statement handle the replace job. */ | 3180 | and let the following if-statement handle the replace job. */ |
| 3181 | if (!NILP (replace) | 3181 | if (!NILP (replace) |
| 3182 | && (! CODING_REQUIRE_CONVERSION (&coding) | 3182 | && CODING_MAY_REQUIRE_NO_CONVERSION (&coding)) |
| 3183 | || (coding.type == coding_type_undecided | ||
| 3184 | && ! CODING_REQUIRE_EOL_CONVERSION (&coding)) | ||
| 3185 | || (coding.eol_type == CODING_EOL_UNDECIDED | ||
| 3186 | && ! CODING_REQUIRE_TEXT_CONVERSION (&coding)))) | ||
| 3187 | { | 3183 | { |
| 3188 | int same_at_start = BEGV; | 3184 | int same_at_start = BEGV; |
| 3189 | int same_at_end = ZV; | 3185 | int same_at_end = ZV; |
| @@ -3218,7 +3214,8 @@ This does code conversion according to the value of\n\ | |||
| 3218 | if (coding.type == coding_type_undecided) | 3214 | if (coding.type == coding_type_undecided) |
| 3219 | detect_coding (&coding, buffer, nread); | 3215 | detect_coding (&coding, buffer, nread); |
| 3220 | if (coding.type != coding_type_undecided | 3216 | if (coding.type != coding_type_undecided |
| 3221 | && CODING_REQUIRE_TEXT_CONVERSION (&coding)) | 3217 | && coding.type != coding_type_no_conversion |
| 3218 | && coding.type != coding_type_emacs_mule) | ||
| 3222 | /* We found that the file should be decoded somehow. | 3219 | /* We found that the file should be decoded somehow. |
| 3223 | Let's give up here. */ | 3220 | Let's give up here. */ |
| 3224 | { | 3221 | { |
| @@ -3229,7 +3226,7 @@ This does code conversion according to the value of\n\ | |||
| 3229 | if (coding.eol_type == CODING_EOL_UNDECIDED) | 3226 | if (coding.eol_type == CODING_EOL_UNDECIDED) |
| 3230 | detect_eol (&coding, buffer, nread); | 3227 | detect_eol (&coding, buffer, nread); |
| 3231 | if (coding.eol_type != CODING_EOL_UNDECIDED | 3228 | if (coding.eol_type != CODING_EOL_UNDECIDED |
| 3232 | && CODING_REQUIRE_EOL_CONVERSION (&coding)) | 3229 | && coding.eol_type != CODING_EOL_LF) |
| 3233 | /* We found that the format of eol should be decoded. | 3230 | /* We found that the format of eol should be decoded. |
| 3234 | Let's give up here. */ | 3231 | Let's give up here. */ |
| 3235 | { | 3232 | { |
| @@ -3304,7 +3301,7 @@ This does code conversion according to the value of\n\ | |||
| 3304 | if (same_at_end > same_at_start | 3301 | if (same_at_end > same_at_start |
| 3305 | && FETCH_BYTE (same_at_end - 1) >= 0200 | 3302 | && FETCH_BYTE (same_at_end - 1) >= 0200 |
| 3306 | && ! NILP (current_buffer->enable_multibyte_characters) | 3303 | && ! NILP (current_buffer->enable_multibyte_characters) |
| 3307 | && CODING_REQUIRE_CONVERSION (&coding)) | 3304 | && ! CODING_REQUIRE_NO_CONVERSION (&coding)) |
| 3308 | giveup_match_end = 1; | 3305 | giveup_match_end = 1; |
| 3309 | break; | 3306 | break; |
| 3310 | } | 3307 | } |
| @@ -3398,7 +3395,7 @@ This does code conversion according to the value of\n\ | |||
| 3398 | 3395 | ||
| 3399 | how_much += this; | 3396 | how_much += this; |
| 3400 | 3397 | ||
| 3401 | if (CODING_REQUIRE_CONVERSION (&coding)) | 3398 | if (! CODING_REQUIRE_NO_CONVERSION (&coding)) |
| 3402 | { | 3399 | { |
| 3403 | int require, produced, consumed; | 3400 | int require, produced, consumed; |
| 3404 | 3401 | ||
| @@ -3543,9 +3540,9 @@ This does code conversion according to the value of\n\ | |||
| 3543 | { | 3540 | { |
| 3544 | /* try is reserved in some compilers (Microsoft C) */ | 3541 | /* try is reserved in some compilers (Microsoft C) */ |
| 3545 | int trytry = min (total - how_much, READ_BUF_SIZE - unprocessed); | 3542 | int trytry = min (total - how_much, READ_BUF_SIZE - unprocessed); |
| 3546 | char *destination = (CODING_REQUIRE_CONVERSION (&coding) | 3543 | char *destination = (CODING_REQUIRE_NO_CONVERSION (&coding) |
| 3547 | ? read_buf + unprocessed | 3544 | ? (char *) (POS_ADDR (PT + inserted - 1) + 1) |
| 3548 | : (char *) (POS_ADDR (PT + inserted - 1) + 1)); | 3545 | : read_buf + unprocessed); |
| 3549 | int this; | 3546 | int this; |
| 3550 | 3547 | ||
| 3551 | /* Allow quitting out of the actual I/O. */ | 3548 | /* Allow quitting out of the actual I/O. */ |
| @@ -3568,7 +3565,7 @@ This does code conversion according to the value of\n\ | |||
| 3568 | if (! not_regular) | 3565 | if (! not_regular) |
| 3569 | how_much += this; | 3566 | how_much += this; |
| 3570 | 3567 | ||
| 3571 | if (CODING_REQUIRE_CONVERSION (&coding)) | 3568 | if (! CODING_REQUIRE_NO_CONVERSION (&coding)) |
| 3572 | { | 3569 | { |
| 3573 | int require, produced, consumed; | 3570 | int require, produced, consumed; |
| 3574 | 3571 | ||
| @@ -3831,9 +3828,10 @@ to the file, instead of any buffer contents, and END is ignored.") | |||
| 3831 | val = Qnil; | 3828 | val = Qnil; |
| 3832 | else if (!NILP (Vcoding_system_for_write)) | 3829 | else if (!NILP (Vcoding_system_for_write)) |
| 3833 | val = Vcoding_system_for_write; | 3830 | val = Vcoding_system_for_write; |
| 3834 | else if (NILP (current_buffer->enable_multibyte_characters) || | 3831 | else if (NILP (current_buffer->enable_multibyte_characters)) |
| 3835 | ! NILP (Fsymbol_value (Qbuffer_file_coding_system))) | 3832 | val = (NILP (Flocal_variable_p (Qbuffer_file_coding_system)) |
| 3836 | val = Fsymbol_value (Qbuffer_file_coding_system); | 3833 | ? Qnil |
| 3834 | : Fsymbol_value (Qbuffer_file_coding_system)); | ||
| 3837 | else | 3835 | else |
| 3838 | { | 3836 | { |
| 3839 | Lisp_Object args[7], coding_systems; | 3837 | Lisp_Object args[7], coding_systems; |
| @@ -3842,7 +3840,7 @@ to the file, instead of any buffer contents, and END is ignored.") | |||
| 3842 | args[3] = filename, args[4] = append, args[5] = visit, | 3840 | args[3] = filename, args[4] = append, args[5] = visit, |
| 3843 | args[6] = lockname; | 3841 | args[6] = lockname; |
| 3844 | coding_systems = Ffind_operation_coding_system (7, args); | 3842 | coding_systems = Ffind_operation_coding_system (7, args); |
| 3845 | val = (CONSP (coding_systems) | 3843 | val = (CONSP (coding_systems) && !NILP (XCONS (coding_systems)->cdr) |
| 3846 | ? XCONS (coding_systems)->cdr | 3844 | ? XCONS (coding_systems)->cdr |
| 3847 | : current_buffer->buffer_file_coding_system); | 3845 | : current_buffer->buffer_file_coding_system); |
| 3848 | } | 3846 | } |