summaryrefslogtreecommitdiff
path: root/ext/mbstring
Commit message (Collapse)AuthorAgeFilesLines
* Normalize mb_ereg() return valueNikita Popov2020-10-1315-77/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mb_ereg()/mb_eregi() currently have an inconsistent return value based on whether the $matches parameter is passed or not: > Returns the byte length of the matched string if a match for > pattern was found in string, or FALSE if no matches were found > or an error occurred. > > If the optional parameter regs was not passed or the length of > the matched string is 0, this function returns 1. Coupling this behavior to the $matches parameter doesn't make sense -- we know the match length either way, there is no technical reason to distinguish them. However, returning the match length is not particularly useful either, especially due to the need to convert 0-length into 1-length to satisfy "truthy" checks. We could always return 1, which would kind of match the behavior of preg_match() -- however, preg_match() actually returns the number of matches, which is 0 or 1 for preg_match(), while false signals an error. However, mb_ereg() returns false both for no match and for an error. This would result in an odd 1|false return value. The patch canonicalizes mb_ereg() to always return a boolean, where true indicates a match and false indicates no match or error. This also matches the behavior of the mb_ereg_match() and mb_ereg_search() functions. This fixes the default value integrity violation in PHP 8. Closes GH-6331.
* Fix incorrect zpp parameter count in mb_substr() / mb_strcut()Nikita Popov2020-10-131-2/+2
| | | | These functions only accept 4 params.
* Fix argument nullability in mbstringNikita Popov2020-10-131-20/+20
| | | | | These arguments were declared nullable in stubs (and should be nullable), but didn't accept null in zpp.
* Update mbstring parameter namesNikita Popov2020-09-2814-78/+78
| | | | Closes GH-6207.
* Standardize mbstring and string on using 'string' as a parameter name.Larry Garfield2020-09-213-32/+29
| | | | Closes GH-6171.
* Consolidate the usage of "either" and "one of" in error messagesMáté Kocsis2020-09-203-5/+4
| | | | Closes GH-6173
* Run tidyNikita Popov2020-09-189-21/+21
| | | | | This should fix most of the remaining issues with tabs and spaces being mixed in tests.
* fix mbfl function prototypesRemi Collet2020-09-154-23/+34
| | | | | re-add mbfl_convert_filter_feed API re-add pointer cast
* Promote a few remaining errors in ext/standardMáté Kocsis2020-09-155-12/+10
| | | | Closes GH-6110
* Make mb_send_mail() consistent with mail()Máté Kocsis2020-09-143-4/+4
| | | | The $additional_headers parameter shouldn't accept null.
* Consolidate new union type ZPP macro namesMáté Kocsis2020-09-111-7/+7
| | | | | | | They will now follow the canonical order of types. Older macros are left intact due to maintaining BC. Closes GH-6112
* Throw ValueError on null bytes in mb_send_mail()Nikita Popov2020-09-112-26/+48
| | | | Instead of silently replacing with spaces.
* Promote some warnings in MBString RegexesGeorge Peter Banyard2020-09-0910-155/+154
| | | | Closes GH-5341
* mb_str_split is already documented on php.netAlex Dowad2020-09-081-1/+0
| | | | So remove TODO comment which implies that it's not.
* Always use PCRE for mbstring.http_output_conv_mimetypesNikita Popov2020-09-081-72/+1
| | | | | | Instead of using either oniguruma or pcre depending on which is available. We always have PCRE, so use it. This ensures consistent behavior.
* Throw on invalid mb_http_input() typeNikita Popov2020-09-072-3/+20
|
* Handle null encoding in mb_http_input()Nikita Popov2020-09-042-10/+29
|
* Use symbolic constants in Japanese kana conversion code (not magic numbers)Alex Dowad2020-09-031-13/+16
| | | | Also correct misspelling of 'hiragana' as 'hirangana' at the same time.
* Remove unused 'from' field from mbfl_buffer_converter structAlex Dowad2020-09-032-6/+4
|
* Add comment to mbfilter_tl_jisx0201_jisx0208.hAlex Dowad2020-09-031-0/+2
| | | | Explain the 'ZEN' and 'HAN' in symbolic constant names.
* Remove unneeded function mbfl_filt_ident_common_dtorAlex Dowad2020-09-0353-90/+4
| | | | | This was the default destructor for mbfl_identify_filter structs, but there's nothing we actually need to do to those structs before freeing them.
* Remove unneeded function mbfl_filt_conv_common_dtorAlex Dowad2020-09-0369-208/+214
| | | | | | | This is a default destructor for mbfl_convert_filter structs. The thing is: there isn't really anything that needs to be done to those structs before freeing them. The default destructor just zeroed out some fields, but there's no reason why we should actually do that.
* Refactor mbfl_convert.cAlex Dowad2020-09-035-136/+65
|
* Fix typos in mbstring testsAlex Dowad2020-09-027-15/+15
| | | | | | Man, I can be pedantic sometimes. Tiny little things like misspelled words just hurt me inside. So while it's not really a big deal, I couldn't leave these typos alone...
* Move custom type checks to ZPPMáté Kocsis2020-09-023-22/+15
| | | | Closes GH-6034
* Code cleanup in mbstring.cAlex Dowad2020-08-311-235/+162
|
* Comment constants in mbfl_consts.h, remove unused onesAlex Dowad2020-08-3113-29/+25
| | | | | | | | | | | | These were unused, and almost certainly will never be used: - MBFL_ENCTYPE_MWC4BE - MBFL_ENCTYPE_MWC4LE - MBFL_ENCTYPE_SHFTCODE - MBFL_ENCTYPE_ENC_STRM For the latter two, there were some encodings which were marked with these flags; but nothing ever _checked_ these particular flags.
* Add comment on mbstring East Asian Width tableAlex Dowad2020-08-311-0/+11
|
* Don't guard mbstring code with #ifdef HAVE_MBSTRINGAlex Dowad2020-08-316-33/+2
| | | | | | | This is just a very silly feature of mbstring -- you can compile the source files with HAVE_MBSTRING undefined, and it will all just compile to (almost) nothing. What is the use of this? Why compile the source files and link against them if you don't want the mbstring extension? It doesn't make any kind of sense.
* Remove redundant includes from mbstring (and make sure correct config.h is used)Alex Dowad2020-08-3193-402/+7
| | | | | | | | | | | Very interesting... it turns out that when Valgrind support was enabled, `#include "config.h"` from within mbstring was actually including the file "config.h" from Valgrind, and not the one from mbstring!! This is because -I/usr/include/valgrind was added to the compiler invocation _before_ -Iext/mbstring/libmbfl. Make sure we actually include the file which was intended.
* Remove useless definition of NULL in mbfl_string.hAlex Dowad2020-08-311-4/+0
| | | | If NULL is not defined by the platform, mbfl_defs.h already defines it.
* Optimize php_unicode_convert_case (cuts mbstring case conversion time ~15%)Alex Dowad2020-08-311-44/+47
| | | | | | | | | | | This function uses various subfunctions to convert case of Unicode wchars. Previously, these subfunctions would store the case-converted characters in a buffer, and the parent function would then pass them (byte by byte) to the next filter in the filter chain. Rather than passing around that buffer, it's better for the subfunctions to directly pass the case-converted bytes to the next filter in the filter chain. This speeds things up nicely.
* Fix typos in comments in mb_send_mailAlex Dowad2020-08-311-3/+3
|
* Remove unused functions from mbstringAlex Dowad2020-08-3112-228/+8
| | | | | | | | | | | | | | | | - mbfl_buffer_converter_reset - mbfl_buffer_converter_strncat - mbfl_buffer_converter_getbuffer - mbfl_oddlen - mbfl_filter_output_pipe_flush - mbfl_memory_device_output2 - mbfl_memory_device_output4 - mbfl_is_support_encoding - mbfl_buffer_converter_feed2 - _php_mb_regex_globals_dtor - mime_header_encoder_feed - mime_header_decoder_feed - mbfl_convert_filter_feed
* Separate implementation of mb_{en,de}code_numericentityAlex Dowad2020-08-311-50/+69
| | | | | | Rather than using a magic boolean parameter to choose different behavior of the subfunction, inline it. The code size doesn't really grow anyways. And soon these will be trimmed down more.
* Use new-style argument parsing macros in mbstring.cAlex Dowad2020-08-311-171/+267
|
* Inline unneeded indirection for mbstring memory managementAlex Dowad2020-08-3114-213/+51
| | | | | | All memory allocation and deallocation for mbstring bounces through a table of function pointers before going to emalloc/efree/etc. But this is unnecessary. The allocators are never swapped out. Better to just call them directly.
* Additional tests for mbstring extensionAlex Dowad2020-08-313-25/+85
|
* Improve type declarations for Zend APIsGeorge Peter Banyard2020-08-281-6/+6
| | | | | | | | | Voidification of Zend API which always succeeded Use bool argument types instead of int for boolean arguments Use bool return type for functions which return true/false (1/0) Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics Closes GH-6002
* Add many missing closing PHP tags to testsMáté Kocsis2020-08-098-0/+8
| | | | Closes GH-5958
* Only force log startup errors if display_startup_errors disabledNikita Popov2020-08-054-16/+0
| | | | | | Otherwise this results in duplicate errors. Closes GH-5941.
* Add a few missing parameter types in stubsMáté Kocsis2020-07-302-4/+7
| | | | Related to GH-5627
* Fix UNKNOWN default values in ext/mbstring and ext/gdMáté Kocsis2020-07-284-140/+139
| | | | Closes GH-5598
* Fix bug #79108Nikita Popov2020-07-241-2/+2
| | | | | | | | | | Don't expose references in debug_backtrace() or exception traces. This is regardless of whether the argument is by-reference or not. As a side-effect of this change, exception traces may now acquire the interior value of a reference, which may be unexpected for some internal functions. This is what necessitated the change in the spl_array sort implementation.
* Fix mb_ereg_search* arg and func infoNikita Popov2020-07-212-7/+10
|
* Review the usage of apostrophes in error messagesMáté Kocsis2020-07-105-18/+18
| | | | Closes GH-5590
* Merge branch 'PHP-7.4'Nikita Popov2020-07-082-5/+29
|\ | | | | | | | | * PHP-7.4: Fix bug #79787
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-07-082-5/+29
| |\ | | | | | | | | | | | | * PHP-7.3: Fix bug #79787
| | * Fix bug #79787XXiang2020-07-082-5/+29
| | | | | | | | | | | | Closes GH-5807.
* | | Remove proto comments from C filesMax Semenik2020-07-062-120/+60
| | | | | | | | | | | | Closes GH-5758