comparison src/fileio.c @ 20224:fb98ec190b6a

(Finsert_file_contents): Use new macros defined in coding.h. (Fwrite_region): Likewise.
author Kenichi Handa <handa@m17n.org>
date Sat, 08 Nov 1997 03:05:44 +0000
parents 0b680b922b56
children 36bbb5e0a687
comparison
equal deleted inserted replaced
20223:1e30a8b4ff3f 20224:fb98ec190b6a
3282 If the code conversion is "automatic" then we try using this 3282 If the code conversion is "automatic" then we try using this
3283 method and hope for the best. 3283 method and hope for the best.
3284 But if we discover the need for conversion, we give up on this method 3284 But if we discover the need for conversion, we give up on this method
3285 and let the following if-statement handle the replace job. */ 3285 and let the following if-statement handle the replace job. */
3286 if (!NILP (replace) 3286 if (!NILP (replace)
3287 && CODING_MAY_REQUIRE_NO_CONVERSION (&coding)) 3287 && ! CODING_REQUIRE_DECODING (&coding))
3288 { 3288 {
3289 int same_at_start = BEGV; 3289 int same_at_start = BEGV;
3290 int same_at_end = ZV; 3290 int same_at_end = ZV;
3291 int overlap; 3291 int overlap;
3292 /* There is still a possibility we will find the need to do code 3292 /* There is still a possibility we will find the need to do code
3316 else if (nread == 0) 3316 else if (nread == 0)
3317 break; 3317 break;
3318 3318
3319 if (coding.type == coding_type_undecided) 3319 if (coding.type == coding_type_undecided)
3320 detect_coding (&coding, buffer, nread); 3320 detect_coding (&coding, buffer, nread);
3321 if (coding.type != coding_type_undecided 3321 if (CODING_REQUIRE_DECODING (&coding))
3322 && coding.type != coding_type_no_conversion
3323 && coding.type != coding_type_emacs_mule)
3324 /* We found that the file should be decoded somehow. 3322 /* We found that the file should be decoded somehow.
3325 Let's give up here. */ 3323 Let's give up here. */
3326 { 3324 {
3327 giveup_match_end = 1; 3325 giveup_match_end = 1;
3328 break; 3326 break;
3404 /* If this discrepancy is because of code conversion, 3402 /* If this discrepancy is because of code conversion,
3405 we cannot use this method; giveup and try the other. */ 3403 we cannot use this method; giveup and try the other. */
3406 if (same_at_end > same_at_start 3404 if (same_at_end > same_at_start
3407 && FETCH_BYTE (same_at_end - 1) >= 0200 3405 && FETCH_BYTE (same_at_end - 1) >= 0200
3408 && ! NILP (current_buffer->enable_multibyte_characters) 3406 && ! NILP (current_buffer->enable_multibyte_characters)
3409 && ! CODING_REQUIRE_NO_CONVERSION (&coding)) 3407 && (CODING_REQUIRE_DECODING (&coding)
3408 || CODING_REQUIRE_DETECTION (&coding)))
3410 giveup_match_end = 1; 3409 giveup_match_end = 1;
3411 break; 3410 break;
3412 } 3411 }
3413 } 3412 }
3414 immediate_quit = 0; 3413 immediate_quit = 0;
3498 break; 3497 break;
3499 } 3498 }
3500 3499
3501 how_much += this; 3500 how_much += this;
3502 3501
3503 if (! CODING_REQUIRE_NO_CONVERSION (&coding)) 3502 if (CODING_REQUIRE_DECODING (&coding)
3503 || CODING_REQUIRE_DETECTION (&coding))
3504 { 3504 {
3505 int require, produced, consumed; 3505 int require, produced, consumed;
3506 3506
3507 this += unprocessed; 3507 this += unprocessed;
3508 3508
3644 unprocessed = 0; 3644 unprocessed = 0;
3645 while (how_much < total) 3645 while (how_much < total)
3646 { 3646 {
3647 /* try is reserved in some compilers (Microsoft C) */ 3647 /* try is reserved in some compilers (Microsoft C) */
3648 int trytry = min (total - how_much, READ_BUF_SIZE - unprocessed); 3648 int trytry = min (total - how_much, READ_BUF_SIZE - unprocessed);
3649 char *destination = (CODING_REQUIRE_NO_CONVERSION (&coding) 3649 char *destination = (! (CODING_REQUIRE_DECODING (&coding)
3650 || CODING_REQUIRE_DETECTION (&coding))
3650 ? (char *) (POS_ADDR (PT + inserted - 1) + 1) 3651 ? (char *) (POS_ADDR (PT + inserted - 1) + 1)
3651 : read_buf + unprocessed); 3652 : read_buf + unprocessed);
3652 int this; 3653 int this;
3653 3654
3654 /* Allow quitting out of the actual I/O. */ 3655 /* Allow quitting out of the actual I/O. */
3669 so don't bother counting in HOW_MUCH. 3670 so don't bother counting in HOW_MUCH.
3670 (INSERTED is where we count the number of characters inserted.) */ 3671 (INSERTED is where we count the number of characters inserted.) */
3671 if (! not_regular) 3672 if (! not_regular)
3672 how_much += this; 3673 how_much += this;
3673 3674
3674 if (! CODING_REQUIRE_NO_CONVERSION (&coding)) 3675 if (CODING_REQUIRE_DECODING (&coding)
3676 || CODING_REQUIRE_DETECTION (&coding))
3675 { 3677 {
3676 int require, produced, consumed; 3678 int require, produced, consumed;
3677 3679
3678 this += unprocessed; 3680 this += unprocessed;
3679 /* Make sure that the gap is large enough. */ 3681 /* Make sure that the gap is large enough. */
4222 coding.last_block = 1; 4224 coding.last_block = 1;
4223 failure = 0 > a_write (desc, "", 0, XINT (start), &annotations, &coding); 4225 failure = 0 > a_write (desc, "", 0, XINT (start), &annotations, &coding);
4224 save_errno = errno; 4226 save_errno = errno;
4225 } 4227 }
4226 4228
4227 if (coding.require_flushing && !coding.last_block) 4229 if (CODING_REQUIRE_FLUSHING (&coding) && !coding.last_block)
4228 { 4230 {
4229 /* We have to flush out a data. */ 4231 /* We have to flush out a data. */
4230 coding.last_block = 1; 4232 coding.last_block = 1;
4231 failure = 0 > e_write (desc, "", 0, &coding); 4233 failure = 0 > e_write (desc, "", 0, &coding);
4232 save_errno = errno; 4234 save_errno = errno;