summaryrefslogtreecommitdiff
path: root/ext/bcmath/libbcmath/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'PHP-7.3' into PHP-7.4Stanislav Malyshev2019-12-171-2/+2
| | | | | | | | | | * PHP-7.3: Fixed bug #78910 Fix #78878: Buffer underflow in bc_shift_addsub Fix test Fix #78862: link() silently truncates after a null byte on Windows Fix #78863: DirectoryIterator class silently truncates after a null byte Fix #78943: mail() may release string with refcount==1 twice
* Fix leak in bcpowmodNikita Popov2019-06-211-0/+1
|
* Warn about non well-formed arguments in bcmathvladyslavstartsev2019-05-142-3/+5
| | | | | Co-Authored-By: Nikita Popov <nikita.ppv@googlemail.com> Co-Authored-By: Christoph M. Becker <cmbecker69@gmx.de>
* [ci skip] Rename libbcmath license file to LICENSEPeter Kokot2019-05-0724-24/+24
| | | | | | - More common filename accross the PHP repository - Additionally, this patch replaces some legacy form feed (FF or ^L) characters (for printers) to LF (\n) newline character.
* Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-03-141-5/+12
|\
| * Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-03-141-5/+12
| |\
| | * Fixed bug #77742Nikita Popov2019-03-141-5/+12
| | | | | | | | | | | | | | | | | | | | | By avoiding integer overflow in the implementation entirely. The multiplication was already explicitly checked for overflow, so also add a check for the addition and remove the overflow checks after the calculation.
| | * Sync leading and final newlines in source code filesPeter Kokot2018-10-1415-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
| * | Sync leading and final newlines in source code filesPeter Kokot2018-10-1415-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
* | | Clean up unnecessary ternary expressions and simplify some returnsGabriel Caruso2018-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | - Simplify conditions - Use ZEND_HASH_APPLY_* instead of hard-coded booleans - Use ZEND_NORMALIZE_BOOL - Drop sign in favor of ZEND_NORMALIZE_BOOL
* | | Sync leading and final newlines in source code filesPeter Kokot2018-10-1415-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
* | | Remove HAVE_ASSERT_HPeter Kokot2018-09-0921-21/+0
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `<assert.h>` header file is part of the standard C89 headers [1] and on older systems there needed to be also a manual check if header is present. Since PHP requires at least C89 manual check and the `HAVE_ASSERT_H` symbol defined by Autoconf in configure.ac can be both removed [2]. This patch also removes unused <assert.h> includes where c files don't use the `assert()` macro. Refs: [1] https://port70.net/~nsz/c/c89/c89-draft.html#4.2 [2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
* | Remove build system files of bundled library libbcmathPeter Kokot2018-05-291-22/+0
| | | | | | | | | | The bundled library libbcmath is maintained in the php-src and its build system files are outdated and not used.
* | Merge branch 'pull-request/2742'Christoph M. Becker2017-09-182-6/+10
|\ \ | | | | | | | | | | | | * pull-request/2742: Fixed bug #66364 (BCMath bcmul ignores scale parameter)
| * | Fixed bug #66364 (BCMath bcmul ignores scale parameter)Christoph M. Becker2017-09-082-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We change `bcmul()` and `bcpow()` so that the result has exactly the requested scale (i.e. decimal places) to make them consistent with the other BCMath functions. This also changes our stance regarding bug #52748, which had been classified as documentation problem. We do not manipulate the numbers themselves (anymore), but rather introduce `bc_num2str_ex()` which accepts a scale parameter that overrides the scale of the number by omitting extraneous decimals and adding zeros, respectively. This also allows us to get rid of `split_bc_num()`, which fixes bug #75164 as well.
* | | Merge branch 'pull-request/2745'Christoph M. Becker2017-09-134-72/+5
|\ \ \ | | | | | | | | | | | | | | | | * pull-request/2745: Fixed bug #75169 (BCMath errors/warnings bypass error handling)
| * | | Fixed bug #75169 (BCMath errors/warnings bypass error handling)Christoph M. Becker2017-09-094-72/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of writing warning messages to `stderr`, we employ PHP's error handling to raise `E_WARNING` even for the single case where `bc_rt_error()` has been called, since that did not actually error out. We choose to call `php_error_docref()` directly in libbcmath, since there is no upstream, and since other PHP core functionality is already used in our bundled libbcmath. Accordingly, we remove `rt.c` so it will not be accidentally used in the future. Besides adapting a few existing tests, we add new tests so that the warnings are tested at least once. We also get rid of the Windows specific tests, since the warning behavior is now supposed to be platform-agnostic.
* | | | Merge branch 'PHP-7.2'Christoph M. Becker2017-09-111-0/+3
|\ \ \ \ | |/ / / |/| | / | | |/ | |/| * PHP-7.2: Fixed bug #46781 (BC math handles minus zero incorrectly)
| * | Merge branch 'PHP-7.1' into PHP-7.2Christoph M. Becker2017-09-111-0/+3
| |\ \ | | | | | | | | | | | | | | | | * PHP-7.1: Fixed bug #46781 (BC math handles minus zero incorrectly)
| | * \ Merge branch 'PHP-7.0' into PHP-7.1Christoph M. Becker2017-09-111-0/+3
| | |\ \ | | | | | | | | | | | | | | | | | | | | * PHP-7.0: Fixed bug #46781 (BC math handles minus zero incorrectly)
| | | * | Fixed bug #46781 (BC math handles minus zero incorrectly)Christoph M. Becker2017-09-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Actually, there is no negative zero at all. We obey Postel's law, and still accept negative zeroes, but we store them as positive zeroes after the conversion from string, i.e. we normalize before further processing.
* | | | | Optimize truncation to zero scale in bc_raisemod()Christoph M. Becker2017-09-091-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | There's no need to use a division by one to truncate to zero scale; instead we introduce and use `_bc_truncate()`, what is more efficient.
* | | | | Merge branch 'PHP-7.2'Christoph M. Becker2017-09-091-7/+15
|\ \ \ \ \ | |/ / / / | | | | / | |_|_|/ |/| | | * PHP-7.2: Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)
| * | | Merge branch 'PHP-7.1' into PHP-7.2Christoph M. Becker2017-09-091-7/+15
| |\ \ \ | | |/ / | | | | | | | | | | | | * PHP-7.1: Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)
| | * | Merge branch 'PHP-7.0' into PHP-7.1Christoph M. Becker2017-09-091-7/+15
| | |\ \ | | | |/ | | | | | | | | | | | | * PHP-7.0: Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)
| | | * Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)Christoph M. Becker2017-09-091-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since `bcpowmod()` does not support non-integral operands, we have to truncate these in addition to emitting a respective warning. We also have to work with the truncated values in the following. We recognize that the division by one to enforce the truncation is actually overkill, but we stick with it for now, and shall tackle the issue for PHP 7.3.
* | | | Remove unused memberChristoph M. Becker2017-09-082-13/+0
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `n_next` member of struct `bc_struct` is unused; the only code that would use this member has been disabled since libbcmath has been bundled nearly 17 years ago. Apparently, `n_next` has been designed to build a linked list of free numbers, but it is doubtful whether that would be an improvement over relying on the efficiency of the ZendMM, so we remove the remaining support altogether. The ABI break probably affects nobody, but would be okay for a new minor version according to our release process, anyway.
* | | Merge branch 'PHP-7.1' into PHP-7.2Christoph M. Becker2017-09-071-8/+15
|\ \ \ | |/ / | | | | | | | | | * PHP-7.1: Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1)
| * | Merge branch 'PHP-7.0' into PHP-7.1Christoph M. Becker2017-09-071-8/+15
| |\ \ | | |/ | | | | | | | | | * PHP-7.0: Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1)
| | * Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1)Christoph M. Becker2017-09-071-8/+15
| | | | | | | | | | | | | | | `x mod 1` is always zero; we have to take the scale into account, though.
* | | Merge branch 'PHP-7.1' into PHP-7.2Christoph M. Becker2017-09-061-1/+1
|\ \ \ | |/ / | | | | | | | | | * PHP-7.1: Fixed bug #44995 (bcpowmod() fails if scale != 0)
| * | Merge branch 'PHP-7.0' into PHP-7.1Christoph M. Becker2017-09-061-1/+1
| |\ \ | | |/ | | | | | | | | | * PHP-7.0: Fixed bug #44995 (bcpowmod() fails if scale != 0)
| | * Fixed bug #44995 (bcpowmod() fails if scale != 0)Christoph M. Becker2017-09-061-1/+1
| | | | | | | | | | | | | | | `bc_divmod()` is supposed to do integer division, so we must not apply a scale factor here.
* | | Merge branch 'PHP-7.1'Xinchen Hui2017-04-101-1/+1
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | * PHP-7.1: Fixed condition check Fixed condition check another place Conflicts: ext/mcrypt/mcrypt.c
| * | Merge branch 'PHP-7.0' into PHP-7.1Xinchen Hui2017-04-101-1/+1
| |\ \ | | |/ | | | | | | | | | * PHP-7.0: Fixed condition check
| | * Fixed condition checkXinchen Hui2017-04-101-1/+1
| | |
* | | Remove dead code from BCMath extensionThomas Punt2017-03-163-21/+2
| | |
* | | Drop unnecessary allocator return value checksNikita Popov2017-03-133-6/+0
|/ /
* | Merge branch 'PHP-7.0' into PHP-7.1Remi Collet2016-10-141-1/+1
|\ \ | |/ | | | | | | * PHP-7.0: use zend_error instead of zend_error_noreturn
| * Merge branch 'PHP-5.6' into PHP-7.0Remi Collet2016-10-141-1/+1
| |\ | | | | | | | | | | | | * PHP-5.6: use zend_error instead of zend_error_noreturn
| | * use zend_error instead of zend_error_noreturnRemi Collet2016-10-141-1/+1
| | |
| | * Fix bug #73190: memcpy negative parameter _bc_new_num_exStanislav Malyshev2016-10-032-3/+5
| | |
| * | Fix bug #73190: memcpy negative parameter _bc_new_num_exStanislav Malyshev2016-10-122-3/+5
| | | | | | | | | | | | (cherry picked from commit 40e7baab3c90001beee4c8f0ed0ef79ad18ee0d6)
* | | Merge branch 'PHP-7.0' into PHP-7.1Anatol Belski2016-10-142-3/+5
| | | | | | | | | | | | | | | | | | | | | * PHP-7.0: Fix bug #73190: memcpy negative parameter _bc_new_num_ex (cherry picked from commit af1bf873fe4fc70be17fa9f270e8f30666f2d2db)
* | | fix clang compatAnatol Belski2016-08-271-1/+1
|/ /
* | Use ZSTR_ API to access zend_string elements (this is just renaming without ↵Dmitry Stogov2015-06-301-2/+2
| | | | | | | | semantick changes).
* | trailing whitespace removalStanislav Malyshev2015-01-1025-30/+30
| |
* | first shot remove TSRMLS_* thingsAnatol Belski2014-12-1312-81/+81
| |
* | master renames phase 1Anatol Belski2014-08-251-2/+2
| |
* | Refactor bcmathXinchen Hui2014-05-052-29/+31
|/