1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 00:18:23 +02:00
Commit Graph

1319 Commits

Author SHA1 Message Date
Takuya Aramaki 5528df1a20 Fix TypeError message of setlocale() (#20625) 2025-12-06 18:06:19 +01:00
Gina Peter Banyard 93676a0425 ext/standard: Deprecate passing string which are not one byte long to ord() (#19440)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_string_which_are_not_one_byte_long_to_ord

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-09-14 11:42:59 +01:00
Alexandre Daubois 29c7ee4cd4 Add a 1-char fastpath to implode() (#19276) 2025-09-10 16:52:31 +02:00
Gina Peter Banyard cab46b27b9 ext/standard: Deprecate passing integers outside the interval [0, 255] to chr() (#19441)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_integers_outside_the_interval_0_255_to_chr
2025-08-14 20:48:48 +01:00
Niels Dossche c4183fba00 Fix GH-19070: setlocale($type, NULL) should not be deprecated
This restores the old behaviour.

Closes GH-19071.
2025-07-10 22:01:16 +02:00
DanielEScherzer 4e42ad5bf2 ext/standard/string.c: don't use STR_EMPTY_ALLOC() (#19033)
This was the only remaining use of a compatibility alias from 10 years ago;
replace with `ZSTR_EMPTY_ALLOC()`.
2025-07-04 14:41:24 -07:00
Niels Dossche 43c18f3cfe Fix GH-18823: setlocale's 2nd and 3rd argument ignores strict_types
Closes GH-18828.
2025-06-13 18:24:01 +02:00
Saki Takamachi 47354a7404 Added zend_simd.h (#18413) 2025-05-16 15:42:20 +09:00
Niels Dossche 24fbe2d61e Micro-optimizations to str_increment() and str_decrement() (#18193)
Since it's a new string we're returning we can use RETURN_NEW_STR() and
we can also use zend_string_efree() for the strings that we replace
because they have RC1.
2025-03-30 18:09:21 +02:00
Christoph M. Becker 300811f1e2 Remove support for unsupported MSVC versions (GH-17128)
As of PHP 8.4.0, MSVC >= 1920 (aka. Visual Studio 2019 RTW 16.0) is
required anyway[1], so we can clean up a bit.

[1] <https://github.com/php/php-src/commit/b3d6414b87cfebf503b5064a78ea1c5120ed638f>
2024-12-12 19:50:14 +01:00
Ilija Tovilo e122152373 Simplify (bitset & flag) == flag conditions
Closes GH-16558
2024-10-30 17:27:52 +01:00
Gina Peter Bnayard 3f1a4441bd ext/standard: Make char* of php_stristr() const 2024-09-14 14:00:46 +01:00
Gina Peter Banyard f756b96e06 Make CSV deprecation less annoying to deal with (#15569) 2024-09-13 15:07:26 +01:00
Gina Peter Bnayard 85e6688791 ext/standard/string.c: Remove to(upper|lower) PHP API in favour of Zend APIs 2024-09-12 18:13:01 +01:00
Gina Peter Bnayard 1b87772f40 ext/standard/string.c: Refactor php_spn_common_handler()
Main objective is to remove the PHP_STR_STR(C)SPN symbols which are only used with this static function
2024-09-12 18:13:01 +01:00
Gina Peter Bnayard 5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard 997199e938 ext/standard/string.c: use standard wording for ValueError in str_pad() 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard e7c4d54d65 Use new helper function for "cannot be empty" ValueErrors 2024-08-21 21:12:17 +01:00
Gina Peter Banyard f5ae5ac804 ext/standard: Throw ValueErrors in str_getcsv() for invalid inputs (#15365)
This was forgotten when adjusting the behaviour of other CSV functions
2024-08-12 17:56:02 +01:00
Gina Peter Banyard c818d944cf ext/(standard|spl): Deprecate passing a non-empty string as the $enclosure parameter (#15362) 2024-08-12 16:09:56 +01:00
Niels Dossche 5b673e99fc Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix uninitialized (dummy) memory in php_strtr_array() (#14812)
2024-07-04 13:36:46 +02:00
Niels Dossche 6467655568 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix uninitialized (dummy) memory in php_strtr_array() (#14812)
2024-07-04 13:35:53 +02:00
Niels Dossche 7b74cadf8c Fix uninitialized (dummy) memory in php_strtr_array() (#14812)
Fixes one issue in GH-14806.
2024-07-04 13:34:33 +02:00
Niels Dossche c151d2d135 standard: change uses of sprintf into snprintf and zend_string_concat2 2024-06-14 08:12:03 -07:00
Gina Peter Banyard 25a5146180 Clean-up unused headers (#14365)
* ext/mbstring.c: clean-up headers and include intrinsics
2024-06-01 17:12:42 +01:00
Niels Dossche 75e3f3e0ca Optimize strpbrk (#13558) 2024-03-05 20:51:12 +01:00
Tim Düsterhus dce6ed3199 random: Adjust status to state (#13521)
* random: Rename `status` local to `state`

* random: Rename `php_random_algo_with_state`'s `status` member to `state`
2024-02-26 20:38:45 +01:00
Tim Düsterhus 79133df156 random: Pass algorithm and state together as php_random_algo_with_state (#13350)
* random: Remove `php_random_status`

Since 162e1dce98, the `php_random_status` struct
contains just a single `void*`, resulting in needless indirection when
accessing the engine state and thus decreasing readability because of the
additional non-meaningful `->state` references / the local helper variables.

There is also a small, but measurable performance benefit:

    <?php
    $e = new Random\Engine\Xoshiro256StarStar(0);
    $r = new Random\Randomizer($e);

    for ($i = 0; $i < 15; $i++)
    	var_dump(strlen($r->getBytes(100000000)));

goes from roughly 3.85s down to 3.60s.

The names of the `status` variables have not yet been touched to keep the diff
small. They will be renamed to the more appropriate `state` in a follow-up
cleanup commit.

* Introduce `php_random_algo_with_state`
2024-02-25 20:48:58 +01:00
Ilija Tovilo 631bc81607 Implement stackless internal function calls
Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-12461
2024-02-06 17:42:28 +01:00
Cristian Rodríguez 927adfb1a6 Use a single version of mempcpy(3) (#12257)
While __php_mempcpy is only used by ext/standard/crypt_sha*, the
mempcpy "pattern" is used everywhere.

This commit removes __php_mempcpy, adds zend_mempcpy and transforms
open-coded parts into function calls.
2023-12-20 15:16:32 +00:00
Niels Dossche e78966386b Remove always-false condition from substr_replace()
l < 0 is checked before and set to a different value.
2023-12-12 16:43:43 +00:00
Vinicius Dias f1af7223f8 Fixing incorrect error message when passing null to join/implode's array parameter (#12683)
Closes GH-12682
2023-12-01 09:55:20 +00:00
Niels Dossche 9a973a3743 Optimize strcspn (#12594) 2023-11-04 13:54:30 +00:00
Ilija Tovilo d35faecbf2 Split strtr zpp (#12583) 2023-11-01 13:08:06 +01:00
Niels Dossche d0b29d8286 Optimize strspn()
The current implementation uses a nested loop (for + goto), which has
complexity O(|s1| * |s2|). If we instead use a lookup table, the
complexity drops to O(|s1| + |s2|).
This is conceptually the same strategy that common C library
implementations such as glibc and musl use.
The variation with a bitvector instead of a table also gives a speed-up,
but the table variation was about 1.34x faster.

On microbenchmarks this easily gave a 5x speedup.

This can bring a 1.4-1.5% performance improvement in the Symfony
benchmark.

Closes GH-12431.
2023-10-14 21:24:55 +02:00
Ilija Tovilo b31a5b2731 Fix str_decrement() on "1"
Closes GH-12339
2023-10-02 16:42:04 +02:00
Kamil Tekiela 649872f105 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix param name in implode() error message
2023-08-24 21:07:50 +01:00
Kamil Tekiela ec82927d25 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix param name in implode() error message
2023-08-24 21:07:18 +01:00
Kamil Tekiela b1ce1d1f21 Fix param name in implode() error message 2023-08-24 21:05:26 +01:00
HypeMC f25474f7f2 Add before_needle argument to strrchr()
Closes GH-11430
2023-08-24 14:26:46 +01:00
George Peter Banyard d8696f9216 [RFC] Path to Saner Increment/Decrement operators (#10358)
* Add behavioural tests for incdec operators

* Add support to ++/-- for objects castable to _IS_NUMBER

* Add str_increment() function

* Add str_decrement() function

RFC: https://wiki.php.net/rfc/saner-inc-dec-operators

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
2023-07-17 15:51:24 +01:00
Niels Dossche 93e0f6b424 Fix undefined behaviour in string uppercasing and lowercasing
At least on 32-bit, the address computations overflow in running the
test on CI with UBSAN enabled. Fix it by reordering the arithmetic.
Since a part of the expression is already used in the code above the
computation, this should not negatively affect performance.

Closes GH-10936.
2023-03-25 21:17:15 +01:00
Michael Voříšek 3821938e81 Imply UTF8 validity in implode function (#10780)
Sets the UTF-8 valid flag if all parts are valid, or numeric (which are valid UTF-8 by definition).

* remove unuseful comments

* Imply UTF8 validity in implode function

* revert zend_string_dup change
2023-03-07 19:30:35 +01:00
George Peter Banyard 524391bcf6 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fixed ValueError message in count_chars()
  Fixed ValueError message in substr_compare()
  The userland constants do not start with PHP_
2023-02-26 14:28:49 +00:00
George Peter Banyard f440911057 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fixed ValueError message in count_chars()
  Fixed ValueError message in substr_compare()
  The userland constants do not start with PHP_
2023-02-26 14:28:22 +00:00
George Peter Banyard adc5edd411 Fixed ValueError message in count_chars()
The value of the mode argument must be between 0 and 4 inclusive, not 1 and 4.
2023-02-26 14:27:46 +00:00
George Peter Banyard 2133970152 Fixed ValueError message in substr_compare()
It used some random argument name instead of
2023-02-26 14:25:02 +00:00
Niels Dossche c2d4bafc4f Copy UTF-8 flag for str_repeat 2023-02-05 14:32:50 +00:00
Niels Dossche 2b55dee4dc Make stripslashes() only dependent on SSE2 configuration. (#10408)
Alex Dowad noticed[1] that the SIMD stripslashes implementation actually
only depended on SSE2, and not on SSE4.2 instructions. Remove the
checking for SSE4.2 and only check for SSE2. This also greatly
simplifies the supporting code.

[1] https://github.com/php/php-src/pull/10313#issuecomment-1382825073
2023-01-23 13:25:00 +00:00
David Carlier 256a34ed15 strtok warns in case the string to split was not set.
Close GH-10016.
2023-01-23 12:13:49 +00:00