Mercurial > emacs
comparison src/fileio.c @ 89937:48c84a32cc68
(e_write): Fix previous change.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 29 Apr 2004 10:00:27 +0000 |
parents | eed0cce8a804 |
children | 4c90ffeb71c5 |
comparison
equal
deleted
inserted
replaced
89936:c7d2136efa9b | 89937:48c84a32cc68 |
---|---|
5352 end = SCHARS (string); | 5352 end = SCHARS (string); |
5353 } | 5353 } |
5354 | 5354 |
5355 /* We used to have a code for handling selective display here. But, | 5355 /* We used to have a code for handling selective display here. But, |
5356 now it is handled within encode_coding. */ | 5356 now it is handled within encode_coding. */ |
5357 if (STRINGP (string)) | 5357 |
5358 { | 5358 while (start < end) |
5359 coding->src_multibyte = SCHARS (string) < SBYTES (string); | 5359 { |
5360 if (CODING_REQUIRE_ENCODING (coding)) | 5360 if (STRINGP (string)) |
5361 { | 5361 { |
5362 encode_coding_object (coding, string, | 5362 coding->src_multibyte = SCHARS (string) < SBYTES (string); |
5363 start, string_char_to_byte (string, start), | 5363 if (CODING_REQUIRE_ENCODING (coding)) |
5364 end, string_char_to_byte (string, end), Qt); | 5364 { |
5365 encode_coding_object (coding, string, | |
5366 start, string_char_to_byte (string, start), | |
5367 end, string_char_to_byte (string, end), Qt); | |
5368 } | |
5369 else | |
5370 { | |
5371 coding->dst_object = string; | |
5372 coding->consumed_char = SCHARS (string); | |
5373 coding->produced = SBYTES (string); | |
5374 } | |
5365 } | 5375 } |
5366 else | 5376 else |
5367 { | 5377 { |
5368 coding->dst_object = string; | 5378 int start_byte = CHAR_TO_BYTE (start); |
5369 coding->produced = SBYTES (string); | 5379 int end_byte = CHAR_TO_BYTE (end); |
5370 } | 5380 |
5371 } | 5381 coding->src_multibyte = (end - start) < (end_byte - start_byte); |
5372 else | 5382 if (CODING_REQUIRE_ENCODING (coding)) |
5373 { | 5383 { |
5374 int start_byte = CHAR_TO_BYTE (start); | 5384 encode_coding_object (coding, Fcurrent_buffer (), |
5375 int end_byte = CHAR_TO_BYTE (end); | 5385 start, start_byte, end, end_byte, Qt); |
5376 | 5386 } |
5377 coding->src_multibyte = (end - start) < (end_byte - start_byte); | 5387 else |
5378 if (CODING_REQUIRE_ENCODING (coding)) | 5388 { |
5379 { | 5389 coding->dst_object = Qnil; |
5380 encode_coding_object (coding, Fcurrent_buffer (), | 5390 coding->dst_pos_byte = start_byte; |
5381 start, CHAR_TO_BYTE (start), | 5391 if (start >= GPT || end <= GPT) |
5382 end, CHAR_TO_BYTE (end), Qt); | 5392 { |
5383 } | 5393 coding->consumed_char = end - start; |
5384 else | 5394 coding->produced = end_byte - start_byte; |
5385 { | 5395 } |
5386 coding->dst_object = Qnil; | 5396 else |
5387 coding->produced = end - start; | 5397 { |
5388 coding->dst_pos_byte = start_byte; | 5398 coding->consumed_char = GPT - start; |
5389 } | 5399 coding->produced = GPT_BYTE - start_byte; |
5390 } | 5400 } |
5391 | 5401 } |
5392 if (coding->produced > 0) | 5402 } |
5393 { | 5403 |
5394 coding->produced -= | 5404 if (coding->produced > 0) |
5395 emacs_write (desc, | 5405 { |
5396 STRINGP (coding->dst_object) | 5406 coding->produced -= |
5397 ? SDATA (coding->dst_object) | 5407 emacs_write (desc, |
5398 : BYTE_POS_ADDR (coding->dst_pos_byte), | 5408 STRINGP (coding->dst_object) |
5399 coding->produced); | 5409 ? SDATA (coding->dst_object) |
5400 | 5410 : BYTE_POS_ADDR (coding->dst_pos_byte), |
5401 if (coding->produced) | 5411 coding->produced); |
5402 return -1; | 5412 |
5413 if (coding->produced) | |
5414 return -1; | |
5415 } | |
5416 start += coding->consumed_char; | |
5403 } | 5417 } |
5404 | 5418 |
5405 return 0; | 5419 return 0; |
5406 } | 5420 } |
5407 | 5421 |