summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-01-21 22:10:20 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2013-01-21 22:10:20 -0800
commitb41b8a7eff8382797d373dcd0ea91ae3ec5fa562 (patch)
tree29d3312a11fa9cf4455efcf3d48596fbe50fae76 /src
parentbb677ef7449aba3c2d5d7ede8cc4b87814f01ab3 (diff)
* fileio.c (Finsert_file_contents): Simplify.
Remove unnecessary assignments and tests.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/fileio.c19
2 files changed, 10 insertions, 14 deletions
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 <eggert@cs.ucla.edu>
+
+ * fileio.c (Finsert_file_contents): Simplify.
+ Remove unnecessary assignments and tests.
+
2013-01-21 Eli Zaretskii <eliz@gnu.org>
* 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));