Skip to content

Commit 3fd60d3

Browse files
committed
ext/spl: Refactor SplFileObject::fgetc()
1 parent f296cba commit 3fd60d3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

ext/spl/spl_directory.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,8 +2538,6 @@ PHP_METHOD(SplFileObject, fseek)
25382538
PHP_METHOD(SplFileObject, fgetc)
25392539
{
25402540
spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS));
2541-
char buf[2];
2542-
int result;
25432541

25442542
if (zend_parse_parameters_none() == FAILURE) {
25452543
RETURN_THROWS();
@@ -2549,18 +2547,16 @@ PHP_METHOD(SplFileObject, fgetc)
25492547

25502548
spl_filesystem_file_free_line(intern);
25512549

2552-
result = php_stream_getc(intern->u.file.stream);
2550+
int result = php_stream_getc(intern->u.file.stream);
25532551

25542552
if (result == EOF) {
25552553
RETURN_FALSE;
25562554
}
25572555
if (result == '\n') {
25582556
intern->u.file.current_line_num++;
25592557
}
2560-
buf[0] = result;
2561-
buf[1] = '\0';
25622558

2563-
RETURN_STRINGL(buf, 1);
2559+
RETURN_STR(ZSTR_CHAR((zend_uchar)result));
25642560
} /* }}} */
25652561

25662562
/* {{{ Output all remaining data from a file pointer */

0 commit comments

Comments
 (0)