Sender: rich AT phekda DOT freeserve DOT co DOT uk Message-ID: <3BC94DFF.69F35BA0@phekda.freeserve.co.uk> Date: Sun, 14 Oct 2001 09:34:07 +0100 From: Richard Dawe X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586) X-Accept-Language: de,fr MIME-Version: 1.0 To: DJGPP workers Subject: fgetpos doesn't check ftell's return code Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com 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;