Commit Graph

462 Commits

Author SHA1 Message Date
Marcus Boerger
da5c076100 - Add array_fill_keys() (Matt W, php_lists at realplain com) 2006-07-15 10:10:47 +00:00
Andrei Zmievski
853ab6e09f Adjust array_pad(), array_reverse(), and array_unique() for params API
and mark them with U.
2006-07-14 22:41:22 +00:00
Andrei Zmievski
5766cdbd01 - Simplify array_combine() and adjust for params API
- Adjust array_count_values() and array_rand() for params API and mark
  with U
2006-07-14 22:15:54 +00:00
Andrei Zmievski
40cabdca59 Adjust array_key_exists(), array_slice(), and array_splice() for params
API and mark them with U.
2006-07-14 21:16:30 +00:00
Andrei Zmievski
8d28257255 Make array_change_key_case() -- a candidate for the quite possibly the
most useless function ever -- use params API and mark it with U.
2006-07-14 20:07:57 +00:00
Andrei Zmievski
6dfb4768b4 Update end(), prev(), next(), reset(), current(), and key() for params
API and mark with U.
2006-07-14 18:12:45 +00:00
Andrei Zmievski
0322c14d14 Update array_search()/in_array() for params API and mark with U. 2006-07-14 18:03:13 +00:00
Andrei Zmievski
f344fe0153 Update array_keys() and array_values() for params API and mark with U. 2006-07-14 17:55:27 +00:00
Andrei Zmievski
c30d1ecf11 - Simplify array_fill().
- Do params API for a couple of funcs and mark them as Unicode
  compliant.
2006-07-14 17:35:54 +00:00
Andrei Zmievski
c8254d82d7 Update array_sum() and array_product() (U). 2006-07-13 22:26:42 +00:00
Andrei Zmievski
8553cf9da8 Mark a few more funcs. 2006-07-13 22:03:42 +00:00
Andrei Zmievski
2fbc36496f - Let the caller output a warning instead of having
zend_get_unified_string_type() do it.
- Mark a few more functions are Unicode compatible.
2006-07-13 21:27:48 +00:00
Andrei Zmievski
c01957091a - Make compact() normalize variablem name before checking symtable.
- Mark tested/upgraded functions with 'U' flag.
2006-07-13 21:08:43 +00:00
Hannes Magnusson
bf0a79d381 Updated protos
Fixed vim folding
2006-06-25 19:19:31 +00:00
Andrei Zmievski
a871adf6bb MFB 2006-06-03 18:58:40 +00:00
Johannes Schlüter
e7747e8d74 - Fix bug #37060 (Type of retval of Countable::count() is not checked) 2006-04-12 19:29:52 +00:00
Derick Rethans
ad6a972de3 - Implemented basic collation support. For some reason "new Collator" gives segfaults when the object's collation resource is used.
- The following example shows what is implemented:

<?php
$orig = $strings = array(
    'côte',
    'cote',
    'côté',
    'coté',
    'fluße',
    'flüße',
);

echo "German phonebook:\n";
$c = collator_create( "de@collation=phonebook" );
foreach($c->sort($strings) as $string) {
    echo $string, "\n";
}
echo $c->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
    ? "With" : "Without", " french accent sorting order\n";

echo "\nFrench with options:\n";
$c = collator_create( "fr" );
$c->setAttribute(Collator::CASE_FIRST, Collator::UPPER_FIRST);
$c->setAttribute(Collator::CASE_LEVEL, Collator::ON);
$c->setStrength(Collator::SECONDARY);
foreach($c->sort($strings) as $string) {
    echo $string, "\n";
}
echo $c->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
    ? "With" : "Without", " french accent sorting order\n";
