Commit Graph

140 Commits

Author SHA1 Message Date
Javier Eguiluz
732d92c0e5
[skip ci] Fix various typos and grammar issues (#11143) 2023-04-28 11:05:32 +02:00
Derick Rethans
93fb2c12b9 Bring minimum precision inline with spprintf
The precision "minimum" for spprintf was changed in
3f23e6bca9 with the cryptic comment "Enable 0
mode for echo/print". Since then the behaviour of spprintf and snprintf has not
been the same. This results in some APIs handling precision differently than
others, which then resulted in the following Xdebug issue:
https://bugs.xdebug.org/view.php?id=2151

The "manpage" for snprinf says about precision:

       An optional precision, in the form of a period ('.')   followed  by  an
       optional  decimal  digit string.  Instead of a decimal digit string one
       may write "*" or "*m$" (for some decimal integer m) to specify that the
       precision  is  given in the next argument, or in the m-th argument, re‐
       spectively, which must be of type int.  If the precision  is  given  as
       just  '.',  the precision is taken to be zero.  A negative precision is
       taken as if the precision were omitted.

However, the snprintf implementation never supported this "negative precision",
which is what PHP's default setting is in PG(precision). However, in
3f23e6bca9 spprintf was made to support this.

Although this techinically can break BC, there is clearly a bug here, and I
could not see any failing tests locally.
2023-01-30 19:00:42 +00:00
Dmitry Stogov
067df26344 Use memrchr() when available
On x86_64 glibc memrchr() uses SSE/AVX CPU extensions and works much
faster then naive loop. On x86 32-bit we still use inlined version.

memrchr() is a GNU extension. Its prototype  becomes available when
<string.h> is included with defined _GNU_SOURCE macro. Previously, we
defined it in "php_config.h", but some sources may include <string.h>
befire it. To avod mess we also pass -D_GNU_SOURCE to C compiler.
2021-11-24 16:13:34 +03:00
Nikita Popov
e14fbc84ac Remove FORMAT_CONV_MAX_PRECISION
This used to be necessary in the past because the NUM_BUF_SIZE
was set to 512, which is shorter than DOUBLE_MAX_LENGTH. Now the
value is either DOUBLE_MAX_LENGTH or larger (2048).
2021-08-02 15:59:26 +02:00
Nikita Popov
d28f6e694d Move php_gcvt to zend_gcvt
Also move PHP_DOUBLE_MAX_LENGTH to ZEND_DOUBLE_MAX_LENGTH.
2021-08-02 14:51:46 +02:00
George Peter Banyard
282abfed95 Drop register keyword 2021-07-15 10:40:36 +02:00
George Peter Banyard
02e48d99c9 Use standard 64bit signed int type 2021-07-15 10:40:36 +02:00
George Peter Banyard
97785545cf Use standard 64bit unsigned int type 2021-07-15 10:40:36 +02:00
George Peter Banyard
b901c0528c Refactor conversion function
Use a size_t instead of int because it tracks the size of the string
Cast to int to maintain the C stdlib API
2021-07-15 10:40:36 +02:00
George Peter Banyard
2bf68b3c01 Remove unused macro 2021-07-15 10:40:36 +02:00
George Peter Banyard
5e4d727f6a Use standard bool type instead of boolean_e 2021-07-15 10:40:36 +02:00
George Peter Banyard
10f416f5c2 Use standard bool type instead of bool_int 2021-07-15 10:40:36 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Nikita Popov
0d6358f2cf Drop support for printf p modifier
To be conservative, cause a fatal error if the p modifier is
encountered, in case this is still used by some extension.
2021-06-16 17:59:00 +02:00
Nikita Popov
a1473aadf8 Avoid make_printable_zval in snprintf
Use zval_get_tmp_string() instead.
2021-06-10 10:12:57 +02: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
Josh Soref
462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
George Peter Banyard
f91f72607b Drop unnecessary stdint and inttypes header checks
These are always available as of C99.

Closes GH-5323

Co-authored-by: "Christoph M. Becker" <cmbecker69@gmx.de>
2020-04-22 20:18:19 +02:00
George Peter Banyard
13178087c7 Drop the custom 'v' format from snprintf custom implementation.
Extensions should instead use the standard 's' format.

Closes GH-5100
2020-01-21 13:18:13 +01:00
George Peter Banyard
aaa1f90e3f Drop the custom I length modifier from snprintf custom implementation.
Extensions should rather use the ZEND_LONG_FMT, ZEND_ULONG_FMT and
ZEND_XLONG_FMT macros defined in php-src/Zend/zend_long.h

Closes GH-5089
2020-01-20 23:03:10 +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
be36d92294 Fix unused value warnings in snprintf.c 2019-06-12 13:17:25 +02:00
Peter Kokot
e06836a1a3 Remove checks for locale.h, setlocale, localeconv
The `<loccale.h>` header file, setlocale, and localeconv are part of the
standard C89 [1] and on current systems can be used unconditionally.

Since PHP 7.4 requires at least C89 or greater, the `HAVE_LOCALE_H`,
`HAVE_SETLOCALE`, and `HAVE_LOCALECONV` symbols defined by Autoconf in
configure.ac [2] can be ommitted and simplifed.

The bundled libmagic (file) has also been patched already in version
5.35 and up in upstream location so when it will be patched also in
php-src the check for locale.h header is still left in the configure.ac
and in windows headers definition file.

[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.4
[2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4

Omit the bundled libmagic files
2019-04-07 18:32:54 +02:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Rijnard van Tonder
8881c3c82f Remove redundant continue in for loops 2018-11-20 21:23:24 +01: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
Dmitry Stogov
4a475a4976 Replace legacy zval_dtor() by zval_ptr_dtor_nogc() or even more specialized destructors.
zval_dtor() doesn't make a lot of sense in PHP-7.* and it's used incorrectly in some places.
Its occurances should be replaced by zval_ptr_dtor() or zval_ptr_dtor_nogc(), or even more specialized destructors.
2018-07-04 19:22:24 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Dmitry Stogov
83e495e0fd Move constants into read-only data segment 2017-12-14 22:14:36 +03:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Yasuo Ohgaki
086835f2b3 Remove unneeded WS change 2016-06-26 13:26:43 +01:00
Yasuo Ohgaki
c71550472a Fix mode when precision=0. Add test 2016-06-26 13:26:43 +01:00
Yasuo Ohgaki
e3d9f1f4d8 Simply use ndigit for flag for zend_dtoa mode 2016-06-26 13:26:43 +01:00
Yasuo Ohgaki
f943daf2d7 Initial patch for 0 mode float conversion. The magic number is better to be improved. Any suggestion where to define it? 2016-06-26 13:26:42 +01:00
Dmitry Stogov
1433162083 Fixed compilation warnings 2016-06-21 20:12:29 +03:00
Lior Kaplan
ed35de784f Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Happy new year (Update copyright to 2016)
2016-01-01 19:48:25 +02:00
Lior Kaplan
49493a2dcf Happy new year (Update copyright to 2016) 2016-01-01 19:21:47 +02:00
Xinchen Hui
fc33f52d8c bump year 2015-01-15 23:27:30 +08:00
Xinchen Hui
0579e8278d bump year 2015-01-15 23:26:37 +08:00
Stanislav Malyshev
b7a7b1a624 trailing whitespace removal 2015-01-10 15:07:38 -08:00
Anatol Belski
bdeb220f48 first shot remove TSRMLS_* things 2014-12-13 23:06:14 +01:00
Anatol Belski
42d7cb4c2c Merge branch 'PHP-5.6'
* PHP-5.6:
  C89 compat
  add include for missing localeconv_r proto
2014-12-06 12:18:36 +01:00
Anatol Belski
08241ee3f3 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  C89 compat
  add include for missing localeconv_r proto
2014-12-06 12:18:05 +01:00
Anatol Belski
373aa7c81f add include for missing localeconv_r proto 2014-12-06 12:09:35 +01:00
Anatol Belski
3d68d843cb Merge branch 'PHP-5.6'
* PHP-5.6:
  updated NEWS
  Fixed bug #65230 setting locale randomly broken
2014-12-06 12:01:09 +01:00
Anatol Belski
ebaf130a15 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Fixed bug #65230 setting locale randomly broken
2014-12-06 12:00:17 +01:00
Anatol Belski
1b4d5ad46a Fixed bug #65230 setting locale randomly broken 2014-12-06 11:59:43 +01:00
Anatol Belski
7e8e7ff634 fix datatype mismatches 2014-11-18 13:19:51 +01:00