Commit Graph

267 Commits

Author SHA1 Message Date
Nikita Popov
217c05da52 Merge branch 'PHP-7.2' into PHP-7.3 2019-03-14 17:25:54 +01:00
Nikita Popov
e7d40afb7a Fixed bug #77742
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.
2019-03-14 17:24:50 +01:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Peter Kokot
b746e69887 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

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
2018-10-15 04:32:30 +02:00
Peter Kokot
f1d7e3ca0b Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

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
2018-10-15 04:31:31 +02:00
Peter Kokot
1c850bfcca Sync leading and final newlines in source code files
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
2018-10-14 12:55:24 +02:00
Peter Kokot
60a69daec6 Sync leading and final newlines in source code files
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
2018-10-14 12:54:08 +02:00
Peter Kokot
3362620b5f Trim trailing whitespace in source code files 2018-10-13 14:16:33 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Peter Kokot
28136b071a Remove build system files of bundled library libbcmath
The bundled library libbcmath is maintained in the php-src and its
build system files are outdated and not used.
2018-05-29 18:56:50 +02:00
Anatol Belski
aebbf38df5 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Refix the tests once more
2018-05-19 13:11:39 +02:00
Anatol Belski
83626ef97a Refix the tests once more
The behavior change seems to be in both runtime and system. The
displaced warning output is of secondary interest anyway.
2018-05-19 13:09:56 +02:00
Anatol Belski
6fc405e851 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix remaining AppVeyor test failures due to the image update
2018-05-19 11:44:26 +02:00
Anatol Belski
589f8107e8 Fix remaining AppVeyor test failures due to the image update 2018-05-19 11:43:19 +02:00
Gabriel Caruso
ded3d984c6 Use EXPECT instead of EXPECTF when possible
EXPECTF logic in run-tests.php is considerable, so let's avoid it.
2018-02-20 21:53:48 +01:00
Gabriel Caruso
3253057021
Add test for bcpwmod
bc_raisemod's mod can't be zero and expo can't be negative
2018-02-12 09:25:31 +01:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Xinchen Hui
ccd4716ec7 year++ 2018-01-02 12:53:31 +08:00
Dmitry Stogov
9e709e2fa0 Move constants into read-only data segment 2017-12-14 18:43:44 +03:00
Christoph M. Becker
512b6c74be Don't reintroduce split_bc_num()
This function has been removed in 870ed5106d,
because it is not necessary to manipulate the `bc_num` itself; instead
we simply omit extraneous decimals when converting the number to
string.

This resolves the issue introduced by 24fd49fbab
in a cleaner way than 121d193514.
2017-11-07 16:37:31 +01:00
Dmitry Stogov
a8a04658b0 Fixed build (missing function borrowed from PHP-7.2) 2017-11-07 09:25:04 +03:00
Sara Golemon
24fd49fbab Merge branch 'PHP-7.2'
* PHP-7.2:
  Scale support for bcmod()
2017-11-06 17:27:22 -05:00
Christoph M. Becker
b152633ecb Scale support for bcmod()
As of commit 90dcbbe (PHP-7.2+) bcmod() supports non-integral
parameters as well. Since formerly only integer modulus has been
supported, it did not make much sense to cater to the scale with regard
to the result. However, now it does for consistency with other BCMath
operations.

Therefore, we add support for an optional `scale` parameter and fall
back to the default scale (`bcmath.scale`) as usual.
2017-11-06 17:26:52 -05:00
Christoph M. Becker
73af7a847c Merge branch 'pull-request/2742'
* pull-request/2742:
  Fixed bug #66364 (BCMath bcmul ignores scale parameter)
2017-09-18 15:21:22 +02:00
Christoph M. Becker
18adc6f0fc Merge branch 'pull-request/2745'
* pull-request/2745:
  Fixed bug #75169 (BCMath errors/warnings bypass error handling)
2017-09-13 16:21:30 +02:00
Christoph M. Becker
1738fa3ec1 Merge branch 'pull-request/2739'
* pull-request/2739:
  Fix proto and indentation
  Fix arginfo
  Return old scale value from bcscale()
2017-09-13 16:04:54 +02:00
Christoph M. Becker
0d890025ec Merge branch 'PHP-7.2'
* PHP-7.2:
  Fixed bug #46781 (BC math handles minus zero incorrectly)
2017-09-11 23:58:31 +02:00
Christoph M. Becker
77f3cef35c Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixed bug #46781 (BC math handles minus zero incorrectly)
2017-09-11 23:52:14 +02:00
Christoph M. Becker
87a91aef83 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed bug #46781 (BC math handles minus zero incorrectly)
2017-09-11 23:46:21 +02:00
Christoph M. Becker
9aa6898b9b Fixed bug #46781 (BC math handles minus zero incorrectly)
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.
2017-09-11 23:44:23 +02:00
Christoph M. Becker
fd73a54c30 Fixed bug #75169 (BCMath errors/warnings bypass error handling)
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.
2017-09-09 23:57:22 +02:00
Christoph M. Becker
d1e82b39e2 Optimize truncation to zero scale in bc_raisemod()
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.
2017-09-09 18:41:59 +02:00
Christoph M. Becker
65b575134f Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix bug75178.phpt on Windows
2017-09-09 17:15:04 +02:00
Christoph M. Becker
20fe838c76 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix bug75178.phpt on Windows
2017-09-09 17:04:42 +02:00
Christoph M. Becker
6602cc0385 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix bug75178.phpt on Windows
2017-09-09 16:54:23 +02:00
Christoph M. Becker
3fd08a1595 Fix bug75178.phpt on Windows
bug75178.phpt fails on Windows, because the stderr output is not
interspersed with stdout output there, but rather is appended to the
end. The fix is analogous to bug72093.phpt.
2017-09-09 16:46:32 +02:00
Christoph M. Becker
8826a563de Merge branch 'PHP-7.2'
* PHP-7.2:
  Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)
2017-09-09 13:38:10 +02:00
Christoph M. Becker
21eab49a53 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)
2017-09-09 13:30:40 +02:00
Christoph M. Becker
afa39038c2 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)
2017-09-09 13:20:14 +02:00
Christoph M. Becker
44eec946e8 Fixed bug #75178 (bcpowmod() misbehaves for non-integer base or modulus)
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.
2017-09-09 13:18:26 +02:00
Christoph M. Becker
870ed5106d Fixed bug #66364 (BCMath bcmul ignores scale parameter)
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.
2017-09-08 18:31:04 +02:00
Christoph M. Becker
657695fe97 Remove unused member
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.
2017-09-08 16:24:38 +02:00
Christoph M. Becker
d254a2cbca Merge branch 'PHP-7.2'
* PHP-7.2:
  Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1)
2017-09-07 00:44:47 +02:00
Christoph M. Becker
d01453b129 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1)
2017-09-07 00:38:59 +02:00
Christoph M. Becker
0f88a49fd5 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1)
2017-09-07 00:32:39 +02:00
Christoph M. Becker
b2919853f8 Fixed bug #54598 (bcpowmod() may return 1 if modulus is 1)
`x mod 1` is always zero; we have to take the scale into account,
though.
2017-09-07 00:30:05 +02:00
Christoph M. Becker
f70d14e407 Merge branch 'PHP-7.2'
* PHP-7.2:
  Fixed bug #44995 (bcpowmod() fails if scale != 0)
2017-09-06 23:48:00 +02:00
Christoph M. Becker
5ce744091c Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fixed bug #44995 (bcpowmod() fails if scale != 0)
2017-09-06 23:41:46 +02:00