Skip to content

Commit

Permalink
Returned interned string from fgetc()
Browse files Browse the repository at this point in the history
Make use of single-character interned strings.
  • Loading branch information
nikic committed Aug 16, 2021
1 parent a4c2fb1 commit 6e20f0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
1 change: 0 additions & 1 deletion Zend/Optimizer/zend_func_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ static const func_info_t func_infos[] = {
# endif
#endif
F1("popen", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("fgetc", MAY_BE_FALSE | MAY_BE_STRING),
F1("fgets", MAY_BE_FALSE | MAY_BE_STRING),
F1("fread", MAY_BE_FALSE | MAY_BE_STRING),
F1("fopen", MAY_BE_FALSE | MAY_BE_RESOURCE),
Expand Down
9 changes: 2 additions & 7 deletions ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,6 @@ PHPAPI PHP_FUNCTION(fgets)
PHPAPI PHP_FUNCTION(fgetc)
{
zval *res;
char buf[2];
int result;
php_stream *stream;

ZEND_PARSE_PARAMETERS_START(1, 1)
Expand All @@ -1079,15 +1077,12 @@ PHPAPI PHP_FUNCTION(fgetc)

PHP_STREAM_TO_ZVAL(stream, res);

result = php_stream_getc(stream);
int result = php_stream_getc(stream);

if (result == EOF) {
RETVAL_FALSE;
} else {
buf[0] = result;
buf[1] = '\0';

RETURN_STRINGL(buf, 1);
RETURN_CHAR(result);
}
}
/* }}} */
Expand Down

0 comments on commit 6e20f0f

Please sign in to comment.