comparison src/fileio.c @ 89935:eed0cce8a804

(WRITE_BUF_SIZE): This macro deleted. (e_write): Fix previous change.
author Kenichi Handa <handa@m17n.org>
date Thu, 29 Apr 2004 00:09:16 +0000
parents 8d0c8d0ae419
children 48c84a32cc68
comparison
equal deleted inserted replaced
89934:5ddb430894bf 89935:eed0cce8a804
5331 *annot = Fcdr (*annot); 5331 *annot = Fcdr (*annot);
5332 } 5332 }
5333 return 0; 5333 return 0;
5334 } 5334 }
5335 5335
5336 #ifndef WRITE_BUF_SIZE
5337 #define WRITE_BUF_SIZE (16 * 1024)
5338 #endif
5339 5336
5340 /* Write text in the range START and END into descriptor DESC, 5337 /* Write text in the range START and END into descriptor DESC,
5341 encoding them with coding system CODING. If STRING is nil, START 5338 encoding them with coding system CODING. If STRING is nil, START
5342 and END are character positions of the current buffer, else they 5339 and END are character positions of the current buffer, else they
5343 are indexes to the string STRING. */ 5340 are indexes to the string STRING. */
5347 int desc; 5344 int desc;
5348 Lisp_Object string; 5345 Lisp_Object string;
5349 int start, end; 5346 int start, end;
5350 struct coding_system *coding; 5347 struct coding_system *coding;
5351 { 5348 {
5352 int return_val = 0;
5353
5354 if (STRINGP (string)) 5349 if (STRINGP (string))
5355 { 5350 {
5356 start = 0; 5351 start = 0;
5357 end = SCHARS (string); 5352 end = SCHARS (string);
5358 } 5353 }
5359 5354
5360 /* 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,
5361 now it is handled within encode_coding. */ 5356 now it is handled within encode_coding. */
5362 do 5357 if (STRINGP (string))
5363 { 5358 {
5364 if (STRINGP (string)) 5359 coding->src_multibyte = SCHARS (string) < SBYTES (string);
5365 { 5360 if (CODING_REQUIRE_ENCODING (coding))
5366 coding->src_multibyte = SCHARS (string) < SBYTES (string); 5361 {
5367 if (CODING_REQUIRE_ENCODING (coding)) 5362 encode_coding_object (coding, string,
5368 encode_coding_object (coding, string, 5363 start, string_char_to_byte (string, start),
5369 start, string_char_to_byte (string, start), 5364 end, string_char_to_byte (string, end), Qt);
5370 end, string_char_to_byte (string, end), Qt);
5371 else
5372 coding->dst_object = string, coding->produced = SBYTES (string);
5373 } 5365 }
5374 else 5366 else
5375 { 5367 {
5376 int start_byte = CHAR_TO_BYTE (start); 5368 coding->dst_object = string;
5377 int end_byte = CHAR_TO_BYTE (end); 5369 coding->produced = SBYTES (string);
5378 5370 }
5379 coding->src_multibyte = (end - start) < (end_byte - start_byte); 5371 }
5380 if (CODING_REQUIRE_ENCODING (coding)) 5372 else
5381 encode_coding_object (coding, Fcurrent_buffer (), 5373 {
5382 start, CHAR_TO_BYTE (start), 5374 int start_byte = CHAR_TO_BYTE (start);
5383 end, CHAR_TO_BYTE (end), Qt); 5375 int end_byte = CHAR_TO_BYTE (end);
5384 else 5376
5385 { 5377 coding->src_multibyte = (end - start) < (end_byte - start_byte);
5386 coding->dst_object = Qnil; 5378 if (CODING_REQUIRE_ENCODING (coding))
5387 coding->produced = end - start; 5379 {
5388 coding->dst_pos_byte = start_byte; 5380 encode_coding_object (coding, Fcurrent_buffer (),
5389 } 5381 start, CHAR_TO_BYTE (start),
5390 } 5382 end, CHAR_TO_BYTE (end), Qt);
5391 5383 }
5392 if (coding->produced > 0) 5384 else
5393 { 5385 {
5394 coding->produced -= 5386 coding->dst_object = Qnil;
5395 emacs_write (desc, 5387 coding->produced = end - start;
5396 STRINGP (coding->dst_object) 5388 coding->dst_pos_byte = start_byte;
5397 ? SDATA (coding->dst_object) 5389 }
5398 : BYTE_POS_ADDR (coding->dst_pos_byte), 5390 }
5399 coding->produced); 5391
5400 5392 if (coding->produced > 0)
5401 if (coding->produced) 5393 {
5402 { 5394 coding->produced -=
5403 return_val = -1; 5395 emacs_write (desc,
5404 break; 5396 STRINGP (coding->dst_object)
5405 } 5397 ? SDATA (coding->dst_object)
5406 } 5398 : BYTE_POS_ADDR (coding->dst_pos_byte),
5407 start += coding->consumed_char; 5399 coding->produced);
5408 } 5400
5409 while (start < end); 5401 if (coding->produced)
5410 5402 return -1;
5411 return return_val; 5403 }
5404
5405 return 0;
5412 } 5406 }
5413 5407
5414 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime, 5408 DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
5415 Sverify_visited_file_modtime, 1, 1, 0, 5409 Sverify_visited_file_modtime, 1, 1, 0,
5416 doc: /* Return t if last mod time of BUF's visited file matches what BUF records. 5410 doc: /* Return t if last mod time of BUF's visited file matches what BUF records.