You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "Aaron M. Folmsbee" <aa...@folmsbee.com> on 2002/03/13 08:38:43 UTC

apr_file_gets return code


apr_file_gets returns APR_EOF if it encounters an eof condition ( or any
error condition...) while there is still room left in the read buffer. 
This means that APR_EOF is returned if you read the last line in a file
with a buffer larger then the last line. I would submit that the correct
behaviour is to return success if anything is read before encountering
the eof.

RE: apr_file_gets return code

Posted by Ryan Bloom <rb...@covalent.net>.
Just a word to the wise, there are apps out there that rely on this
behavior.  Apache is one of them, so if you modify this, please double
check Apache at the same time.

Ryan

----------------------------------------------
Ryan Bloom                  rbb@covalent.net
645 Howard St.              rbb@apache.org
San Francisco, CA 

> -----Original Message-----
> From: trawick@rdu88-250-166.nc.rr.com [mailto:trawick@rdu88-250-
> 166.nc.rr.com] On Behalf Of Jeff Trawick
> Sent: Wednesday, March 13, 2002 6:55 AM
> To: Aaron M. Folmsbee
> Cc: dev@apr.apache.org
> Subject: Re: apr_file_gets return code
> 
> "Aaron M. Folmsbee" <aa...@folmsbee.com> writes:
> 
> > apr_file_gets returns APR_EOF if it encounters an eof condition ( or
any
> > error condition...) while there is still room left in the read
buffer.
> > This means that APR_EOF is returned if you read the last line in a
file
> > with a buffer larger then the last line. I would submit that the
correct
> > behaviour is to return success if anything is read before
encountering
> > the eof.
> 
> I think I agree with your comment about the proper behavior: It should
> return APR_SUCCESS if it read any bytes into the caller's buffer.
> 
> What OS did you encounter the problem on?
> 
> Was there a '\n' at the end of the file?
> 
> Do you have a patch?
> 
> --
> Jeff Trawick | trawick@attglobal.net
> Born in Roswell... married an alien...


Re: apr_file_gets return code

Posted by Jeff Trawick <tr...@attglobal.net>.
"Aaron M. Folmsbee" <aa...@folmsbee.com> writes:

> apr_file_gets returns APR_EOF if it encounters an eof condition ( or any
> error condition...) while there is still room left in the read buffer. 
> This means that APR_EOF is returned if you read the last line in a file
> with a buffer larger then the last line. I would submit that the correct
> behaviour is to return success if anything is read before encountering
> the eof.

I think I agree with your comment about the proper behavior: It should
return APR_SUCCESS if it read any bytes into the caller's buffer.

What OS did you encounter the problem on?

Was there a '\n' at the end of the file?

Do you have a patch?

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

RE: apr_file_gets return code

Posted by Ryan Bloom <rb...@covalent.net>.
This has been discussed before, and the decision was that return EOF
allows programmers to notice the EOF immediately and not call
apr_file_gets again.  That decision can be changed, but I rather like
that I can remove one call to the function.

 

Ryan

 

----------------------------------------------
Ryan Bloom                  rbb@covalent.net
645 Howard St.              rbb@apache.org
San Francisco, CA 

-----Original Message-----
From: Aaron M. Folmsbee [mailto:aaron@folmsbee.com] 
Sent: Tuesday, March 12, 2002 11:39 PM
To: dev@apr.apache.org
Subject: apr_file_gets return code

 



apr_file_gets returns APR_EOF if it encounters an eof condition ( or any
error condition...) while there is still room left in the read buffer.
This means that APR_EOF is returned if you read the last line in a file
with a buffer larger then the last line. I would submit that the correct
behaviour is to return success if anything is read before encountering
the eof.