1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00
2002-02-25  Jakub Jelinek  <jakub@redhat.com>

	* libio/iofopen.c (__fopen_maybe_mmap): Set the initial
	position to fp->_offset if it is set.
	* stdio-common/Makefile (tests): Add tst-fdopen.
	* stdio-common/tst-fdopen.c: New test.

2002-02-25  Jakub Jelinek  <jakub@redhat.com>

	* libio/fileops.c (_IO_file_xsgetn_mmap): Handle reading from backup.
	* stdio-common/tst-ungetc.c (main): Add another test.
This commit is contained in:
Ulrich Drepper
2002-02-26 05:23:31 +00:00
parent 77fe0b9cd8
commit b39d571990
6 changed files with 116 additions and 13 deletions

View File

@ -1197,28 +1197,54 @@ _IO_file_xsgetn_mmap (fp, data, n)
{
register _IO_size_t have;
char *read_ptr = fp->_IO_read_ptr;
register char *s = (char *) data;
have = fp->_IO_read_end - fp->_IO_read_ptr;
if (have < n)
{
/* Maybe the read buffer is not yet fully set up. */
fp->_IO_read_ptr = fp->_IO_read_end;
if (fp->_IO_read_end < fp->_IO_buf_end
&& _IO_file_underflow_mmap (fp) != EOF)
have = fp->_IO_read_end - read_ptr;
if (__builtin_expect (_IO_in_backup (fp), 0))
{
#ifdef _LIBC
s = __mempcpy (s, read_ptr, have);
#else
memcpy (s, read_ptr, have);
s += have;
#endif
n -= have;
_IO_switch_to_main_get_area (fp);
read_ptr = fp->_IO_read_ptr;
have = fp->_IO_read_end - fp->_IO_read_ptr;
}
if (have < n)
{
/* Maybe the read buffer is not yet fully set up. */
fp->_IO_read_ptr = fp->_IO_read_end;
if (fp->_IO_read_end < fp->_IO_buf_end
&& _IO_file_underflow_mmap (fp) != EOF)
have = fp->_IO_read_end - read_ptr;
}
}
if (have == 0)
fp->_flags |= _IO_EOF_SEEN;
{
if (s == (char *) data)
fp->_flags |= _IO_EOF_SEEN;
}
else
{
have = MIN (have, n);
memcpy (data, read_ptr, have);
#ifdef _LIBC
s = __mempcpy (s, read_ptr, have);
#else
memcpy (s, read_ptr, have);
s += have;
#endif
fp->_IO_read_ptr = read_ptr + have;
}
return have;
return s - (char *) data;
}
struct _IO_jump_t _IO_file_jumps =