Wed Dec 20 18:23:10 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>

* stdio/internals.c (flushbuf): If the target is -1, always
	discard the buffer of read data.
	Only set TWIDDLED flag in !ALIGNED case.
	Never increment target or offset when old value is -1.
This commit is contained in:
Roland McGrath 1995-12-21 10:00:22 +00:00
parent f94a3574d5
commit 8ef76445e8
2 changed files with 31 additions and 16 deletions

View File

@ -1,3 +1,10 @@
Wed Dec 20 18:23:10 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* stdio/internals.c (flushbuf): If the target is -1, always
discard the buffer of read data.
Only set TWIDDLED flag in !ALIGNED case.
Never increment target or offset when old value is -1.
Tue Dec 19 17:00:42 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* hurd/hurdpid.c (_S_msg_proc_newids): Only run the hook when the

View File

@ -199,9 +199,14 @@ DEFUN(flushbuf, (fp, c),
size_t buffer_offset = 0;
/* If the user has read some of the buffer, the target position
is incremented for each character he has read. */
fp->__target += fp->__bufp - fp->__buffer;
if (fp->__target == -1)
/* For an unseekable object, data recently read bears no relation
to data we will write later. Discard the buffer. */
fp->__get_limit = fp->__buffer;
else
/* If the user has read some of the buffer, the target position
is incremented for each character he has read. */
fp->__target += fp->__bufp - fp->__buffer;
if (fp->__mode.__read && fp->__room_funcs.__input != NULL &&
!fp->__mode.__append)
@ -231,12 +236,12 @@ DEFUN(flushbuf, (fp, c),
/* Start bufp as far into the buffer as we were into
this block before we read it. */
buffer_offset = o;
}
/* The target position is now set to where the beginning of the
buffer maps to; and the get_limit was set by the input-room
function. */
twiddled = 1;
/* The target position is now set to where the beginning of the
buffer maps to; and the get_limit was set by the input-room
function. */
twiddled = 1;
}
}
if (fp->__buffer != NULL)
@ -289,7 +294,8 @@ DEFUN(flushbuf, (fp, c),
call with nothing in the buffer, so just say the buffer's
been flushed, increment the file offset, and return. */
fp->__bufp = fp->__buffer;
fp->__offset += to_write;
if (fp->__offset != -1)
fp->__offset += to_write;
goto end;
}
@ -315,7 +321,7 @@ DEFUN(flushbuf, (fp, c),
bother to find the current position; we can get it
later if we need it. */
fp->__offset = fp->__target = -1;
else
else if (fp->__offset != -1)
/* Record that we've moved forward in the file. */
fp->__offset += wrote;
}
@ -339,7 +345,7 @@ DEFUN(flushbuf, (fp, c),
char cc = (unsigned char) c;
if ((*fp->__io_funcs.__write)(fp->__cookie, &cc, 1) < 1)
fp->__error = 1;
else
else if (fp->__offset != -1)
{
/* Record that we've moved forward in the file. */
++fp->__offset;
@ -355,9 +361,10 @@ DEFUN(flushbuf, (fp, c),
if (!twiddled)
{
/* The new target position moves up as
much as the user wrote into the buffer. */
fp->__target += buffer_written;
if (fp->__target != -1)
/* The new target position moves up as
much as the user wrote into the buffer. */
fp->__target += buffer_written;
/* Set the reading limit to the beginning of the buffer,
so the next `getc' will call __fillbf. */
@ -433,8 +440,9 @@ DEFUN(fillbuf, (fp), register FILE *fp)
buffer += count;
nread += count;
to_read -= count;
/* Record that we've moved forward in the file. */
fp->__offset += count;
if (fp->__offset != -1)
/* Record that we've moved forward in the file. */
fp->__offset += count;
}
}