Re: Should fopen() succeed on a directory?

2007-01-19 Thread Otto Moerbeek
On Fri, 19 Jan 2007, Tobias Ulmer wrote: > On Fri, Jan 19, 2007 at 11:07:14AM -0500, Adam wrote: > > Darrin Chandler <[EMAIL PROTECTED]> wrote: > > > > > On Thu, Jan 18, 2007 at 05:17:50PM -0500, Adam wrote: > > > > Why does fopen()ing a directory for reading succeed instead of failing > > > > wi

Re: Should fopen() succeed on a directory?

2007-01-19 Thread Tobias Ulmer
On Fri, Jan 19, 2007 at 11:07:14AM -0500, Adam wrote: > Darrin Chandler <[EMAIL PROTECTED]> wrote: > > > On Thu, Jan 18, 2007 at 05:17:50PM -0500, Adam wrote: > > > Why does fopen()ing a directory for reading succeed instead of failing > > > with EISDIR? This has the possibly unexpected consequen

Re: Should fopen() succeed on a directory?

2007-01-19 Thread Matthew R. Dempsky
On Fri, Jan 19, 2007 at 11:07:14AM -0500, Adam wrote: > If you can't fread() from a stream > that is associated with a directory, then why associate the stream with > a directory in the first place? Does the C (or any) standard say it should fail? fopen(3) works on directories under Linux and Sol

Re: Should fopen() succeed on a directory?

2007-01-19 Thread Adam
Darrin Chandler <[EMAIL PROTECTED]> wrote: > On Thu, Jan 18, 2007 at 05:17:50PM -0500, Adam wrote: > > Why does fopen()ing a directory for reading succeed instead of failing > > with EISDIR? This has the possibly unexpected consequence of letting > > you pass yyin to yylex() as a fopen()ed direct

Re: Should fopen() succeed on a directory?

2007-01-18 Thread Darrin Chandler
On Thu, Jan 18, 2007 at 05:17:50PM -0500, Adam wrote: > Why does fopen()ing a directory for reading succeed instead of failing > with EISDIR? This has the possibly unexpected consequence of letting > you pass yyin to yylex() as a fopen()ed directory, which then thinks it > finished successfully be

Re: Should fopen() succeed on a directory?

2007-01-18 Thread Marco S Hyman
Adam writes: > Why does fopen()ing a directory for reading succeed instead of failing > with EISDIR? This has the possibly unexpected consequence of letting I believe it is so things like "grep -r regex *" work. // marc

Should fopen() succeed on a directory?

2007-01-18 Thread Adam
Why does fopen()ing a directory for reading succeed instead of failing with EISDIR? This has the possibly unexpected consequence of letting you pass yyin to yylex() as a fopen()ed directory, which then thinks it finished successfully because fread() returns 0 immediately. Adam