?>
2006-03-26 11:06:24 +00:00
Antony Dovgal
932c5d9e0e MF51: prevent segfault when exception is thrown from Countable::count() 2006-03-22 22:06:08 +00:00
Antony Dovgal
2c750d7f84 make the code a bit cleaner - no need for two different checks that are doing effectively the same 2006-03-19 22:12:39 +00:00
Dmitry Stogov
c366cc6d1a Nuke int32_t (everywhere except streams layer) and signed/unsigned warnings 2006-03-02 13:12:45 +00:00
Dmitry Stogov
e3b7f3fd0d Unicode support: MS Visual C compatibility 2006-02-26 11:57:14 +00:00
Dmitry Stogov
84f0adff86 Unicode support: fixed GLOBALS protection 2006-02-22 13:10:32 +00:00
Dmitry Stogov
0f1209ab3d Portable unicode string API:
- use the same type (int) for zval.value.usr.len and zval.value.str.len
  - use union "zstr" as char*/UChar* mixture instead of void*
  - Z_UNISTR() and Z_UNILEN() no longer check for Z_TYPE()
  - nuke int32_t from ZE (not finisned)
2006-02-21 20:12:43 +00:00
Dmitry Stogov
09ca61c125 Made server wide switch for unicode on/off (according to PDM). 2006-02-13 10:23:59 +00:00
Andrei Zmievski
f0a9b2d51b MFB. 2006-02-07 17:54:52 +00:00
Dmitry Stogov
227295a4f1 Unicode stuff is changed according to decision maden on PDM.
Now IS_BINRAY data type is removed and IS_STRING starts behave as IS_BINARY in unicode mode. IS_STRING is incompatible with IS_UNICODE, so ALL functions should be improved to support unicode mode.
2006-01-17 12:18:53 +00:00
Andrey Hristov
9be53ac7a5 cast and fix a warning 2006-01-04 22:42:17 +00:00
foobar
251c5173fd bump year and license version 2006-01-01 13:10:10 +00:00
Antony Dovgal
64d9c70e4c tweak the fix 2005-12-27 23:27:02 +00:00
Antony Dovgal
41973d8969 MF51: fix #35821 (array_map() segfaults when exception is throwed from the callback) 2005-12-27 22:33:40 +00:00
foobar
0ac2b74b0b - Nuke php3 legacy 2005-12-05 22:53:34 +00:00
Ilia Alshanetsky
1321658d91 MFB51: Fixed bug #35014 (array_product() always returns 0). 2005-10-30 13:46:34 +00:00
Dmitry Stogov
44e9370026 Fixed bug #34982 (array_walk_recursive() modifies elements outside function scope) 2005-10-28 09:57:50 +00:00
Dmitry Stogov
47893ed920 Reverted fix for bug #34934. The bug marked as bogus. 2005-10-24 07:01:43 +00:00
Antony Dovgal
aff2ed53ca fix ws 2005-10-21 15:54:46 +00:00
Dmitry Stogov
02090106d8 Fixed bug #34934 (offsetExists is not called from array_key_exists) 2005-10-21 15:20:30 +00:00
Antony Dovgal
f3e70f5b8c fix #34723 (array_count_values() strips leading zeroes) 2005-10-04 20:47:48 +00:00
Ilia Alshanetsky
63cd70e920 GLOBALS protection for extract() function. 2005-10-03 14:01:36 +00:00
Dmitry Stogov
03c6efab67 Additinal fix for bug #34277 (array_filter() crashes with references and objects) 2005-09-12 09:58:35 +00:00
Derick Rethans
161777af26 - Reimplement SORT_LOCALE_STRING with ICU locales. 2005-09-12 09:53:23 +00:00
Dmitry Stogov
cbd1c89e81 Fixed bug #34277 (array_filter() crashes with references and objects) 2005-09-01 11:58:41 +00:00
Dmitry Stogov
f4b8f4e958 Unicode support cleanup 2005-08-23 09:33:46 +00:00
Dmitry Stogov
6b622046dc zend_is_callable() and zend_make_callable() were changed to return readable function name as zval (instead of string). 2005-08-22 12:22:16 +00:00
Dmitry Stogov
2b5ebdde1d ZTS fix 2005-08-19 07:49:41 +00:00
Dmitry Stogov
974b209f78 ZTS fix 2005-08-19 07:26:13 +00:00
Andrei Zmievski
fd05d40cbe Rework range() to be able to work on binary strings and also on Unicode
code points. Binary strings are not interpreted as numeric.
2005-08-18 22:51:46 +00:00
Dmitry Stogov
74dafa95d1 Unicode support for extract() 2005-08-18 15:14:08 +00:00
Dmitry Stogov
263d919a20 Unicode support for range() 2005-08-17 15:12:03 +00:00
Dmitry Stogov
909e0a1c4e Unicode support 2005-08-15 17:29:07 +00:00
Antony Dovgal
969c533b83 fix compile warnings 2005-08-12 18:03:55 +00:00
Antony Dovgal
e458e45486 fix array_merge() adding one superfluous byte to the key 2005-08-12 16:49:20 +00:00
Andrei Zmievski
264cec8be6 Unicode support. 2005-08-11 23:36:07 +00:00
Antony Dovgal
c48f944a04 fix build 2005-08-10 10:28:18 +00:00
Dmitry Stogov
b03e53836e Fixed bug #33940 (array_map() fails to pass by reference when called recursively) 2005-08-10 08:23:39 +00:00
Dmitry Stogov
655e19326d Fixed bug #29253 (array_diff with $GLOBALS argument fails) 2005-08-10 07:43:16 +00:00
Dmitry Stogov
98e70ab585 Fixed bug #33989 (extract($GLOBALS,EXTR_REFS) crashes PHP) 2005-08-04 10:34:39 +00:00
foobar
23e671a51e - Bumber up year 2005-08-03 14:08:58 +00:00
Dmitry Stogov
1d33a3e95e Fixed bug #31158 (array_splice on $GLOBALS crashes) 2005-07-04 10:01:10 +00:00
foobar
340bcffdf0 - Unify (+ spl can't be build shared so COMPILE_DL_SPL 2005-06-30 11:15:00 +00:00
Dmitry Stogov
27374bfaf5 Fixed bug #31213 (Sideeffects caused by fix of bug #29493) 2005-06-21 12:10:51 +00:00
Wez Furlong
4de4565710 Fix compile on win32 at least. 2005-06-16 15:03:36 +00:00
Andrei Zmievski
be0458269e WS fix 2005-06-15 21:20:26 +00:00
Andrei Zmievski
ec09711101 Fix FCI cache for array_walk and user array compare functions. Bug
#33286. (Patch from m.bretz@metropolis-ag.de)
2005-06-15 20:51:33 +00:00
Dmitry Stogov
72c6d5cbaf Fixed memory allocation bugs in array_reduce() with initial value (#22463 & #24980) 2005-06-08 19:54:24 +00:00
Andrey Hristov
be3a9ccdf3 add function array_product() 2005-05-11 11:43:11 +00:00
Dmitry Stogov
c78ec1615a Fixed call to estrndup() with invalid length 2005-04-25 06:13:57 +00:00
Antony Dovgal
a13b29add7 fix #30833 (array_count_values modifying input array) 2005-04-12 14:00:54 +00:00
Ilia Alshanetsky
b30d8beebf Simplify argument checking code for array_combine(). 2005-03-22 01:45:17 +00:00
Marcus Boerger
e38141478a - Check another incarnation of bug #30266 2005-03-19 14:24:17 +00:00
Andrey Hristov
070147105f Fixed #30871 2005-03-12 10:11:46 +00:00
Marcus Boerger
faae6ac159 - Do not touch return_valu's refcount or is_ref 2005-03-11 00:14:02 +00:00
Andrei Zmievski
f8fc9a3256 Check that object can actually return a class entry. I need this for a
class-entry-less helper objects that should not be present in the class
table.
2005-03-05 00:45:47 +00:00
Derick Rethans
ff1687731d - Fixed bug #32021: Crash caused by range('', 'z') 2005-02-18 13:37:23 +00:00
Rob Richards
bb9ba8e36e fix segfault when retval_ptr is empty - such as when exception thrown 2005-02-10 22:59:26 +00:00
Stanislav Malyshev
7b241027fa fix memory leak if function call fails 2005-02-02 10:37:50 +00:00
Antony Dovgal
38d8e20f68 destroy return_value and fix leak in array_fill() 2004-12-23 16:35:48 +00:00
Antony Dovgal
33c24b5436 fix leak (init array only if we got valid start key) 2004-12-16 19:13:58 +00:00
Antony Dovgal
b6b8bf0010 fix array_walk_recursive() so it doesn't reuse cached fci between calls
and add test for it
2004-12-03 17:43:23 +00:00
Antony Dovgal
ccc6462cc5 revert my previous patch as it breaks more than fixes 2004-12-02 16:35:02 +00:00
Antony Dovgal
dbc0bb7514 fix #29954 (array_reduce segfaults when initial value is array) 2004-11-28 17:03:45 +00:00
Antony Dovgal
2a588879ef fix bug #30587 (array_multisort doesn't separate zvals before changing them) 2004-11-19 16:55:37 +00:00
Marcus Boerger
c18e248e60 - Remove doubled definition 2004-11-01 22:28:59 +00:00
Marcus Boerger
b0c2af58f7 - Add some comment 2004-11-01 21:06:42 +00:00
Marcus Boerger
2ce7bcd742 - Allow direct access to spl class entries (SPL cannot be build shared) 2004-11-01 20:57:23 +00:00
Marcus Boerger
db47e478c5 - Use new way for global variables
- Cache class lookup
2004-11-01 12:09:46 +00:00
Marcus Boerger
8e3a8b1e8e - Add interface Countable (PECL #30113) 2004-11-01 10:45:54 +00:00
Andi Gutmans
11bcaedfc8 - Rename delete_global_variable() to zend_delete_global_variable() 2004-10-04 20:17:06 +00:00
Andi Gutmans
db507dd153 - Commit the variable fetch optimization.
- Extensions which delete global variables need to use new special function
- delete_global_variable() (I'm about to rename it) to remove them.
- Will post to internals@ or via commit messages if there's anything else.
2004-10-04 19:54:35 +00:00
Derick Rethans
7795da58e6 - Added new boolean (fourth) parameter to array_slice() that turns on the
preservation of keys in the returned array.
2004-09-15 11:50:27 +00:00
Derick Rethans
4bae5cb4d0 - MFB: Added the sorting flag SORT_LOCALE_STRING to the sort() functions which
makes them sort based on the current locale. (Derick)
2004-09-11 14:22:35 +00:00
Ilia Alshanetsky
fe73e4d851 Fixed bug #29808 (array_count_values() breaks with numeric strings). 2004-08-26 00:26:19 +00:00
Andi Gutmans
0286913937 - Use FREE_HASHTABLE() 2004-08-12 06:17:42 +00:00
Moriyoshi Koizumi
51fc7b8ea5 - Bugfix #29493 (extract(array, EXTR_REFS) misbehaves with elements referred
twice or more times). (Patch inspired by Michael Manley. Thanks.)
2004-08-10 06:00:30 +00:00
Ilia Alshanetsky
739696d2d7 Fixed but #29437 (Possible crash inside array_walk_recursive()). 2004-07-29 00:35:07 +00:00
Andrey Hristov
e64af9a898 proto fix
(thanks to dave%php.net for spotting)
2004-07-26 06:32:54 +00:00
Andrey Hristov
d77a3f92e6 make behavior a bit field 2004-07-24 09:25:52 +00:00
Andrey Hristov
5e5d2640fb add array_:
intersect_key()
intersect_ukey()
diff_key()
diff_ukey()
The first two by a patch of Cristiano Duarte. The second two were
implemented in almost the same way except one small difference.
2004-07-21 21:17:56 +00:00
Andrey Hristov
0eef82a733 fixing bug #28974 : overflow in array_slice()
The same kind of overflow appeared in array_splice(), substr() and
substr_replace()
2004-07-11 21:15:04 +00:00
Andrey Hristov
268d3d7ba3 fixing bug #28739
array_*diff() and array_*intersect() not clearing the fci cache before work.
FCI call cache was introduced in HEAD. All functions that perform sorting
of arrays clear the fci cache before work. array_*diff() and\ array_*intersect()
were somehow missed to be updated.
2004-07-11 19:20:05 +00:00
Andrey Hristov
7af08c0c34 fixing bug 29038:
EXTR_PREFIX_SAME is prevented from creating a new variable when the key
is a empty string. EXTR_PREFIX_ALL is also prevented from doing that,
but works for numbers.
2004-07-11 18:18:05 +00:00
Ilia Alshanetsky
4ebcb2ecfe Fixed bug #29008 (array_combine() does not handle non-numeric/string keys). 2004-07-11 15:23:57 +00:00
Ilia Alshanetsky
79c28f7618 Fixed bug #29049 (array sorting via user function/method does not validate
it).
2004-07-08 17:07:22 +00:00
Wez Furlong
263723ec9b Update for count_elements handler for overloaded objects. 2004-05-04 15:03:48 +00:00
Ilia Alshanetsky
c85843aec1 MFB: Revert patch for bug #27782. 2004-04-01 22:07:42 +00:00
Ilia Alshanetsky
ec4655f864 Fixed bug #27782 (Wrong behaviour of next(), prev() and each()). 2004-03-30 19:08:43 +00:00
Andrey Hristov
eaab3ef8cd this should not belong to HEAD 2004-01-28 20:25:30 +00:00
Andrey Hristov
9957fc6305 Added third parameter (optional) to array_keys for strictness. It behaves
like the "strict" parameter of in_array().
#Closing feature request #24258
2004-01-24 00:25:58 +00:00
Andrey Hristov
9e5df0c666 HEAD is now bundled only with ZE2 2004-01-17 17:33:11 +00:00
Andi Gutmans
dbeb4158d2 - A belated happy holidays and PHP 5 2004-01-08 08:18:22 +00:00
Andrey Hristov
638b940307 New array functions for doing intersection of arrays that are complementary
to array_*diff* family of functions. Namely array_uintersect(), array_uintersect_assoc(),
array_intersect_uassoc() and array_uintersect_uassoc(). Test case is also included.
#docs and news entry later.
2003-10-09 08:10:39 +00:00
Ilia Alshanetsky
31a3c87159 Fixed clobbering of the source array, when merging complex
multi-dimensional arrays. Bug reported by Lukas Smith.
2003-10-05 19:37:02 +00:00
Moriyoshi Koizumi
75bb36ed09 Fixed bug #25708 (extract($GLOBALS, EXTR_REFS) mangles $GLOBALS) 2003-10-02 22:20:48 +00:00
Andrey Hristov
40088d0bbc smash a segmentation fault 2003-09-30 15:00:36 +00:00
Andrey Hristov
02827c46be Memory leak fixed (no need of MFH since this is code specific to PHP5) 2003-09-30 12:43:58 +00:00
Hartmut Holzgraefe
075e66cc08 signed/unsigned compiler warning fixes 2003-09-26 08:09:56 +00:00
Ilia Alshanetsky
6966350013 Fixed typo. 2003-09-26 00:40:32 +00:00
Andrey Hristov
3579f212df 4 new functions :
array_udiff()
array_udiff_assoc()
array_diff_uassoc()
array_udiff_uassoc()
They work like array_diff() or array_diff_assoc() but callback function(s)
can be used to perform the comparisons. For example array_udiff_uassoc()
expects 2 callbacks are last 2 parameters one is used to compare the values
of the entries in the arrays the second to compare the keys.
Class methods are also valid callbacks. Even when the data that should be
used in the comparison is private or protected then a static method of a
class should be used (this behaviour can be seen in the regression test -
007.phpt).
2003-09-23 17:37:29 +00:00
Andrey Hristov
63d7df3e2f improve the fix for #25494. If more then one bad parameter is passed
an warning for all will be emitted.
2003-09-22 23:19:17 +00:00
Jay Smith
6c6fd76bac Fixed bug #25494 (array_merge allowing "false" as argument (silent when
non-array is passed))
# 4.3 throws E_NOTICEs, 5 errors out on non-array args as per Ilia's
# suggestion.
2003-09-11 17:40:18 +00:00
foobar
8733d2dacb revert that, it did not fix anything 2003-08-13 01:37:31 +00:00
foobar
0ee19d47d9 Fix external builds (configure run outside srcdir) 2003-08-13 01:24:27 +00:00
Ilia Alshanetsky
ed40ae2650 emalloc -> safe_emalloc 2003-08-11 23:16:54 +00:00
Ilia Alshanetsky
e5b7d5ccb4 Fixed bug #24897 (inconsistent behavior of shuffle() & array_multisort()) 2003-08-09 20:49:00 +00:00
Ilia Alshanetsky
e49964fe99 Do not assume array contains numeric values. 2003-08-09 16:43:28 +00:00
Ilia Alshanetsky
a2873880f6 Fixed bug #24980 (array_reduce() uses first element as default running
total).
Fixed memory leak that can be replicated using the function example on
http://www.php.net/array_reduce
2003-08-08 23:50:36 +00:00
Zeev Suraski
90b29aa076 Replace fast_call_user_function() with zend_call_function() 2003-08-05 10:29:03 +00:00
Zeev Suraski
2547b6f6f6 Fix bug #24652 - Sterling, do you begin to think that maybe it wasn't such
a good idea?
2003-08-04 08:38:24 +00:00
Ilia Alshanetsky
ee3e4f79df Removed unused variable. 2003-07-25 03:03:26 +00:00
Zeev Suraski
0a49c033d0 - Use the new infrastructure of zend_symtable_*() (fixes bug #24565)
- Fix bogus use of get_current_key()
2003-07-22 16:08:50 +00:00
Ilia Alshanetsky
6057160dbf Fixed bug #24198 (Invalid recursion detection in array_merge_recurcive()) 2003-06-16 17:35:16 +00:00
Andrey Hristov
2d4449caf9 silly bug 2003-06-12 15:11:11 +00:00
James Cox
f68c7ff249 updating license information in the headers. 2003-06-10 20:04:29 +00:00
Sterling Hughes
295a1c665c fix array_key_exists() from HANDLE_NUMERIC() changes
# need to go through this file and find any stuff that relies on this
# change
2003-06-05 13:58:14 +00:00
Sterling Hughes
3c6fd35007 initialize these to NULL 2003-05-20 18:18:56 +00:00
Sterling Hughes
9ac50a13d7 convert array functions to use fast_call_user_function(), gives a nice
performance win.
2003-05-20 16:46:53 +00:00
Moriyoshi Koizumi
4e9e9c6e21 Fixed bug #22463 and bug #23581 2003-05-11 06:36:37 +00:00
Sara Golemon
07c679064a Bug Fix (22433). When the bottom of a range() is chr(0) or the top is chr(255), the for loop carries over and never exits. 2003-05-02 00:58:02 +00:00
Moriyoshi Koizumi
0c5548e636 Fixed implicit cast issue with is*() and to*() functions 2003-04-16 21:40:48 +00:00
Sara Golemon
465bb61357 Kludgy fix for floating point drift causing problems like range(1.0,1.5,0.1) == array(1.0,1.1,1.2,1.3,1.4); 2003-04-03 18:33:05 +00:00
Rasmus Lerdorf
4b343a0562 MFB 2003-04-01 21:47:21 +00:00
Ilia Alshanetsky
3db5278dcc CS 2003-03-27 18:57:53 +00:00
Andrey Hristov
8c2dbd5f0f additional speedup for array_shift(). No need to rehash if the removed element's
key is not scalar and elements with scalar keys are already well numbered
(sequentially from 0) for some reason. This is the case if the leading
elements have no scalar indexes.
2003-02-22 13:55:11 +00:00
Andrey Hristov
94040a28ce rehash only in case something is changed.
#lowers the execution time in half on my machine on array with 1000 elements
#with nonscalar keys. Maybe it can be optimized further.
2003-02-22 10:54:26 +00:00
foobar
20f9b6d02c - Fixed bug #22088 (array_shift() leaves next index to be +1 too much) 2003-02-06 15:27:53 +00:00
Ilia Alshanetsky
f12a6b7663 Added array_walk_recursive() function that can apply array_walk recursively
to an array.
2003-02-05 17:56:08 +00:00
foobar
07a9729071 - Fixed bug: #21998 (array_pop() did not reset the current array position)
# This behaves now same as in PHP 4.2.3
2003-02-03 16:57:02 +00:00
Ilia Alshanetsky
38ad0e9104 zend_error -> php_error_docref. 2003-01-24 16:29:40 +00:00
Ilia Alshanetsky
8a9e09a44a ARG_COUNT(ht) -> ZEND_NUM_ARGS(). 2003-01-21 14:56:40 +00:00
Andrey Hristov
1cdc956637 added array_combine().
Creates an array by using the elements of the first parameter as keys and
the elements of the second as correspoding keys. Error is thrown in case
the arrays has different number of elements. Number of elements 0 is not
valid for both parameters.
2003-01-13 18:12:23 +00:00
Moriyoshi Koizumi
f962ba6abb Fixed small leaks in array_map() in case the first parameter is NULL like
array_map(NULL, array(...));
2003-01-03 05:05:12 +00:00