@@ -339,33 +339,33 @@ static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN };
339
339
Portable file locking */
340
340
PHP_FUNCTION (flock )
341
341
{
342
- zval * arg1 , * arg3 = NULL ;
342
+ zval * res , * wouldblock = NULL ;
343
343
int act ;
344
344
php_stream * stream ;
345
345
zend_long operation = 0 ;
346
346
347
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rl|z/ " , & arg1 , & operation , & arg3 ) == FAILURE ) {
347
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rl|z" , & res , & operation , & wouldblock ) == FAILURE ) {
348
348
return ;
349
349
}
350
350
351
- PHP_STREAM_TO_ZVAL (stream , arg1 );
351
+ PHP_STREAM_TO_ZVAL (stream , res );
352
352
353
353
act = operation & 3 ;
354
354
if (act < 1 || act > 3 ) {
355
355
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Illegal operation argument ");
356
356
RETURN_FALSE ;
357
357
}
358
358
359
- if (arg3 ) {
360
- zval_dtor (arg3 );
361
- ZVAL_LONG (arg3 , 0 );
359
+ if (wouldblock ) {
360
+ zval_dtor (wouldblock );
361
+ ZVAL_LONG (wouldblock , 0 );
362
362
}
363
363
364
364
/* flock_values contains all possible actions if (operation & 4) we won't block on the lock */
365
365
act = flock_values [act - 1 ] | (operation & PHP_LOCK_NB ? LOCK_NB : 0 );
366
366
if (php_stream_lock (stream , act )) {
367
- if (operation && errno == EWOULDBLOCK && arg3 ) {
368
- ZVAL_LONG (arg3 , 1 );
367
+ if (operation && errno == EWOULDBLOCK && wouldblock ) {
368
+ ZVAL_LONG (wouldblock , 1 );
369
369
}
370
370
RETURN_FALSE ;
371
371
}
@@ -887,20 +887,20 @@ PHP_NAMED_FUNCTION(php_if_fopen)
887
887
Close an open file pointer */
888
888
PHPAPI PHP_FUNCTION (fclose )
889
889
{
890
- zval * arg1 ;
890
+ zval * res ;
891
891
php_stream * stream ;
892
892
893
893
#ifndef FAST_ZPP
894
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & arg1 ) == FAILURE ) {
894
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & res ) == FAILURE ) {
895
895
RETURN_FALSE ;
896
896
}
897
897
#else
898
898
ZEND_PARSE_PARAMETERS_START (1 , 1 )
899
- Z_PARAM_RESOURCE (arg1 )
899
+ Z_PARAM_RESOURCE (res )
900
900
ZEND_PARSE_PARAMETERS_END_EX (RETURN_FALSE );
901
901
#endif
902
902
903
- PHP_STREAM_TO_ZVAL (stream , arg1 );
903
+ PHP_STREAM_TO_ZVAL (stream , res );
904
904
905
905
if ((stream -> flags & PHP_STREAM_FLAG_NO_FCLOSE ) != 0 ) {
906
906
php_error_docref (NULL TSRMLS_CC , E_WARNING , "%pd is not a valid stream resource" , stream -> res -> handle );
@@ -965,14 +965,14 @@ PHP_FUNCTION(popen)
965
965
Close a file pointer opened by popen() */
966
966
PHP_FUNCTION (pclose )
967
967
{
968
- zval * arg1 ;
968
+ zval * res ;
969
969
php_stream * stream ;
970
970
971
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & arg1 ) == FAILURE ) {
971
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & res ) == FAILURE ) {
972
972
RETURN_FALSE ;
973
973
}
974
974
975
- PHP_STREAM_TO_ZVAL (stream , arg1 );
975
+ PHP_STREAM_TO_ZVAL (stream , res );
976
976
977
977
FG (pclose_wait ) = 1 ;
978
978
zend_list_close (stream -> res );
@@ -985,14 +985,14 @@ PHP_FUNCTION(pclose)
985
985
Test for end-of-file on a file pointer */
986
986
PHPAPI PHP_FUNCTION (feof )
987
987
{
988
- zval * arg1 ;
988
+ zval * res ;
989
989
php_stream * stream ;
990
990
991
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & arg1 ) == FAILURE ) {
991
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & res ) == FAILURE ) {
992
992
RETURN_FALSE ;
993
993
}
994
994
995
- PHP_STREAM_TO_ZVAL (stream , arg1 );
995
+ PHP_STREAM_TO_ZVAL (stream , res );
996
996
997
997
if (php_stream_eof (stream )) {
998
998
RETURN_TRUE ;
@@ -1006,18 +1006,18 @@ PHPAPI PHP_FUNCTION(feof)
1006
1006
Get a line from file pointer */
1007
1007
PHPAPI PHP_FUNCTION (fgets )
1008
1008
{
1009
- zval * arg1 ;
1009
+ zval * res ;
1010
1010
zend_long len = 1024 ;
1011
1011
char * buf = NULL ;
1012
1012
int argc = ZEND_NUM_ARGS ();
1013
1013
size_t line_len = 0 ;
1014
1014
php_stream * stream ;
1015
1015
1016
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r|l" , & arg1 , & len ) == FAILURE ) {
1016
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r|l" , & res , & len ) == FAILURE ) {
1017
1017
RETURN_FALSE ;
1018
1018
}
1019
1019
1020
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1020
+ PHP_STREAM_TO_ZVAL (stream , res );
1021
1021
1022
1022
if (argc == 1 ) {
1023
1023
/* ask streams to give us a buffer of an appropriate size */
@@ -1062,16 +1062,16 @@ PHPAPI PHP_FUNCTION(fgets)
1062
1062
Get a character from file pointer */
1063
1063
PHPAPI PHP_FUNCTION (fgetc )
1064
1064
{
1065
- zval * arg1 ;
1065
+ zval * res ;
1066
1066
char buf [2 ];
1067
1067
int result ;
1068
1068
php_stream * stream ;
1069
1069
1070
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & arg1 ) == FAILURE ) {
1070
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & res ) == FAILURE ) {
1071
1071
RETURN_FALSE ;
1072
1072
}
1073
1073
1074
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1074
+ PHP_STREAM_TO_ZVAL (stream , res );
1075
1075
1076
1076
result = php_stream_getc (stream );
1077
1077
@@ -1193,39 +1193,31 @@ PHP_FUNCTION(fscanf)
1193
1193
Binary-safe file write */
1194
1194
PHPAPI PHP_FUNCTION (fwrite )
1195
1195
{
1196
- zval * arg1 ;
1197
- char * arg2 ;
1198
- size_t arg2len ;
1196
+ zval * res ;
1197
+ char * input ;
1198
+ size_t inputlen ;
1199
1199
size_t ret ;
1200
1200
size_t num_bytes ;
1201
- zend_long arg3 = 0 ;
1202
- char * buffer = NULL ;
1201
+ zend_long maxlen = 0 ;
1203
1202
php_stream * stream ;
1204
1203
1205
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rs|l" , & arg1 , & arg2 , & arg2len , & arg3 ) == FAILURE ) {
1204
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rs|l" , & res , & input , & inputlen , & maxlen ) == FAILURE ) {
1206
1205
RETURN_FALSE ;
1207
1206
}
1208
1207
1209
1208
if (ZEND_NUM_ARGS () == 2 ) {
1210
- num_bytes = arg2len ;
1209
+ num_bytes = inputlen ;
1211
1210
} else {
1212
- if (arg3 > 0 ) {
1213
- num_bytes = MIN ((size_t )arg3 , arg2len );
1214
- } else {
1215
- num_bytes = 0 ;
1216
- }
1211
+ num_bytes = MAX (0 , MIN ((size_t ) maxlen , inputlen ));
1217
1212
}
1218
1213
1219
1214
if (!num_bytes ) {
1220
1215
RETURN_LONG (0 );
1221
1216
}
1222
1217
1223
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1218
+ PHP_STREAM_TO_ZVAL (stream , res );
1224
1219
1225
- ret = php_stream_write (stream , buffer ? buffer : arg2 , num_bytes );
1226
- if (buffer ) {
1227
- efree (buffer );
1228
- }
1220
+ ret = php_stream_write (stream , input , num_bytes );
1229
1221
1230
1222
RETURN_LONG (ret );
1231
1223
}
@@ -1235,15 +1227,15 @@ PHPAPI PHP_FUNCTION(fwrite)
1235
1227
Flushes output */
1236
1228
PHPAPI PHP_FUNCTION (fflush )
1237
1229
{
1238
- zval * arg1 ;
1230
+ zval * res ;
1239
1231
int ret ;
1240
1232
php_stream * stream ;
1241
1233
1242
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & arg1 ) == FAILURE ) {
1234
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & res ) == FAILURE ) {
1243
1235
RETURN_FALSE ;
1244
1236
}
1245
1237
1246
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1238
+ PHP_STREAM_TO_ZVAL (stream , res );
1247
1239
1248
1240
ret = php_stream_flush (stream );
1249
1241
if (ret ) {
@@ -1257,14 +1249,14 @@ PHPAPI PHP_FUNCTION(fflush)
1257
1249
Rewind the position of a file pointer */
1258
1250
PHPAPI PHP_FUNCTION (rewind )
1259
1251
{
1260
- zval * arg1 ;
1252
+ zval * res ;
1261
1253
php_stream * stream ;
1262
1254
1263
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & arg1 ) == FAILURE ) {
1255
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & res ) == FAILURE ) {
1264
1256
RETURN_FALSE ;
1265
1257
}
1266
1258
1267
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1259
+ PHP_STREAM_TO_ZVAL (stream , res );
1268
1260
1269
1261
if (-1 == php_stream_rewind (stream )) {
1270
1262
RETURN_FALSE ;
@@ -1277,15 +1269,15 @@ PHPAPI PHP_FUNCTION(rewind)
1277
1269
Get file pointer's read/write position */
1278
1270
PHPAPI PHP_FUNCTION (ftell )
1279
1271
{
1280
- zval * arg1 ;
1272
+ zval * res ;
1281
1273
zend_long ret ;
1282
1274
php_stream * stream ;
1283
1275
1284
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & arg1 ) == FAILURE ) {
1276
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & res ) == FAILURE ) {
1285
1277
RETURN_FALSE ;
1286
1278
}
1287
1279
1288
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1280
+ PHP_STREAM_TO_ZVAL (stream , res );
1289
1281
1290
1282
ret = php_stream_tell (stream );
1291
1283
if (ret == -1 ) {
@@ -1299,17 +1291,17 @@ PHPAPI PHP_FUNCTION(ftell)
1299
1291
Seek on a file pointer */
1300
1292
PHPAPI PHP_FUNCTION (fseek )
1301
1293
{
1302
- zval * arg1 ;
1303
- zend_long arg2 , whence = SEEK_SET ;
1294
+ zval * res ;
1295
+ zend_long offset , whence = SEEK_SET ;
1304
1296
php_stream * stream ;
1305
1297
1306
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rl|l" , & arg1 , & arg2 , & whence ) == FAILURE ) {
1298
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rl|l" , & res , & offset , & whence ) == FAILURE ) {
1307
1299
RETURN_FALSE ;
1308
1300
}
1309
1301
1310
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1302
+ PHP_STREAM_TO_ZVAL (stream , res );
1311
1303
1312
- RETURN_LONG (php_stream_seek (stream , arg2 , (int )whence ));
1304
+ RETURN_LONG (php_stream_seek (stream , offset , (int ) whence ));
1313
1305
}
1314
1306
/* }}} */
1315
1307
@@ -1411,7 +1403,7 @@ PHP_FUNCTION(readfile)
1411
1403
Return or change the umask */
1412
1404
PHP_FUNCTION (umask )
1413
1405
{
1414
- zend_long arg1 = 0 ;
1406
+ zend_long mask = 0 ;
1415
1407
int oldumask ;
1416
1408
1417
1409
oldumask = umask (077 );
@@ -1420,14 +1412,14 @@ PHP_FUNCTION(umask)
1420
1412
BG (umask ) = oldumask ;
1421
1413
}
1422
1414
1423
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|l" , & arg1 ) == FAILURE ) {
1415
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|l" , & mask ) == FAILURE ) {
1424
1416
RETURN_FALSE ;
1425
1417
}
1426
1418
1427
1419
if (ZEND_NUM_ARGS () == 0 ) {
1428
1420
umask (oldumask );
1429
1421
} else {
1430
- umask ((int )arg1 );
1422
+ umask ((int ) mask );
1431
1423
}
1432
1424
1433
1425
RETURN_LONG (oldumask );
@@ -1438,15 +1430,15 @@ PHP_FUNCTION(umask)
1438
1430
Output all remaining data from a file pointer */
1439
1431
PHPAPI PHP_FUNCTION (fpassthru )
1440
1432
{
1441
- zval * arg1 ;
1433
+ zval * res ;
1442
1434
size_t size ;
1443
1435
php_stream * stream ;
1444
1436
1445
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & arg1 ) == FAILURE ) {
1437
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "r" , & res ) == FAILURE ) {
1446
1438
RETURN_FALSE ;
1447
1439
}
1448
1440
1449
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1441
+ PHP_STREAM_TO_ZVAL (stream , res );
1450
1442
1451
1443
size = php_stream_passthru (stream );
1452
1444
RETURN_LONG (size );
@@ -1780,15 +1772,15 @@ PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_flg, php
1780
1772
Binary-safe file read */
1781
1773
PHPAPI PHP_FUNCTION (fread )
1782
1774
{
1783
- zval * arg1 ;
1775
+ zval * res ;
1784
1776
zend_long len ;
1785
1777
php_stream * stream ;
1786
1778
1787
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rl" , & arg1 , & len ) == FAILURE ) {
1779
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "rl" , & res , & len ) == FAILURE ) {
1788
1780
RETURN_FALSE ;
1789
1781
}
1790
1782
1791
- PHP_STREAM_TO_ZVAL (stream , arg1 );
1783
+ PHP_STREAM_TO_ZVAL (stream , res );
1792
1784
1793
1785
if (len <= 0 ) {
1794
1786
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Length parameter must be greater than 0" );
0 commit comments