Skip to content

Commit 6096c8b

Browse files
committed
ext/standard/head.c: no need to rely on ZEND_NUM_ARGS()
1 parent 3ce7623 commit 6096c8b

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

ext/standard/head.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -294,39 +294,34 @@ PHP_FUNCTION(setrawcookie)
294294
/* {{{ Returns true if headers have already been sent, false otherwise */
295295
PHP_FUNCTION(headers_sent)
296296
{
297-
zval *arg1 = NULL, *arg2 = NULL;
298-
const char *file="";
299-
int line=0;
297+
zval *by_ref_filename = NULL;
298+
zval *by_ref_line = NULL;
299+
const char *file = "";
300+
int line = 0;
300301

301302
ZEND_PARSE_PARAMETERS_START(0, 2)
302303
Z_PARAM_OPTIONAL
303-
Z_PARAM_ZVAL(arg1)
304-
Z_PARAM_ZVAL(arg2)
304+
Z_PARAM_ZVAL(by_ref_filename)
305+
Z_PARAM_ZVAL(by_ref_line)
305306
ZEND_PARSE_PARAMETERS_END();
306307

307308
if (SG(headers_sent)) {
308309
line = php_output_get_start_lineno();
309310
file = php_output_get_start_filename();
310311
}
311312

312-
switch(ZEND_NUM_ARGS()) {
313-
case 2:
314-
ZEND_TRY_ASSIGN_REF_LONG(arg2, line);
315-
ZEND_FALLTHROUGH;
316-
case 1:
313+
if (by_ref_filename) {
317314
if (file) {
318-
ZEND_TRY_ASSIGN_REF_STRING(arg1, file);
315+
ZEND_TRY_ASSIGN_REF_STRING(by_ref_filename, file);
319316
} else {
320-
ZEND_TRY_ASSIGN_REF_EMPTY_STRING(arg1);
317+
ZEND_TRY_ASSIGN_REF_EMPTY_STRING(by_ref_filename);
321318
}
322-
break;
323319
}
324-
325-
if (SG(headers_sent)) {
326-
RETURN_TRUE;
327-
} else {
328-
RETURN_FALSE;
320+
if (by_ref_line) {
321+
ZEND_TRY_ASSIGN_REF_LONG(by_ref_line, line);
329322
}
323+
324+
RETURN_BOOL(SG(headers_sent));
330325
}
331326
/* }}} */
332327

0 commit comments

Comments
 (0)