Skip to content

Commit 2068217

Browse files
committed
support \f in trim, rtrim and ltrim
1 parent 77d306e commit 2068217

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,16 +2310,16 @@ function strcoll(string $string1, string $string2): int {}
23102310
* @frameless-function {"arity": 1}
23112311
* @frameless-function {"arity": 2}
23122312
*/
2313-
function trim(string $string, string $characters = " \n\r\t\v\0"): string {}
2313+
function trim(string $string, string $characters = " \f\n\r\t\v\0"): string {}
23142314

23152315
/** @compile-time-eval */
2316-
function rtrim(string $string, string $characters = " \n\r\t\v\0"): string {}
2316+
function rtrim(string $string, string $characters = " \f\n\r\t\v\0"): string {}
23172317

23182318
/** @alias rtrim */
2319-
function chop(string $string, string $characters = " \n\r\t\v\0"): string {}
2319+
function chop(string $string, string $characters = " \f\n\r\t\v\0"): string {}
23202320

23212321
/** @compile-time-eval */
2322-
function ltrim(string $string, string $characters = " \n\r\t\v\0"): string {}
2322+
function ltrim(string $string, string $characters = " \f\n\r\t\v\0"): string {}
23232323

23242324
/**
23252325
* @compile-time-eval

ext/standard/string.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static inline zend_result php_charmask(const unsigned char *input, size_t len, c
519519
* mode 1 : trim left
520520
* mode 2 : trim right
521521
* mode 3 : trim left and right
522-
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
522+
* what indicates which chars are to be trimmed. NULL->default (' \f\t\n\r\v\0')
523523
*/
524524
static zend_always_inline zend_string *php_trim_int(zend_string *str, const char *what, size_t what_len, int mode)
525525
{
@@ -576,7 +576,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
576576
unsigned char c = (unsigned char)*start;
577577

578578
if (c <= ' ' &&
579-
(c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
579+
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
580580
start++;
581581
} else {
582582
break;
@@ -588,7 +588,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
588588
unsigned char c = (unsigned char)*(end-1);
589589

590590
if (c <= ' ' &&
591-
(c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
591+
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
592592
end--;
593593
} else {
594594
break;
@@ -611,7 +611,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
611611
* mode 1 : trim left
612612
* mode 2 : trim right
613613
* mode 3 : trim left and right
614-
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
614+
* what indicates which chars are to be trimmed. NULL->default (' \f\t\n\r\v\0')
615615
*/
616616
PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode)
617617
{

tests/classes/tostring_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class test2
1212
function __toString()
1313
{
1414
echo __METHOD__ . "()\n";
15-
return "Converted\n";
15+
return "\fConverted\n";
1616
}
1717
}
1818

0 commit comments

Comments
 (0)