Fri 27 Jul 2007 11:00:04 PM UTC, comment #3:
>Maybe it's possible for two distinct pointers to be associated
>with the same stdio stream, or perhaps it could fail after a call
>to freopen ?? I don't know.
My goal here is that if you use fn_open("-", <mode>) and thereby get a standard stream out of it, then fn_close("-", <stream>) won't close that standard stream. What you're saying can't happen in ISO C, which doesn't allow the standard streams to be assigned to, and freopen always returns the same FILE * that it is passed. In the GNU C library, you can actually assign new streams to stdin/out/err, so the problem could arise, but it's a bad idea to assign to them and PSPP (and gnulib) doesn't do that.
I considered using dup and fdopen to actually duplicate the standard streams instead of just trying to detect them. But that's troublesome for another reason: we'd have to be pretty careful about calling fflush in the right places to avoid interleaving output strangely.
>Perhaps it would be better to use
> if ( fileno(f) == STDIN_FILENO || ...
I don't know why I bothered to write all the text above. I think your solution is fine. I'll do that.
>2. I'll assume that the HAVE_LIBTERMCAP vs. HAVE_LIBNCURSES
>change is correct.
I think it is: that code didn't do anything before and now it appears to work in testing.
Thanks! I checked this in.
|