Commit graph

52 commits

Author SHA1 Message Date
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
f5be0e5110 Inline pair production in json parser
Having this as a separate production has a noticeable performance
impact, and doesn't really make things clearer either.
2020-11-13 14:56:29 +01:00
George Peter Banyard
9839752a9c Voidify some ZEND_API functions
Closes GH-5805
2020-07-09 14:15:57 +02:00
twosee
88355dd338 Constify char * arguments of APIs
Closes GH-5676.
2020-06-08 10:38:45 +02:00
Akim Demaille
4cbffd89d9
Clean up the generation of the parsers
Prefer '%define api.value.type' to '#define YYSTYPE', so that Bison
know the type.

Use '%code requires' to declare what is needed to define the api.value.type
(that code is output in the generated header before the generated
definition of YYSTYPE).

Prefer '%define api.prefix' inside the grammar file to '-p' outside,
as anyway the functions defined in the file actually use this prefix.

Prefer `%param` to both `%parse-param` and `%lex-param`.

Closes GH-5138
2020-02-01 14:21:53 +01:00
Akim Demaille
37d0f7d3b3
Use "%empty" in the parsers, instead of comments
The annotation %empty is properly enforced: warnings when it's
missing, and errors when it's inappropriate.  Support for %empty was
introduced in Bison 3.0.

Pass -Wempty-rule to Bison.

Closes GH-5134
2020-01-31 09:52:40 +01:00
Nikita Popov
9241037837 Merge branch 'PHP-7.4'
* PHP-7.4:
  Optimize creation of empty arrays in json_decode
2019-10-30 11:06:59 +01:00
Tyson Andre
447f07cd28 Optimize creation of empty arrays in json_decode
Use the shared empty array from ZVAL_EMPTY_ARRAY

For code that created an 10 arrays of 100000 empty arrays
(has the same result with `$assoc=true` and `{}`)

- This is the worst-case comparison, but I'd expect 0-length arrays to be fairly
  common in regular data for json_decode
- The parser implementation was using function pointers so that third party
  extension developers could reuse the json parser for their own
  data structures, etc. (I think).

  This PR is meant to let those third party extensions continue working
  without changes.

Before this patch: In 0.126 seconds: added 97.99 MiB
After this patch:  In 0.096 seconds: added 41.99 MiB

```php
<?php
$json = '[' . str_repeat('[],', 100000) . "null]";
$start_memory = memory_get_usage();
$start_time = microtime(true);
$result = [];
for ($i = 0; $i < 10; $i++) {
    $result[] = json_decode($json);
}
$end_memory = memory_get_usage();
$end_time = microtime(true);
// Before this patch: In 0.126 seconds: added 97.99 MiB
// After this patch:  In 0.096 seconds: added 41.99 MiB
printf("In %.3f seconds: added %.2f MiB\n", $end_time - $start_time, ($end_memory - $start_memory)/1000000);

// For objects
$json = '[' . str_repeat('{},', 100000) . "null]";
$start_memory = memory_get_usage();
$start_time = microtime(true);
for ($i = 0; $i < 10; $i++) {
    $result[] = json_decode($json, true);
}
$end_memory = memory_get_usage();
$end_time = microtime(true);
// Before this patch: In 0.126 seconds: added 97.99 MiB
// After this patch:  In 0.096 seconds: added 41.99 MiB
printf("In %.3f seconds: added %.2f MiB (objects decoded as arrays) \n", $end_time - $start_time, ($end_memory - $start_memory)/1000000);
```

Closes GH-4861.
2019-10-30 11:06:46 +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
Nikita Popov
eedc4f1295 Merge branch 'PHP-7.4' 2019-09-19 21:02:20 +02:00
Nikita Popov
3fd68fd827 Clean up JSON parser
Don't use <value> type for JSON tokens that don't have a value
and remove the errlex productions -- we're going to get an
unexpected token error anyway, there's no need to handle these
explicitly.

This also removes the awkward workarounds for the unused value
warnings.
2019-09-19 21:00:22 +02:00
Nikita Popov
9fa009c86d Merge branch 'PHP-7.4' 2019-06-12 09:29:06 +02:00
Nikita Popov
852ab5d83f Use %define api.pure instead of %pure-parser
%pure-parser is deprecated. In our case there is no difference between
true & full, as we don't use locations.
2019-06-12 09:26:34 +02:00
Peter Kokot
1f150b5b96 Merge branch 'PHP-7.4'
* PHP-7.4:
  Upgrade deprecated directives and use non-posix bison
2019-03-19 20:29:36 +01:00
Peter Kokot
864366ef20 Upgrade deprecated directives and use non-posix bison
With Bison 3.0 some directives are deprecated:
- %name-prefix "x" should be %define api.prefix {x}
- %error-verbose should be %define parse.error verbose

