[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib portability issues
From: |
Paul Eggert |
Subject: |
Re: gnulib portability issues |
Date: |
Sat, 09 Jun 2012 22:01:38 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 |
On 06/09/2012 09:25 PM, Rich Felker wrote:
> For seekable input, comparing ftello(f) and the underlying fd offset
> from lseek(fileno(f),0,SEEK_CUR) would work, but that also will fail
> for non-seekable input.
Thanks, that's better than what I wrote. Perhaps you could write up
a patch along those lines. At least it will work for seekable files.
Come to think of it, a variant might even work for seekable files.
Use dup2 to move the file descriptor somewhere else. Close the
fd. Keep reading until error, and count the bytes read. Then
ungetc all the bytes that you read, in reverse order, and restore
the file descriptor. Of course ISO C doesn't guarantee this, but
it should be fairly portable in practice.
> it might be better to make sense of WHY it's needed/wanted
Yes, quite true, but that information wasn't communicated to the
gnulib mailing list.
- gnulib portability issues, Rich Felker, 2012/06/09
- Re: gnulib portability issues, Paul Eggert, 2012/06/10
- Re: gnulib portability issues, Rich Felker, 2012/06/10
- Re: gnulib portability issues,
Paul Eggert <=
- Re: gnulib portability issues, Rich Felker, 2012/06/10
- Re: gnulib portability issues, Paul Eggert, 2012/06/10
- Re: gnulib portability issues, Eric Blake, 2012/06/11
- Re: gnulib portability issues, Rich Felker, 2012/06/11
- Re: gnulib portability issues, Ben Pfaff, 2012/06/12
- Re: gnulib portability issues, Eric Blake, 2012/06/12
- Re: gnulib portability issues, Rich Felker, 2012/06/12
- Re: gnulib portability issues, Eric Blake, 2012/06/12
- Re: gnulib portability issues, Rich Felker, 2012/06/10
- Re: gnulib portability issues, Paul Eggert, 2012/06/10