* libio/iofopncook.c (_IO_cookie_seekoff): Define.  Mark offset as
	invalid to disable optimizations in fileops which won't work here.
	(_IO_cookie_jumps): Use it.
	(_IO_old_cookie_jumps): Likewise.
	* libio/fmemopen.c (fmemopen_seek): Result must be returned in *P,
	not the return value.
	* stdio-common/Makefile (tests): Add tst-fmemopen2.
	* stdio-common/tst-fmemopen2.c: New file.
This commit is contained in:
Ulrich Drepper 2005-01-06 00:42:22 +00:00
parent 6c4b3f1607
commit 1e7cceb99e
4 changed files with 32 additions and 10 deletions

View File

@ -1,5 +1,14 @@
2005-01-05 Ulrich Drepper <drepper@redhat.com>
* libio/iofopncook.c (_IO_cookie_seekoff): Define. Mark offset as
invalid to disable optimizations in fileops which won't work here.
(_IO_cookie_jumps): Use it.
(_IO_old_cookie_jumps): Likewise.
* libio/fmemopen.c (fmemopen_seek): Result must be returned in *P,
not the return value.
* stdio-common/Makefile (tests): Add tst-fmemopen2.
* stdio-common/tst-fmemopen2.c: New file.
* sysdeps/unix/sysv/linux/bits/waitflags.h: Define __WNOTHREAD.
2005-01-05 Roland McGrath <roland@redhat.com>

View File

@ -1,5 +1,5 @@
/* Fmemopen implementation.
Copyright (C) 2000, 2002 Free Software Foundation, Inc.
Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Hanno Mueller, kontakt@hanno.de, 2000.
@ -27,8 +27,6 @@
* but couldn't find it in libio. The following snippet of code is an
* attempt to implement what glibc's documentation describes.
*
* No, it isn't really tested yet. :-)
*
*
*
* I already see some potential problems:
@ -176,9 +174,9 @@ fmemopen_seek (void *cookie, _IO_off64_t *p, int w)
if (np < 0 || (size_t) np > c->size)
return -1;
c->pos = np;
*p = c->pos = np;
return np;
return 0;
}

View File

@ -1,4 +1,5 @@
/* Copyright (C) 1993,95,97,99,2000,2002,2004 Free Software Foundation, Inc.
/* Copyright (C) 1993,95,97,99,2000,2002,2004, 2005
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -94,6 +95,20 @@ _IO_cookie_close (fp)
}
static _IO_off64_t
_IO_cookie_seekoff (fp, offset, dir, mode)
_IO_FILE *fp;
_IO_off64_t offset;
int dir;
int mode;
{
/* We must force the fileops code to always use seek to determine
the position. */
fp->_offset = _IO_pos_BAD;
return INTUSE(_IO_file_seekoff) (fp, offset, dir, mode);
}
static const struct _IO_jump_t _IO_cookie_jumps = {
JUMP_INIT_DUMMY,
JUMP_INIT(finish, INTUSE(_IO_file_finish)),
@ -103,7 +118,7 @@ static const struct _IO_jump_t _IO_cookie_jumps = {
JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)),
JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
JUMP_INIT(seekoff, INTUSE(_IO_file_seekoff)),
JUMP_INIT(seekoff, _IO_cookie_seekoff),
JUMP_INIT(seekpos, _IO_default_seekpos),
JUMP_INIT(setbuf, INTUSE(_IO_file_setbuf)),
JUMP_INIT(sync, INTUSE(_IO_file_sync)),
@ -223,7 +238,7 @@ static const struct _IO_jump_t _IO_old_cookie_jumps = {
JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)),
JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
JUMP_INIT(seekoff, INTUSE(_IO_file_seekoff)),
JUMP_INIT(seekoff, _IO_cookie_seekoff),
JUMP_INIT(seekpos, _IO_default_seekpos),
JUMP_INIT(setbuf, INTUSE(_IO_file_setbuf)),
JUMP_INIT(sync, INTUSE(_IO_file_sync)),

View File

@ -1,4 +1,4 @@
# Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc.
# Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@ -53,7 +53,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
scanf11 scanf12 tst-tmpnam tst-cookie tst-obprintf tst-sscanf \
tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
tst-popen tst-unlockedio
tst-popen tst-unlockedio tst-fmemopen2
test-srcs = tst-unbputc tst-printf