Bison 3.3 also started emiting more warnings and since PHP souce parsers
are not POSIX compliant this patch fixes this as pointed out via
495a46aa1d.
2019-03-19 20:29:20 +01:00
Dmitry Stogov
91ef4124e5 Refactor zend_object_handlers API to pass zend_object* and zend_string* insted of zval(s). 2019-02-04 13:20:25 +03:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Zeev Suraski
38c337f22e Remove year range from copyright notice 2019-01-30 11:00:23 +02:00
Dmitry Stogov
918a9f09f8 Use zval_ptr_dtor_nogc() in JSON parser (it can't produce circular data structures) 2018-07-05 15:07:16 +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
Xinchen Hui
d56a534acc RC manipulation cleanup 2 2017-11-02 12:13:35 +08:00
Anatol Belski
3b2e8f8f70 Sync json parser defs 2017-09-20 15:08:45 +02:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Jakub Zelenka
f0d1cca672 Use empty keys instead of _empty_ in json decoding 2016-06-20 19:44:00 +01:00
Jakub Zelenka
b91c05ea14 Fix and clean up exporting of json parser 2016-05-11 20:54:42 +01:00
Jakub Zelenka
37048c0f6c Use embedded json parser method structure 2016-05-02 13:02:40 +01:00
Jakub Zelenka
93b67dd511 Remove json parser depth methods and tidy it up 2016-04-10 16:10:26 +01:00
Jakub Zelenka
72ccfda25a Add method hooking support to json parser
This commit is just a slight modification (renaming and some small
changes) of the patch that has been provided by Andrey Hristov.
It adds support for hooking of the json parser operations and
allows re-using of modified JSON parsing outside of json ext.
2016-04-10 15:35:41 +01:00
Lior Kaplan
2eb1f38d24 Happy new year (Update copyright to 2016) 2016-01-01 20:03:16 +02: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
Jakub Zelenka
f3df3df873 Fix bug #68546 (json_decode cannot access property started with \0) 2015-06-21 15:30:33 +01:00
Jakub Zelenka
61de771afa Improve json parser code 2015-06-07 15:22:09 +01:00
Jakub Zelenka
359df4dea8 Tidy up and regenerate json parser with latest bison version 2015-05-10 18:08:16 +01:00
Xinchen Hui
76fb02123f Optimized json_parser
1. use zend_string in key
2. use faster APIs
3. use ZVAL_COPY_VALUE instead of assignment (save u2 copy)
2015-05-06 11:37:30 +08:00
Anatol Belski
fe36285de2 fix datatype mismatches 2015-03-25 15:32:35 +01:00
Lior Kaplan
a4384bd3d4 s/PHP Version 5/PHP Version 7/g
Follow up for d0cb7153
2015-03-13 11:09:42 +02:00
Reeze Xia
609f05fc19 ZTS cleanup 2015-03-08 19:25:55 +08:00
Jakub Zelenka
549c6fa465 Remove unused destructor in json parser 2015-02-15 19:46:41 +00:00
Anatol Belski
ef2fd13de8 fix datatype mismatches 2015-02-09 11:06:02 +01:00
Anatol Belski
12fff5251b fix inconsistend dll linkage warn 2015-02-09 10:51:29 +01:00
Anatol Belski
a1208b4726 use size_t for str length 2015-02-09 10:43:27 +01:00
Jakub Zelenka
3159d518d0 Merge branch 'master' into jsond
Conflicts:
	ext/json/JSON_parser.c
	ext/json/json.c
2015-01-25 18:43:15 +00:00
Jakub Zelenka
8e10250449 Use ZVAL_COPY_VALUE for copying parser result to return_value 2015-01-01 19:19:31 +00:00
Jakub Zelenka
b68da91d52 Merge branch 'master' into jsond
Conflicts:
	ext/json/JSON_parser.c
	ext/json/JSON_parser.h
	ext/json/config.m4
	ext/json/config.w32
	ext/json/json.c
	ext/json/php_json.h
2014-12-27 19:42:04 +00:00
Jakub Zelenka
9e5f687957 Fix json object decoding 2014-12-12 19:52:45 +00:00
Jakub Zelenka
c6d0905158 Do not copy return_value in parser 2014-12-07 20:27:03 +00:00
Jakub Zelenka
098097d83f Fix compilation for json scanner 2014-11-30 18:29:48 +00:00
Jakub Zelenka
79e8355631 Fix compilation issues in json_parser 2014-11-26 20:49:55 +00:00
Jakub Zelenka
f00b80a511 Implement initial changes for json_parser 2014-11-23 19:53:06 +00:00