]> granicus.if.org Git - php/commitdiff
Merge remote-tracking branch 'origin/PHP-5.6'
authorBob Weinand <bobwei9@hotmail.com>
Tue, 4 Nov 2014 16:16:49 +0000 (17:16 +0100)
committerBob Weinand <bobwei9@hotmail.com>
Tue, 4 Nov 2014 16:16:49 +0000 (17:16 +0100)
Conflicts:
ext/standard/file.c

1  2 
ext/standard/file.c

index ff7c5433ebe51ccfd932a6506ac2d179273f441a,a2b4db154a65522307f35d7916ec0f7247e5db1a..97ffe694535f0e6ac53d0f92389b681cd54a5464
@@@ -339,16 -339,16 +339,16 @@@ static int flock_values[] = { LOCK_SH, 
     Portable file locking */
  PHP_FUNCTION(flock)
  {
-       zval *arg1, *arg3 = NULL;
+       zval *res, *wouldblock = NULL;
        int act;
        php_stream *stream;
 -      long operation = 0;
 +      zend_long operation = 0;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &arg1, &operation, &arg3) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &res, &operation, &wouldblock) == FAILURE) {
                return;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        act = operation & 3;
        if (act < 1 || act > 3) {
                RETURN_FALSE;
        }
  
-       if (arg3) {
-               zval_dtor(arg3);
-               ZVAL_LONG(arg3, 0);
 -      if (wouldblock && PZVAL_IS_REF(wouldblock)) {
 -              convert_to_long_ex(&wouldblock);
 -              Z_LVAL_P(wouldblock) = 0;
++      if (wouldblock) {
++              zval_dtor(wouldblock);
++              ZVAL_LONG(wouldblock, 0);
        }
  
        /* flock_values contains all possible actions if (operation & 4) we won't block on the lock */
        act = flock_values[act - 1] | (operation & PHP_LOCK_NB ? LOCK_NB : 0);
        if (php_stream_lock(stream, act)) {
-               if (operation && errno == EWOULDBLOCK && arg3) {
-                       ZVAL_LONG(arg3, 1);
 -              if (operation && errno == EWOULDBLOCK && wouldblock && PZVAL_IS_REF(wouldblock)) {
 -                      Z_LVAL_P(wouldblock) = 1;
++              if (operation && errno == EWOULDBLOCK && wouldblock) {
++                      ZVAL_LONG(wouldblock, 1);
                }
                RETURN_FALSE;
        }
@@@ -887,23 -896,17 +887,23 @@@ PHP_NAMED_FUNCTION(php_if_fopen
     Close an open file pointer */
  PHPAPI PHP_FUNCTION(fclose)
  {
-       zval *arg1;
+       zval *res;
        php_stream *stream;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
 +#ifndef FAST_ZPP
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) {
                RETURN_FALSE;
        }
-               Z_PARAM_RESOURCE(arg1)
 +#else
 +      ZEND_PARSE_PARAMETERS_START(1, 1)
++              Z_PARAM_RESOURCE(res)
 +      ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 +#endif
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) {
 -              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid stream resource", stream->rsrc_id);
 +              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%pd is not a valid stream resource", stream->res->handle);
                RETURN_FALSE;
        }
  
@@@ -972,10 -975,10 +972,10 @@@ PHP_FUNCTION(pclose
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        FG(pclose_wait) = 1;
 -      zend_list_delete(stream->rsrc_id);
 +      zend_list_close(stream->res);
        FG(pclose_wait) = 0;
        RETURN_LONG(FG(pclose_ret));
  }
@@@ -992,7 -995,7 +992,7 @@@ PHPAPI PHP_FUNCTION(feof
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        if (php_stream_eof(stream)) {
                RETURN_TRUE;
     Get a line from file pointer */
  PHPAPI PHP_FUNCTION(fgets)
  {
-       zval *arg1;
+       zval *res;
 -      long len = 1024;
 +      zend_long len = 1024;
        char *buf = NULL;
        int argc = ZEND_NUM_ARGS();
        size_t line_len = 0;
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        if (argc == 1) {
                /* ask streams to give us a buffer of an appropriate size */
@@@ -1071,7 -1069,7 +1071,7 @@@ PHPAPI PHP_FUNCTION(fgetc
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        result = php_stream_getc(stream);
  
@@@ -1193,39 -1180,31 +1193,31 @@@ PHP_FUNCTION(fscanf
     Binary-safe file write */
  PHPAPI PHP_FUNCTION(fwrite)
  {
-       zval *arg1;
-       char *arg2;
-       size_t arg2len;
+       zval *res;
+       char *input;
 -      int inputlen;
 -      int ret;
 -      int num_bytes;
 -      long maxlen = 0;
++      size_t inputlen;
 +      size_t ret;
 +      size_t num_bytes;
-       zend_long arg3 = 0;
-       char *buffer = NULL;
++      zend_long maxlen = 0;
        php_stream *stream;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &arg2, &arg2len, &arg3) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &res, &input, &inputlen, &maxlen) == FAILURE) {
                RETURN_FALSE;
        }
  
        if (ZEND_NUM_ARGS() == 2) {
-               num_bytes = arg2len;
+               num_bytes = inputlen;
        } else {
-               if (arg3 > 0) {
-                       num_bytes = MIN((size_t)arg3, arg2len);
-               } else {
-                       num_bytes = 0;
-               }
 -              num_bytes = MAX(0, MIN((int) maxlen, inputlen));
++              num_bytes = MAX(0, MIN((size_t) maxlen, inputlen));
        }
  
        if (!num_bytes) {
                RETURN_LONG(0);
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
-       ret = php_stream_write(stream, buffer ? buffer : arg2, num_bytes);
-       if (buffer) {
-               efree(buffer);
-       }
+       ret = php_stream_write(stream, input, num_bytes);
  
        RETURN_LONG(ret);
  }
@@@ -1243,7 -1222,7 +1235,7 @@@ PHPAPI PHP_FUNCTION(fflush
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        ret = php_stream_flush(stream);
        if (ret) {
@@@ -1264,7 -1243,7 +1256,7 @@@ PHPAPI PHP_FUNCTION(rewind
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        if (-1 == php_stream_rewind(stream)) {
                RETURN_FALSE;
     Get file pointer's read/write position */
  PHPAPI PHP_FUNCTION(ftell)
  {
-       zval *arg1;
+       zval *res;
 -      long ret;
 +      zend_long ret;
        php_stream *stream;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) {
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        ret = php_stream_tell(stream);
        if (ret == -1)  {
     Seek on a file pointer */
  PHPAPI PHP_FUNCTION(fseek)
  {
-       zval *arg1;
-       zend_long arg2, whence = SEEK_SET;
+       zval *res;
 -      long offset, whence = SEEK_SET;
++      zend_long offset, whence = SEEK_SET;
        php_stream *stream;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &arg2, &whence) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &res, &offset, &whence) == FAILURE) {
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
-       RETURN_LONG(php_stream_seek(stream, arg2, (int)whence));
 -      RETURN_LONG(php_stream_seek(stream, offset, whence));
++      RETURN_LONG(php_stream_seek(stream, offset, (int) whence));
  }
  /* }}} */
  
@@@ -1411,7 -1390,7 +1403,7 @@@ PHP_FUNCTION(readfile
     Return or change the umask */
  PHP_FUNCTION(umask)
  {
-       zend_long arg1 = 0;
 -      long mask = 0;
++      zend_long mask = 0;
        int oldumask;
  
        oldumask = umask(077);
        if (ZEND_NUM_ARGS() == 0) {
                umask(oldumask);
        } else {
-               umask((int)arg1);
 -              umask(mask);
++              umask((int) mask);
        }
  
        RETURN_LONG(oldumask);
     Output all remaining data from a file pointer */
  PHPAPI PHP_FUNCTION(fpassthru)
  {
-       zval *arg1;
+       zval *res;
 -      int size;
 +      size_t size;
        php_stream *stream;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) {
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        size = php_stream_passthru(stream);
        RETURN_LONG(size);
@@@ -1780,15 -1747,15 +1772,15 @@@ safe_to_copy
     Binary-safe file read */
  PHPAPI PHP_FUNCTION(fread)
  {
-       zval *arg1;
+       zval *res;
 -      long len;
 +      zend_long len;
        php_stream *stream;
  
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &res, &len) == FAILURE) {
                RETURN_FALSE;
        }
  
-       PHP_STREAM_TO_ZVAL(stream, arg1);
 -      PHP_STREAM_TO_ZVAL(stream, &res);
++      PHP_STREAM_TO_ZVAL(stream, res);
  
        if (len <= 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0");