php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #2483 set_file_buffer return value
Submitted: 1999-10-10 17:51 UTC Modified: 2002-02-24 06:58 UTC
From: leon at leonatkinson dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0 OS: all
Private report: No CVE-ID: None
 [1999-10-10 17:51 UTC] leon at leonatkinson dot com
I know this is nit-picky, but...  Can someone change set_file_buffer() so that its return values are more like other PHP functions?  Right now it returns false when you pass it bad file handle, otherwise it returns whatever setvbuf returns.  But setvbuf() returns zero on success and non-negative if you pass it bad type argument.  The type is hard-coded, so it should always return zero.  Is there a problem with changing the return code from

  RETURN_LONG(ret);

to

  if(ret){
    php3_error(E_WARNING,"illegal value for setvbuf type",id);
    RETURN_FALSE;
    }
  else{
    RETURN_TRUE;
  }

which allows PHP code like

<?
  if(!set_file_buffer($fp))
  {
    print("New buffer size not set!");
  }

?>

Also, this sentence appears in my man page:
The setvbuf() function may be used after a stream is opened but before it is read or written.

It doesn't return any error when you try to do this, though, so it must just ignore the request.  How about adding a warning in PHP about trying to set the buffer size after a read or write?  Or is it too much overhead to track this info?

Thanks,
Leon

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-10 13:49 UTC] jimw@php.net
refiling against 4.0.
 [2001-11-11 14:29 UTC] sander@php.net
No need for this anymore as you can use "if($ret_value===false)" in PHP4.

 [2001-11-11 14:35 UTC] jeroen@php.net
Leon ment the other way around: the current behaviour is to return integers, instead of bools

Unfortunately, changing this is a BC problem...

I'm adding a warning at least now, but won't touch the return-value.

Reopened
 [2002-02-24 06:58 UTC] sander@php.net
I guess we can't change this anymore, so I'm closing this one.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 21:01:29 2024 UTC