Commit Graph

32 Commits

Author SHA1 Message Date
Ilija Tovilo
998bce117c
Show enum cases in errors
Closes GH-14496
2024-06-10 22:58:25 +02:00
Christoph M. Becker
c8955c078a
Revert GH-10220
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491.
This reverts commit 588a07f737.
This reverts commit f377e15751.
This reverts commit b4ba16fe18.
This reverts commit 694ec1deea.
This reverts commit 6b34de8eba.
This reverts commit aa1cd02a43.
This reverts commit 308fd311ea.
This reverts commit 16203b53e1.
This reverts commit 738fb5ca54.
This reverts commit 9fdbefacd3.
This reverts commit cd4a7c1d90.
This reverts commit 928685eba2.
This reverts commit 01e5ffc85c.
2023-01-16 12:27:33 +01:00
Max Kellermann
738fb5ca54 Zend/zend_smart_str: include cleanup 2023-01-10 14:19:03 +00:00
Max Kellermann
00a918f0cc Zend/zend_smart_str: make several pointers const 2023-01-04 12:59:16 +00:00
George Peter Banyard
faa83f2f34
Convert some macros to zend_always_inline functions (#8288)
This doesn't have an effect really, but humans and IDEs can struggle to see through the macro soup when they first interact with PHP's source code.

Moreover, this reduces some of the macro expansion hell when they appear in compiler warnings.
2022-08-04 13:24:12 +01:00
Arnaud Le Blanc
4df3dd7679
Reduce memory allocated by var_export, json_encode, serialize, and other (#8902)
smart_str uses an over-allocated string to optimize for append operations. Functions that use smart_str tend to return the over-allocated string directly. This results in unnecessary memory usage, especially for small strings.

The overhead can be up to 231 bytes for strings smaller than that, and 4095 for other strings. This can be avoided for strings smaller than `4096 - zend_string header size - 1` by reallocating the string.

This change introduces `smart_str_trim_to_size()`, and calls it in `smart_str_extract()`. Functions that use `smart_str` are updated to use `smart_str_extract()`.

Fixes GH-8896
2022-07-08 14:47:46 +02:00
Joe Watkins
05ef6334cd
Fix bug #81303 improve match errors 2021-08-02 17:31:26 +02:00
Nikita Popov
604848188b Add additional double to string APIs
zend_double_to_str() converts a double to string in the way that
(string) would (using %.*H using precision).

smart_str_append_double() provides some more fine control over
the precision, and whether a zero fraction should be appeneded
for whole numbers.

A caveat here is that raw calls to zend_gcvt and going through
s*printf has slightly different behavior for the degenarate
precision=0 case. zend_gcvt will add a dummy E+0 in that case,
while s*printf convert this to precision=1 and will not. I'm
going with the s*printf behavior here, which is more common,
but does result in a minor change to the precision.phpt test.
2021-08-02 16:14:53 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Dmitry Stogov
c1ce43d1d2 php_json_escape_string() optimization 2018-06-13 18:26:48 +03:00
Dmitry Stogov
180bf90ded Fastcall calling convention is not comaptible with variable number of arguments 2018-06-06 15:27:18 +03:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Anatol Belski
bc5811f361 further sync for vim mode lines 2017-07-04 18:12:45 +02:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Nikita Popov
f3f594a47d Switch reflection to use smart_str
Instead of yet-another-smart-string-implementation.

Expand the smart_str API by:
 * smart_str_extract() which gets a finalized zend_string* from a
   smart_str, including insertion of the zero byte and handling of
   the empty string case. This should be preferred over using
   smart_str_0() in conjunction with str.s.
 * smart_str_get_len() which gets the length of the smart_str with
   handling of the empty string case.
2017-01-01 21:28:21 +01:00
Nikita Popov
384e959a3a Add smart_str_append_printf 2017-01-01 21:28:21 +01:00
Xinchen Hui
563659822d Merge branch 'PHP-7.0' 2016-01-02 17:56:54 +08:00
Xinchen Hui
97a9470d97 bump year which is missed in rev 49493a2 2016-01-02 17:56:11 +08:00
Xinchen Hui
7bfc4fca60 cleanup 2015-11-21 07:14:12 -08:00
Dmitry Stogov
4a2e40bb86 Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes). 2015-06-30 04:05:24 +03:00
Dmitry Stogov
e38ed4c28f Changed zend_smart_str allocation granularity to do the better job together with Zend MM and avoid useless calls to erealloc().
The actual reallocation routiones are seprated from inlined code to reduce code size.
2015-04-16 14:45:08 +03:00
Dmitry Stogov
05232cc810 Revert "Changed zend_smart_str allocation granularity to do the better job together with Zend MM and avoid useless calls to erealloc()." That commit significantly increased the code size because of intensive inlining and more expensive reallocation code.
This reverts commit 5275e5560b.
2015-04-16 13:11:54 +03:00
Dmitry Stogov
5275e5560b Changed zend_smart_str allocation granularity to do the better job together with Zend MM and avoid useless calls to erealloc(). 2015-04-16 12:32:56 +03:00
Xinchen Hui
fc33f52d8c bump year 2015-01-15 23:27:30 +08:00
Nikita Popov
a770d29df7 Add smart_str_append for appending zend_strings
Also replaces usages in Zend/ and ext/standard
2014-09-21 20:58:31 +02:00
Nikita Popov
2a7de9fdbb Rename smart_str_append to smart_str_append_smart_str
It's used only rarely and I'm running out of append names...
2014-09-21 20:49:39 +02:00
Nikita Popov
e33f3d3b7c Move smart_str implementation into Zend/
So we can use it there as well...

For now I've retained the zend_smart_str_public.h header, though
it would probably be better to just move that one struct into
zend_types.h.
2014-09-21 20:49:39 +02:00