Mail Archives: djgpp-workers/2001/10/14/04:35:40
Hello.
fgetpos doesn't check the return code from ftell. Below is a patch that
fixes this. Looking at Unix98 I see that fgetpos and ftell return the same
error codes.
One thing that worries me is that ftell could return a negative offset.
But I think we now use negative off_t to mean the 2GB of >2GB files. So
maybe this isn't a problem.
OK to commit?
Bye, Rich =]
--
Richard Dawe
http://www.phekda.freeserve.co.uk/richdawe/
Index: src/libc/ansi/stdio/fgetpos.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/stdio/fgetpos.c,v
retrieving revision 1.1
diff -p -c -3 -r1.1 fgetpos.c
*** src/libc/ansi/stdio/fgetpos.c 1994/12/13 10:01:28 1.1
--- src/libc/ansi/stdio/fgetpos.c 2001/10/14 08:29:57
***************
*** 5,14 ****
int
fgetpos(FILE *stream, fpos_t *pos)
{
if (stream && pos)
{
! *pos = (fpos_t)ftell(stream);
! return 0;
}
errno = EFAULT;
return 1;
--- 5,25 ----
int
fgetpos(FILE *stream, fpos_t *pos)
{
+ int ret;
+
if (stream && pos)
{
! ret = (fpos_t)ftell(stream);
! if (ret != -1)
! {
! *pos = ret;
! return 0;
! }
! else
! {
! /* ftell will have set errno appropriately. */
! return -1;
! }
}
errno = EFAULT;
return 1;
- Raw text -