Commit Graph

329 Commits

Author SHA1 Message Date
Arnaud Le Blanc
efc8f0ebf8
Deprecate zend_atol() / add zend_ini_parse_quantity() (#7951)
Add zend_ini_parse_quantity() and deprecate zend_atol(), zend_atoi()

zend_atol() and zend_atoi() don't just do number parsing.
They also check for a 'K', 'M', or 'G' at the end of the string,
and multiply the parsed value out accordingly.

Unfortunately, they ignore any other non-numerics between the
numeric component and the last character in the string.
This means that numbers such as the following are both valid
and non-intuitive in their final output.

* "123KMG" is interpreted as "123G" -> 132070244352
* "123G " is interpreted as "123 " -> 123
* "123GB" is interpreted as "123B" -> 123
* "123 I like tacos." is also interpreted as "123." -> 123

Currently, in php-src these functions are used only for parsing ini values.

In this change we deprecate zend_atol(), zend_atoi(), and introduce a new
function with the same behavior, but with the ability to report invalid inputs
to the caller. The function's name also makes the behavior less unexpected:
zend_ini_parse_quantity().

Co-authored-by: Sara Golemon <pollita@php.net>
2022-06-17 14:12:53 +02:00
Chun-Sheng, Li
f2b50156bc
Add some more test cases for BCMath
Closes GH-7851.
2021-12-30 13:02:56 +01:00
Máté Kocsis
50f31829b1
Generate optimizer func info from stubs for a few extensions - part 2 (#7401)
ext/bcmath, ext/fileinfo, ext/filter, ext/gettext, ext/session
2021-08-25 15:29:46 +02:00
Christoph M. Becker
d66854bece
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #78238: BCMath returns "-0"
2021-07-16 16:01:03 +02:00
Christoph M. Becker
9fbcaa57aa
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #78238: BCMath returns "-0"
2021-07-16 15:56:15 +02:00
Christoph M. Becker
bcb89c75ec
Fix #78238: BCMath returns "-0"
There is no negative zero in the decimal system, so we must suppress
the sign.

Closes GH-7250.
2021-07-16 15:54:24 +02:00
Patrick Allaert
ac18dd0dc7 Prefer EXPECT over EXPECTF 2021-06-29 17:13:02 +02:00
George Peter Banyard
57a8bf62dd
Use standard function declaration style instead of K&R in libbcmath
Fixes [-Wstrict-prototypes] warnings.
2021-05-12 15:33:55 +01: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
Max Semenik
56f90492d6 Migrate skip checks to --EXTENSIONS--, p1
For rationale, see https://github.com/php/php-src/pull/6787

Extensions migrated in this part:
* bcmath
* bz2
* calendar
* com_dotnet
* ctype

Closes GH-6797.
2021-03-22 17:51:02 +01:00
Alex McLean
ec5e811dbd Add test cases for bcmath ValueErrors
Closes GH-6714

Signed-off-by: George Peter Banyard <girgias@php.net>
2021-03-03 18:35:15 +00:00
Máté Kocsis
bf0f6aaf18
Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Máté Kocsis
99b08ac281
Implicitly enable function entry generation when class entry generation is enabled
Closes GH-6675
2021-02-09 13:37:24 +01:00
Máté Kocsis
5f21062054
Generate class entries for a few extensions
Relates to GH-6644
2021-02-03 09:24:09 +01: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
Jens de Nies
94a151a018 Fixed bug #80545
This converts the remaining "non well-formed" warnings in bcmath
to ValueErrors, in line with the other warning promotions that
have been performed in this extension.

Closes GH-80545.
2021-01-12 09:50:27 +01:00
Nikita Popov
3d2819e491 Fix memory leak with bcsqrt on number 0<X<1 2020-11-12 11:37:54 +01:00
Nikita Popov
ac87880add Update bcmath.scale when calling bcscale()
We should keep the value of bcmath.scale and the internal
bc_precision global synchronized.

Probably more important than the ability to retrieve bcmath.scale
via ini_get(), this also makes sure that the set scale does not
leak into the next request, as it currently does.
2020-10-21 17:06:48 +02:00
Nikita Popov
2519827732 Update gmp+bcmath parameter names
Closes GH-6205.
2020-09-29 12:34:16 +02:00
George Peter Banyard
cd05b56a6f Promote some warnings in BCMath to Errors
Also do a bit of refactoring at the same time.

Closes GH-6105
2020-09-11 17:40:06 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
Vladyslav Startsev
2c97b401c6
make bcpowmod stricter by not returning false, instead throw exception
Closes GH-5747
2020-06-22 09:31:55 +02:00
George Peter Banyard
2bb1cc4ba9 Fix [-Wundef] warning in BCMath extension 2020-05-16 15:31:11 +02:00
Máté Kocsis
8a41c9e025
Convert UNKNOWN default values to null in ext/bcmath 2020-05-02 11:05:19 +02:00
Vladyslav Startsev
b64aee9706 Ensure bcmath scale is between 0 and INT_MAX
Make sure bcmatch scale is between 0 and INT_MAX, both for the
ini setting, and all the functions accepting a scale argument.
A ValueError is thrown if a function argument is out of range.

Closes GH-5455.
2020-04-27 11:53:26 +02:00
Máté Kocsis
7c3078737f
Generate function entries from stubs for a couple of extensions
Closes GH-5347
2020-04-04 20:41:48 +02:00
Máté Kocsis
d1764ca330
Make error messages more consistent by fixing capitalization
Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.
2020-01-17 14:52:46 +01:00
Máté Kocsis
afdaa91170
Fix #78880: Final spelling fixes 2020-01-16 19:14:31 +01:00
Máté Kocsis
d59bc80782
Fix smaller issues with stubs
GH-5025
2019-12-20 14:31:07 +01:00
Stanislav Malyshev
6556916759 Merge branch 'PHP-7.4'
* PHP-7.4:
  Test fixes
2019-12-16 10:31:40 -08:00
Stanislav Malyshev
d82a2f6c21 Test fixes 2019-12-16 10:31:22 -08:00
Stanislav Malyshev
0dfff646a2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix test
  Fix bug #78793
  Fix build - no model field anymore
  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
2019-12-16 10:07:15 -08:00
Stanislav Malyshev
d9f57e8316 Merge branch 'PHP-7.3' into PHP-7.4
* 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
2019-12-16 00:39:37 -08:00
Stanislav Malyshev
a65b8abf2c Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  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
2019-12-16 00:38:54 -08:00
Christoph M. Becker
eb23c60087 Fix #78878: Buffer underflow in bc_shift_addsub
We must not rely on `isdigit()` to detect digits, since we only support
decimal ASCII digits in the following processing.
2019-12-16 00:05:03 -08:00
Máté Kocsis
27e83d0fb8
Add union return types for function stubs 2019-11-11 14:54:55 +01:00
Fabien Villepinte
a555cc0b3d Clean DONE tags from tests
Remove most of the `===DONE===` tags and its variations.
Keep `===DONE===` if the test output otherwise becomes empty.

Closes GH-4872.
2019-11-07 21:31:47 +01:00
Christoph M. Becker
84f2a984d4 Elevate warnings to Error Exceptions in ext/bcmath
`bcdiv()` and `bcmod()` throw DivisionByZeroError if the divisor is 0,
which matches the behavior of the `/` and `%` operators, and `bcsqrt()`
throws ValueError for negative operands.
2019-10-28 12:22:31 +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
Simon Podlipsky
4799b76f39 Add BCMath PHP stubs
Closes GH-4508.
2019-08-10 22:18:04 +02:00
Nikita Popov
1834994d0d Merge branch 'PHP-7.4' 2019-06-21 12:56:48 +02:00
Nikita Popov
f781c8f110 Fix leak in bcpowmod 2019-06-21 12:56:28 +02:00
Gabriel Caruso
b27366f29d Add return type for bcmath extension functions
Except for bcpowmod, as it returns string|false
2019-06-01 11:50:01 -03:00
vladyslavstartsev
a07d422ade Warn about non well-formed arguments in bcmath
Co-Authored-By: Nikita Popov <nikita.ppv@googlemail.com>
Co-Authored-By: Christoph M. Becker <cmbecker69@gmx.de>
2019-05-14 15:04:21 +02:00
Peter Kokot
75fb74860d Normalize comments in *nix build system m4 files
Normalization include:
- Use dnl for everything that can be ommitted when configure is built in
  favor of the shell comment character # which is visible in the output.
- Line length normalized to 80 columns
- Dots for most of the one line sentences
- Macro definitions include similar pattern header comments now
2019-05-12 18:43:03 +02:00
Peter Kokot
eb9ad31b48 [ci skip] Rename libbcmath license file to LICENSE
- 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.
2019-05-07 01:09:25 +02:00
Peter Kokot
bb95805327 [ci skip] Fix typo 2019-04-20 22:55:37 +02:00
Peter Kokot
e8a8128665 Refactor docs files for bcmath library 2019-04-20 22:41:00 +02:00