From: Paul Eggert Date: Tue, 22 Jan 2013 06:10:20 +0000 (-0800) Subject: * fileio.c (Finsert_file_contents): Simplify. X-Git-Tag: emacs-24.3.90~173^2~7^2~242 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b41b8a7eff8382797d373dcd0ea91ae3ec5fa562;p=emacs.git * fileio.c (Finsert_file_contents): Simplify. Remove unnecessary assignments and tests. --- diff --git a/src/ChangeLog b/src/ChangeLog index ca37bb3ea56..57e024757ec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-01-22 Paul Eggert + + * fileio.c (Finsert_file_contents): Simplify. + Remove unnecessary assignments and tests. + 2013-01-21 Eli Zaretskii * w32.c (acl_set_file): Don't test for errors unless diff --git a/src/fileio.c b/src/fileio.c index 175f363ec92..a826ac1f94a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3573,7 +3573,6 @@ by calling `format-decode', which see. */) report_file_error ("Opening input file", Fcons (orig_filename, Qnil)); mtime = time_error_value (save_errno); st.st_size = -1; - how_much = 0; if (!NILP (Vcoding_system_for_read)) Fset (Qbuffer_file_coding_system, Vcoding_system_for_read); goto notfound; @@ -4008,30 +4007,25 @@ by calling `format-decode', which see. */) report_file_error ("Setting file position", Fcons (orig_filename, Qnil)); - total = st.st_size; /* Total bytes in the file. */ - how_much = 0; /* Bytes read from file so far. */ inserted = 0; /* Bytes put into CONVERSION_BUFFER so far. */ unprocessed = 0; /* Bytes not processed in previous loop. */ GCPRO1 (conversion_buffer); - while (how_much < total) + while (1) { - /* We read one bunch by one (READ_BUF_SIZE bytes) to allow - quitting while reading a huge while. */ - /* `try'' is reserved in some compilers (Microsoft C). */ - int trytry = min (total - how_much, READ_BUF_SIZE - unprocessed); + /* Read at most READ_BUF_SIZE bytes at a time, to allow + quitting while reading a huge file. */ /* Allow quitting out of the actual I/O. */ immediate_quit = 1; QUIT; - this = emacs_read (fd, read_buf + unprocessed, trytry); + this = emacs_read (fd, read_buf + unprocessed, + READ_BUF_SIZE - unprocessed); immediate_quit = 0; if (this <= 0) break; - how_much += this; - BUF_TEMP_SET_PT (XBUFFER (conversion_buffer), BUF_Z (XBUFFER (conversion_buffer))); decode_coding_c_string (&coding, (unsigned char *) read_buf, @@ -4048,9 +4042,6 @@ by calling `format-decode', which see. */) so defer the removal till we reach the `handled' label. */ deferred_remove_unwind_protect = 1; - /* At this point, HOW_MUCH should equal TOTAL, or should be <= 0 - if we couldn't read the file. */ - if (this < 0) error ("IO error reading %s: %s", SDATA (orig_filename), emacs_strerror (errno));