Commit 43aae36e authored by Paul Eggert's avatar Paul Eggert
Browse files

* fileio.c (Finsert_file_contents): Make EOF condition clearer.

parent 163c5f32
2011-04-03 Paul Eggert <eggert@cs.ucla.edu>
* fileio.c (Finsert_file_contents): Make EOF condition clearer.
2011-04-02 Paul Eggert <eggert@cs.ucla.edu> 2011-04-02 Paul Eggert <eggert@cs.ucla.edu>
   
* fileio.c (Finsert_file_contents): Avoid signed integer overflow. * fileio.c (Finsert_file_contents): Avoid signed integer overflow.
...@@ -3607,6 +3607,7 @@ variable `last-coding-system-used' to the coding system actually used. */) ...@@ -3607,6 +3607,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
EMACS_INT bufpos; EMACS_INT bufpos;
unsigned char *decoded; unsigned char *decoded;
EMACS_INT temp; EMACS_INT temp;
EMACS_INT this = 0;
int this_count = SPECPDL_INDEX (); int this_count = SPECPDL_INDEX ();
int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
Lisp_Object conversion_buffer; Lisp_Object conversion_buffer;
...@@ -3633,7 +3634,6 @@ variable `last-coding-system-used' to the coding system actually used. */) ...@@ -3633,7 +3634,6 @@ variable `last-coding-system-used' to the coding system actually used. */)
/* try is reserved in some compilers (Microsoft C) */ /* try is reserved in some compilers (Microsoft C) */
EMACS_INT trytry = min (total - how_much, EMACS_INT trytry = min (total - how_much,
READ_BUF_SIZE - unprocessed); READ_BUF_SIZE - unprocessed);
EMACS_INT this;
/* Allow quitting out of the actual I/O. */ /* Allow quitting out of the actual I/O. */
immediate_quit = 1; immediate_quit = 1;
...@@ -3642,11 +3642,7 @@ variable `last-coding-system-used' to the coding system actually used. */) ...@@ -3642,11 +3642,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
immediate_quit = 0; immediate_quit = 0;
if (this <= 0) if (this <= 0)
{ break;
if (this < 0)
how_much = this;
break;
}
how_much += this; how_much += this;
...@@ -3669,7 +3665,7 @@ variable `last-coding-system-used' to the coding system actually used. */) ...@@ -3669,7 +3665,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
/* At this point, HOW_MUCH should equal TOTAL, or should be <= 0 /* At this point, HOW_MUCH should equal TOTAL, or should be <= 0
if we couldn't read the file. */ if we couldn't read the file. */
if (how_much < 0) if (this < 0)
error ("IO error reading %s: %s", error ("IO error reading %s: %s",
SDATA (orig_filename), emacs_strerror (errno)); SDATA (orig_filename), emacs_strerror (errno));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment