[PHP-CVS] com php-src: Update NEWS/UPGRADING with info about incompat ctx: NEWS UPGRADING
Commit:04fcf6a98b8901ae7c442aa92368c82fa7bd671d Author:Gustavo André dos Santos Lopes cataphr...@php.net Mon, 2 Sep 2013 23:19:53 +0200 Parents: 825c1f239b3432e76299c1dba0869df2b57b4c0d Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=04fcf6a98b8901ae7c442aa92368c82fa7bd671d Log: Update NEWS/UPGRADING with info about incompat ctx Changed paths: M NEWS M UPGRADING Diff: diff --git a/NEWS b/NEWS index 0c94ea2..29b5c9c 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ PHP NEWS . Improved IS_VAR operands fetching. (Laruence, Dmitry) . Implemented internal operator overloading (RFC: https://wiki.php.net/rfc/operator_overloading_gmp). (Nikita) + . Made calls from incompatible context issue an E_DEPRECATED warning instead +of E_STRICT (phase 1 of RFC: https://wiki.php.net/rfc/incompat_ctx). + (Gustavo) - Session: . Fixed Bug #65315 (session.hash_function silently fallback to default md5) diff --git a/UPGRADING b/UPGRADING index 431ad79..f392edd 100755 --- a/UPGRADING +++ b/UPGRADING @@ -35,6 +35,9 @@ PHP X.Y UPGRADE NOTES 3. Deprecated Functionality +- Incompatible context calls: + Instance calls from an incompatible context are now deprecated and issue + E_DEPRECATED instead of E_STRICT. See https://wiki.php.net/rfc/incompat_ctx 4. Changed Functions -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Implement phase 1 of rfc/incompat_ctx: Zend/tests/incompat_ctx_user.phpt Zend/zend_vm_def.h Zend/zend_vm_execute.h
Commit:d515455589d836e709a65590e14d85575bdd2766 Author:Gustavo André dos Santos Lopes cataphr...@php.net Mon, 2 Sep 2013 01:53:06 +0200 Parents: 47ee470992014c738891d05b5acc89c2de90f2ac Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d515455589d836e709a65590e14d85575bdd2766 Log: Implement phase 1 of rfc/incompat_ctx Just changing the error level of the message from E_STRICT to E_DEPRECATED. This comes one version later than the timeline mentioned in the RFC. Oddly, there were no tests for this ‘feature’. I added a simple one. Changed paths: A Zend/tests/incompat_ctx_user.phpt M Zend/zend_vm_def.h M Zend/zend_vm_execute.h diff --git a/Zend/tests/incompat_ctx_user.phpt b/Zend/tests/incompat_ctx_user.phpt new file mode 100644 index 000..2d9b59c --- /dev/null +++ b/Zend/tests/incompat_ctx_user.phpt @@ -0,0 +1,20 @@ +--TEST-- +Incompatible context call (non-internal function) +--INI-- +error_reporting=E_ALL +--FILE-- +?php + +class A { + function foo() { var_dump(get_class($this)); } +} +class B { + function bar() { A::foo(); } +} +$b = new B; +$b-bar(); + +? +--EXPECTF-- +Deprecated: Non-static method A::foo() should not be called statically, assuming $this from incompatible context in %s on line %d +string(1) B diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 4ab2129..2bc80fa 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2609,7 +2609,7 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ if (call-fbc-common.fn_flags ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, Non-static method %s::%s() should not be called statically, assuming $this from incompatible context, call-fbc-common.scope-name, call-fbc-common.function_name); + zend_error(E_DEPRECATED, Non-static method %s::%s() should not be called statically, assuming $this from incompatible context, call-fbc-common.scope-name, call-fbc-common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ zend_error_noreturn(E_ERROR, Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context, call-fbc-common.scope-name, call-fbc-common.function_name); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 0ea5fc4..08fb847 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3661,7 +3661,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER( /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ if (call-fbc-common.fn_flags ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, Non-static method %s::%s() should not be called statically, assuming $this from incompatible context, call-fbc-common.scope-name, call-fbc-common.function_name); + zend_error(E_DEPRECATED, Non-static method %s::%s() should not be called statically, assuming $this from incompatible context, call-fbc-common.scope-name, call-fbc-common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */ zend_error_noreturn(E_ERROR, Non-static method %s::%s() cannot be called statically, assuming $this from incompatible context, call-fbc-common.scope-name, call-fbc-common.function_name); @@ -4654,7 +4654,7 @@ static int ZEND_FASTCALL ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZE /* We are calling method of the other (incompatible) class, but passing $this. This is done for compatibility with php-4. */ if (call-fbc-common.fn_flags ZEND_ACC_ALLOW_STATIC) { - zend_error(E_STRICT, Non-static method %s::%s() should not be called statically, assuming $this from incompatible context, call-fbc-common.scope-name, call-fbc-common.function_name); + zend_error(E_DEPRECATED, Non-static method %s::%s() should not be called statically, assuming $this from incompatible context, call-fbc-common.scope-name, call-fbc-common.function_name); } else { /* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call
[PHP-CVS] com php-src: intl: remove extra quotes from arginfo params: ext/intl/breakiterator/breakiterator_class.cpp
Commit:3363e04fb48088cb6873ab79d993e556880483a3 Author:Gustavo André dos Santos Lopes cataphr...@php.net Sun, 21 Jul 2013 03:29:36 +0200 Parents: 1dc7d0da083ff77f02957ffdff9f4e8e7e3cf477 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3363e04fb48088cb6873ab79d993e556880483a3 Log: intl: remove extra quotes from arginfo params Changed paths: M ext/intl/breakiterator/breakiterator_class.cpp Diff: diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index 7bf271a..7ca7e94 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -245,32 +245,32 @@ ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_void, 0, 0, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_locale, 0, 0, 0) - ZEND_ARG_INFO(0, locale) + ZEND_ARG_INFO(0, locale) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_setText, 0, 0, 1) - ZEND_ARG_INFO(0, text) + ZEND_ARG_INFO(0, text) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_next, 0, 0, 0) - ZEND_ARG_INFO(0, offset) + ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_offset, 0, 0, 1) - ZEND_ARG_INFO(0, offset) + ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_get_locale, 0, 0, 1) - ZEND_ARG_INFO(0, locale_type) + ZEND_ARG_INFO(0, locale_type) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_getPartsIterator, 0, 0, 0) - ZEND_ARG_INFO(0, key_type) + ZEND_ARG_INFO(0, key_type) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_rbbi___construct, 0, 0, 1) - ZEND_ARG_INFO(0, rules) - ZEND_ARG_INFO(0, areCompiled) + ZEND_ARG_INFO(0, rules) + ZEND_ARG_INFO(0, areCompiled) ZEND_END_ARG_INFO() /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: socket: fix bug #65260 (SCM_RIGHTS): ext/sockets/conversions.c ext/sockets/tests/socket_cmsg_rights.phpt
Commit:e2744f1aa33da3afade2c454b008c0de65a72da9 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 15 Jul 2013 01:44:38 +0200 Parents: e7a4cf8d7ee68ade2901c1069f2af7ff1427 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e2744f1aa33da3afade2c454b008c0de65a72da9 Log: socket: fix bug #65260 (SCM_RIGHTS) The data for messages of type SOL_SOCKET/SCM_RIGHTS was not being passed correctly. There were actually two bugs: (1) the number of file descriptors being passed was being read incorrectly (the length of the cmsg array was being read instead of that of its 'data' element), as a result it was generally being reported as always three elements ('level', 'type' and 'data') and (2) the allocated block for writing the file descriptors was being acessed incorrectly because a 1-based counter was being used as if it was 0-based. Any of these two bugs would probably be enough to cause heap corruption. Bugs: https://bugs.php.net/65260 Changed paths: M ext/sockets/conversions.c M ext/sockets/tests/socket_cmsg_rights.phpt Diff: diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index ea1c952..3b58b39 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -223,6 +223,7 @@ static unsigned from_array_iterate(const zval *arr, charbuf[sizeof(element #4294967295)]; char*bufp = buf; + /* Note i starts at 1, not 0! */ for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), pos), i = 1; !ctx-err.has_error zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **)elem, pos) == SUCCESS; @@ -869,7 +870,14 @@ static void from_zval_write_control(const zval *arr, } if (entry-calc_space) { - data_len = entry-calc_space(arr, ctx); + zval **data_elem; + /* arr must be an array at this point */ + if (zend_hash_find(Z_ARRVAL_P(arr), data, sizeof(data), + (void**)data_elem) == FAILURE) { + do_from_zval_err(ctx, cmsghdr should have a 'data' element here); + return; + } + data_len = entry-calc_space(*data_elem, ctx); if (ctx-err.has_error) { return; } @@ -1370,7 +1378,7 @@ static void from_zval_write_fd_array_aux(zval **elem, unsigned i, void **args, s return; } - if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)iarr[i], + if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)iarr[i - 1], REPORT_ERRORS) == FAILURE) { do_from_zval_err(ctx, cast stream to file descriptor failed); return; diff --git a/ext/sockets/tests/socket_cmsg_rights.phpt b/ext/sockets/tests/socket_cmsg_rights.phpt index 8290f03..8c1734a 100644 --- a/ext/sockets/tests/socket_cmsg_rights.phpt +++ b/ext/sockets/tests/socket_cmsg_rights.phpt @@ -84,6 +84,7 @@ Array [0] = Resource id #%d [1] = Resource id #%d [2] = Resource id #%d +[3] = Resource id #%d ) ) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: NEWS for 710150c and e2744f1: NEWS
Commit:ceecfaff5ac793d50426ae051fd4bec932d23bb1 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 16 Jul 2013 00:02:43 +0200 Parents: 710150ccb7d62c87eb198e5cbb13d0f1867c176f Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ceecfaff5ac793d50426ae051fd4bec932d23bb1 Log: NEWS for 710150c and e2744f1 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 5422b0b..f524acb 100644 --- a/NEWS +++ b/NEWS @@ -40,7 +40,7 @@ PHP NEWS - Intl: . Add IntlCalendar::setMinimalDaysInFirstWeek()/ intlcal_set_minimal_days_in_first_week(). - . Fixed trailing space in the name of constant IntlCalendar::FIELD_FIELD_COUNT. + . Fixed trailing space in name of constant IntlCalendar::FIELD_FIELD_COUNT. . Fixed bug #62759 (Buggy grapheme_substr() on edge case). (Stas) . Fixed bug #61860 (Offsets may be wrong for grapheme_stri* functions). (Stas) @@ -65,6 +65,10 @@ PHP NEWS - Sockets: . Implemented FR #63472 (Setting SO_BINDTODEVICE with socket_set_option). (Damjan Cvetko) + . Allowed specifying paths in the abstract namespace for the functions +socket_bind(), socket_connect() and socket_sendmsg(). (Gustavo) + . Fixed bug #65260 (sendmsg() ancillary data construction for SCM_RIGHTS is +faulty). (Gustavo) - SPL: . Fixed bug #65136 (RecursiveDirectoryIterator segfault). (Laruence) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: socket: support unix paths in the abstract namespace: ext/sockets/conversions.c ext/sockets/sockets.c ext/sockets/tests/socket_abstract_path.phpt ext/sockets/tests/socket_abstra
Commit:710150ccb7d62c87eb198e5cbb13d0f1867c176f Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 15 Jul 2013 01:51:15 +0200 Parents: e2744f1aa33da3afade2c454b008c0de65a72da9 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=710150ccb7d62c87eb198e5cbb13d0f1867c176f Log: socket: support unix paths in the abstract namespace Those starting with '\0'. Changed paths: M ext/sockets/conversions.c M ext/sockets/sockets.c A ext/sockets/tests/socket_abstract_path.phpt A ext/sockets/tests/socket_abstract_path_sendmsg.phpt Diff: diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index 3b58b39..ed55ed5 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -98,8 +98,8 @@ typedef struct { } field_descriptor; #define KEY_FILL_SOCKADDR fill_sockaddr -#define KEY_RECVMSG_RET recvmsg_ret -#define KEY_CMSG_LEN cmsg_len +#define KEY_RECVMSG_RET recvmsg_ret +#define KEY_CMSG_LEN cmsg_len const struct key_value empty_key_value_list[] = {{0}}; @@ -667,6 +667,13 @@ static void from_zval_write_sun_path(const zval *path, char *sockaddr_un_c, ser_ path = lzval; } + /* code in this file relies on the path being nul terminated, even though +* this is not required, at least on linux for abstract paths. It also +* assumes that the path is not empty */ + if (Z_STRLEN_P(path) == 0) { + do_from_zval_err(ctx, %s, the path is cannot be empty); + return; + } if (Z_STRLEN_P(path) = sizeof(saddr-sun_path)) { do_from_zval_err(ctx, the path is too long, the maximum permitted length is %ld, sizeof(saddr-sun_path) - 1); @@ -768,10 +775,22 @@ static void from_zval_write_sockaddr_aux(const zval *container, return; } *sockaddr_ptr = accounted_ecalloc(1, sizeof(struct sockaddr_un), ctx); - *sockaddr_len = sizeof(struct sockaddr_un); if (fill_sockaddr) { + struct sockaddr_un *sock_un = (struct sockaddr_un*)*sockaddr_ptr; + from_zval_write_sockaddr_un(container, (char*)*sockaddr_ptr, ctx); (*sockaddr_ptr)-sa_family = AF_UNIX; + + /* calculating length is more complicated here. Giving the size of +* struct sockaddr_un here and relying on the nul termination of +* sun_path does not work for paths in the abstract namespace. Note +* that we always assume the path is not empty and nul terminated */ + *sockaddr_len = offsetof(struct sockaddr_un, sun_path) + + (sock_un-sun_path[0] == '\0' + ? (1 + strlen(sock_un-sun_path[1])) + : strlen(sock_un-sun_path)); + } else { + *sockaddr_len = sizeof(struct sockaddr_un); } break; diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 801af0a..b226d94 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -1479,7 +1479,7 @@ PHP_FUNCTION(socket_strerror) PHP_FUNCTION(socket_bind) { zval*arg1; - php_sockaddr_storagesa_storage; + php_sockaddr_storagesa_storage = {0}; struct sockaddr *sock_type = (struct sockaddr*) sa_storage; php_socket *php_sock; char*addr; @@ -1497,10 +1497,19 @@ PHP_FUNCTION(socket_bind) case AF_UNIX: { struct sockaddr_un *sa = (struct sockaddr_un *) sock_type; - memset(sa, 0, sizeof(sa_storage)); + sa-sun_family = AF_UNIX; - snprintf(sa-sun_path, 108, %s, addr); - retval = bind(php_sock-bsd_socket, (struct sockaddr *) sa, SUN_LEN(sa)); + + if (addr_len = sizeof(sa-sun_path)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + Invalid path: too long (maximum size is %d), + (int)sizeof(sa-sun_path) - 1); + RETURN_FALSE; + } + memcpy(sa-sun_path, addr, addr_len); + + retval = bind(php_sock-bsd_socket, (struct sockaddr *) sa, + offsetof(struct sockaddr_un, sun_path) + addr_len); break; } @@ -1508,8
[PHP-CVS] com php-src: intl: add intlcal_set_minimal_days_in_first_week(): ext/intl/calendar/calendar_class.cpp ext/intl/calendar/calendar_methods.cpp ext/intl/calendar/calendar_methods.h ext/intl/php
Commit:a4538a4ca2db39706625bf29379360ea963c908a Author:Gustavo André dos Santos Lopes cataphr...@php.net Wed, 3 Jul 2013 04:57:23 +0100 Parents: 1aeb2514fe210c99c3e566d59788e76a8b3018d8 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a4538a4ca2db39706625bf29379360ea963c908a Log: intl: add intlcal_set_minimal_days_in_first_week() and IntlCalendar::setMinimalDaysInFirstWeek(). This one had slipped. we had a ::getMinimalDaysInFirstWeek() but no way to change the value. Changed paths: M ext/intl/calendar/calendar_class.cpp M ext/intl/calendar/calendar_methods.cpp M ext/intl/calendar/calendar_methods.h M ext/intl/php_intl.c A ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt A ext/intl/tests/calendar_setMinimalDaysInFirstWeek_error.phpt Diff: diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp index beb65f7..9495a00 100644 --- a/ext/intl/calendar/calendar_class.cpp +++ b/ext/intl/calendar/calendar_class.cpp @@ -361,6 +361,10 @@ ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setLenient, 0, 0, 1) ZEND_ARG_INFO(0, isLenient) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_set_minimal_days_in_first_week, 0, 0, 1) + ZEND_ARG_INFO(0, numberOfDays) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1) ZEND_ARG_INFO(0, dateTime) ZEND_END_ARG_INFO() @@ -433,6 +437,7 @@ static const zend_function_entry Calendar_class_functions[] = { #endif PHP_ME_MAPPING(setFirstDayOfWeek, intlcal_set_first_day_of_week, ainfo_cal_dow, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(setLenient, intlcal_set_lenient, ainfo_cal_setLenient, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(setMinimalDaysInFirstWeek,intlcal_set_minimal_days_in_first_week,ainfo_cal_set_minimal_days_in_first_week,ZEND_ACC_PUBLIC) PHP_ME_MAPPING(equals, intlcal_equals, ainfo_cal_other_cal,ZEND_ACC_PUBLIC) #if U_ICU_VERSION_MAJOR_NUM = 49 PHP_ME_MAPPING(getRepeatedWallTimeOption,intlcal_get_repeated_wall_time_option,ainfo_cal_void, ZEND_ACC_PUBLIC) diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp index 2d33bd1..db10502 100644 --- a/ext/intl/calendar/calendar_methods.cpp +++ b/ext/intl/calendar/calendar_methods.cpp @@ -997,6 +997,32 @@ U_CFUNC PHP_FUNCTION(intlcal_set_lenient) RETURN_TRUE; } +U_CFUNC PHP_FUNCTION(intlcal_set_minimal_days_in_first_week) +{ + longnum_days; + CALENDAR_METHOD_INIT_VARS; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), + Ol, object, Calendar_ce_ptr, num_days) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + intlcal_set_minimal_days_in_first_week: bad arguments, 0 TSRMLS_CC); + RETURN_FALSE; + } + + if (num_days 1 || num_days 7) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + intlcal_set_minimal_days_in_first_week: invalid number of days; + must be between 1 and 7, 0 TSRMLS_CC); + RETURN_FALSE; + } + + CALENDAR_METHOD_FETCH_OBJECT; + + co-ucal-setMinimalDaysInFirstWeek((uint8_t)num_days); + + RETURN_TRUE; +} + U_CFUNC PHP_FUNCTION(intlcal_equals) { zval*other_object; diff --git a/ext/intl/calendar/calendar_methods.h b/ext/intl/calendar/calendar_methods.h index 2be13e4..dfd0bbe 100644 --- a/ext/intl/calendar/calendar_methods.h +++ b/ext/intl/calendar/calendar_methods.h @@ -91,6 +91,8 @@ PHP_FUNCTION(intlcal_set_first_day_of_week); PHP_FUNCTION(intlcal_set_lenient); +PHP_FUNCTION(intlcal_set_minimal_days_in_first_week); + PHP_FUNCTION(intlcal_equals); PHP_FUNCTION(intlcal_get_repeated_wall_time_option); diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index a2c4d77..65e53c8 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -590,6 +590,11 @@ ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_lenient, 0, 0, 2 ) ZEND_ARG_INFO( 0, isLenient ) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX( ainfo_cal_set_minimal_days_in_first_week, 0, 0, 2 ) + ZEND_ARG_OBJ_INFO( 0, calendar, IntlCalendar, 0 ) + ZEND_ARG_INFO( 0, numberOfDays ) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1) ZEND_ARG_INFO(0, dateTime) ZEND_END_ARG_INFO() @@ -828,6 +833,7 @@ zend_function_entry intl_functions[] = { #endif PHP_FE( intlcal_set_first_day_of_week, ainfo_cal_dow ) PHP_FE( intlcal_set_lenient, ainfo_cal_set_lenient ) + PHP_FE( intlcal_set_minimal_days_in_first_week, ainfo_cal_set_minimal_days_in_first_week ) PHP_FE( intlcal_equals, ainfo_cal_other_cal
[PHP-CVS] com php-src: NEWS for two lst intl changes: NEWS
Commit:b52fea6f3595d630541253f675c16a5db55eb8d0 Author:Gustavo André dos Santos Lopes cataphr...@php.net Wed, 3 Jul 2013 05:22:33 +0100 Parents: 9487f0b4bb17b86adb5d40e169552fd8e7269613 Branches: PHP-5.5 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b52fea6f3595d630541253f675c16a5db55eb8d0 Log: NEWS for two lst intl changes Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 860b3c3..d59945f 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,9 @@ PHP NEWS that other formats. (Remi) - Intl: + . Add IntlCalendar::setMinimalDaysInFirstWeek()/ +intlcal_set_minimal_days_in_first_week(). + . Fixed trailing space in the name of constant IntlCalendar::FIELD_FIELD_COUNT. . Fixed bug #62759 (Buggy grapheme_substr() on edge case). (Stas) . Fixed bug #61860 (Offsets may be wrong for grapheme_stri* functions). (Stas) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug #64506: fix build with --disable-ipv6: NEWS ext/sockets/conversions.c ext/sockets/sendrecvmsg.c ext/sockets/sockets.c
Commit:6f3c3862ca5c136bb123c1e60e1f163bb7efcf3f Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 8 May 2013 19:51:39 +0200 Parents: 288f04c430b271c416b4cc0a4cef7845927be7b0 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6f3c3862ca5c136bb123c1e60e1f163bb7efcf3f Log: Fix bug #64506: fix build with --disable-ipv6 Bugs: https://bugs.php.net/64506 Changed paths: M NEWS M ext/sockets/conversions.c M ext/sockets/sendrecvmsg.c M ext/sockets/sockets.c diff --git a/NEWS b/NEWS index 2a3b917..67e5196 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,9 @@ PHP NEWS (Boris Lytochkin) . Fixed bug #64159 (Truncated snmpget). (Boris Lytochkin) +- Sockets: + . Fixed bug #64506 (Fails to build with --disable-ipv6). (Gustavo) + - Streams: . Fixed bug #64770 (stream_select() fails with pipes returned by proc_open() on Windows x64). (Anatol) @@ -28,7 +31,7 @@ PHP NEWS 25 Apr 2013, PHP 5.5.0 Beta 4 - Core: - . Fixed bug #64677 (execution operator `` stealing surrounding arguments). + . Fixed bug #64677 (execution operator `` stealing surrounding arguments). (Laruence) - CURL: @@ -47,13 +50,13 @@ PHP NEWS (Eric Iversen) - Streams: - . Fixed Windows x64 version of stream_socket_pair() and improved error handling -(Anatol Belski) + . Fixed Windows x64 version of stream_socket_pair() and improved error +handling. (Anatol Belski) 11 Apr 2013, PHP 5.5.0 Beta 3 - Core: - . Fixed bug #64578 (debug_backtrace in set_error_handler corrupts zend heap: + . Fixed bug #64578 (debug_backtrace in set_error_handler corrupts zend heap: segfault). (Laruence) . Fixed bug #64565 (copy doesn't report failure on partial copy). (Remi) . Fixed bug #64555 (foreach no longer copies keys if they are interned). @@ -71,7 +74,7 @@ PHP NEWS Kapelushnik, Derick) - General improvements: - . Drop support for bison 2.4 when building PHP from GIT source. + . Drop support for bison 2.4 when building PHP from GIT source. (Laruence) - Fileinfo: @@ -109,7 +112,7 @@ PHP NEWS 21 Mar 2013, PHP 5.5.0 Beta 1 - Core: - . Added Zend Opcache extension and enable building it by default. + . Added Zend Opcache extension and enable building it by default. More details here: https://wiki.php.net/rfc/optimizerplus. (Dmitry) . Added array_column function which returns a column in a multidimensional array. https://wiki.php.net/rfc/array_column. (Ben Ramsey) @@ -217,7 +220,7 @@ PHP NEWS . Fixed bug #64264 (SPLFixedArray toArray problem). (Laruence) . Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS). (patch by kr...@krizalys.com, Laruence) - . Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended). + . Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended). (Nikita Popov) . Fixed bug #52861 (unset fails with ArrayObject and deep arrays). (Mike Willbanks) diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index e3ff271..ea1c952 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -37,7 +37,7 @@ struct _WSAMSG { DWORDdwFlags; //int msg_flags } struct __WSABUF { - u_long len;//size_t iov_len (2nd member) + u_long len;//size_t iov_len (2nd member) char FAR *buf; //void *iov_base (1st member) } struct _WSACMSGHDR { @@ -593,6 +593,7 @@ static void to_zval_read_sockaddr_in(const char *data, zval *zv, res_context *ct { to_zval_read_aggregation(data, zv, descriptors_sockaddr_in, ctx); } +#if HAVE_IPV6 static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_context *ctx) { int res; @@ -652,6 +653,7 @@ static void to_zval_read_sockaddr_in6(const char *data, zval *zv, res_context *c { to_zval_read_aggregation(data, zv, descriptors_sockaddr_in6, ctx); } +#endif /* HAVE_IPV6 */ static void from_zval_write_sun_path(const zval *path, char *sockaddr_un_c, ser_context *ctx) { zvallzval = zval_used_for_init; @@ -742,6 +744,7 @@ static void from_zval_write_sockaddr_aux(const zval *container, } break; +#if HAVE_IPV6 case AF_INET6: if (ctx-sock-type != AF_INET6) { do_from_zval_err(ctx, the specified
[PHP-CVS] com php-src: Fix bug #64506: fix build with --disable-ipv6: NEWS ext/sockets/conversions.c ext/sockets/sendrecvmsg.c ext/sockets/sockets.c
Commit:8687332e086bc332c99692c099514be7996a2139 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 8 May 2013 19:51:39 +0200 Parents: 7b09e5fe35bbb5ae65bbb5fb717e374bb9e9a5bb Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8687332e086bc332c99692c099514be7996a2139 Log: Fix bug #64506: fix build with --disable-ipv6 Bugs: https://bugs.php.net/64506 Changed paths: M NEWS M ext/sockets/conversions.c M ext/sockets/sendrecvmsg.c M ext/sockets/sockets.c diff --git a/NEWS b/NEWS index 192d62d..e4f5aa4 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,9 @@ PHP NEWS (Boris Lytochkin) . Fixed bug #64159 (Truncated snmpget). (Boris Lytochkin) +- Sockets: + . Fixed bug #64506 (Fails to build with --disable-ipv6). (Gustavo) + - Streams: . Fixed bug #64770 (stream_select() fails with pipes returned by proc_open() on Windows x64). (Anatol) @@ -31,7 +34,7 @@ PHP NEWS 25 Apr 2013, PHP 5.5.0 Beta 4 - Core: - . Fixed bug #64677 (execution operator `` stealing surrounding arguments). + . Fixed bug #64677 (execution operator `` stealing surrounding arguments). (Laruence) - CURL: @@ -50,13 +53,13 @@ PHP NEWS (Eric Iversen) - Streams: - . Fixed Windows x64 version of stream_socket_pair() and improved error handling -(Anatol Belski) + . Fixed Windows x64 version of stream_socket_pair() and improved error +handling. (Anatol Belski) 11 Apr 2013, PHP 5.5.0 Beta 3 - Core: - . Fixed bug #64578 (debug_backtrace in set_error_handler corrupts zend heap: + . Fixed bug #64578 (debug_backtrace in set_error_handler corrupts zend heap: segfault). (Laruence) . Fixed bug #64565 (copy doesn't report failure on partial copy). (Remi) . Fixed bug #64555 (foreach no longer copies keys if they are interned). @@ -74,7 +77,7 @@ PHP NEWS Kapelushnik, Derick) - General improvements: - . Drop support for bison 2.4 when building PHP from GIT source. + . Drop support for bison 2.4 when building PHP from GIT source. (Laruence) - Fileinfo: @@ -112,7 +115,7 @@ PHP NEWS 21 Mar 2013, PHP 5.5.0 Beta 1 - Core: - . Added Zend Opcache extension and enable building it by default. + . Added Zend Opcache extension and enable building it by default. More details here: https://wiki.php.net/rfc/optimizerplus. (Dmitry) . Added array_column function which returns a column in a multidimensional array. https://wiki.php.net/rfc/array_column. (Ben Ramsey) @@ -220,7 +223,7 @@ PHP NEWS . Fixed bug #64264 (SPLFixedArray toArray problem). (Laruence) . Fixed bug #64228 (RecursiveDirectoryIterator always assumes SKIP_DOTS). (patch by kr...@krizalys.com, Laruence) - . Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended). + . Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended). (Nikita Popov) . Fixed bug #52861 (unset fails with ArrayObject and deep arrays). (Mike Willbanks) diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index e3ff271..ea1c952 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -37,7 +37,7 @@ struct _WSAMSG { DWORDdwFlags; //int msg_flags } struct __WSABUF { - u_long len;//size_t iov_len (2nd member) + u_long len;//size_t iov_len (2nd member) char FAR *buf; //void *iov_base (1st member) } struct _WSACMSGHDR { @@ -593,6 +593,7 @@ static void to_zval_read_sockaddr_in(const char *data, zval *zv, res_context *ct { to_zval_read_aggregation(data, zv, descriptors_sockaddr_in, ctx); } +#if HAVE_IPV6 static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_context *ctx) { int res; @@ -652,6 +653,7 @@ static void to_zval_read_sockaddr_in6(const char *data, zval *zv, res_context *c { to_zval_read_aggregation(data, zv, descriptors_sockaddr_in6, ctx); } +#endif /* HAVE_IPV6 */ static void from_zval_write_sun_path(const zval *path, char *sockaddr_un_c, ser_context *ctx) { zvallzval = zval_used_for_init; @@ -742,6 +744,7 @@ static void from_zval_write_sockaddr_aux(const zval *container, } break; +#if HAVE_IPV6 case AF_INET6: if (ctx-sock-type != AF_INET6) { do_from_zval_err(ctx, the
[PHP-CVS] com php-src: Fix NEWS (wrong bug # AND wrong section...): NEWS
Commit:98302ee3cc880bca26e26c7377c311002bd2b43e Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 8 May 2013 20:03:43 +0200 Parents: 8687332e086bc332c99692c099514be7996a2139 Branches: PHP-5.5 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=98302ee3cc880bca26e26c7377c311002bd2b43e Log: Fix NEWS (wrong bug # AND wrong section...) It's bug #64508, not #64506. Bugs: https://bugs.php.net/64508 https://bugs.php.net/64506 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index e4f5aa4..7c83bd5 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ PHP NEWS - mbstring: . Fixed bug #64769 (mbstring PHPTs crash on Windows x64). (Anatol) +- Sockets: + . Fixed bug #64508 (Fails to build with --disable-ipv6). (Gustavo) + 09 May 2013, PHP 5.5.0 Release Candidate 1 @@ -24,9 +27,6 @@ PHP NEWS (Boris Lytochkin) . Fixed bug #64159 (Truncated snmpget). (Boris Lytochkin) -- Sockets: - . Fixed bug #64506 (Fails to build with --disable-ipv6). (Gustavo) - - Streams: . Fixed bug #64770 (stream_select() fails with pipes returned by proc_open() on Windows x64). (Anatol) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: NEWS for 514afd67: NEWS
Commit:1656b337ce97abc0b9981692ecb5c4c349334418 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 30 Apr 2013 19:41:27 +0200 Parents: 514afd67b651bea834bdb84b7685b48e9e56ac21 Branches: PHP-5.4 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1656b337ce97abc0b9981692ecb5c4c349334418 Log: NEWS for 514afd67 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 3a9199b..7d9702b 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ PHP NEWS ||| ?? ??? 2013, PHP 5.4.16 +- Core: + . Fixed bug #64729 (compilation failure on x32). (Gustavo) + - FPM: . Ignore QUERY_STRING when sent in SCRIPT_FILENAME. (Remi) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: Zend/zend_alloc.c Zend/zend_multiply.h
Commit:865cc3a8005ed82282f6c366c5d681160e52e221 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 30 Apr 2013 19:36:08 +0200 Parents: 062519ed4186d5f19a131a3a4c0e430a83dc0766 514afd67b651bea834bdb84b7685b48e9e56ac21 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=865cc3a8005ed82282f6c366c5d681160e52e221 Log: Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: Fix bug #64729: compilation failure on x32 Conflicts: Zend/zend_alloc.c Bugs: https://bugs.php.net/64729 Changed paths: MM Zend/zend_alloc.c MM Zend/zend_multiply.h Diff: diff --cc Zend/zend_alloc.c index 1c76bd4,0bbd59a..c6aee57 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@@ -672,7 -672,7 +672,7 @@@ static inline unsigned int zend_mm_high #elif defined(__GNUC__) defined(__x86_64__) unsigned long n; - __asm__(bsrq %1,%0\n\t : =r (n) : rm (_size) : cc); -__asm__(bsr %1,%0\n\t : =r (n) : rm (_size)); ++__asm__(bsr %1,%0\n\t : =r (n) : rm (_size) : cc); return (unsigned int)n; #elif defined(_MSC_VER) defined(_M_IX86) __asm { @@@ -700,14 -698,12 +700,14 @@@ static inline unsigned int zend_mm_low_ #elif defined(__GNUC__) defined(__x86_64__) unsigned long n; - __asm__(bsfq %1,%0\n\t : =r (n) : rm (_size) : cc); -__asm__(bsf %1,%0\n\t : =r (n) : rm (_size)); ++__asm__(bsf %1,%0\n\t : =r (n) : rm (_size) : cc); return (unsigned int)n; #elif defined(_MSC_VER) defined(_M_IX86) __asm { bsf eax, _size -- } ++ } +#elif defined(__GNUC__) (defined(__arm__) || defined(__aarch64__)) + return __builtin_ctzl(_size); #else static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0}; unsigned int n; @@@ -2491,46 -2495,7 +2499,47 @@@ static inline size_t safe_address(size_ rm(size), rm(offset)); + #undef LP_SUFF +if (UNEXPECTED(overflow)) { +zend_error_noreturn(E_ERROR, Possible integer overflow in memory allocation (%zu * %zu + %zu), nmemb, size, offset); +return 0; +} +return res; +} + +#elif defined(__GNUC__) defined(__arm__) + +static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) +{ +size_t res; +unsigned long overflow; + +__asm__ (umlal %0,%1,%2,%3 + : =r(res), =r(overflow) + : r(nmemb), + r(size), + 0(offset), + 1(0)); + +if (UNEXPECTED(overflow)) { +zend_error_noreturn(E_ERROR, Possible integer overflow in memory allocation (%zu * %zu + %zu), nmemb, size, offset); +return 0; +} +return res; +} + +#elif defined(__GNUC__) defined(__aarch64__) + +static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) +{ +size_t res; +unsigned long overflow; + +__asm__ (mul %0,%2,%3\n\tumulh %1,%2,%3\n\tadds %0,%0,%4\n\tadc %1,%1,%1 + : =r(res), =r(overflow) + : r(nmemb), + r(size), + r(offset)); if (UNEXPECTED(overflow)) { zend_error_noreturn(E_ERROR, Possible integer overflow in memory allocation (%zu * %zu + %zu), nmemb, size, offset); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug #64729: compilation failure on x32: Zend/zend_alloc.c Zend/zend_multiply.h
Commit:514afd67b651bea834bdb84b7685b48e9e56ac21 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 30 Apr 2013 19:00:31 +0200 Parents: 4a92ae34011ad2246500f27469f378b66d832976 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=514afd67b651bea834bdb84b7685b48e9e56ac21 Log: Fix bug #64729: compilation failure on x32 Bugs: https://bugs.php.net/64729 Changed paths: M Zend/zend_alloc.c M Zend/zend_multiply.h Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 605e396..0bbd59a 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -672,7 +672,7 @@ static inline unsigned int zend_mm_high_bit(size_t _size) #elif defined(__GNUC__) defined(__x86_64__) unsigned long n; -__asm__(bsrq %1,%0\n\t : =r (n) : rm (_size)); +__asm__(bsr %1,%0\n\t : =r (n) : rm (_size)); return (unsigned int)n; #elif defined(_MSC_VER) defined(_M_IX86) __asm { @@ -698,12 +698,12 @@ static inline unsigned int zend_mm_low_bit(size_t _size) #elif defined(__GNUC__) defined(__x86_64__) unsigned long n; -__asm__(bsfq %1,%0\n\t : =r (n) : rm (_size)); +__asm__(bsf %1,%0\n\t : =r (n) : rm (_size)); return (unsigned int)n; #elif defined(_MSC_VER) defined(_M_IX86) __asm { bsf eax, _size - } + } #else static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0}; unsigned int n; @@ -2481,12 +2481,22 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) size_t res = nmemb; unsigned long overflow = 0; -__asm__ (mulq %3\n\taddq %4,%0\n\tadcq %1,%1 +#ifdef __ILP32__ /* x32 */ +# define LP_SUFF l +#else /* amd64 */ +# define LP_SUFF q +#endif + +__asm__ (mul LP_SUFF %3\n\t + add %4,%0\n\t + adc %1,%1 : =a(res), =d (overflow) : %0(res), rm(size), rm(offset)); +#undef LP_SUFF + if (UNEXPECTED(overflow)) { zend_error_noreturn(E_ERROR, Possible integer overflow in memory allocation (%zu * %zu + %zu), nmemb, size, offset); return 0; diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index c3c9657..092d3cd 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -35,8 +35,8 @@ #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ long __tmpvar; \ - __asm__ (imulq %3,%0\n \ - adcq $0,%1 \ + __asm__ (imul %3,%0\n \ + adc $0,%1 \ : =r(__tmpvar),=r(usedval) \ : 0(a), r(b), 1(0)); \ if (usedval) (dval) = (double) (a) * (double) (b); \ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: NEWS for 8718755: NEWS
Commit:fa3cb8608c35096dc5037291ab29548cdcf6a954 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sat, 23 Feb 2013 18:07:01 +0100 Parents: 12745594a4ba5f0185e80c46097072419d80f295 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fa3cb8608c35096dc5037291ab29548cdcf6a954 Log: NEWS for 8718755 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 417f4fa..2fb0da7 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ PHP NEWS . Fixed bug #64142 (dval to lval different behavior on ppc64). (Remi) . Added ARMv7/v8 versions of various Zend arithmetic functions that are implemented using inline assembler (Ard Biesheuvel) + . Fix undefined behavior when converting double variables to integers. +The double is now always rounded towards zero, the remainder of its division + by 2^32 or 2^64 (depending on sizeof(long)) is calculated and it's made + signed assuming a two's complement representation. (Gustavo) - CLI server: . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Remove trailing whitespace; break long lines: NEWS
Commit:12745594a4ba5f0185e80c46097072419d80f295 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sat, 23 Feb 2013 18:00:21 +0100 Parents: 8718755c9f152e153b575d6bc71fda1fa5420b40 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=12745594a4ba5f0185e80c46097072419d80f295 Log: Remove trailing whitespace; break long lines Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index fe647f2..417f4fa 100644 --- a/NEWS +++ b/NEWS @@ -3,8 +3,8 @@ PHP NEWS ?? ??? 201?, PHP 5.5.0 Beta 1 - Core: - . Fixed bug #49348 (Uninitialized ++$foo-bar; does not cause a notice). -(Stas) + . Fixed bug #49348 (Uninitialized ++$foo-bar; does not cause a notice). +(Stas) 21 Feb 2013, PHP 5.5.0 Alpha 5 @@ -14,7 +14,7 @@ PHP NEWS propagated). (Laruence) . Fixed bug #63830 (Segfault on undefined function call in nested generator). (Nikita Popov) - . Fixed bug #60833 (self, parent, static behave inconsistently + . Fixed bug #60833 (self, parent, static behave inconsistently case-sensitive). (Stas, mario at include-once dot org) . Implemented FR #60524 (specify temp dir by php.ini). (ALeX Kazik). . Fixed bug #64142 (dval to lval different behavior on ppc64). (Remi) @@ -33,8 +33,8 @@ PHP NEWS to master. - mysqli - . Added mysqli_begin_transaction()/mysqli::begin_transaction(). Implemented all -options, per MySQL 5.6, which can be used with START TRANSACTION, COMMIT + . Added mysqli_begin_transaction()/mysqli::begin_transaction(). Implemented +all options, per MySQL 5.6, which can be used with START TRANSACTION, COMMIT and ROLLBACK through options to mysqli_commit()/mysqli_rollback() and their respective OO counterparts. They work in libmysql and mysqlnd mode. (Andrey) . Added mysqli_savepoint(), mysqli_release_savepoint(). (Andrey) @@ -78,8 +78,8 @@ PHP NEWS (marc-bennewitz at arcor dot de, Lars) - Reflection: - . Fixed bug #64007 (There is an ability to create instance of Generator by hand). -(Laruence) + . Fixed bug #64007 (There is an ability to create instance of Generator by +hand). (Laruence) 10 Jan 2013, PHP 5.5.0 Alpha 3 @@ -97,7 +97,7 @@ PHP NEWS - cURL: . Added new functions curl_escape, curl_multi_setopt, curl_multi_strerror -curl_pause, curl_reset, curl_share_close, curl_share_init, +curl_pause, curl_reset, curl_share_close, curl_share_init, curl_share_setopt curl_strerror and curl_unescape. (Pierrick) . Addes new curl options CURLOPT_TELNETOPTIONS, CURLOPT_GSSAPI_DELEGATION, CURLOPT_ACCEPTTIMEOUT_MS, CURLOPT_SSL_OPTIONS, CURLOPT_TCP_KEEPALIVE, @@ -170,22 +170,22 @@ PHP NEWS set_exception_handler. (Nikita Popov) - cURL: - . Added support for CURLOPT_FTP_RESPONSE_TIMEOUT, CURLOPT_APPEND, -CURLOPT_DIRLISTONLY, CURLOPT_NEW_DIRECTORY_PERMS, CURLOPT_NEW_FILE_PERMS, + . Added support for CURLOPT_FTP_RESPONSE_TIMEOUT, CURLOPT_APPEND, +CURLOPT_DIRLISTONLY, CURLOPT_NEW_DIRECTORY_PERMS, CURLOPT_NEW_FILE_PERMS, CURLOPT_NETRC_FILE, CURLOPT_PREQUOTE, CURLOPT_KRBLEVEL, CURLOPT_MAXFILESIZE, CURLOPT_FTP_ACCOUNT, CURLOPT_COOKIELIST, CURLOPT_IGNORE_CONTENT_LENGTH, -CURLOPT_CONNECT_ONLY, CURLOPT_LOCALPORT, CURLOPT_LOCALPORTRANGE, -CURLOPT_FTP_ALTERNATIVE_TO_USER, CURLOPT_SSL_SESSIONID_CACHE, -CURLOPT_FTP_SSL_CCC, CURLOPT_HTTP_CONTENT_DECODING, -CURLOPT_HTTP_TRANSFER_DECODING, CURLOPT_PROXY_TRANSFER_MODE, -CURLOPT_ADDRESS_SCOPE, CURLOPT_CRLFILE, CURLOPT_ISSUERCERT, -CURLOPT_USERNAME, CURLOPT_PASSWORD, CURLOPT_PROXYUSERNAME, -CURLOPT_PROXYPASSWORD, CURLOPT_NOPROXY, CURLOPT_SOCKS5_GSSAPI_NEC, -CURLOPT_SOCKS5_GSSAPI_SERVICE, CURLOPT_TFTP_BLKSIZE, -CURLOPT_SSH_KNOWNHOSTS, CURLOPT_FTP_USE_PRET, CURLOPT_MAIL_FROM, -CURLOPT_MAIL_RCPT, CURLOPT_RTSP_CLIENT_CSEQ, CURLOPT_RTSP_SERVER_CSEQ, +CURLOPT_CONNECT_ONLY, CURLOPT_LOCALPORT, CURLOPT_LOCALPORTRANGE, +CURLOPT_FTP_ALTERNATIVE_TO_USER, CURLOPT_SSL_SESSIONID_CACHE, +CURLOPT_FTP_SSL_CCC, CURLOPT_HTTP_CONTENT_DECODING, +CURLOPT_HTTP_TRANSFER_DECODING, CURLOPT_PROXY_TRANSFER_MODE, +CURLOPT_ADDRESS_SCOPE, CURLOPT_CRLFILE, CURLOPT_ISSUERCERT, +CURLOPT_USERNAME, CURLOPT_PASSWORD, CURLOPT_PROXYUSERNAME, +CURLOPT_PROXYPASSWORD, CURLOPT_NOPROXY, CURLOPT_SOCKS5_GSSAPI_NEC, +CURLOPT_SOCKS5_GSSAPI_SERVICE, CURLOPT_TFTP_BLKSIZE, +CURLOPT_SSH_KNOWNHOSTS, CURLOPT_FTP_USE_PRET, CURLOPT_MAIL_FROM, +CURLOPT_MAIL_RCPT, CURLOPT_RTSP_CLIENT_CSEQ, CURLOPT_RTSP_SERVER_CSEQ,
[PHP-CVS] com php-src: Fix zend_dval_to_lval outside 64bit integers range: Zend/tests/bug39018.phpt Zend/tests/dval_to_lval_32.phpt Zend/tests/dval_to_lval_64.phpt Zend/zend_operators.h
Commit:77566edbafb969e166239b3fbc929588c6630ee9 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sun, 17 Feb 2013 23:40:26 +0100 Parents: 64a2a8a7536de781aac015e7392cb56308d8aed0 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=77566edbafb969e166239b3fbc929588c6630ee9 Log: Fix zend_dval_to_lval outside 64bit integers range PHP should preserve the least significant bits when casting from double to long. Zend.m4 contains this: AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits]) If ZEND_DVAL_TO_LVAL_CAST_OK is not defined, zend_operators.h had an inline implementation of zend_dval_to_lval() that would do a cast to an int64_t (when sizeof(long) == 4), then a cast to unsigned long and finally the cast to long. While this works well for doubles inside the range of values of the type used in the first cast (int64_t in the 32-bit version and unsigned long in the 64-bit version), if outside the range, it is undefined behavior that WILL give varying and not particularly useful results. This commit uses fmod() to first put the double in a range that can safely be cast to unsigned long and then casts this unsigned long to long. This last cast is implementation defined, but it's very likely that this gives the expected result (i.e. the internal 2's complement representation is unchanged) on all platforms that PHP supports. In any case, the previous implementationa already had this assumption. This alternative code path is indeed significantly slower than simply casting the double (almost an order of magnitude), but that should not matter because casting doubles with a very high absolute value is a rare event. Changed paths: M Zend/tests/bug39018.phpt A Zend/tests/dval_to_lval_32.phpt A Zend/tests/dval_to_lval_64.phpt M Zend/zend_operators.h Diff: diff --git a/Zend/tests/bug39018.phpt b/Zend/tests/bug39018.phpt index 32566ba..a00e1fb 100644 --- a/Zend/tests/bug39018.phpt +++ b/Zend/tests/bug39018.phpt @@ -64,6 +64,8 @@ print \nDone\n; --EXPECTF-- Notice: String offset cast occurred in %s on line %d +Notice: Uninitialized string offset: %s in %s on line 6 + Notice: Uninitialized string offset: 0 in %s on line %d Notice: Uninitialized string offset: 0 in %s on line %d diff --git a/Zend/tests/dval_to_lval_32.phpt b/Zend/tests/dval_to_lval_32.phpt new file mode 100644 index 000..ddb16cc --- /dev/null +++ b/Zend/tests/dval_to_lval_32.phpt @@ -0,0 +1,29 @@ +--TEST-- +zend_dval_to_lval preserves low bits (32 bit long) +--SKIPIF-- +?php +if (PHP_INT_SIZE != 4) +die(skip for machines with 32-bit longs); +? +--FILE-- +?php + /* test doubles around -4e21 */ + $values = [ + -4001048576., + -4000524288., + -40., + -3999475712., + -3998951424., + ]; + + foreach ($values as $v) { + var_dump((int)$v); + } + +? +--EXPECT-- +int(-2056257536) +int(-2055733248) +int(-2055208960) +int(-2054684672) +int(-2054160384) diff --git a/Zend/tests/dval_to_lval_64.phpt b/Zend/tests/dval_to_lval_64.phpt new file mode 100644 index 000..da7f56d --- /dev/null +++ b/Zend/tests/dval_to_lval_64.phpt @@ -0,0 +1,29 @@ +--TEST-- +zend_dval_to_lval preserves low bits (64 bit long) +--SKIPIF-- +?php +if (PHP_INT_SIZE != 8) +die(skip for machines with 64-bit longs); +? +--FILE-- +?php + /* test doubles around -4e21 */ + $values = [ + -4001048576., + -4000524288., + -40., + -3999475712., + -3998951424., + ]; + + foreach ($values as $v) { + var_dump((int)$v); + } + +? +--EXPECT-- +int(2943463994971652096) +int(2943463994972176384) +int(2943463994972700672) +int(2943463994973224960) +int(2943463994973749248) diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 93c60e4..a3a432f 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -68,22 +68,36 @@ END_EXTERN_C() #if ZEND_DVAL_TO_LVAL_CAST_OK # define zend_dval_to_lval(d) ((long) (d)) -#elif SIZEOF_LONG == 4 defined(HAVE_ZEND_LONG64) +#elif SIZEOF_LONG == 4 static zend_always_inline long zend_dval_to_lval(double d) { if (d LONG_MAX || d LONG_MIN) { - return (long)(unsigned long)(zend_long64) d; + double two_pow_32 = pow(2., 32.), + dmod; + + dmod = fmod(d, two_pow_32); + if (dmod 0) { + dmod += two_pow_32; + } + return (long)(unsigned long)dmod; } - return (long) d; + return (long)d; } #else static zend_always_inline long zend_dval_to_lval(double d) { /* = as (double)LONG_MAX is outside
[PHP-CVS] com php-src: Fix ext/intl build with phpize: ext/intl/converter/converter.c
Commit:97f22702c4b3af574049160f20982d1e38424296 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sun, 24 Feb 2013 00:30:08 +0100 Parents: fa3cb8608c35096dc5037291ab29548cdcf6a954 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=97f22702c4b3af574049160f20982d1e38424296 Log: Fix ext/intl build with phpize Fixes bug #64284. Bugs: https://bugs.php.net/64284 Changed paths: M ext/intl/converter/converter.c Diff: diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 387760a..5f2d1e7 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -21,7 +21,7 @@ #include unicode/ucnv.h #include unicode/ustring.h -#include ext/intl/intl_error.h +#include ../intl_error.h typedef struct _php_converter_object { zend_object obj; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: sendrecvmsg_shutdown function moved to mshutdown: NEWS ext/sockets/sockets.c
Commit:59ec22b370a74e9af62fdea68550feade6f36c81 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sun, 24 Feb 2013 03:40:22 +0100 Parents: 189fbfd53b087099689b9198407ee0c50b17fc61 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=59ec22b370a74e9af62fdea68550feade6f36c81 Log: sendrecvmsg_shutdown function moved to mshutdown The function php_socket_sendrecvmsg_shutdown() should have been called in MSHUTDOWN, not RSHUTDOWN. Bug only on TSRM builds. Should fix bug #64287. Bugs: https://bugs.php.net/64287 Changed paths: M NEWS M ext/sockets/sockets.c Diff: diff --git a/NEWS b/NEWS index 2fb0da7..b75c052 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ PHP NEWS . Fixed bug #49348 (Uninitialized ++$foo-bar; does not cause a notice). (Stas) +- Sockets: + . Fixed bug #64287 (sendmsg/recvmsg shutdown handler causes segfault). +(Gustavo) + 21 Feb 2013, PHP 5.5.0 Alpha 5 - Core: diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 5ecc014..f305fa0 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -69,7 +69,6 @@ #include sendrecvmsg.h ZEND_DECLARE_MODULE_GLOBALS(sockets) -static PHP_GINIT_FUNCTION(sockets); #ifndef MSG_WAITALL #ifdef LINUX @@ -271,9 +270,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_cmsg_space, 0, 0, 2) ZEND_END_ARG_INFO() /* }}} */ -PHP_MINIT_FUNCTION(sockets); -PHP_MINFO_FUNCTION(sockets); -PHP_RSHUTDOWN_FUNCTION(sockets); +static PHP_GINIT_FUNCTION(sockets); +static PHP_MINIT_FUNCTION(sockets); +static PHP_MSHUTDOWN_FUNCTION(sockets); +static PHP_MINFO_FUNCTION(sockets); +static PHP_RSHUTDOWN_FUNCTION(sockets); PHP_FUNCTION(socket_select); PHP_FUNCTION(socket_create_listen); @@ -356,7 +357,7 @@ zend_module_entry sockets_module_entry = { sockets, sockets_functions, PHP_MINIT(sockets), - NULL, + PHP_MSHUTDOWN(sockets), NULL, PHP_RSHUTDOWN(sockets), PHP_MINFO(sockets), @@ -607,7 +608,7 @@ static PHP_GINIT_FUNCTION(sockets) /* {{{ PHP_MINIT_FUNCTION */ -PHP_MINIT_FUNCTION(sockets) +static PHP_MINIT_FUNCTION(sockets) { le_socket = zend_register_list_destructors_ex(php_destroy_socket, NULL, le_socket_name, module_number); @@ -728,9 +729,19 @@ PHP_MINIT_FUNCTION(sockets) } /* }}} */ +/* {{{ PHP_MSHUTDOWN_FUNCTION + */ +static PHP_MSHUTDOWN_FUNCTION(sockets) +{ + php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS_PASSTHRU); + + return SUCCESS; +} +/* }}} */ + /* {{{ PHP_MINFO_FUNCTION */ -PHP_MINFO_FUNCTION(sockets) +static PHP_MINFO_FUNCTION(sockets) { php_info_print_table_start(); php_info_print_table_row(2, Sockets Support, enabled); @@ -739,13 +750,12 @@ PHP_MINFO_FUNCTION(sockets) /* }}} */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ -PHP_RSHUTDOWN_FUNCTION(sockets) +static PHP_RSHUTDOWN_FUNCTION(sockets) { if (SOCKETS_G(strerror_buf)) { efree(SOCKETS_G(strerror_buf)); SOCKETS_G(strerror_buf) = NULL; } - php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS_PASSTHRU); return SUCCESS; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Move macro back to .c file: ext/sockets/php_sockets.h ext/sockets/sockets.c
Commit:0110662ae9e89d21c119b3287118e82fd435f779 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sat, 2 Feb 2013 18:32:38 +0100 Parents: 73de4d8c689ff5c82373a4837dc8a21c9902a8b2 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0110662ae9e89d21c119b3287118e82fd435f779 Log: Move macro back to .c file Because it depends on a static function on that .c file. Changed paths: M ext/sockets/php_sockets.h M ext/sockets/sockets.c Diff: diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 3762e02..fabc9c4 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -64,14 +64,6 @@ PHP_SOCKETS_API int php_sockets_le_socket(void); #define php_sockets_le_socket_name Socket -#define PHP_SOCKET_ERROR(socket, msg, errn) \ - do { \ - int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \ - (socket)-error = _err; \ - SOCKETS_G(last_error) = _err; \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, %s [%d]: %s, msg, _err, php_strerror(_err TSRMLS_CC)); \ - } while (0) - ZEND_BEGIN_MODULE_GLOBALS(sockets) int last_error; char *strerror_buf; diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index c6c5477..06bd0ec 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -114,6 +114,14 @@ static PHP_GINIT_FUNCTION(sockets); static char *php_strerror(int error TSRMLS_DC); +#define PHP_SOCKET_ERROR(socket, msg, errn) \ + do { \ + int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \ + (socket)-error = _err; \ + SOCKETS_G(last_error) = _err; \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, %s [%d]: %s, msg, _err, php_strerror(_err TSRMLS_CC)); \ + } while (0) + #define PHP_NORMAL_READ 0x0001 #define PHP_BINARY_READ 0x0002 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix wrong blocking state being set: ext/sockets/sockets.c
Commit:ac6342bbc0a2a41cf2b698e37b981ce63e8b6305 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 1 Feb 2013 16:38:54 +0100 Parents: 40663ede837c401212e950a3f65a7cd2885ccead Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ac6342bbc0a2a41cf2b698e37b981ce63e8b6305 Log: Fix wrong blocking state being set Changed paths: M ext/sockets/sockets.c Diff: diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 6069fc5..c6c5477 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -1126,7 +1126,7 @@ PHP_FUNCTION(socket_set_nonblock) if (stream != NULL) { if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, 0, NULL) != -1) { - php_sock-blocking = 1; + php_sock-blocking = 0; RETURN_TRUE; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Remove a Windows only warning: main/network.c
Commit:24e380f97033b54ba0994fcf9f7c6c76111a3c93 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sat, 2 Feb 2013 12:44:00 +0100 Parents: 9283b8aea4c681e39fed772543919bea4bba44a1 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=24e380f97033b54ba0994fcf9f7c6c76111a3c93 Log: Remove a Windows only warning Changed paths: M main/network.c Diff: diff --git a/main/network.c b/main/network.c index 4b7a8d4..ba2ee1c 100644 --- a/main/network.c +++ b/main/network.c @@ -1076,11 +1076,6 @@ PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC) /* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */ flags = !block; if (ioctlsocket(socketd, FIONBIO, flags) == SOCKET_ERROR) { - char *error_string; - - error_string = php_socket_strerror(WSAGetLastError(), NULL, 0); - php_error_docref(NULL TSRMLS_CC, E_WARNING, %s, error_string); - efree(error_string); ret = FAILURE; } #else -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix tests (Windows): ext/sockets/tests/socket_import_stream-4-win.phpt ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt ext/sockets/tests/socket_sentto_recvfrom_ipv6
Commit:40663ede837c401212e950a3f65a7cd2885ccead Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 1 Feb 2013 14:58:35 +0100 Parents: 24e380f97033b54ba0994fcf9f7c6c76111a3c93 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=40663ede837c401212e950a3f65a7cd2885ccead Log: Fix tests (Windows) Changed paths: M ext/sockets/tests/socket_import_stream-4-win.phpt A ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt M ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt Diff: diff --git a/ext/sockets/tests/socket_import_stream-4-win.phpt b/ext/sockets/tests/socket_import_stream-4-win.phpt index e2fc523..b36764f 100644 --- a/ext/sockets/tests/socket_import_stream-4-win.phpt +++ b/ext/sockets/tests/socket_import_stream-4-win.phpt @@ -80,9 +80,6 @@ stream_set_blocking Warning: stream_set_blocking(): %d is not a valid stream resource in %s on line %d socket_set_block -Warning: socket_set_block(): An operation was attempted on something that is not a socket. - in %ssocket_import_stream-4-win.php on line %d - Warning: socket_set_block(): unable to set blocking mode [%d]: An operation was attempted on something that is not a socket. in %ssocket_import_stream-4-win.php on line %d diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt new file mode 100644 index 000..ec96509 --- /dev/null +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test if socket_recvfrom() receives data sent by socket_sendto() via IPv6 UDP (Win32) +--SKIPIF-- +?php +if (!extension_loaded('sockets')) { +die('SKIP The sockets extension is not loaded.'); +} +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip only for Windows'); +} +require 'ipv6_skipif.inc'; +--FILE-- +?php +$socket = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP); +if (!$socket) { +die('Unable to create AF_INET6 socket'); +} +if (!socket_set_nonblock($socket)) { +die('Unable to set nonblocking mode for socket'); +} +socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning +$address = '::1'; +socket_sendto($socket, '', 1, 0, $address); // cause warning +if (!socket_bind($socket, $address, 1223)) { +die(Unable to bind to $address:1223); +} + +$msg = Ping!; +$len = strlen($msg); +$bytes_sent = socket_sendto($socket, $msg, $len, 0, $address, 1223); +if ($bytes_sent == -1) { +die('An error occurred while sending to the socket'); +} else if ($bytes_sent != $len) { +die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' bytes expected'); +} + +$from = ; +$port = 0; +socket_recvfrom($socket, $buf, 12, 0); // cause warning +socket_recvfrom($socket, $buf, 12, 0, $from); // cause warning +$bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from, $port); +if ($bytes_received == -1) { +die('An error occurred while receiving from the socket'); +} else if ($bytes_received != $len) { +die($bytes_received . ' bytes have been received instead of the ' . $len . ' bytes expected'); +} +echo Received $buf from remote address $from and remote port $port . PHP_EOL; + +socket_close($socket); +--EXPECTF-- +Warning: socket_recvfrom(): unable to recvfrom [10022]: An invalid argument was supplied. + in %s on line %d + +Warning: Wrong parameter count for socket_sendto() in %s on line %d + +Warning: socket_recvfrom() expects at least 5 parameters, 4 given in %s on line %d + +Warning: Wrong parameter count for socket_recvfrom() in %s on line %d +Received Ping! from remote address ::1 and remote port 1223 +--CREDITS-- +Falko Menge mail at falko-menge dot de +PHP Testfest Berlin 2009-05-09 diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt index 04f62ed..2beb808 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt @@ -5,6 +5,9 @@ Test if socket_recvfrom() receives data sent by socket_sendto() via IPv6 UDP if (!extension_loaded('sockets')) { die('SKIP The sockets extension is not loaded.'); } +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip Not valid for Windows'); +} require 'ipv6_skipif.inc'; --FILE-- ?php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Move improve PHP_SOCKET_ERROR def: ext/sockets/php_sockets.h ext/sockets/sockets.c
Commit:9283b8aea4c681e39fed772543919bea4bba44a1 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 1 Feb 2013 14:39:56 +0100 Parents: 97d656fc82104d9879b59dba9b80773346ec1f61 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9283b8aea4c681e39fed772543919bea4bba44a1 Log: Move improve PHP_SOCKET_ERROR def Changed paths: M ext/sockets/php_sockets.h M ext/sockets/sockets.c Diff: diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 2b6700d..3762e02 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -64,13 +64,13 @@ PHP_SOCKETS_API int php_sockets_le_socket(void); #define php_sockets_le_socket_name Socket -/* Prototypes */ -#ifdef ilia_0 /* not needed, only causes a compiler warning */ -static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC); -static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct sockaddr *la TSRMLS_DC); -static int php_read(php_socket *sock, void *buf, size_t maxlen, int flags); -static char *php_strerror(int error TSRMLS_DC); -#endif +#define PHP_SOCKET_ERROR(socket, msg, errn) \ + do { \ + int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \ + (socket)-error = _err; \ + SOCKETS_G(last_error) = _err; \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, %s [%d]: %s, msg, _err, php_strerror(_err TSRMLS_CC)); \ + } while (0) ZEND_BEGIN_MODULE_GLOBALS(sockets) int last_error; diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 1cb36cd..6069fc5 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -117,10 +117,6 @@ static char *php_strerror(int error TSRMLS_DC); #define PHP_NORMAL_READ 0x0001 #define PHP_BINARY_READ 0x0002 -#define PHP_SOCKET_ERROR(socket,msg,errn) socket-error = errn; \ - SOCKETS_G(last_error) = errn; \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, %s [%d]: %s, msg, errn, php_strerror(errn TSRMLS_CC)) - static int le_socket; #define le_socket_name php_sockets_le_socket_name -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'sendrecvmsg_rebase_55' into PHP-5.5: ext/sockets/php_sockets.h
Commit:b11777ca2aea339430dfc70d352ef4b994450189 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sat, 2 Feb 2013 16:40:25 +0100 Parents: ac47448abb477be99963f0b38fe82ffe78c21a8b e2fc17c833c5122327438c82fc0dc4b689268f59 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b11777ca2aea339430dfc70d352ef4b994450189 Log: Merge branch 'sendrecvmsg_rebase_55' into PHP-5.5 * sendrecvmsg_rebase_55: (31 commits) Fix multicast.c not defining errno on Windows Fix non-Windows build send/recvmsg() support for Windows Remove some pre-vista code Revert Payload of HOPLIMIT/TCLASS are 8-bit Ensure memory is initialized Payload of HOPLIMIT/TCLASS are 8-bit Fix buf in string - int conv. Build fixes; accept names for if_index Refactoring: move stuff to new conversions.c Support sticky IPV6_PKTINFO Rename some functions for consistency Destroy ancillary registry on shutdown Move some multicast stuff to multicast.c Fix mcast_ipv6_send test Check return of fstat() Fix build on Mac OS X Register extra MSG_* constants Add test for CMSG_RIGHTS Add test for CMSG_CREDENTIALS message ... Changed paths: MM ext/sockets/php_sockets.h Diff: diff --cc ext/sockets/php_sockets.h index 9c5dc5a,a5699c7..5082a9b --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@@ -85,6 -87,23 +87,17 @@@ ZEND_END_MODULE_GLOBALS(sockets #define SOCKETS_G(v) (sockets_globals.v) #endif + ZEND_EXTERN_MODULE_GLOBALS(sockets); + + enum sockopt_return { + SOCKOPT_ERROR, + SOCKOPT_CONTINUE, + SOCKOPT_SUCCESS + }; + + char *sockets_strerror(int error TSRMLS_DC); + php_socket *socket_import_file_descriptor(PHP_SOCKET sock TSRMLS_DC); + -#define PHP_SOCKET_ERROR(socket,msg,errn) \ - socket-error = errn; \ - SOCKETS_G(last_error) = errn; \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, %s [%d]: %s, msg, errn, \ - sockets_strerror(errn TSRMLS_CC)) - #else #define phpext_sockets_ptr NULL #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Remove some pre-vista code: win32/inet.c win32/inet.h
Commit:8561680533c7fd6b66497ed10246fe9e57e9d351 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 30 Jan 2013 21:40:45 +0100 Parents: 95f8d34f9c0980924098ce9554e899e461ce7cec Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8561680533c7fd6b66497ed10246fe9e57e9d351 Log: Remove some pre-vista code Changed paths: M win32/inet.c M win32/inet.h Diff: diff --git a/win32/inet.c b/win32/inet.c index d424c8a..686cf12 100644 --- a/win32/inet.c +++ b/win32/inet.c @@ -1,83 +1,4 @@ -#include config.w32.h -#include php.h -#include winsock2.h -#include windows.h -#include Ws2tcpip.h - #include inet.h -#if (_WIN32_WINNT 0x0600) /* Vista/2k8 have these functions */ - - -PHPAPI int inet_pton(int af, const char* src, void* dst) -{ - int address_length; - struct sockaddr_storage sa; - struct sockaddr_in *sin = (struct sockaddr_in *)sa; - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; - - switch (af) { - case AF_INET: - address_length = sizeof (struct sockaddr_in); - break; - - case AF_INET6: - address_length = sizeof (struct sockaddr_in6); - break; - - default: - return -1; - } - - if (WSAStringToAddress ((LPTSTR) src, af, NULL, (LPSOCKADDR) sa, address_length) == 0) { - switch (af) { - case AF_INET: - memcpy (dst, sin-sin_addr, sizeof (struct in_addr)); - break; - - case AF_INET6: - memcpy (dst, sin6-sin6_addr, sizeof (struct in6_addr)); - break; - } - return 1; - } - - return 0; -} - -PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size) -{ - int address_length; - DWORD string_length = size; - struct sockaddr_storage sa; - struct sockaddr_in *sin = (struct sockaddr_in *)sa; - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; - - memset (sa, 0, sizeof (sa)); - switch (af) { - case AF_INET: - address_length = sizeof (struct sockaddr_in); - sin-sin_family = af; - memcpy (sin-sin_addr, src, sizeof (struct in_addr)); - break; - - case AF_INET6: - address_length = sizeof (struct sockaddr_in6); - sin6-sin6_family = af; - memcpy (sin6-sin6_addr, src, sizeof (struct in6_addr)); - break; - - default: - return NULL; - } - - if (WSAAddressToString ((LPSOCKADDR) sa, address_length, NULL, dst, string_length) == 0) { - return dst; - } - - return NULL; -} - -#endif int inet_aton(const char *cp, struct in_addr *inp) { inp-s_addr = inet_addr(cp); diff --git a/win32/inet.h b/win32/inet.h index 623d114..d717237 100644 --- a/win32/inet.h +++ b/win32/inet.h @@ -1,11 +1,4 @@ -#if _MSC_VER = 1500 -# include In6addr.h -#endif -#include Ws2tcpip.h - -#if (_WIN32_WINNT = 0x502) -PHPAPI int inet_pton(int af, const char* src, void* dst); -PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size); -#endif +#include php.h +#include Winsock2.h PHPAPI int inet_aton(const char *cp, struct in_addr *inp); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Revert Payload of HOPLIMIT/TCLASS are 8-bit: ext/sockets/conversions.c ext/sockets/conversions.h ext/sockets/sendrecvmsg.c
Commit:95f8d34f9c0980924098ce9554e899e461ce7cec Author:Gustavo Lopes glo...@nebm.ist.utl.pt Thu, 31 Jan 2013 15:26:10 +0100 Parents: 5c0a8b1a2a34ec504091e4e105e1c3b79d9fff89 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=95f8d34f9c0980924098ce9554e899e461ce7cec Log: Revert Payload of HOPLIMIT/TCLASS are 8-bit This reverts commit 61a5ec7381ba5388a52926779fe3f58af0caea83. I checked Linux and OpenBSD and both use integers to write the IPV6_TCLASS messages and they don't force any endianness. This is despite RFC 3542 explicitly saying the first byte of cmsg_data will have the result. In any case, it doesn't make any difference in little-endian archs. Changed paths: M ext/sockets/conversions.c M ext/sockets/conversions.h M ext/sockets/sendrecvmsg.c Diff: diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index d0d0c4b..fa6d949 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -317,7 +317,7 @@ double_case: return ret; } -static void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx) +void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx) { long lval; int ival; @@ -355,25 +355,6 @@ static void from_zval_write_uint32(const zval *arr_value, char *field, ser_conte ival = (uint32_t)lval; memcpy(field, ival, sizeof(ival)); } -void from_zval_write_uint8(const zval *arr_value, char *field, ser_context *ctx) -{ - long lval; - uint8_t ival; - - lval = from_zval_integer_common(arr_value, ctx); - if (ctx-err.has_error) { - return; - } - - if (lval 0 || lval 0xFF) { - do_from_zval_err(ctx, %s, given PHP integer is out of bounds - for an unsigned 8-bit integer); - return; - } - - ival = (uint8_t)lval; - memcpy(field, ival, sizeof(ival)); -} static void from_zval_write_net_uint16(const zval *arr_value, char *field, ser_context *ctx) { long lval; @@ -460,7 +441,7 @@ static void from_zval_write_uid_t(const zval *arr_value, char *field, ser_contex memcpy(field, ival, sizeof(ival)); } -static void to_zval_read_int(const char *data, zval *zv, res_context *ctx) +void to_zval_read_int(const char *data, zval *zv, res_context *ctx) { int ival; memcpy(ival, data, sizeof(ival)); @@ -474,13 +455,6 @@ static void to_zval_read_unsigned(const char *data, zval *zv, res_context *ctx) ZVAL_LONG(zv, (long)ival); } -void to_zval_read_uint8(const char *data, zval *zv, res_context *ctx) -{ - uint8_t ival; - memcpy(ival, data, sizeof(ival)); - - ZVAL_LONG(zv, (long)ival); -} static void to_zval_read_net_uint16(const char *data, zval *zv, res_context *ctx) { uint16_t ival; diff --git a/ext/sockets/conversions.h b/ext/sockets/conversions.h index 79ca4ab..70f31ba 100644 --- a/ext/sockets/conversions.h +++ b/ext/sockets/conversions.h @@ -37,8 +37,8 @@ void err_msg_dispose(struct err_s *err TSRMLS_DC); void allocations_dispose(zend_llist **allocations); /* CONVERSION FUNCTIONS */ -void from_zval_write_uint8(const zval *arr_value, char *field, ser_context *ctx); -void to_zval_read_uint8(const char *data, zval *zv, res_context *ctx); +void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx); +void to_zval_read_int(const char *data, zval *zv, res_context *ctx); #ifdef IPV6_PKTINFO void from_zval_write_in6_pktinfo(const zval *container, char *in6_pktinfo_c, ser_context *ctx); diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index f325b03..b83b3ae 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -73,14 +73,12 @@ static void init_ancillary_registry(void) #endif #ifdef IPV6_HOPLIMIT - PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_uint8, - to_zval_read_uint8, IPPROTO_IPV6, IPV6_HOPLIMIT); + PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, + to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT); #endif -#ifdef IPV6_TCLASS - PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_uint8, - to_zval_read_uint8, IPPROTO_IPV6, IPV6_TCLASS); -#endif + PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, + to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS); #ifdef SO_PASSCRED PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Ensure memory is initialized: ext/sockets/conversions.c
Commit:5c0a8b1a2a34ec504091e4e105e1c3b79d9fff89 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Thu, 31 Jan 2013 15:25:55 +0100 Parents: f10baf14eda4a6fd0e4c8a24d008975184e31207 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5c0a8b1a2a34ec504091e4e105e1c3b79d9fff89 Log: Ensure memory is initialized Changed paths: M ext/sockets/conversions.c Diff: diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index ef1f884..d0d0c4b 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -858,6 +858,7 @@ static void from_zval_write_control(const zval *arr, if (space_left req_space) { *control_buf = safe_erealloc(*control_buf, 2, req_space, *control_len); *control_len += 2 * req_space; + memset(*control_buf, '\0', *control_len - *offset); memcpy(alloc-data, *control_buf, sizeof *control_buf); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Payload of HOPLIMIT/TCLASS are 8-bit: ext/sockets/conversions.c ext/sockets/conversions.h ext/sockets/sendrecvmsg.c
Commit:f10baf14eda4a6fd0e4c8a24d008975184e31207 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Thu, 31 Jan 2013 00:59:05 +0100 Parents: c846fcef685c14a42ae770d56340a41d936deae9 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f10baf14eda4a6fd0e4c8a24d008975184e31207 Log: Payload of HOPLIMIT/TCLASS are 8-bit Changed paths: M ext/sockets/conversions.c M ext/sockets/conversions.h M ext/sockets/sendrecvmsg.c Diff: diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index 9cbc6e5..ef1f884 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -317,7 +317,7 @@ double_case: return ret; } -void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx) +static void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx) { long lval; int ival; @@ -355,6 +355,25 @@ static void from_zval_write_uint32(const zval *arr_value, char *field, ser_conte ival = (uint32_t)lval; memcpy(field, ival, sizeof(ival)); } +void from_zval_write_uint8(const zval *arr_value, char *field, ser_context *ctx) +{ + long lval; + uint8_t ival; + + lval = from_zval_integer_common(arr_value, ctx); + if (ctx-err.has_error) { + return; + } + + if (lval 0 || lval 0xFF) { + do_from_zval_err(ctx, %s, given PHP integer is out of bounds + for an unsigned 8-bit integer); + return; + } + + ival = (uint8_t)lval; + memcpy(field, ival, sizeof(ival)); +} static void from_zval_write_net_uint16(const zval *arr_value, char *field, ser_context *ctx) { long lval; @@ -441,7 +460,7 @@ static void from_zval_write_uid_t(const zval *arr_value, char *field, ser_contex memcpy(field, ival, sizeof(ival)); } -void to_zval_read_int(const char *data, zval *zv, res_context *ctx) +static void to_zval_read_int(const char *data, zval *zv, res_context *ctx) { int ival; memcpy(ival, data, sizeof(ival)); @@ -455,6 +474,13 @@ static void to_zval_read_unsigned(const char *data, zval *zv, res_context *ctx) ZVAL_LONG(zv, (long)ival); } +void to_zval_read_uint8(const char *data, zval *zv, res_context *ctx) +{ + uint8_t ival; + memcpy(ival, data, sizeof(ival)); + + ZVAL_LONG(zv, (long)ival); +} static void to_zval_read_net_uint16(const char *data, zval *zv, res_context *ctx) { uint16_t ival; diff --git a/ext/sockets/conversions.h b/ext/sockets/conversions.h index 70f31ba..79ca4ab 100644 --- a/ext/sockets/conversions.h +++ b/ext/sockets/conversions.h @@ -37,8 +37,8 @@ void err_msg_dispose(struct err_s *err TSRMLS_DC); void allocations_dispose(zend_llist **allocations); /* CONVERSION FUNCTIONS */ -void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx); -void to_zval_read_int(const char *data, zval *zv, res_context *ctx); +void from_zval_write_uint8(const zval *arr_value, char *field, ser_context *ctx); +void to_zval_read_uint8(const char *data, zval *zv, res_context *ctx); #ifdef IPV6_PKTINFO void from_zval_write_in6_pktinfo(const zval *container, char *in6_pktinfo_c, ser_context *ctx); diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index b83b3ae..f325b03 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -73,12 +73,14 @@ static void init_ancillary_registry(void) #endif #ifdef IPV6_HOPLIMIT - PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, - to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT); + PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_uint8, + to_zval_read_uint8, IPPROTO_IPV6, IPV6_HOPLIMIT); #endif - PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, - to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS); +#ifdef IPV6_TCLASS + PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_uint8, + to_zval_read_uint8, IPPROTO_IPV6, IPV6_TCLASS); +#endif #ifdef SO_PASSCRED PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix buf in string - int conv.: ext/sockets/conversions.c
Commit:c846fcef685c14a42ae770d56340a41d936deae9 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Thu, 31 Jan 2013 00:40:17 +0100 Parents: bd580db373ce35aa2e60ca452ae4eb1984b0520e Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c846fcef685c14a42ae770d56340a41d936deae9 Log: Fix buf in string - int conv. Changed paths: M ext/sockets/conversions.c Diff: diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index 5463160..9cbc6e5 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -297,7 +297,7 @@ double_case: case IS_LONG: zval_dtor(lzval); Z_TYPE(lzval) = IS_LONG; - Z_DVAL(lzval) = lval; + Z_LVAL(lzval) = lval; goto long_case; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Build fixes; accept names for if_index: ext/sockets/conversions.c ext/sockets/multicast.c ext/sockets/multicast.h ext/sockets/sendrecvmsg.c ext/sockets/sendrecvmsg.h ext/sockets
Commit:bd580db373ce35aa2e60ca452ae4eb1984b0520e Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 1 Jan 2013 23:38:19 +0100 Parents: 4414b33abd087bba26cb2cbdc2bf05938d5a6690 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bd580db373ce35aa2e60ca452ae4eb1984b0520e Log: Build fixes; accept names for if_index Changed paths: M ext/sockets/conversions.c M ext/sockets/multicast.c M ext/sockets/multicast.h M ext/sockets/sendrecvmsg.c M ext/sockets/sendrecvmsg.h M ext/sockets/sockets.c diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index 7ca9972..5463160 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -12,6 +12,9 @@ #include netinet/in.h #include sys/un.h +#include sys/ioctl.h +#include net/if.h + #include limits.h #include stdarg.h #include stddef.h @@ -53,6 +56,8 @@ typedef struct { #define KEY_RECVMSG_RET recvmsg_ret #define KEY_CMSG_LEN cmsg_len +const struct key_value empty_key_value_list[] = {{0}}; + /* PARAMETERS */ static int param_get_bool(void *ctx, const char *key, int def) { @@ -331,25 +336,6 @@ void from_zval_write_int(const zval *arr_value, char *field, ser_context *ctx) ival = (int)lval; memcpy(field, ival, sizeof(ival)); } -static void from_zval_write_unsigned(const zval *arr_value, char *field, ser_context *ctx) -{ - long lval; - unsigned ival; - - lval = from_zval_integer_common(arr_value, ctx); - if (ctx-err.has_error) { - return; - } - - if (sizeof(long) sizeof(ival) (lval 0 || lval UINT_MAX)) { - do_from_zval_err(ctx, %s, given PHP integer is out of bounds - for a native unsigned int); - return; - } - - ival = (unsigned)lval; - memcpy(field, ival, sizeof(ival)); -} static void from_zval_write_uint32(const zval *arr_value, char *field, ser_context *ctx) { long lval; @@ -1192,20 +1178,17 @@ void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx) /* CONVERSIONS for if_index */ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context *ctx) { - zval *va; unsigned *out; - unsigned ret; - zvallzval = zval_used_for_init; + unsignedret; + zvallzval = zval_used_for_init; if (Z_TYPE_P(zv) == IS_LONG) { - if (Z_LVAL_P(zv) 0 || Z_LVAL_P(zv) UINT_MAX) { + if (Z_LVAL_P(zv) 0 || Z_LVAL_P(zv) UINT_MAX) { /* allow 0 (unspecified interface) */ do_from_zval_err(ctx, the interface index cannot be negative or larger than %u; given %ld, UINT_MAX, Z_LVAL_P(zv)); } else { ret = (unsigned)Z_LVAL_P(zv); } } else { -#if HAVE_IF_NAMETOINDEX - if (Z_TYPE_P(zv) != IS_STRING) { ZVAL_COPY_VALUE(lzval, zv); zval_copy_ctor(lzval); @@ -1213,11 +1196,32 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context zv = lzval; } +#if HAVE_IF_NAMETOINDEX ret = if_nametoindex(Z_STRVAL_P(zv)); if (ret == 0) { do_from_zval_err(ctx, no interface with name \%s\ could be found, Z_STRVAL_P(zv)); } +#elif defined(SIOCGIFINDEX) + { + struct ifreq ifr; + if (strlcpy(ifr.ifr_name, Z_STRVAL_P(zv), sizeof(ifr.ifr_name)) + = sizeof(ifr.ifr_name)) { + do_from_zval_err(ctx, the interface name \%s\ is too large , + Z_STRVAL_P(zv)); + } else if (ioctl(ctx-sock-bsd_socket, SIOCGIFINDEX, ifr) 0) { + if (errno == ENODEV) { + do_from_zval_err(ctx, no interface with name \%s\ could be + found, Z_STRVAL_P(zv)); + } else { + do_from_zval_err(ctx, error fetching interface index for + interface with name \%s\ (errno %d), + Z_STRVAL_P(zv), errno); + } + } else { + ret = (unsigned)ifr.ifr_ifindex; + } + } #else do_from_zval_err(ctx, this platform does not support looking up an interface by @@ -1236,7 +1240,7 @@ static void from_zval_write_ifindex(const zval *zv, char
[PHP-CVS] com php-src: Rename some functions for consistency: ext/sockets/sendrecvmsg.c ext/sockets/sendrecvmsg.h ext/sockets/sockets.c
Commit:b18bd8904e41941db204ac6b2bf4cf43421e8838 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 6 Nov 2012 13:38:57 +0100 Parents: 8fb1aa618453149bb876bda4cafd1860468c4443 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b18bd8904e41941db204ac6b2bf4cf43421e8838 Log: Rename some functions for consistency Changed paths: M ext/sockets/sendrecvmsg.c M ext/sockets/sendrecvmsg.h M ext/sockets/sockets.c Diff: diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index 88b937f..201adbd 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -1723,7 +1723,7 @@ PHP_FUNCTION(socket_cmsg_space) RETURN_LONG((long)CMSG_SPACE(entry-size + n * entry-var_el_size)); } -void _socket_sendrecvmsg_init(INIT_FUNC_ARGS) +void php_socket_sendrecvmsg_init(INIT_FUNC_ARGS) { /* IPv6 ancillary data * Note that support for sticky options via setsockopt() is not implemented @@ -1763,7 +1763,7 @@ void _socket_sendrecvmsg_init(INIT_FUNC_ARGS) #endif } -void _socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS) +void php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS) { #ifdef ZTS tsrm_mutex_free(ancillary_mutex); diff --git a/ext/sockets/sendrecvmsg.h b/ext/sockets/sendrecvmsg.h index 82dc456..929a6ad 100644 --- a/ext/sockets/sendrecvmsg.h +++ b/ext/sockets/sendrecvmsg.h @@ -4,5 +4,5 @@ PHP_FUNCTION(socket_sendmsg); PHP_FUNCTION(socket_recvmsg); PHP_FUNCTION(socket_cmsg_space); -void _socket_sendrecvmsg_init(INIT_FUNC_ARGS); -void _socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS); +void php_socket_sendrecvmsg_init(INIT_FUNC_ARGS); +void php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS); diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 9f11594..1d86028 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -751,7 +751,7 @@ PHP_MINIT_FUNCTION(sockets) REGISTER_LONG_CONSTANT(IPV6_UNICAST_HOPS, IPV6_UNICAST_HOPS, CONST_CS | CONST_PERSISTENT); #endif - _socket_sendrecvmsg_init(INIT_FUNC_ARGS_PASSTHRU); + php_socket_sendrecvmsg_init(INIT_FUNC_ARGS_PASSTHRU); return SUCCESS; } @@ -774,7 +774,7 @@ PHP_RSHUTDOWN_FUNCTION(sockets) efree(SOCKETS_G(strerror_buf)); SOCKETS_G(strerror_buf) = NULL; } - _socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS_PASSTHRU); + php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS_PASSTHRU); return SUCCESS; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Destroy ancillary registry on shutdown: ext/sockets/sendrecvmsg.c
Commit:8fb1aa618453149bb876bda4cafd1860468c4443 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 6 Nov 2012 13:36:40 +0100 Parents: 51394f76a5fca718fbf21d97402f845ee261 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8fb1aa618453149bb876bda4cafd1860468c4443 Log: Destroy ancillary registry on shutdown Changed paths: M ext/sockets/sendrecvmsg.c Diff: diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index 16330e0..88b937f 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -1541,6 +1541,13 @@ static void init_ancillary_registry(void) #endif } +static void destroy_ancillary_registry(void) +{ + if (ancillary_registry.initialized) { + zend_hash_destroy(ancillary_registry.ht); + ancillary_registry.initialized = 0; + } +} static ancillary_reg_entry *get_ancillary_reg_entry(int cmsg_level, int msg_type) { anc_reg_key key = { cmsg_level, msg_type }; @@ -1761,4 +1768,6 @@ void _socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS) #ifdef ZTS tsrm_mutex_free(ancillary_mutex); #endif + + destroy_ancillary_registry(); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Move some multicast stuff to multicast.c: ext/sockets/multicast.c ext/sockets/multicast.h ext/sockets/php_sockets.h ext/sockets/sockets.c
Commit:51394f76a5fca718fbf21d97402f845ee261 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 6 Nov 2012 12:48:47 +0100 Parents: 3e515a2fd93204594c80ad2379f42fbb2db18d78 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=51394f76a5fca718fbf21d97402f845ee261 Log: Move some multicast stuff to multicast.c Changed paths: M ext/sockets/multicast.c M ext/sockets/multicast.h M ext/sockets/php_sockets.h M ext/sockets/sockets.c diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index d4a00a8..dc24269 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -54,6 +54,7 @@ #include php_sockets.h #include multicast.h +#include sockaddr_conv.h #include main/php_network.h @@ -76,6 +77,309 @@ static const char *_php_source_op_to_string(enum source_op sop); static int _php_source_op_to_ipv4_op(enum source_op sop); #endif +static int php_get_if_index_from_zval(zval *val, unsigned *out TSRMLS_DC) +{ + int ret; + + if (Z_TYPE_P(val) == IS_LONG) { + if (Z_LVAL_P(val) 0 || Z_LVAL_P(val) UINT_MAX) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + the interface index cannot be negative or larger than %u; +given %ld, UINT_MAX, Z_LVAL_P(val)); + ret = FAILURE; + } else { + *out = Z_LVAL_P(val); + ret = SUCCESS; + } + } else { +#if HAVE_IF_NAMETOINDEX + unsigned int ind; + zval_add_ref(val); + convert_to_string_ex(val); + ind = if_nametoindex(Z_STRVAL_P(val)); + if (ind == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + no interface with name \%s\ could be found, Z_STRVAL_P(val)); + ret = FAILURE; + } else { + *out = ind; + ret = SUCCESS; + } + zval_ptr_dtor(val); +#else + php_error_docref(NULL TSRMLS_CC, E_WARNING, + this platform does not support looking up an interface by + name, an integer interface index must be supplied instead); + ret = FAILURE; +#endif + } + + return ret; +} + +static int php_get_if_index_from_array(const HashTable *ht, const char *key, + php_socket *sock, unsigned int *if_index TSRMLS_DC) +{ + zval **val; + + if (zend_hash_find(ht, key, strlen(key) + 1, (void **)val) == FAILURE) { + *if_index = 0; /* default: 0 */ + return SUCCESS; + } + + return php_get_if_index_from_zval(*val, if_index TSRMLS_CC); +} + +static int php_get_address_from_array(const HashTable *ht, const char *key, + php_socket *sock, php_sockaddr_storage *ss, socklen_t *ss_len TSRMLS_DC) +{ + zval **val, +*valcp; + + if (zend_hash_find(ht, key, strlen(key) + 1, (void **)val) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, no key \%s\ passed in optval, key); + return FAILURE; + } + valcp = *val; + zval_add_ref(valcp); + convert_to_string_ex(val); + if (!php_set_inet46_addr(ss, ss_len, Z_STRVAL_P(valcp), sock TSRMLS_CC)) { + zval_ptr_dtor(valcp); + return FAILURE; + } + zval_ptr_dtor(valcp); + return SUCCESS; +} + +static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval **arg4 TSRMLS_DC) +{ + HashTable *opt_ht; + unsigned intif_index; + int retval; + int (*mcast_req_fun)(php_socket *, int, struct sockaddr *, socklen_t, + unsigned TSRMLS_DC); +#ifdef HAS_MCAST_EXT + int (*mcast_sreq_fun)(php_socket *, int, struct sockaddr *, socklen_t, + struct sockaddr *, socklen_t, unsigned TSRMLS_DC); +#endif + + switch (optname) { + case MCAST_JOIN_GROUP: + mcast_req_fun = php_mcast_join; + goto mcast_req_fun; + case MCAST_LEAVE_GROUP: + { + php_sockaddr_storagegroup = {0}; + socklen_t glen; + + mcast_req_fun = php_mcast_leave; +mcast_req_fun: + convert_to_array_ex(arg4); + opt_ht = HASH_OF(*arg4); + + if (php_get_address_from_array(opt_ht, group, php_sock, group, + glen TSRMLS_CC) == FAILURE) { + return FAILURE; + } + if (php_get_if_index_from_array(opt_ht, interface, php_sock, +
[PHP-CVS] com php-src: Check return of fstat(): ext/sockets/sendrecvmsg.c
Commit:5bf7b08efd691780f421e0b4f176404fe3a80b2c Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 5 Nov 2012 17:35:46 +0100 Parents: 190a0ed71377519425f1b33ef3b21f41064e416b Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5bf7b08efd691780f421e0b4f176404fe3a80b2c Log: Check return of fstat() Changed paths: M ext/sockets/sendrecvmsg.c Diff: diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index 4436d18..16330e0 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -1387,7 +1387,12 @@ static void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx) fd = *((int *)data + i); /* determine whether we have a socket */ - fstat(fd, statbuf); + if (fstat(fd, statbuf) == -1) { + do_to_zval_err(ctx, error creating resource for received file + descriptor %d: fstat() call failed with errno %d, fd, errno); + efree(elem); + return; + } if (S_ISSOCK(statbuf.st_mode)) { php_socket *sock = socket_import_file_descriptor(fd); zend_register_resource(elem, sock, php_sockets_le_socket()); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix mcast_ipv6_send test: ext/sockets/tests/mcast_ipv6_send.phpt
Commit:3e515a2fd93204594c80ad2379f42fbb2db18d78 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 6 Nov 2012 11:25:23 +0100 Parents: 5bf7b08efd691780f421e0b4f176404fe3a80b2c Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3e515a2fd93204594c80ad2379f42fbb2db18d78 Log: Fix mcast_ipv6_send test Changed paths: M ext/sockets/tests/mcast_ipv6_send.phpt Diff: diff --git a/ext/sockets/tests/mcast_ipv6_send.phpt b/ext/sockets/tests/mcast_ipv6_send.phpt index b8d38bf..f75bb09 100644 --- a/ext/sockets/tests/mcast_ipv6_send.phpt +++ b/ext/sockets/tests/mcast_ipv6_send.phpt @@ -9,8 +9,8 @@ if (!defined('IPPROTO_IPV6')) { die('skip IPv6 not available.'); } $level = IPPROTO_IPV6; -$s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die(skip Can not create socket); -if (socket_set_option($s, $level, IP_MULTICAST_IF, 1) === false) { +$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die(skip Can not create socket); +if (socket_set_option($s, $level, IPV6_MULTICAST_IF, 1) === false) { die(skip interface 1 either doesn't exist or has no ipv6 address); } --FILE-- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix build on Mac OS X: ext/sockets/sendrecvmsg.c
Commit:190a0ed71377519425f1b33ef3b21f41064e416b Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 5 Nov 2012 17:10:10 +0100 Parents: 51e65667f5dcb60af24603a543946aa258ac9003 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=190a0ed71377519425f1b33ef3b21f41064e416b Log: Fix build on Mac OS X By deactivating unsupported features on this OS. Changed paths: M ext/sockets/sendrecvmsg.c Diff: diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index 385c232..4436d18 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -1252,6 +1252,7 @@ static void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx /* CONVERSIONS for struct in6_pktinfo */ +#ifdef IPV6_PKTINFO static const field_descriptor descriptors_in6_pktinfo[] = { {addr, sizeof(addr), 1, offsetof(struct in6_pktinfo, ipi6_addr), from_zval_write_sin6_addr, to_zval_read_sin6_addr}, {ifindex, sizeof(ifindex), 1, offsetof(struct in6_pktinfo, ipi6_ifindex), from_zval_write_unsigned, to_zval_read_unsigned}, @@ -1267,8 +1268,10 @@ static void to_zval_read_in6_pktinfo(const char *data, zval *zv, res_context *ct to_zval_read_aggregation(data, zv, descriptors_in6_pktinfo, ctx); } +#endif /* CONVERSIONS for struct ucred */ +#ifdef SO_PASSCRED static const field_descriptor descriptors_ucred[] = { {pid, sizeof(pid), 1, offsetof(struct ucred, pid), from_zval_write_pid_t, to_zval_read_pid_t}, {uid, sizeof(uid), 1, offsetof(struct ucred, uid), from_zval_write_uid_t, to_zval_read_uid_t}, @@ -1286,8 +1289,10 @@ static void to_zval_read_ucred(const char *data, zval *zv, res_context *ctx) to_zval_read_aggregation(data, zv, descriptors_ucred, ctx); } +#endif /* CONVERSIONS for SCM_RIGHTS */ +#ifdef SCM_RIGHTS static size_t calculate_scm_rights_space(const zval *arr, ser_context *ctx) { int num_elems; @@ -1394,6 +1399,7 @@ static void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx) add_next_index_zval(zv, elem); } } +#endif /* ENTRY POINT for conversions */ static void free_from_zval_allocation(void *alloc_ptr_ptr) @@ -1506,20 +1512,28 @@ static void init_ancillary_registry(void) zend_hash_update(ancillary_registry.ht, (char*)key, sizeof(key), \ (void*)entry, sizeof(entry), NULL) +#ifdef IPV6_PKTINFO PUT_ENTRY(sizeof(struct in6_pktinfo), 0, 0, from_zval_write_in6_pktinfo, to_zval_read_in6_pktinfo, IPPROTO_IPV6, IPV6_PKTINFO); +#endif +#ifdef IPV6_HOPLIMIT PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT); +#endif PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS); +#ifdef SO_PASSCRED PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred, to_zval_read_ucred, SOL_SOCKET, SCM_CREDENTIALS); +#endif +#ifdef SCM_RIGHTS PUT_ENTRY(0, sizeof(int), calculate_scm_rights_space, from_zval_write_fd_array, to_zval_read_fd_array, SOL_SOCKET, SCM_RIGHTS); +#endif } static ancillary_reg_entry *get_ancillary_reg_entry(int cmsg_level, int msg_type) @@ -1702,8 +1716,14 @@ void _socket_sendrecvmsg_init(INIT_FUNC_ARGS) /* IPv6 ancillary data * Note that support for sticky options via setsockopt() is not implemented * yet (where special support is needed, i.e., the optval is not an int). */ +#ifdef IPV6_RECVPKTINFO REGISTER_LONG_CONSTANT(IPV6_RECVPKTINFO, IPV6_RECVPKTINFO, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(IPV6_PKTINFO, IPV6_PKTINFO, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef IPV6_RECVHOPLIMIT REGISTER_LONG_CONSTANT(IPV6_RECVHOPLIMIT, IPV6_RECVHOPLIMIT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(IPV6_HOPLIMIT, IPV6_HOPLIMIT, CONST_CS | CONST_PERSISTENT); +#endif /* would require some effort: REGISTER_LONG_CONSTANT(IPV6_RECVRTHDR,IPV6_RECVRTHDR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(IPV6_RECVHOPOPTS, IPV6_RECVHOPOPTS, CONST_CS | CONST_PERSISTENT); @@ -1711,8 +1731,6 @@ void _socket_sendrecvmsg_init(INIT_FUNC_ARGS) */ REGISTER_LONG_CONSTANT(IPV6_RECVTCLASS, IPV6_RECVTCLASS,CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(IPV6_PKTINFO, IPV6_PKTINFO, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT(IPV6_HOPLIMIT, IPV6_HOPLIMIT, CONST_CS | CONST_PERSISTENT); /* REGISTER_LONG_CONSTANT(IPV6_RTHDR,IPV6_RTHDR, CONST_CS |
[PHP-CVS] com php-src: Register extra MSG_* constants: ext/sockets/sockets.c
Commit:51e65667f5dcb60af24603a543946aa258ac9003 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 5 Nov 2012 16:12:21 +0100 Parents: 74cf40c2fdccdfaed419482d080be4f73fb23a7e Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=51e65667f5dcb60af24603a543946aa258ac9003 Log: Register extra MSG_* constants Changed paths: M ext/sockets/sockets.c Diff: diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 449be8f..37e2e9f 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -718,19 +718,38 @@ PHP_MINIT_FUNCTION(sockets) REGISTER_LONG_CONSTANT(SOCK_RAW, SOCK_RAW, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SOCK_SEQPACKET,SOCK_SEQPACKET, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SOCK_RDM, SOCK_RDM, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(MSG_OOB, MSG_OOB, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_WAITALL, MSG_WAITALL,CONST_CS | CONST_PERSISTENT); -#ifdef MSG_DONTWAIT - REGISTER_LONG_CONSTANT(MSG_DONTWAIT, MSG_DONTWAIT, CONST_CS | CONST_PERSISTENT); -#endif + REGISTER_LONG_CONSTANT(MSG_CTRUNC,MSG_CTRUNC, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(MSG_TRUNC, MSG_TRUNC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_PEEK, MSG_PEEK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_DONTROUTE, MSG_DONTROUTE, CONST_CS | CONST_PERSISTENT); -#ifdef MSG_EOR REGISTER_LONG_CONSTANT(MSG_EOR, MSG_EOR, CONST_CS | CONST_PERSISTENT); -#endif -#ifdef MSG_EOF REGISTER_LONG_CONSTANT(MSG_EOF, MSG_EOF, CONST_CS | CONST_PERSISTENT); + +#ifdef MSG_CONFIRM + REGISTER_LONG_CONSTANT(MSG_CONFIRM, MSG_CONFIRM,CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_ERRQUEUE + REGISTER_LONG_CONSTANT(MSG_ERRQUEUE, MSG_ERRQUEUE, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_NOSIGNAL + REGISTER_LONG_CONSTANT(MSG_NOSIGNAL, MSG_NOSIGNAL, CONST_CS | CONST_PERSISTENT); #endif +#ifdef MSG_DONTWAIT + REGISTER_LONG_CONSTANT(MSG_DONTWAIT, MSG_DONTWAIT, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_MORE + REGISTER_LONG_CONSTANT(MSG_MORE, MSG_MORE, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_WAITFORONE + REGISTER_LONG_CONSTANT(MSG_WAITFORONE,MSG_WAITFORONE, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_CMSG_CLOEXEC + REGISTER_LONG_CONSTANT(MSG_CMSG_CLOEXEC,MSG_CMSG_CLOEXEC,CONST_CS | CONST_PERSISTENT); +#endif + REGISTER_LONG_CONSTANT(SO_DEBUG, SO_DEBUG, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SO_REUSEADDR, SO_REUSEADDR, CONST_CS | CONST_PERSISTENT); #ifdef SO_REUSEPORT -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Redactor to expose socket_import_file_descriptor(): ext/sockets/php_sockets.h ext/sockets/sockets.c
Commit:131245474bf95490cf1a1dfdb5debe5d46133522 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 5 Nov 2012 14:52:48 +0100 Parents: b3effa60c73922ddf4a7df3be3a0e4e5ca47f70d Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=131245474bf95490cf1a1dfdb5debe5d46133522 Log: Redactor to expose socket_import_file_descriptor() Changed paths: M ext/sockets/php_sockets.h M ext/sockets/sockets.c Diff: diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 9158ca4..3138eb6 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -88,6 +88,7 @@ ZEND_END_MODULE_GLOBALS(sockets) ZEND_EXTERN_MODULE_GLOBALS(sockets); char *sockets_strerror(int error TSRMLS_DC); +php_socket *socket_import_file_descriptor(PHP_SOCKET sock TSRMLS_DC); #define PHP_SOCKET_ERROR(socket,msg,errn) \ socket-error = errn; \ diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 863825d..449be8f 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -2426,41 +2426,25 @@ PHP_FUNCTION(socket_clear_error) } /* }}} */ -/* {{{ proto void socket_import_stream(resource stream) - Imports a stream that encapsulates a socket into a socket extension resource. */ -PHP_FUNCTION(socket_import_stream) +php_socket *socket_import_file_descriptor(PHP_SOCKET socket TSRMLS_DC) { - zval *zstream; - php_stream *stream; - php_socket *retsock = NULL; - PHP_SOCKET socket; /* fd */ - php_sockaddr_storage addr; - socklen_taddr_len = sizeof(addr); +#ifdef SO_DOMAIN + int type; + socklen_t type_len = sizeof(type); +#endif + php_socket *retsock; + php_sockaddr_storageaddr; + socklen_t addr_len = sizeof(addr); #ifndef PHP_WIN32 int t; #endif -#ifdef SO_DOMAIN - int type; - socklen_t type_len = sizeof(type); -#endif - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, zstream) == FAILURE) { - return; - } - php_stream_from_zval(stream, zstream); - - if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void**)socket, 1)) { - /* error supposedly already shown */ - RETURN_FALSE; - } - - retsock = php_create_socket(); +retsock = php_create_socket(); +retsock-bsd_socket = socket; - retsock-bsd_socket = socket; - - /* determine family */ +/* determine family */ #ifdef SO_DOMAIN - if (getsockopt(socket, SOL_SOCKET, SO_DOMAIN, type, type_len) == 0) { +if (getsockopt(socket, SOL_SOCKET, SO_DOMAIN, type, type_len) == 0) { retsock-type = type; } else #endif @@ -2471,16 +2455,49 @@ PHP_FUNCTION(socket_import_stream) goto error; } - /* determine blocking mode */ +/* determine blocking mode */ #ifndef PHP_WIN32 - t = fcntl(socket, F_GETFL); - if(t == -1) { +t = fcntl(socket, F_GETFL); +if (t == -1) { PHP_SOCKET_ERROR(retsock, unable to obtain blocking state, errno); goto error; - } else { - retsock-blocking = !(t O_NONBLOCK); +} else { + retsock-blocking = !(t O_NONBLOCK); +} +#endif + +return retsock; + +error: + efree(retsock); + return NULL; +} + +/* {{{ proto void socket_import_stream(resource stream) + Imports a stream that encapsulates a socket into a socket extension resource. */ +PHP_FUNCTION(socket_import_stream) +{ + zval *zstream; + php_stream *stream; + php_socket *retsock = NULL; + PHP_SOCKET socket; /* fd */ + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, zstream) == FAILURE) { + return; } -#else + php_stream_from_zval(stream, zstream); + + if (php_stream_cast(stream, PHP_STREAM_AS_SOCKETD, (void**)socket, 1)) { + /* error supposedly already shown */ + RETURN_FALSE; + } + + retsock = socket_import_file_descriptor(socket); + if (retsock == NULL) { + RETURN_FALSE; + } + +#ifdef PHP_WIN32 /* on windows, check if the stream is a socket stream and read its * private data; otherwise assume it's in non-blocking mode */ if (php_stream_is(stream, PHP_STREAM_IS_SOCKET)) { @@ -2504,11 +2521,6 @@ PHP_FUNCTION(socket_import_stream) PHP_STREAM_BUFFER_NONE, NULL); ZEND_REGISTER_RESOURCE(return_value, retsock, le_socket); - return; -error:
[PHP-CVS] com php-src: Improve imported socket family detection: ext/sockets/sockets.c
Commit:b3effa60c73922ddf4a7df3be3a0e4e5ca47f70d Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 23 Oct 2012 13:09:38 +0200 Parents: 17540788ad8c25969f1dbd02c1a3b75a8417fe9c Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b3effa60c73922ddf4a7df3be3a0e4e5ca47f70d Log: Improve imported socket family detection Also added constant SO_FAMILY. Changed paths: M ext/sockets/sockets.c Diff: diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index b213b0a..863825d 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -748,6 +748,9 @@ PHP_MINIT_FUNCTION(sockets) REGISTER_LONG_CONSTANT(SO_SNDTIMEO, SO_SNDTIMEO,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SO_RCVTIMEO, SO_RCVTIMEO,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SO_TYPE, SO_TYPE, CONST_CS | CONST_PERSISTENT); +#ifdef SO_FAMILY + REGISTER_LONG_CONSTANT(SO_FAMILY, SO_FAMILY, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT(SO_ERROR, SO_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SOL_SOCKET,SOL_SOCKET, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SOMAXCONN, SOMAXCONN, CONST_CS | CONST_PERSISTENT); @@ -2436,6 +2439,10 @@ PHP_FUNCTION(socket_import_stream) #ifndef PHP_WIN32 int t; #endif +#ifdef SO_DOMAIN + int type; + socklen_t type_len = sizeof(type); +#endif if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, zstream) == FAILURE) { return; @@ -2452,6 +2459,11 @@ PHP_FUNCTION(socket_import_stream) retsock-bsd_socket = socket; /* determine family */ +#ifdef SO_DOMAIN + if (getsockopt(socket, SOL_SOCKET, SO_DOMAIN, type, type_len) == 0) { + retsock-type = type; + } else +#endif if (getsockname(socket, (struct sockaddr*)addr, addr_len) == 0) { retsock-type = addr.ss_family; } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Added missing return statements: ext/sockets/sendrecvmsg.c
Commit:17540788ad8c25969f1dbd02c1a3b75a8417fe9c Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 5 Nov 2012 11:36:00 +0100 Parents: 0f849fe2aa7c8894b2dbde57abd8a3a3aa8f764a Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=17540788ad8c25969f1dbd02c1a3b75a8417fe9c Log: Added missing return statements Changed paths: M ext/sockets/sendrecvmsg.c Diff: diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index e47bd46..3405215 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -918,6 +918,7 @@ static void from_zval_write_iov_array(const zval *arr, char *msghdr_c, ser_conte if (Z_TYPE_P(arr) != IS_ARRAY) { do_from_zval_err(ctx, %s, expected an array here); + return; } num_elem = zend_hash_num_elements(Z_ARRVAL_P(arr)); @@ -964,6 +965,7 @@ static void from_zval_write_controllen(const zval *elem, char *msghdr_c, ser_con from_zval_write_uint32(elem, (char*)len, ctx); if (!ctx-err.has_error len == 0) { do_from_zval_err(ctx, controllen cannot be 0); + return; } msghdr-msg_control = accounted_emalloc(len, ctx); msghdr-msg_controllen = len; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug converting zval sockaddr: ext/sockets/sendrecvmsg.c
Commit:b06f00477ce4f20516c6f727797f208ffaefcae9 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 2 Nov 2012 17:52:13 +0100 Parents: 806a6e6399568d3bfbef355992fb3d09e29a607c Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b06f00477ce4f20516c6f727797f208ffaefcae9 Log: Fix bug converting zval sockaddr The bug ocurred when the family was not specified but was instead guessed. Changed paths: M ext/sockets/sendrecvmsg.c Diff: diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index 379af12..837ae23 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -627,6 +627,7 @@ static void from_zval_write_sockaddr_aux(const zval *container, *sockaddr_len = sizeof(struct sockaddr_in); if (fill_sockaddr) { from_zval_write_sockaddr_in(container, (char*)*sockaddr_ptr, ctx); + (*sockaddr_ptr)-sa_family = AF_INET; } break; case AF_INET6: @@ -639,6 +640,7 @@ static void from_zval_write_sockaddr_aux(const zval *container, *sockaddr_len = sizeof(struct sockaddr_in6); if (fill_sockaddr) { from_zval_write_sockaddr_in6(container, (char*)*sockaddr_ptr, ctx); + (*sockaddr_ptr)-sa_family = AF_INET6; } break; default: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Add test for recvmsg(): ext/sockets/tests/recvmsg.phpt
Commit:eb4b1f6d46d94772611a24c70b15e46c557caeec Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 2 Nov 2012 14:03:47 +0100 Parents: 5e51c851431189677aa80f7a3a863699488678cd Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eb4b1f6d46d94772611a24c70b15e46c557caeec Log: Add test for recvmsg() Changed paths: A ext/sockets/tests/recvmsg.phpt Diff: diff --git a/ext/sockets/tests/recvmsg.phpt b/ext/sockets/tests/recvmsg.phpt new file mode 100644 index 000..30263a4 --- /dev/null +++ b/ext/sockets/tests/recvmsg.phpt @@ -0,0 +1,86 @@ +--TEST-- +recvmsg(): basic test +--SKIPIF-- +?php +if (!extension_loaded('sockets')) { +die('skip sockets extension not available.'); +} +if (!defined('IPPROTO_IPV6')) { +die('skip IPv6 not available.'); +} + +--FILE-- +?php +include __DIR__./mcast_helpers.php.inc; +$addr = '::1'; + +echo creating send socket\n; +$sends1 = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die(err); +var_dump($sends1); +$br = socket_bind($sends1, '::', 7001) or die(err); +var_dump($br); +socket_set_nonblock($sends1) or die(Could not put in non-blocking mode); + +echo creating receive socket\n; +$s = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP) or die(err); +var_dump($s); +$br = socket_bind($s, '::0', 3000) or die(err); +var_dump($br); + +socket_set_option($s, IPPROTO_IPV6, IPV6_RECVPKTINFO, 1) or die(err); + +$r = socket_sendto($sends1, $m = testing packet, strlen($m), 0, $addr, 3000); +var_dump($r); +if ($r 12) die; +checktimeout($s, 500); + +$data = [ +name = [family = AF_INET6, addr = ::1], +buffer_size = 2000, +controllen = socket_cmsg_space(IPPROTO_IPV6, IPV6_PKTINFO), +]; +if (!socket_recvmsg($s, $data, 0)) die(recvmsg); +print_r($data); + +--EXPECTF-- +creating send socket +resource(%d) of type (Socket) +bool(true) +creating receive socket +resource(%d) of type (Socket) +bool(true) +int(14) +Array +( +[name] = Array +( +[family] = %d +[addr] = ::1 +[port] = 7001 +[flowinfo] = 0 +[scope_id] = 0 +) + +[control] = Array +( +[0] = Array +( +[level] = %d +[type] = %d +[data] = Array +( +[addr] = ::1 +[ifindex] = %d +) + +) + +) + +[iov] = Array +( +[0] = testing packet +) + +[flags] = 0 +) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Ignore warnings on EAGAIN/EWOULDBLOCK/EINPROGRESS: ext/sockets/php_sockets.h ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt ext/sockets/tests/socket_sentto_recvfrom_ipv6
Commit:ac47448abb477be99963f0b38fe82ffe78c21a8b Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sat, 2 Feb 2013 15:43:05 +0100 Parents: e8f0e863ae48d58d2bb95e667606d7846f782d08 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ac47448abb477be99963f0b38fe82ffe78c21a8b Log: Ignore warnings on EAGAIN/EWOULDBLOCK/EINPROGRESS See bug #63570 Bugs: https://bugs.php.net/63570 Changed paths: M ext/sockets/php_sockets.h M ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt M ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt M ext/sockets/tests/socket_sentto_recvfrom_unix.phpt Diff: diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 3762e02..9c5dc5a 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -69,7 +69,9 @@ PHP_SOCKETS_API int php_sockets_le_socket(void); int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \ (socket)-error = _err; \ SOCKETS_G(last_error) = _err; \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, %s [%d]: %s, msg, _err, php_strerror(_err TSRMLS_CC)); \ + if (_err != EAGAIN _err != EWOULDBLOCK _err != EINPROGRESS) { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, %s [%d]: %s, msg, _err, php_strerror(_err TSRMLS_CC)); \ + } \ } while (0) ZEND_BEGIN_MODULE_GLOBALS(sockets) diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt index bf95044..00d69a8 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt @@ -14,7 +14,7 @@ if (!extension_loaded('sockets')) { if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } -socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning +var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); //false (EAGAIN - no warning) $address = '127.0.0.1'; socket_sendto($socket, '', 1, 0, $address); // cause warning if (!socket_bind($socket, $address, 1223)) { @@ -44,7 +44,7 @@ if (!extension_loaded('sockets')) { socket_close($socket); --EXPECTF-- -Warning: socket_recvfrom(): unable to recvfrom [%d]: %a in %s on line %d +bool(false) Warning: Wrong parameter count for socket_sendto() in %s on line %d diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt index 2beb808..bd07904 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt @@ -18,7 +18,7 @@ require 'ipv6_skipif.inc'; if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } -socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning +var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); // false (EAGAIN, no warning) $address = '::1'; socket_sendto($socket, '', 1, 0, $address); // cause warning if (!socket_bind($socket, $address, 1223)) { @@ -48,7 +48,7 @@ require 'ipv6_skipif.inc'; socket_close($socket); --EXPECTF-- -Warning: socket_recvfrom(): unable to recvfrom [11]: Resource temporarily unavailable in %s on line %d +bool(false) Warning: Wrong parameter count for socket_sendto() in %s on line %d diff --git a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt index 55ad75c..e25bf4d 100644 --- a/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt +++ b/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt @@ -18,7 +18,7 @@ if (!extension_loaded('sockets')) { if (!socket_set_nonblock($socket)) { die('Unable to set nonblocking mode for socket'); } -socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning +var_dump(socket_recvfrom($socket, $buf, 12, 0, $from, $port)); //false (EAGAIN, no warning) $address = sprintf(/tmp/%s.sock, uniqid()); if (!socket_bind($socket, $address)) { die(Unable to bind to $address); @@ -53,8 +53,7 @@ if (!extension_loaded('sockets')) { ? --EXPECTF-- Warning: socket_create(): Unable to create socket [%d]: Protocol not supported in %s on line %d - -Warning: socket_recvfrom(): unable to recvfrom [%d]: Resource temporarily unavailable in %s on line %d +bool(false) Warning: socket_sendto() expects at least 5 parameters, 4 given in %s on line %d bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/sockets/sockets.c main/network.c
Commit:e8f0e863ae48d58d2bb95e667606d7846f782d08 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sat, 2 Feb 2013 15:32:03 +0100 Parents: 114245c1b9cf153583c918e130faccc1f61d3ba5 73de4d8c689ff5c82373a4837dc8a21c9902a8b2 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e8f0e863ae48d58d2bb95e667606d7846f782d08 Log: Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: Fix wrong blocking state being set Fix tests (Windows) Remove a Windows only warning Move improve PHP_SOCKET_ERROR def Move some declarations to sockets.c Fix overbroad skipif include Changed paths: MM ext/sockets/sockets.c MM main/network.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug and hopefully build on WinSDK 6.1: ext/sockets/php_sockets.h ext/sockets/sendrecvmsg.c ext/sockets/windows_common.h
Commit:af1b90d62ba69953de2065864d2a1284314323ba Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sun, 3 Feb 2013 01:22:44 +0100 Parents: 6ba5d0a4a5b714c048e0ded9933bfef2031f17c2 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=af1b90d62ba69953de2065864d2a1284314323ba Log: Fix bug and hopefully build on WinSDK 6.1 There build was failing on rmtools on the sockets extension for two reasons: 1. IPV6_TCLASS and IPV6_RECVTCLASS not being defined. These are probably recent additions to SDK. Windows 7 doesn't event seem to have complete support for IPV6_TCLASS, not accepting in WSASendMsg(). The parts that needed this constant were not guarded by #ifdefs. They are now. 2. The constants EWOULDBLOCK and EINPROGRESS not being defined. These were only defined in php_network.h, outside of the extension, and not all source files included this header. Nevertheless, a macro defined in php_sockets.h needed these constants. When this macro was used in files that did not include php_network.h, the compilation would fail. Surprisingly, the build did not fail when using the 7.1 Windows SDK (more likely, the CRT headers used in VC10), as somehow errno.h was being included through some other standard header. This would make the constant EWOULDBLOCK defined; however, it would be defined to the wrong value. In the winsock context, WSAEWOULDBLOCK should be used instead. Because we have difficulty using Windows-only constants in the code, we (re)define EWOULDBLOCK to WSAEWOULDBLOCK. This has the obvious disavantage we may miss problems like this again in the future. Changed paths: M ext/sockets/php_sockets.h M ext/sockets/sendrecvmsg.c M ext/sockets/windows_common.h Diff: diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index bad83b3..dd2b993 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -27,6 +27,9 @@ #if HAVE_SOCKETS #include php.h +#ifdef PHP_WIN32 +# include windows_common.h +#endif extern zend_module_entry sockets_module_entry; #define phpext_sockets_ptr sockets_module_entry diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c index f75fdcd..50b43ec 100644 --- a/ext/sockets/sendrecvmsg.c +++ b/ext/sockets/sendrecvmsg.c @@ -115,8 +115,10 @@ static void init_ancillary_registry(void) to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT); #endif +#ifdef IPV6_TCLASS PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int, to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS); +#endif #ifdef SO_PASSCRED PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred, @@ -416,14 +418,16 @@ void php_socket_sendrecvmsg_init(INIT_FUNC_ARGS) REGISTER_LONG_CONSTANT(IPV6_RECVHOPOPTS, IPV6_RECVHOPOPTS, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(IPV6_RECVDSTOPTS, IPV6_RECVDSTOPTS, CONST_CS | CONST_PERSISTENT); */ +#ifdef IPV6_RECVTCLASS REGISTER_LONG_CONSTANT(IPV6_RECVTCLASS, IPV6_RECVTCLASS,CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(IPV6_TCLASS, IPV6_TCLASS, CONST_CS | CONST_PERSISTENT); +#endif /* REGISTER_LONG_CONSTANT(IPV6_RTHDR,IPV6_RTHDR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(IPV6_HOPOPTS, IPV6_HOPOPTS, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(IPV6_DSTOPTS, IPV6_DSTOPTS, CONST_CS | CONST_PERSISTENT); */ - REGISTER_LONG_CONSTANT(IPV6_TCLASS, IPV6_TCLASS, CONST_CS | CONST_PERSISTENT); #ifdef SCM_RIGHTS REGISTER_LONG_CONSTANT(SCM_RIGHTS,SCM_RIGHTS, CONST_CS | CONST_PERSISTENT); diff --git a/ext/sockets/windows_common.h b/ext/sockets/windows_common.h index c72c698..3a9cb59 100644 --- a/ext/sockets/windows_common.h +++ b/ext/sockets/windows_common.h @@ -24,14 +24,7 @@ #define HAVE_IF_NAMETOINDEX 1 #define IS_INVALID_SOCKET(a) (a-bsd_socket == INVALID_SOCKET) -#ifdef EPROTONOSUPPORT -# undef EPROTONOSUPPORT -#endif -#ifdef ECONNRESET -# undef ECONNRESET -#endif -#define EPROTONOSUPPORTWSAEPROTONOSUPPORT -#define ECONNRESET WSAECONNRESET + #ifdef errno # undef errno #endif @@ -40,4 +33,88 @@ #define set_errno(a) WSASetLastError(a) #define close(a) closesocket(a) -#endif \ No newline at end of file +#ifdef ENETUNREACH /* errno.h probably included */ +# undef EWOULDBLOCK +# undef EINPROGRESS +# undef EALREADY +# undef ENOTSOCK +# undef EDESTADDRREQ +# undef EMSGSIZE +# undef EPROTOTYPE +# undef ENOPROTOOPT +# undef EPROTONOSUPPORT +# undef ESOCKTNOSUPPORT +# undef EOPNOTSUPP +# undef EPFNOSUPPORT +# undef EAFNOSUPPORT +# undef EADDRINUSE +# undef EADDRNOTAVAIL +# undef ENETDOWN +#
[PHP-CVS] com php-src: NEWS/UPGRADING for changes in sockets, intl: NEWS UPGRADING
Commit:a000920dfb099fac3b58ea344d33f4b6c3ee51a1 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sun, 3 Feb 2013 01:59:35 +0100 Parents: af1b90d62ba69953de2065864d2a1284314323ba Branches: PHP-5.5 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a000920dfb099fac3b58ea344d33f4b6c3ee51a1 Log: NEWS/UPGRADING for changes in sockets, intl Changed paths: M NEWS M UPGRADING Diff: diff --git a/NEWS b/NEWS index e79cffe..11ae31c 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,14 @@ PHP NEWS . Implemented FR #46439 - added CURLFile for safer file uploads. (Stas) +- Intl: + . Cherry-picked UConverter wrapper, which had accidentaly been committed only +to master. + +- Sockets: + . Added recvmsg() and sendmsg() wrappers. (Gustavo) +See https://wiki.php.net/rfc/sendrecvmsg + 24 Jan 2013, PHP 5.5.0 Alpha 4 - Core: diff --git a/UPGRADING b/UPGRADING index 22ad969..790803e 100755 --- a/UPGRADING +++ b/UPGRADING @@ -157,6 +157,8 @@ PHP 5.5 UPGRADE NOTES Expires headers. (see https://wiki.php.net/rfc/cookie_max-age) - curl_setopt now accepts new option CURLOPT_SAFE_UPLOAD and CURLFile object for safer file uploads (see https://wiki.php.net/rfc/curl-file-upload) +- Functions in the socket extension now do not emit warnings when the errno is + EAGAIN, EWOULDBLOCK or EINPROGRESS. 5. New Functions @@ -257,6 +259,11 @@ PHP 5.5 UPGRADE NOTES - IntlDateFormatter::getTimeZone() - IntlDateFormatter::setTimeZone() +- Sockets: + - socket_sendmsg() + - socket_recvmsg() + - socket_cmsg_space() + - SPL: - SplFixedArray::__wakeup() @@ -271,6 +278,7 @@ PHP 5.5 UPGRADE NOTES - IntlBreakIterator - IntlRuleBasedBreakIterator - IntlCodePointBreakIterator + - UConverter - cURL: - CURLFile -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fixed paramter count: ext/intl/converter/converter.c
Commit:3bedc8ec277a246db6d3bfbe6313a861e46c4505 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 26 Dec 2012 18:16:04 + Parents: 9d1bdaa569e0de0c36ee483784606246e106013f Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3bedc8ec277a246db6d3bfbe6313a861e46c4505 Log: Fixed paramter count Changed paths: M ext/intl/converter/converter.c Diff: diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 09ea609..387760a 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -93,7 +93,7 @@ static void php_converter_default_callback(zval *return_value, zval *zobj, long /* {{{ proto void UConverter::toUCallback(long $reason, string $source, string $codeUnits, long $error) */ -ZEND_BEGIN_ARG_INFO_EX(php_converter_toUCallback_arginfo, 0, ZEND_RETURN_VALUE, 5) +ZEND_BEGIN_ARG_INFO_EX(php_converter_toUCallback_arginfo, 0, ZEND_RETURN_VALUE, 4) ZEND_ARG_INFO(0, reason) ZEND_ARG_INFO(0, source) ZEND_ARG_INFO(0, codeUnits) @@ -115,7 +115,7 @@ static PHP_METHOD(UConverter, toUCallback) { /* {{{ proto void UConverter::fromUCallback(long $reason, Array $source, long $codePoint, long $error) */ -ZEND_BEGIN_ARG_INFO_EX(php_converter_fromUCallback_arginfo, 0, ZEND_RETURN_VALUE, 5) +ZEND_BEGIN_ARG_INFO_EX(php_converter_fromUCallback_arginfo, 0, ZEND_RETURN_VALUE, 4) ZEND_ARG_INFO(0, reason) ZEND_ARG_INFO(0, source) ZEND_ARG_INFO(0, codePoint) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix zpp() call in intl/converter: ext/intl/converter/converter.c
Commit:a721fe2b224f1e1d6fca31183778018147628a10 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 29 Jan 2013 17:50:15 +0100 Parents: ee6522bebf5e5b4652d01da6e6eaec4cf59051b2 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a721fe2b224f1e1d6fca31183778018147628a10 Log: Fix zpp() call in intl/converter Changed paths: M ext/intl/converter/converter.c Diff: diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 6be8698..eeb596f 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -746,7 +746,7 @@ static PHP_METHOD(UConverter, convert) { int str_len, dest_len; zend_bool reverse = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|b!, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|b, str, str_len, reverse) == FAILURE) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Improve ERROR.CONVENTIONS: ext/intl/ERROR.CONVENTIONS
Commit:363fd6d6fb5c962c8d1339dfaad2bd18373de36c Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 29 Jan 2013 16:17:55 +0100 Parents: b4ba46cb996e813ea3d99140cadbcc44822fcbe4 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=363fd6d6fb5c962c8d1339dfaad2bd18373de36c Log: Improve ERROR.CONVENTIONS Changed paths: M ext/intl/ERROR.CONVENTIONS Diff: diff --git a/ext/intl/ERROR.CONVENTIONS b/ext/intl/ERROR.CONVENTIONS index 54f30ed..6f9079c 100644 --- a/ext/intl/ERROR.CONVENTIONS +++ b/ext/intl/ERROR.CONVENTIONS @@ -81,3 +81,35 @@ ICU operates, where functions return immediately if an error is set. Error resetting can be done with: void intl_error_reset(NULL TSRMLS_DC); /* reset global error */ void intl_errors_reset(intl_error* err TSRMLS_DC );/* reset global and object error */ + +In practice, intl_errors_reset() is not used because most classes have also +plain functions mapped to the same internal functions as their instance methods. +Fetching of the object is done with zend_parse_method_parameters() instead of +directly using getThis(). Therefore, no reference to object is obtained until +the arguments are fully parsed. Without a reference to the object, there's no +way to reset the object's internal error code. Instead, resetting of the +object's internal error code is done upon fetching the object from its zval. + +Example: +U_CFUNC PHP_FUNCTION(breakiter_set_text) +{ + /* ... variable declations ... */ + BREAKITER_METHOD_INIT_VARS; /* macro also resets global error */ + object = getThis(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, + text, text_len) == FAILURE) { + intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, + breakiter_set_text: bad arguments, 0 TSRMLS_CC); + RETURN_FALSE; + } + + /* ... */ + + BREAKITER_METHOD_FETCH_OBJECT; /* macro also resets object's error */ + + /* ... */ +} + +Implementations of ::getErrorCode() and ::getErrorMessage() should not reset the +object's error code. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Make converter work on VS: ext/intl/converter/converter.c
Commit:9d1bdaa569e0de0c36ee483784606246e106013f Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 26 Dec 2012 00:51:45 + Parents: 1da67fc65e4909c671a9ccffec7d8d314f1829f1 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9d1bdaa569e0de0c36ee483784606246e106013f Log: Make converter work on VS Changed paths: M ext/intl/converter/converter.c Diff: diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 8b578c4..09ea609 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -673,9 +673,11 @@ static zend_bool php_converter_do_convert(UConverter *dest_cnv, char **pdest, in UConverter *src_cnv, const char *src, int32_t src_len, php_converter_object *objval TSRMLS_DC) { - UErrorCode error = U_ZERO_ERROR; - int32_t dest_len; - char *dest; + UErrorCode error = U_ZERO_ERROR; + int32_t dest_len, + temp_len; + char*dest; + UChar *temp; if (!src_cnv || !dest_cnv) { php_converter_throw_failure(objval, U_INVALID_STATE_ERROR TSRMLS_CC, @@ -684,12 +686,12 @@ static zend_bool php_converter_do_convert(UConverter *dest_cnv, char **pdest, in } /* Get necessary buffer size first */ - int32_t temp_len = 1 + ucnv_toUChars(src_cnv, NULL, 0, src, src_len, error); + temp_len = 1 + ucnv_toUChars(src_cnv, NULL, 0, src, src_len, error); if (U_FAILURE(error) error != U_BUFFER_OVERFLOW_ERROR) { THROW_UFAILURE(objval, ucnv_toUChars, error); return 0; } - UChar *temp = safe_emalloc(sizeof(UChar), temp_len, sizeof(UChar)); + temp = safe_emalloc(sizeof(UChar), temp_len, sizeof(UChar)); /* Convert to intermediate UChar* array */ error = U_ZERO_ERROR; @@ -941,8 +943,10 @@ static PHP_METHOD(UConverter, getAliases) { array_init(return_value); for(i = 0; i count; i++) { + const char *alias; + error = U_ZERO_ERROR; - const char *alias = ucnv_getAlias(name, i, error); + alias = ucnv_getAlias(name, i, error); if (U_FAILURE(error)) { THROW_UFAILURE(NULL, ucnv_getAlias, error); zval_dtor(return_value); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Write local err on intlcal_get_time_zone() failure: ext/intl/calendar/calendar_methods.cpp
Commit:ee6522bebf5e5b4652d01da6e6eaec4cf59051b2 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 29 Jan 2013 16:36:14 +0100 Parents: 363fd6d6fb5c962c8d1339dfaad2bd18373de36c Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ee6522bebf5e5b4652d01da6e6eaec4cf59051b2 Log: Write local err on intlcal_get_time_zone() failure Changed paths: M ext/intl/calendar/calendar_methods.cpp Diff: diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp index f2758fd..2d33bd1 100644 --- a/ext/intl/calendar/calendar_methods.cpp +++ b/ext/intl/calendar/calendar_methods.cpp @@ -782,7 +782,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_time_zone) TimeZone *tz = co-ucal-getTimeZone().clone(); if (tz == NULL) { - intl_error_set(NULL, U_MEMORY_ALLOCATION_ERROR, + intl_errors_set(CALENDAR_ERROR_P(co), U_MEMORY_ALLOCATION_ERROR, intlcal_get_time_zone: could not clone TimeZone, 0 TSRMLS_CC); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix arginfo of BreakIterator::getLocale: ext/intl/breakiterator/breakiterator_class.cpp
Commit:b4ba46cb996e813ea3d99140cadbcc44822fcbe4 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 29 Jan 2013 15:43:58 +0100 Parents: 4badc0c071e7c99946e7420707392e4de19d250e Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b4ba46cb996e813ea3d99140cadbcc44822fcbe4 Log: Fix arginfo of BreakIterator::getLocale Changed paths: M ext/intl/breakiterator/breakiterator_class.cpp Diff: diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index de4bfbb..7bf271a 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -296,7 +296,7 @@ static const zend_function_entry BreakIterator_class_functions[] = { PHP_ME_MAPPING(following, breakiter_following,ainfo_biter_offset, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(preceding, breakiter_preceding,ainfo_biter_offset, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(isBoundary, breakiter_is_boundary, ainfo_biter_offset, ZEND_ACC_PUBLIC) - PHP_ME_MAPPING(getLocale, breakiter_get_locale, ainfo_biter_void, ZEND_ACC_PUBLIC) + PHP_ME_MAPPING(getLocale, breakiter_get_locale, ainfo_biter_get_locale, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(getPartsIterator, breakiter_get_parts_iterator, ainfo_biter_getPartsIterator, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(getErrorCode, breakiter_get_error_code, ainfo_biter_void, ZEND_ACC_PUBLIC) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: intl: doc explaining error conventions: ext/intl/ERROR.CONVENTIONS
Commit:4badc0c071e7c99946e7420707392e4de19d250e Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 29 Jan 2013 15:33:33 +0100 Parents: 1faddd15d967d7296b049fbb580681463c05ba83 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4badc0c071e7c99946e7420707392e4de19d250e Log: intl: doc explaining error conventions Changed paths: A ext/intl/ERROR.CONVENTIONS Diff: diff --git a/ext/intl/ERROR.CONVENTIONS b/ext/intl/ERROR.CONVENTIONS new file mode 100644 index 000..54f30ed --- /dev/null +++ b/ext/intl/ERROR.CONVENTIONS @@ -0,0 +1,83 @@ +The intl extension has particular conventions regarding error reporting. +These conventions are enumerated in this document. + +:: The last error is always stored globally. + +The global error code can be obtained in userland with intl_get_error_code(). +This is a U_* error code defined by ICU, but it does not have necessarily to be +returned obtained after a call to an ICU function. That is to say, the internal +PHP wrapper functions can set these error codes when appropriate. For instance, +in response to bad arguments (e.g. zend_parse_parameters() failure), the PHP +wrapper function should set the global error code to U_ILLEGAL_ARGUMENT_ERROR). + +The error code (an integer) can be converter to the corresponding enum name +string in userland with intl_error_name(). + +The associated message can be obtained with intl_get_error_message(). This is a +message set by the PHP wrapping code, not by ICU. The message should include the +name of the function that failed in order to make debugging easier (though if +you activate warnings with intl.error_level or exceptions with +intl.use_exceptions you get more fine-grained information about where the +error ocurred). + +The internal PHP code can set the global last error with: +void intl_error_set_code(intl_error* err, UErrorCode err_code TSRMLS_DC); +void intl_error_set_custom_msg(intl_error* err, char* msg, int copyMsg TSRMLS_DC); +void intl_error_set(intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC); + +and by passing NULL as the first parameter. The last function is a combination +of the first two. If the message is not a static buffer, copyMsg should be 1. +This makes the message string be copied and freed when no longer needed. There's +no way to pass ownership of the string without it being copied. + + +:: The last is ALSO stored in the object whose method call triggered the error, + unless the error is due to bad arguments, in which case only the global error + should be set + +Objects store an intl_error structed in their private data. For instance: +typedef struct { + zend_object zo; + intl_error err; + Calendar* ucal; +} Calendar_object; + +The global error and the object error can be SIMULTANEOUSLY set with these +functions: +void intl_errors_set_custom_msg(intl_error* err, char* msg, int copyMsg TSRMLS_DC); +void intl_errors_set_code(intl_error* err, UErrorCode err_code TSRMLS_DC); +void intl_errors_set(intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC); + +by passing a pointer to the object's intl_error structed as the first parameter. +Node the extra 's' in the functions' names ('errors', not 'error'). + +Static methods should only set the global error. + + +:: Intl classes that can be instantiated should provide ::getErrorCode() and + getErrorMessage() methods + +These methods are used to retrieve the error codes stored in the object's +private intl_error structured and mirror the global intl_get_error_code() and +intl_get_error_message(). + + +:: Intl methods and functions should return FALSE on error (even argument + parsing errors), not NULL. Constructors and factory methods are the + exception; these should return NULL, not FALSE. + +Not that constructors in Intl generally (always?) don't throws exceptions. +They instead destroy the object to that the result of new IntlClass() can +be NULL. This may be surprising. + + +:: Intl functions and methods should reset the global error before doing + anything else (even parse the arguments); instance methods should also reset + the object's private error + +Errors should be lost after a function call. This is different from the way +ICU operates, where functions return immediately if an error is set. + +Error resetting can be done with: +void intl_error_reset(NULL TSRMLS_DC); /* reset global error */ +void intl_errors_reset(intl_error* err TSRMLS_DC );/* reset global and object error */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix bug #64023 (__toString() SplFileInfo): Zend/zend_vm_def.h Zend/zend_vm_execute.h ext/spl/spl_directory.c ext/spl/tests/bug64023.phpt
Commit:aa0adce47d9b8ead59efede63a769e395e27bcd5 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Sat, 19 Jan 2013 16:21:26 +0100 Parents: 33b104c778c5c0e5446671397aaddd66efa4a7bc Branches: PHP-5.3 PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=aa0adce47d9b8ead59efede63a769e395e27bcd5 Log: Fix bug #64023 (__toString() SplFileInfo) Defining a __toString() method was having no effect when concatenating the object. This was because the cast_object() handler would ignore __toString(). Using echo() directly would actually use __toString(), but this was a bug: the ECHO handler would try zend_std_cast_object_tostring() before cast_object(), but cast_object() should have priority as zend_std_cast_object_tostring() assumes an object with a zend_class_entry. Bugs: https://bugs.php.net/64023 Changed paths: M Zend/zend_vm_def.h M Zend/zend_vm_execute.h M ext/spl/spl_directory.c A ext/spl/tests/bug64023.phpt Diff: diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 3fa5327..e8d3250 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -896,23 +896,12 @@ ZEND_VM_HANDLER(40, ZEND_ECHO, CONST|TMP|VAR|CV, ANY) { zend_op *opline = EX(opline); zend_free_op free_op1; - zval z_copy; zval *z = GET_OP1_ZVAL_PTR(BP_VAR_R); - if (OP1_TYPE != IS_CONST - Z_TYPE_P(z) == IS_OBJECT Z_OBJ_HT_P(z)-get_method != NULL) { - if (OP1_TYPE == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (OP1_TYPE == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 1ad7f77..f5cedd8 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1320,23 +1320,12 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); - zval z_copy; zval *z = opline-op1.u.constant; - if (IS_CONST != IS_CONST - Z_TYPE_P(z) == IS_OBJECT Z_OBJ_HT_P(z)-get_method != NULL) { - if (IS_CONST == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_CONST == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); ZEND_VM_NEXT_OPCODE(); } @@ -4635,23 +4624,12 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); zend_free_op free_op1; - zval z_copy; zval *z = _get_zval_ptr_tmp(opline-op1, EX(Ts), free_op1 TSRMLS_CC); - if (IS_TMP_VAR != IS_CONST - Z_TYPE_P(z) == IS_OBJECT Z_OBJ_HT_P(z)-get_method != NULL) { - if (IS_TMP_VAR == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_TMP_VAR == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); zval_dtor(free_op1.var); ZEND_VM_NEXT_OPCODE(); @@ -7898,23 +7876,12 @@ static int ZEND_FASTCALL ZEND_ECHO_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); zend_free_op free_op1; - zval z_copy; zval *z = _get_zval_ptr_var(opline-op1, EX(Ts), free_op1 TSRMLS_CC); - if (IS_VAR != IS_CONST - Z_TYPE_P(z) == IS_OBJECT Z_OBJ_HT_P(z)-get_method != NULL) { - if (IS_VAR == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_VAR == IS_TMP_VAR
[PHP-CVS] com php-src: Merge branch 'bug64023' into PHP-5.4: Zend/zend_vm_def.h Zend/zend_vm_execute.h ext/spl/spl_directory.c
Commit:b8b3bb08b22a28041f5c02b371a88f231ec510de Author:Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 22 Jan 2013 12:24:33 +0100 Parents: 86c1a26169ce44c9ea48e424b62128ee62f31d59 aa0adce47d9b8ead59efede63a769e395e27bcd5 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b8b3bb08b22a28041f5c02b371a88f231ec510de Log: Merge branch 'bug64023' into PHP-5.4 * bug64023: Fix bug #64023 (__toString() SplFileInfo) Conflicts: Zend/zend_vm_def.h Zend/zend_vm_execute.h Bugs: https://bugs.php.net/64023 Changed paths: MM Zend/zend_vm_def.h MM Zend/zend_vm_execute.h MM ext/spl/spl_directory.c Diff: diff --cc Zend/zend_vm_def.h index b7fa907,e8d3250..e5cdd1d --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@@ -972,32 -894,16 +972,20 @@@ ZEND_VM_HANDLER(37, ZEND_POST_DEC, VAR| ZEND_VM_HANDLER(40, ZEND_ECHO, CONST|TMP|VAR|CV, ANY) { - zend_op *opline = EX(opline); + USE_OPLINE zend_free_op free_op1; - zval z_copy; - zval *z = GET_OP1_ZVAL_PTR(BP_VAR_R); + zval *z; + + SAVE_OPLINE(); + z = GET_OP1_ZVAL_PTR(BP_VAR_R); - if (OP1_TYPE != IS_CONST - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) - Z_OBJ_HT_P(z)-get_method != NULL) { - if (OP1_TYPE == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (OP1_TYPE == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); FREE_OP1(); + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } diff --cc Zend/zend_vm_execute.h index 2680d85,f5cedd8..97e5a8e --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@@ -2022,31 -1318,15 +2022,19 @@@ static int ZEND_FASTCALL ZEND_BOOL_NOT static int ZEND_FASTCALL ZEND_ECHO_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { - zend_op *opline = EX(opline); + USE_OPLINE + - zval z_copy; + zval *z; - zval *z = opline-op1.u.constant; + SAVE_OPLINE(); + z = opline-op1.zv; - if (IS_CONST != IS_CONST - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) - Z_OBJ_HT_P(z)-get_method != NULL) { - if (IS_CONST == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_CONST == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@@ -6441,32 -4622,16 +6429,20 @@@ static int ZEND_FASTCALL ZEND_BOOL_NOT static int ZEND_FASTCALL ZEND_ECHO_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { - zend_op *opline = EX(opline); + USE_OPLINE zend_free_op free_op1; - zval z_copy; - zval *z = _get_zval_ptr_tmp(opline-op1, EX(Ts), free_op1 TSRMLS_CC); + zval *z; + + SAVE_OPLINE(); + z = _get_zval_ptr_tmp(opline-op1.var, EX_Ts(), free_op1 TSRMLS_CC); - if (IS_TMP_VAR != IS_CONST - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) - Z_OBJ_HT_P(z)-get_method != NULL) { - if (IS_TMP_VAR == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_TMP_VAR == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); zval_dtor(free_op1.var); + CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } @@@ -10759,32 -7874,16 +10735,20 @@@ static int ZEND_FASTCALL ZEND_POST_DEC static int ZEND_FASTCALL ZEND_ECHO_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { - zend_op *opline = EX(opline); + USE_OPLINE zend_free_op free_op1; - zval z_copy; - zval *z = _get_zval_ptr_var(opline-op1, EX(Ts), free_op1 TSRMLS_CC); + zval *z; + + SAVE_OPLINE(); + z = _get_zval_ptr_var(opline-op1.var, EX_Ts(), free_op1 TSRMLS_CC); - if (IS_VAR != IS_CONST -
[PHP-CVS] com php-src: NEWS for bug #64023 (see aa0adce): NEWS
Commit:38bf6951b3615775cc91955ca71c07ecbf50120f Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 23 Jan 2013 13:30:40 +0100 Parents: aa0adce47d9b8ead59efede63a769e395e27bcd5 Branches: PHP-5.3 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=38bf6951b3615775cc91955ca71c07ecbf50120f Log: NEWS for bug #64023 (see aa0adce) Bugs: https://bugs.php.net/64023 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index d753d28..5215dc6 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ PHP NEWS ?? ??? 2013, PHP 5.3.22 - Zend Engine: + . Fixed bug #64023 (echo tries standard cast_object implementation before the +one for the actual object; also fixed bug in SplFileInfo's cast_object). + (Gustavo, Dmitry) . Fixed bug #63899 (Use after scope error in zend_compile). (Laruence) . Fixed bug #63762 (Sigsegv when Exception::$trace is changed by user). (Johannes) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.5': Zend/zend_vm_def.h Zend/zend_vm_execute.h
Commit:ddc98aa814fe2e540029ee28cf01e54a5c328359 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 23 Jan 2013 13:26:15 +0100 Parents: 40d9075677de0087256a467331eb09d12ad3 fc7b054c2d3aa0855c69b50dd7d386d558d6317e Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ddc98aa814fe2e540029ee28cf01e54a5c328359 Log: Merge branch 'PHP-5.5' * PHP-5.5: Fix bug #64023 (__toString() SplFileInfo) Bugs: https://bugs.php.net/64023 Changed paths: MM Zend/zend_vm_def.h MM Zend/zend_vm_execute.h Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: Zend/zend_vm_def.h Zend/zend_vm_execute.h
Commit:fc7b054c2d3aa0855c69b50dd7d386d558d6317e Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 23 Jan 2013 13:24:50 +0100 Parents: 95346c017c55e44a3e3d19945902a0275d3fafe4 b8b3bb08b22a28041f5c02b371a88f231ec510de Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=fc7b054c2d3aa0855c69b50dd7d386d558d6317e Log: Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: Fix bug #64023 (__toString() SplFileInfo) Bugs: https://bugs.php.net/64023 Changed paths: MM Zend/zend_vm_def.h MM Zend/zend_vm_execute.h Diff: diff --cc Zend/zend_vm_execute.h index ab69ee2,97e5a8e..25ac1ea --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@@ -7414,24 -6434,12 +7402,12 @@@ static int ZEND_FASTCALL ZEND_ECHO_SPE zval *z; SAVE_OPLINE(); - z = _get_zval_ptr_tmp(opline-op1.var, EX_Ts(), free_op1 TSRMLS_CC); + z = _get_zval_ptr_tmp(opline-op1.var, execute_data, free_op1 TSRMLS_CC); - if (IS_TMP_VAR != IS_CONST - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) - Z_OBJ_HT_P(z)-get_method != NULL) { - if (IS_TMP_VAR == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_TMP_VAR == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); zval_dtor(free_op1.var); CHECK_EXCEPTION(); @@@ -12625,24 -10740,12 +12601,12 @@@ static int ZEND_FASTCALL ZEND_ECHO_SPE zval *z; SAVE_OPLINE(); - z = _get_zval_ptr_var(opline-op1.var, EX_Ts(), free_op1 TSRMLS_CC); + z = _get_zval_ptr_var(opline-op1.var, execute_data, free_op1 TSRMLS_CC); - if (IS_VAR != IS_CONST - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) - Z_OBJ_HT_P(z)-get_method != NULL) { - if (IS_VAR == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_VAR == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); if (free_op1.var) {zval_ptr_dtor(free_op1.var);}; CHECK_EXCEPTION(); @@@ -30217,24 -26708,12 +30181,12 @@@ static int ZEND_FASTCALL ZEND_ECHO_SPE zval *z; SAVE_OPLINE(); - z = _get_zval_ptr_cv_BP_VAR_R(EX_CVs(), opline-op1.var TSRMLS_CC); + z = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline-op1.var TSRMLS_CC); - if (IS_CV != IS_CONST - UNEXPECTED(Z_TYPE_P(z) == IS_OBJECT) - Z_OBJ_HT_P(z)-get_method != NULL) { - if (IS_CV == IS_TMP_VAR) { - INIT_PZVAL(z); - } - if (zend_std_cast_object_tostring(z, z_copy, IS_STRING TSRMLS_CC) == SUCCESS) { - zend_print_variable(z_copy); - zval_dtor(z_copy); - } else { - zend_print_variable(z); - } - } else { - zend_print_variable(z); + if (IS_CV == IS_TMP_VAR Z_TYPE_P(z) == IS_OBJECT) { + INIT_PZVAL(z); } + zend_print_variable(z); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: NEWS for bug #64011. See 77ee200: NEWS
Commit:b69fd9c9b8052b1ae2442f03b09be615146fc6c5 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 18 Jan 2013 12:12:08 +0100 Parents: 77ee200097b592c54fc2f925abcd6db829862d56 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b69fd9c9b8052b1ae2442f03b09be615146fc6c5 Log: NEWS for bug #64011. See 77ee200 Bugs: https://bugs.php.net/64011 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index a10ef4e..81e01cc 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP NEWS ?? ??? 2012, PHP 5.4.12 - Core: + . Fixed bug #64011 (get_html_translation_table() output incomplete with +HTML_ENTITIES and ISO-8859-1). (Gustavo) . Fixed bug #63982 (isset() inconsistently produces a fatal error on protected property). (Stas) . Fixed bug #63943 (Bad warning text from strpos() on empty needle). -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge remote-tracking branch 'cataphract/zpp_improv' into PHP-5.5: Zend/zend_API.c Zend/zend_API.h
Commit:b8603035d0c8f1fc9907c3bc521c11d6a10f1c7e Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 16 Jan 2013 23:37:06 +0100 Parents: 77010bf9bf45c46d844b336c18cc8102cfc7e249 428aec8ce36a65cbfda061e8438d14789199a404 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b8603035d0c8f1fc9907c3bc521c11d6a10f1c7e Log: Merge remote-tracking branch 'cataphract/zpp_improv' into PHP-5.5 See https://wiki.php.net/rfc/zpp_improv * cataphract/zpp_improv: Update README.PARAMETER_PARSING_API Export zend_parse_parameter() Expose zend_parse_arg() as zend_parse_parameter() zend_parse_parameters: allow ! for non pointers Changed paths: MM Zend/zend_API.c MM Zend/zend_API.h Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Update README.PARAMETER_PARSING_API: README.PARAMETER_PARSING_API
Commit:428aec8ce36a65cbfda061e8438d14789199a404 Author:Gustavo Lopes gust...@icemobile.com Wed, 9 Jan 2013 17:16:40 +0100 Parents: 07590e6e456349192272da5ccfe8becbaa57fc67 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=428aec8ce36a65cbfda061e8438d14789199a404 Log: Update README.PARAMETER_PARSING_API Changed paths: M README.PARAMETER_PARSING_API Diff: diff --git a/README.PARAMETER_PARSING_API b/README.PARAMETER_PARSING_API index 927e481..edcee0f 100644 --- a/README.PARAMETER_PARSING_API +++ b/README.PARAMETER_PARSING_API @@ -28,6 +28,17 @@ Both functions return SUCCESS or FAILURE depending on the result. The auto-conversions are performed as necessary. Arrays, objects, and resources cannot be auto-converted. +PHP 5.5 includes a new function: + +int zend_parse_parameter(int flags, int arg_num TSRMLS_DC, zval **arg, const char *spec, ...); + +This function behaves like zend_parse_parameters_ex() except that instead of +reading the arguments from the stack, it receives a single zval to convert +(passed with double indirection). The passed zval may be changed in place as +part of the conversion process. + +See also https://wiki.php.net/rfc/zpp_improv#expose_zend_parse_arg_as_zend_parse_parameter + Type specifiers --- @@ -65,9 +76,13 @@ Type specifiers will not be touched by the parsing function if they are not passed to it. / - use SEPARATE_ZVAL_IF_NOT_REF() on the parameter it follows -! - the parameter it follows can be of specified type or NULL (applies - to all specifiers except for 'b', 'l', and 'd'). If NULL is passed, the - results pointer is set to NULL as well. +! - the parameter it follows can be of specified type or NULL. If NULL is + passed and the output for such type is a pointer, then the output + pointer is set to a native NULL pointer. + For 'b', 'l' and 'd', an extra argument of type zend_bool* must be + passed after the corresponding bool*, long* or double* arguments, + respectively. A non-zero value will be written to the zend_bool iif a + PHP NULL is passed. Note on 64bit compatibility -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: zend_parse_parameters: allow ! for non pointers: Zend/zend_API.c
Commit:980dc7111bc1d1e759c5b6044f6e7d203915d81f Author:Gustavo André dos Santos Lopes cataphr...@php.net Wed, 18 Jul 2012 21:42:36 +0200 Parents: 94a0f8722b1f480f2cd8c0fc044cff40f2418607 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=980dc7111bc1d1e759c5b6044f6e7d203915d81f Log: zend_parse_parameters: allow ! for non pointers This commit allows getting information about whether a certain value was a NULL value by using the ! modifier together with the l/L, d and b. Example: long l; zend_bool is_null; zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, l!, l, is_null) For the specifiers l/L, d and b, NULL values are reported as 0, 0., or false. But sometimes one wants to distinguish NULL from those other values -- for instance, to give NULL the same effect as the argument not having been passed. The usual way this problem is handled is by fetching the parameter with 'z' or 'Z', check if it is NULL and if not use convert_to_long_ex()/convert_to_double_ex(), etc. Unfortunately, this is not equivalent. convert_to_long_ex() does a cast, while zpp() is stricter. For instance, zpp will not accept 'foo' for a long argument, and it will emit a notice when encountering '5foo'. In fact, the only way to otherwise zpp semantics (without duplicating its logic) is to fetch the raw zval from the stack and check whether it's NULL (with zpp itself or its relatives) and then run zpp again. That is not an elegant solution. Changed paths: M Zend/zend_API.c Diff: diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 98a33e5..d7170eb 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -306,16 +306,14 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con { const char *spec_walk = *spec; char c = *spec_walk++; - int return_null = 0; + int check_null = 0; /* scan through modifiers */ while (1) { if (*spec_walk == '/') { SEPARATE_ZVAL_IF_NOT_REF(arg); } else if (*spec_walk == '!') { - if (Z_TYPE_PP(arg) == IS_NULL) { - return_null = 1; - } + check_null = 1; } else { break; } @@ -327,6 +325,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'L': { long *p = va_arg(*va, long *); + + if (check_null) { + zend_bool *p = va_arg(*va, zend_bool *); + *p = (Z_TYPE_PP(arg) == IS_NULL); + } + switch (Z_TYPE_PP(arg)) { case IS_STRING: { @@ -380,6 +384,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'd': { double *p = va_arg(*va, double *); + + if (check_null) { + zend_bool *p = va_arg(*va, zend_bool *); + *p = (Z_TYPE_PP(arg) == IS_NULL); + } + switch (Z_TYPE_PP(arg)) { case IS_STRING: { @@ -418,7 +428,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con int *pl = va_arg(*va, int *); switch (Z_TYPE_PP(arg)) { case IS_NULL: - if (return_null) { + if (check_null) { *p = NULL; *pl = 0; break; @@ -462,6 +472,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'b': { zend_bool *p = va_arg(*va, zend_bool *); + + if (check_null) { + zend_bool *p = va_arg(*va, zend_bool *); + *p = (Z_TYPE_PP(arg) == IS_NULL); + } + switch (Z_TYPE_PP(arg)) { case IS_NULL: case IS_STRING: @@ -484,7 +500,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con case 'r
[PHP-CVS] com php-src: NEWS for bug #63893: NEWS
Commit:4c38003dbdbb5b66c9d61db4cfd3248d15c93729 Author:Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 17:17:58 +0100 Committer: Gustavo Lopes glo...@nebm.ist.utl.pt Tue, 15 Jan 2013 21:07:21 +0100 Parents: 93e35137aaba98c0a000ed442320e3173bb0a3f2 Branches: PHP-5.4 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4c38003dbdbb5b66c9d61db4cfd3248d15c93729 Log: NEWS for bug #63893 Bugs: https://bugs.php.net/63893 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 8201ce1..bcff155 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ PHP NEWS . Fixed bug #63943 (Bad warning text from strpos() on empty needle). (Laruence) . Fixed bug #63899 (Use after scope error in zend_compile). (Laruence) + . Fixed bug #63893 (Poor efficiency of strtr() using array with keys of very +different length). (Gustavo) . Fixed bug #63882 (zend_std_compare_objects crash on recursion). (Dmitry) . Support BITMAPV5HEADER in getimagesize(). (AsamK, Lars) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fixed inconsequential bug in strtr(): ext/standard/string.c
Commit:930ef9ddd663dcda5726b5d33c54c49a2f4f97d6 Author:Gustavo Lopes gust...@icemobile.com Tue, 15 Jan 2013 17:25:59 +0100 Parents: d7bac4f5ba17c6fba00943a8bada49a4735a15a6 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=930ef9ddd663dcda5726b5d33c54c49a2f4f97d6 Log: Fixed inconsequential bug in strtr() Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index 953dfd1..58b5483 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3021,7 +3021,7 @@ static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, res-shift-table_mask = SHIFT_TAB_SIZE - 1; php_strtr_populate_shift(patterns, patnum, B, res-m, res-shift); - res-hash = safe_emalloc(HASH_TAB_SIZE, sizeof(*res-hash-entries), sizeof(*res-shift)); + res-hash = safe_emalloc(HASH_TAB_SIZE, sizeof(*res-hash-entries), sizeof(*res-hash)); res-hash-table_mask = HASH_TAB_SIZE - 1; res-patterns = safe_emalloc(patnum, sizeof(*res-patterns), 0); @@ -3051,7 +3051,7 @@ static PPRES *php_strtr_array_prepare(STR *text, PATNREPL *patterns, int patnum, } } } - res-hash-entries[HASH_TAB_SIZE] = patnum; + res-hash-entries[HASH_TAB_SIZE] = patnum; /* OK, we effectively allocated SIZE+1 */ for (i = HASH_TAB_SIZE - 1; i = 0; i--) { if (res-hash-entries[i] == -1) { res-hash-entries[i] = res-hash-entries[i + 1]; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Remove unused block: ext/standard/string.c
Commit:93d1171c47d10158e6e9855236277deb09cf7e6b Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 9 Jan 2013 23:20:11 +0100 Committer: Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 12:22:42 +0100 Parents: cddbb98ada6bdba1596ea82386401edf9b680d47 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=93d1171c47d10158e6e9855236277deb09cf7e6b Log: Remove unused block Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index 4947a67..14259ca 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2790,11 +2790,6 @@ typedef struct { const char *s; STRLEN l; } STR; -typedef struct _match_node MATCH_NODE; -struct _match_node { - STRLEN pos; - MATCH_NODE *next; -}; typedef struct _pat_and_repl { STR pat; STR repl; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: The compiler can figure this out: ext/standard/string.c
Commit:e5029ac40bd84fd3545538afa013051e161d86a4 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 9 Jan 2013 23:20:32 +0100 Committer: Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 12:22:42 +0100 Parents: 93d1171c47d10158e6e9855236277deb09cf7e6b Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e5029ac40bd84fd3545538afa013051e161d86a4 Log: The compiler can figure this out Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index 14259ca..c7ed884 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2821,7 +2821,7 @@ static inline HASH php_strtr_hash(const char *str, int len) HASHres = 0; int i; for (i = 0; i len; i++) { - res = (res 5) + res + (unsigned char)str[i]; + res = res * 33 + (unsigned char)str[i]; } return res; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: strtr() with 2nd param array - optimization: ext/standard/string.c
Commit:cddbb98ada6bdba1596ea82386401edf9b680d47 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 9 Jan 2013 22:29:28 +0100 Committer: Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 12:22:42 +0100 Parents: 2111ee3df54e890c9e2f14b09c01d68445389540 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cddbb98ada6bdba1596ea82386401edf9b680d47 Log: strtr() with 2nd param array - optimization About a 1.25x speedup in my test script by writing the result string only when a match is found and at the end instead of on each iteration. Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index 827f9de..4947a67 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3028,6 +3028,7 @@ static void php_strtr_array_destroy_ppres(PPRES *d) static void php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value) { STRLEN pos = 0, + nextwpos = 0, lastpos = L(text) - d-m; smart_str result = {0}; @@ -3036,7 +3037,6 @@ static void php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value) STRLEN shift = d-shift-entries[h]; if (shift 0) { - smart_str_appendl(result, S(text)[pos], MIN(shift, L(text) - pos)); pos += shift; } else { HASHh2 = h d-hash-table_mask, @@ -3056,20 +3056,19 @@ static void php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value) memcmp(S(pnr-pat), S(text)[pos], L(pnr-pat)) != 0) continue; - smart_str_appendl(result, S(pnr-repl), (int)L(pnr-repl)); + smart_str_appendl(result, S(text)[nextwpos], pos - nextwpos); + smart_str_appendl(result, S(pnr-repl), L(pnr-repl)); pos += L(pnr-pat); + nextwpos = pos; goto end_outer_loop; } - smart_str_appendc(result, S(text)[pos]); pos++; end_outer_loop: ; } } - if (pos L(text)) { - smart_str_appendl(result, S(text)[pos], (int)(L(text) - pos)); - } + smart_str_appendl(result, S(text)[nextwpos], L(text) - nextwpos); if (result.c != NULL) { smart_str_0(result); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Refactoring, bugs leaks: ext/standard/string.c
Commit:2111ee3df54e890c9e2f14b09c01d68445389540 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Wed, 9 Jan 2013 00:33:14 +0100 Committer: Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 12:22:41 +0100 Parents: ccf15cf2dc92d11f92ee30c97e2d86b07f81e030 Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2111ee3df54e890c9e2f14b09c01d68445389540 Log: Refactoring, bugs leaks Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index dc92e8e..827f9de 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2863,7 +2863,91 @@ static int php_strtr_compare_hash_suffix(const void *a, const void *b, void *ctx hash_b = php_strtr_hash(S(pnr_b-pat)[res-m - res-B], res-B) res-hash-table_mask; /* TODO: don't recalculate the hashes all the time */ - return hash_a - hash_b; + if (hash_a hash_b) { + return 1; + } else if (hash_a hash_b) { + return -1; + } else { + /* longer patterns must be sorted first */ + if (L(pnr_a-pat) L(pnr_b-pat)) { + return -1; + } else if (L(pnr_a-pat) L(pnr_b-pat)) { + return 1; + } else { + return 0; + } + } +} +/* }}} */ +/* {{{ php_strtr_free_strp */ +static void php_strtr_free_strp(void *strp) +{ + STR_FREE(*(char**)strp); +} +/* }}} */ +/* {{{ php_strtr_array_prepare_repls */ +static PATNREPL *php_strtr_array_prepare_repls(int slen, HashTable *pats, zend_llist **allocs, int *outsize) +{ + PATNREPL*patterns; + HashPositionhpos; + zval**entry; + int num_pats = zend_hash_num_elements(pats), + i; + + patterns = safe_emalloc(num_pats, sizeof(*patterns), 0); + *allocs = emalloc(sizeof **allocs); + zend_llist_init(*allocs, sizeof(void*), php_strtr_free_strp, 0); + + for (i = 0, zend_hash_internal_pointer_reset_ex(pats, hpos); + zend_hash_get_current_data_ex(pats, (void **)entry, hpos) == SUCCESS; + zend_hash_move_forward_ex(pats, hpos)) { + char*string_key; + uintstring_key_len; + ulong num_key; + zval*tzv = NULL; + + switch (zend_hash_get_current_key_ex(pats, string_key, string_key_len, num_key, 0, hpos)) { + case HASH_KEY_IS_LONG: + string_key_len = 1 + zend_spprintf(string_key, 0, %ld, (long)num_key); + zend_llist_add_element(*allocs, string_key); + /* break missing intentionally */ + + case HASH_KEY_IS_STRING: + string_key_len--; /* exclude final '\0' */ + if (string_key_len == 0) { /* empty string given as pattern */ + efree(patterns); + zend_llist_destroy(*allocs); + efree(*allocs); + *allocs = NULL; + return NULL; + } + if (string_key_len slen) { /* this pattern can never match */ + continue; + } + + if (Z_TYPE_PP(entry) != IS_STRING) { + tzv = *entry; + zval_addref_p(tzv); + SEPARATE_ZVAL(tzv); + convert_to_string(tzv); + entry = tzv; + zend_llist_add_element(*allocs, Z_STRVAL_PP(entry)); + } + + S(patterns[i].pat) = string_key; + L(patterns[i].pat) = string_key_len; + S(patterns[i].repl) = Z_STRVAL_PP(entry); + L(patterns[i].repl) = Z_STRLEN_PP(entry); + i++; + + if (tzv) { + efree(tzv); + } + } + } + + *outsize = i; + return patterns; } /* }}} */ @@ -2952,7 +3036,7 @@ static void php_strtr_array_do_repl(STR *text, PPRES *d, zval *return_value) STRLEN shift = d-shift-entries[h]; if (shift 0) { - smart_str_appendl(result, S(text)[pos], shift); + smart_str_appendl(result, S(text)[pos], MIN(shift, L(text) - pos)); pos += shift; } else { HASHh2 = h d-hash-table_mask,
[PHP-CVS] com php-src: Optimize strtr w/ 2nd arg array: ext/standard/string.c
Commit:ccf15cf2dc92d11f92ee30c97e2d86b07f81e030 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 7 Jan 2013 03:13:11 +0100 Committer: Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 12:22:41 +0100 Parents: 1a96fe0b3260b4b63627cf69d71a5b350ad3163f Branches: PHP-5.4 PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ccf15cf2dc92d11f92ee30c97e2d86b07f81e030 Log: Optimize strtr w/ 2nd arg array Fixes bug #63893: poor efficiency of strtr() using array with keys of very different length. The implementation is basically all new, which carries some risk with it. The algorithm is described in A Fast Algorithm For Multi-Pattern Searching (1994) by Sun Wu and Udi Manber. Bugs: https://bugs.php.net/63893 Changed paths: M ext/standard/string.c diff --git a/ext/standard/string.c b/ext/standard/string.c index 29115fe..dc92e8e 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -22,7 +22,9 @@ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ +#define _GNU_SOURCE 1 #include stdio.h +#include stdint.h #include php.h #include php_rand.h #include php_string.h @@ -57,6 +59,7 @@ #include php_globals.h #include basic_functions.h #include php_smart_str.h +#include Zend/zend_exceptions.h #ifdef ZTS #include TSRM.h #endif @@ -2772,112 +2775,288 @@ PHPAPI char *php_strtr(char *str, int len, char *str_from, char *str_to, int trl } /* }}} */ -/* {{{ php_strtr_array - */ -static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *hash) +/* {{{ Definitions for php_strtr_array */ +typedef size_t STRLEN; /* STRLEN should be unsigned */ +typedef uint16_t HASH; +typedef struct { + HASHtable_mask; + STRLEN entries[1]; +} SHIFT_TAB; +typedef struct { + HASHtable_mask; + int entries[1]; +} HASH_TAB; +typedef struct { + const char *s; + STRLEN l; +} STR; +typedef struct _match_node MATCH_NODE; +struct _match_node { + STRLEN pos; + MATCH_NODE *next; +}; +typedef struct _pat_and_repl { + STR pat; + STR repl; +} PATNREPL; + +#define S(a) ((a)-s) +#define L(a) ((a)-l) + +#define SHIFT_TAB_BITS 13 +#define HASH_TAB_BITS 10 /* should be less than sizeof(HASH) * 8 */ +#define SHIFT_TAB_SIZE (1U SHIFT_TAB_BITS) +#define HASH_TAB_SIZE (1U HASH_TAB_BITS) + +typedef struct { + int B; /* size of suffixes */ + int Bp; /* size of prefixes */ + STRLEN m; /* minimum pattern length */ + int patnum; /* number of patterns */ + SHIFT_TAB *shift; /* table mapping hash to allowed shift */ + HASH_TAB*hash; /* table mapping hash to int (pair of pointers) */ + HASH*prefix;/* array of hashes of prefixes by pattern suffix hash order */ + PATNREPL*patterns; /* array of prefixes by pattern suffix hash order */ +} PPRES; +/* }}} */ + +/* {{{ php_strtr_hash */ +static inline HASH php_strtr_hash(const char *str, int len) { - zval **entry; - char *string_key; - uint string_key_len; - zval **trans; - zval ctmp; - ulong num_key; - int minlen = 128*1024; - int maxlen = 0, pos, len, found; - char *key; - HashPosition hpos; - smart_str result = {0}; - HashTable tmp_hash; - - zend_hash_init(tmp_hash, zend_hash_num_elements(hash), NULL, NULL, 0); - zend_hash_internal_pointer_reset_ex(hash, hpos); - while (zend_hash_get_current_data_ex(hash, (void **)entry, hpos) == SUCCESS) { - switch (zend_hash_get_current_key_ex(hash, string_key, string_key_len, num_key, 0, hpos)) { - case HASH_KEY_IS_STRING: - len = string_key_len-1; - if (len 1) { - zend_hash_destroy(tmp_hash); - RETURN_FALSE; - } - zend_hash_add(tmp_hash, string_key, string_key_len, entry, sizeof(zval*), NULL); - if (len maxlen) { - maxlen = len; - } - if (len minlen) { - minlen = len; - } - break; + HASHres = 0; + int i; + for (i = 0; i len; i++) { + res = (res 5) + res + (unsigned char)str[i]; + } - case HASH_KEY_IS_LONG: -
[PHP-CVS] com php-src: UPGRADING.INTERNALS: document zend_qsort_r: UPGRADING.INTERNALS
Commit:70b25e9c61c849e590cc97137e893678cb5f98c3 Author:Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 17:27:20 +0100 Parents: 22390d33935d72d897a1c97158ce2848f8551cc1 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=70b25e9c61c849e590cc97137e893678cb5f98c3 Log: UPGRADING.INTERNALS: document zend_qsort_r Changed paths: M UPGRADING.INTERNALS Diff: diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 90c7a43..44cdfae 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -5,6 +5,7 @@ UPGRADE NOTES - PHP X.Y 1. Internal API changes a. Streams pooling API b. Lowercasing and locales + c. zend_qsort_r 2. Build system changes a. Unix build system changes @@ -53,6 +54,16 @@ such as strcasecmp, will be using locale rules. Two new functions - zend_binary_strncasecmp_l and zend_binary_strcasecmp_l - added as locale-based counterparts to zend_binary_strcasecmp and zend_binary_strncasecmp. + c. zend_qsort_r + +Added the function zend_qsort_r(): + +typedef int (*compare_r_func_t)(const void *, const void * TSRMLS_DC, void *); +void zend_qsort_r(void *base, size_t nmemb, size_t siz, compare_r_func_t compare, void *arg TSRMLS_DC); + +The extra argument it has (relatively to zend_qsort()) is passed to the +comparison function. + 2. Build system changes -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4' into PHP-5.5: ext/standard/string.c
Commit:1ce5a225899c19b79c64451e830cd3940ee2bff3 Author:Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 17:19:23 +0100 Parents: be07f815f240803fe7a48a5fb3d68a169bef4707 200242595dabfdaf6093da3e9ae6fef246ea8906 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1ce5a225899c19b79c64451e830cd3940ee2bff3 Log: Merge branch 'PHP-5.4' into PHP-5.5 Conflicts: NEWS Changed paths: MM ext/standard/string.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: NEWS for bug #63893: NEWS
Commit:200242595dabfdaf6093da3e9ae6fef246ea8906 Author:Gustavo Lopes gust...@icemobile.com Mon, 14 Jan 2013 17:17:58 +0100 Parents: d7bac4f5ba17c6fba00943a8bada49a4735a15a6 Branches: PHP-5.5 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=200242595dabfdaf6093da3e9ae6fef246ea8906 Log: NEWS for bug #63893 Bugs: https://bugs.php.net/63893 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 28040f7..418bcc9 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS protected property). (Stas) . Fixed bug #63943 (Bad warning text from strpos() on empty needle). (Laruence) + . Fixed bug #63893 (poor efficiency of strtr() using array with keys of very +different length). (Gustavo) . Fixed bug #63882 (zend_std_compare_objects crash on recursion). (Dmitry) - Litespeed: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: List ext/intl changes also in NEWS: NEWS
Commit:acbc6d182b3a9b13cd2dab06f631852d741fabc5 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Mon, 12 Nov 2012 19:16:12 +0100 Parents: 0b96b4c4e9d4dc818713eee3159ff7c4ec6f5e9b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=acbc6d182b3a9b13cd2dab06f631852d741fabc5 Log: List ext/intl changes also in NEWS Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index ca21853..568ae65 100644 --- a/NEWS +++ b/NEWS @@ -63,6 +63,89 @@ PHP NEWS - Hash . Added support for PBKDF2 via hash_pbkdf2(). (Anthony Ferrara) +- Intl + . The intl extension now requires ICU 4.0+. + . Added intl.use_exceptions INI directive, which controls what happens when +global errors are set together with intl.error_level. (Gustavo) + . MessageFormatter::format() and related functions now accepted named +arguments and mixed numeric/named arguments in ICU 4.8+. (Gustavo) + . MessageFormatter::format() and related functions now don't error out when +an insufficient argument count is provided. Instead, the placeholders will +remain unsubstituted. (Gustavo) + . MessageFormatter::parse() and MessageFormat::format() (and their static +equivalents) don't throw away better than second precision in the arguments. +(Gustavo) + . IntlDateFormatter::__construct and datefmt_create() now accept for the +$timezone argument time zone identifiers, IntlTimeZone objects, DateTimeZone +objects and NULL. (Gustavo) + . IntlDateFormatter::__construct and datefmt_create() no longer accept invalid +timezone identifiers or empty strings. (Gustavo) + . The default time zone used in IntlDateFormatter::__construct and +datefmt_create() (when the corresponding argument is not passed or NULL is +passed) is now the one given by date_default_timezone_get(), not the +default ICU time zone. (Gustavo) + . The time zone passed to the IntlDateFormatter is ignored if it is NULL and +if the calendar passed is an IntlCalendar object -- in this case, the +IntlCalendar's time zone will be used instead. Otherwise, the time zone +specified in the $timezone argument is used instead. This does not affect +old code, as IntlCalendar was introduced in this version. (Gustavo) + . IntlDateFormatter::__construct and datefmt_create() now accept for the +$calendar argument also IntlCalendar objects. (Gustavo) + . IntlDateFormatter::getCalendar() and datefmt_get_calendar() return false +if the IntlDateFormatter was set up with an IntlCalendar instead of the +constants IntlDateFormatter::GREGORIAN/TRADITIONAL. IntlCalendar did not +exist before this version. (Gustavo) + . IntlDateFormatter::setCalendar() and datefmt_set_calendar() now also accept +an IntlCalendar object, in which case its time zone is taken. Passing a +constant is still allowed, and still keeps the time zone. (Gustavo) + . IntlDateFormatter::setTimeZoneID() and datefmt_set_timezone_id() are +deprecated. Use IntlDateFormatter::setTimeZone() or datefmt_set_timezone() +instead. (Gustavo) + . IntlDateFormatter::format() and datefmt_format() now also accept an +IntlCalendar object for formatting. (Gustavo) + . Added the classes: IntlCalendar, IntlGregorianCalendar, IntlTimeZone, +IntlBreakIterator, IntlRuleBasedBreakIterator and +IntlCodePointBreakIterator. (Gustavo) + . Added the functions: intlcal_get_keyword_values_for_locale(), +intlcal_get_now(), intlcal_get_available_locales(), intlcal_get(), +intlcal_get_time(), intlcal_set_time(), intlcal_add(), +intlcal_set_time_zone(), intlcal_after(), intlcal_before(), intlcal_set(), +intlcal_roll(), intlcal_clear(), intlcal_field_difference(), +intlcal_get_actual_maximum(), intlcal_get_actual_minimum(), +intlcal_get_day_of_week_type(), intlcal_get_first_day_of_week(), +intlcal_get_greatest_minimum(), intlcal_get_least_maximum(), +intlcal_get_locale(), intlcal_get_maximum(), +intlcal_get_minimal_days_in_first_week(), intlcal_get_minimum(), +intlcal_get_time_zone(), intlcal_get_type(), +intlcal_get_weekend_transition(), intlcal_in_daylight_time(), +intlcal_is_equivalent_to(), intlcal_is_lenient(), intlcal_is_set(), +intlcal_is_weekend(), intlcal_set_first_day_of_week(), +intlcal_set_lenient(), intlcal_equals(), +intlcal_get_repeated_wall_time_option(), +intlcal_get_skipped_wall_time_option(), +intlcal_set_repeated_wall_time_option(), +intlcal_set_skipped_wall_time_option(), intlcal_from_date_time(), +intlcal_to_date_time(), intlcal_get_error_code(), +intlcal_get_error_message(), intlgregcal_create_instance(), +intlgregcal_set_gregorian_change(), intlgregcal_get_gregorian_change() and +intlgregcal_is_leap_year(). (Gustavo) + . Added the functions: intltz_create_time_zone(), intltz_create_default(), +intltz_get_id(), intltz_get_gmt(),
[PHP-CVS] com php-src: Merge branch 'PHP-5.3' into PHP-5.4: main/streams/streams.c
Commit:f8e26d95f27779276a2dcf9d3aefb6b2b604ba63 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 12 Oct 2012 20:24:13 +0200 Parents: 9eff1a217885d9ea4750bdabd9d6ba88b2565e21 76601c4fd1052bd46e8db4addb1bb9dd3b001f98 Branches: PHP-5.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f8e26d95f27779276a2dcf9d3aefb6b2b604ba63 Log: Merge branch 'PHP-5.3' into PHP-5.4 * PHP-5.3: Fix bug #63240 on stream_get_line() Bugs: https://bugs.php.net/63240 Changed paths: MM main/streams/streams.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge branch 'PHP-5.4': main/streams/streams.c
Commit:2634f55992f28e95fe6ee41a40b9ede56639c1ce Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 12 Oct 2012 20:24:28 +0200 Parents: 1d87ad89b24d8a1b992cb2dbc770fac6cfcc1fcb f8e26d95f27779276a2dcf9d3aefb6b2b604ba63 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2634f55992f28e95fe6ee41a40b9ede56639c1ce Log: Merge branch 'PHP-5.4' * PHP-5.4: Fix bug #63240 on stream_get_line() Bugs: https://bugs.php.net/63240 Changed paths: MM main/streams/streams.c Diff: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: NEWS for 76601c4: NEWS
Commit:519f93ef99d41d5720e76a08c6b64ffa927d184b Author:Gustavo Lopes glo...@nebm.ist.utl.pt Fri, 12 Oct 2012 20:27:53 +0200 Parents: 76601c4fd1052bd46e8db4addb1bb9dd3b001f98 Branches: PHP-5.3 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=519f93ef99d41d5720e76a08c6b64ffa927d184b Log: NEWS for 76601c4 Changed paths: M NEWS Diff: diff --git a/NEWS b/NEWS index 46c9bf4..fb7f83e 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ PHP NEWS . Fixed bug #63235 (buffer overflow in use of SQLGetDiagRec). (Martin Osvald, Remi) +- Streams: + . Fixed bug #63240 (stream_get_line() return contains delimiter string). +(Tjerk, Gustavo) + ?? ??? 2012, PHP 5.3.18 (NOTE: Add your entries above for 5.3.19, entries for 5.3.18 should only -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Do not disable RFC3678 multicast API on Windows: ext/sockets/multicast.h
Commit:bf19838c874de166ea01de33a38b14cbaf8b3a76 Author:Gustavo Lopes glo...@nebm.ist.utl.pt Thu, 20 Sep 2012 23:31:10 +0200 Parents: fa5477d9d45f076f4b4a6c50252668e2a437230b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bf19838c874de166ea01de33a38b14cbaf8b3a76 Log: Do not disable RFC3678 multicast API on Windows The API is supported since Windows Vista and requires targeting Vista when compiling PHP. Pierre had asked to disable this by default, even when targeting Vista/Windows Server 2008. Since XP will not be supported anymore on php-next, any rationale for this option will not apply anymore. Changed paths: M ext/sockets/multicast.h Diff: diff --git a/ext/sockets/multicast.h b/ext/sockets/multicast.h index 5619c9c..9470a39 100644 --- a/ext/sockets/multicast.h +++ b/ext/sockets/multicast.h @@ -18,9 +18,7 @@ /* $Id$ */ -#if defined(MCAST_JOIN_GROUP) \ - (!defined(PHP_WIN32) || (_WIN32_WINNT = 0x600 SOCKETS_ENABLE_VISTA_API)) \ - !defined(__APPLE__) +#if defined(MCAST_JOIN_GROUP) !defined(__APPLE__) #define RFC3678_API 1 /* has block/unblock and source membership, in this case for both IPv4 and IPv6 */ #define HAS_MCAST_EXT 1 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Generators UPGRADING: UPGRADING
Commit:5246d6f02e52798e343bd5208692f1a5ed89b9d9 Author:Gustavo André dos Santos Lopes cataphr...@php.net Wed, 12 Sep 2012 09:05:28 +0100 Parents: f6000a01e286f855a7f40fcad738a1f9b00aa81e Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5246d6f02e52798e343bd5208692f1a5ed89b9d9 Log: Generators UPGRADING Changed paths: M UPGRADING Diff: diff --git a/UPGRADING b/UPGRADING index ba55635..59dfbb4 100755 --- a/UPGRADING +++ b/UPGRADING @@ -40,6 +40,8 @@ PHP X.Y UPGRADE NOTES - Add support for using empty() on the result of function calls and other expressions. Thus it is now possible to write empty(getArray()), for example. (https://wiki.php.net/rfc/empty_isset_exprs) +- Added generators. + (https://wiki.php.net/rfc/generators) 2. Changes in SAPI modules -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Make sure that exception is thrown on rewind() after closing too: Zend/tests/generators/generator_rewind.phpt Zend/zend_generators.c
Commit:cc07038fa9b2a59893c52fb0c515a1fb03e56d5c Author:Nikita Popov ni...@php.net Wed, 29 Aug 2012 20:31:34 +0200 Parents: d60e3c6ef53986e82178bb657ad907edc16d2c34 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cc07038fa9b2a59893c52fb0c515a1fb03e56d5c Log: Make sure that exception is thrown on rewind() after closing too Changed paths: M Zend/tests/generators/generator_rewind.phpt M Zend/zend_generators.c Diff: diff --git a/Zend/tests/generators/generator_rewind.phpt b/Zend/tests/generators/generator_rewind.phpt index 3224f6a..af885ef 100644 --- a/Zend/tests/generators/generator_rewind.phpt +++ b/Zend/tests/generators/generator_rewind.phpt @@ -21,6 +21,14 @@ try { echo \n, $e, \n\n; } +$gen = gen(); +foreach ($gen as $v) { } +try { +foreach ($gen as $v) { } +} catch (Exception $e) { +echo \n, $e, \n\n; +} + function gen2() { echo in generator\n; @@ -40,4 +48,12 @@ Stack trace: #0 %s(%d): Generator-rewind() #1 {main} +before yield +after yield + +exception 'Exception' with message 'Cannot rewind a generator that was already run' in %s:%d +Stack trace: +#0 %s(%d): unknown() +#1 {main} + in generator diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 03294f7..0eb17d0 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -500,7 +500,7 @@ void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ static void zend_generator_ensure_initialized(zend_generator *generator TSRMLS_DC) /* {{{ */ { - if (!generator-value) { + if (generator-execute_data !generator-value) { zend_generator_resume(generator TSRMLS_CC); generator-flags |= ZEND_GENERATOR_AT_FIRST_YIELD; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix segfault when traversing a by-ref generator twice: Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt Zend/tests/generators/generator_rewind.phpt Zend
Commit:bef79588d543db996d092191ac498751a1cc161f Author:Nikita Popov ni...@php.net Wed, 29 Aug 2012 20:46:56 +0200 Parents: cc07038fa9b2a59893c52fb0c515a1fb03e56d5c Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bef79588d543db996d092191ac498751a1cc161f Log: Fix segfault when traversing a by-ref generator twice If you try to traverse an already closed generator an exception will now be thrown. Furthermore this changes the error for traversing a by-val generator by-ref from an E_ERROR to an Exception. Changed paths: M Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt M Zend/tests/generators/generator_rewind.phpt M Zend/zend_generators.c Diff: diff --git a/Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt b/Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt index 9c618d2..de5b22f 100644 --- a/Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt +++ b/Zend/tests/generators/errors/non_ref_generator_iterated_by_ref_error.phpt @@ -10,4 +10,9 @@ foreach ($gen as $value) { } ? --EXPECTF-- -Fatal error: You can only iterate a generator by-reference if it declared that it yields by-reference in %s on line %d +Fatal error: Uncaught exception 'Exception' with message 'You can only iterate a generator by-reference if it declared that it yields by-reference' in %s:%d +Stack trace: +#0 %s(%d): unknown() +#1 {main} + thrown in %s on line %d + diff --git a/Zend/tests/generators/generator_rewind.phpt b/Zend/tests/generators/generator_rewind.phpt index af885ef..c4b5bbb 100644 --- a/Zend/tests/generators/generator_rewind.phpt +++ b/Zend/tests/generators/generator_rewind.phpt @@ -21,21 +21,27 @@ try { echo \n, $e, \n\n; } -$gen = gen(); +function gen2() { +$foo = 'bar'; +yield $foo; +yield $foo; +} + +$gen = gen2(); foreach ($gen as $v) { } try { foreach ($gen as $v) { } } catch (Exception $e) { -echo \n, $e, \n\n; +echo $e, \n\n; } -function gen2() { +function gen3() { echo in generator\n; if (false) yield; } -$gen = gen2(); +$gen = gen3(); $gen-rewind(); ? @@ -48,10 +54,7 @@ Stack trace: #0 %s(%d): Generator-rewind() #1 {main} -before yield -after yield - -exception 'Exception' with message 'Cannot rewind a generator that was already run' in %s:%d +exception 'Exception' with message 'Cannot traverse an already closed generator' in %s:%d Stack trace: #0 %s(%d): unknown() #1 {main} diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 0eb17d0..60fa8b6 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -766,8 +766,14 @@ zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *ob generator = (zend_generator *) zend_object_store_get_object(object TSRMLS_CC); + if (!generator-execute_data) { + zend_throw_exception(NULL, Cannot traverse an already closed generator, 0 TSRMLS_CC); + return NULL; + } + if (by_ref !(generator-execute_data-op_array-fn_flags ZEND_ACC_RETURN_REFERENCE)) { - zend_error(E_ERROR, You can only iterate a generator by-reference if it declared that it yields by-reference); + zend_throw_exception(NULL, You can only iterate a generator by-reference if it declared that it yields by-reference, 0 TSRMLS_CC); + return NULL; } iterator = emalloc(sizeof(zend_generator_iterator)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport: Zend/zend_compile.c Zend/zend_compile.h Zend/zend_language_parser.y Zend/zend_vm_def.h Zend/zend_vm_exec
Commit:d60e3c6ef53986e82178bb657ad907edc16d2c34 Author:Nikita Popov ni...@php.net Sat, 25 Aug 2012 20:07:01 +0200 Parents: bd70d155885fdc087afba912c1b290615b864e2f 35951d4be0bd27c85519995a95429bd0d0a76a00 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d60e3c6ef53986e82178bb657ad907edc16d2c34 Log: Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport Conflicts: Zend/zend_language_parser.y Zend/zend_vm_execute.skl Changed paths: MM Zend/zend_compile.c MM Zend/zend_compile.h MM Zend/zend_language_parser.y MM Zend/zend_vm_def.h MM Zend/zend_vm_execute.h MM Zend/zend_vm_execute.skl Diff: diff --cc Zend/zend_vm_def.h index 1016679,92c5fcf..ffd81b0 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@@ -3049,20 -3053,12 +3051,20 @@@ ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF FREE_OP1_IF_VAR(); - if (EX(op_array)-has_finally_block) { - ZEND_VM_DISPATCH_TO_HELPER_EX(zend_finally_handler_leaving, type, ZEND_RETURN_BY_REF); + if (EXPECTED(!EX(op_array)-has_finally_block)) { + ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); } - ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); + ZEND_VM_DISPATCH_TO_HELPER_EX(zend_finally_handler_leaving, type, ZEND_RETURN_BY_REF); } +ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, ANY, ANY) +{ + if (EX(op_array)-has_finally_block) { + ZEND_VM_DISPATCH_TO_HELPER_EX(zend_finally_handler_leaving, type, ZEND_RETURN); + } + ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); +} + ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY) { USE_OPLINE diff --cc Zend/zend_vm_execute.h index a643967,1e0b2b5..b0e05b1 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@@ -409,26 -400,6 +409,26 @@@ zend_execute_data *zend_create_execute_ EX(function_state).function = (zend_function *) op_array; EX(function_state).arguments = NULL; + return execute_data; +} + +ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC) +{ + DCL_OPLINE - - zend_bool original_in_execution = EG(in_execution); ++ zend_bool original_in_execution; + + + + if (EG(exception)) { + return; + } + ++ original_in_execution = EG(in_execution); + EG(in_execution) = 1; + + LOAD_REGS(); + LOAD_OPLINE(); + while (1) { int ret; #ifdef ZEND_WIN32 diff --cc Zend/zend_vm_execute.skl index 25b3d71,0c5e8a3..58e5631 --- a/Zend/zend_vm_execute.skl +++ b/Zend/zend_vm_execute.skl @@@ -70,28 -63,6 +70,28 @@@ zend_execute_data *zend_create_execute_ EX(function_state).function = (zend_function *) op_array; EX(function_state).arguments = NULL; + return execute_data; +} + +ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *execute_data TSRMLS_DC) +{ + DCL_OPLINE - - zend_bool original_in_execution = EG(in_execution); ++ zend_bool original_in_execution; + + {%HELPER_VARS%} + + {%INTERNAL_LABELS%} + + if (EG(exception)) { + return; + } + ++ original_in_execution = EG(in_execution); + EG(in_execution) = 1; + + LOAD_REGS(); + LOAD_OPLINE(); + while (1) { {%ZEND_VM_CONTINUE_LABEL%} #ifdef ZEND_WIN32 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Add dedicated opcode for returns from a generator: Zend/zend_opcode.c Zend/zend_vm_def.h Zend/zend_vm_execute.h Zend/zend_vm_opcodes.h
Commit:68c1e1cfe95b026086cacf40a005ea8f399e9595 Author:Nikita Popov ni...@php.net Fri, 24 Aug 2012 13:51:39 +0200 Parents: 6517ed021520a608a18da4653cb9c6b414121f6f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=68c1e1cfe95b026086cacf40a005ea8f399e9595 Log: Add dedicated opcode for returns from a generator Generators don't have a return value, so it doesn't make sense to have a shared implementation here. Changed paths: M Zend/zend_opcode.c M Zend/zend_vm_def.h M Zend/zend_vm_execute.h M Zend/zend_vm_opcodes.h Diff: diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 0f39b8a..5c4b20f 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -586,9 +586,8 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC) CG(zend_lineno) = opline-lineno; zend_error(E_COMPILE_ERROR, Generators cannot return values using \return\); } - if (opline-opcode == ZEND_RETURN_BY_REF) { - opline-opcode = ZEND_RETURN; - } + + opline-opcode = ZEND_GENERATOR_RETURN; } break; } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 975a2a7..216cd59 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2931,17 +2931,6 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY) zval *retval_ptr; zend_free_op free_op1; - if (EX(op_array)-fn_flags ZEND_ACC_GENERATOR) { - /* The generator object is stored in return_value_ptr_ptr */ - zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); - - /* Close the generator to free up resources */ - zend_generator_close(generator, 1 TSRMLS_CC); - - /* Pass execution back to handling code */ - ZEND_VM_RETURN(); - } - SAVE_OPLINE(); retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); @@ -3066,6 +3055,14 @@ ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY) ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); } +ZEND_VM_HANDLER(162, ZEND_GENERATOR_RETURN, ANY, ANY) +{ + if (EX(op_array)-has_finally_block) { + ZEND_VM_DISPATCH_TO_HELPER_EX(zend_finally_handler_leaving, type, ZEND_RETURN); + } + ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); +} + ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY) { USE_OPLINE diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 402442f..ebc0fb9 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -885,6 +885,14 @@ static int ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER(ZEND_OPCODE_HANDLER return zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } +static int ZEND_FASTCALL ZEND_GENERATOR_RETURN_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) +{ + if (EX(op_array)-has_finally_block) { + return zend_finally_handler_leaving_SPEC(ZEND_RETURN, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); + } + return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); +} + static int ZEND_FASTCALL ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -2443,17 +2451,6 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG zval *retval_ptr; - if (EX(op_array)-fn_flags ZEND_ACC_GENERATOR) { - /* The generator object is stored in return_value_ptr_ptr */ - zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); - - /* Close the generator to free up resources */ - zend_generator_close(generator, 1 TSRMLS_CC); - - /* Pass execution back to handling code */ - ZEND_VM_RETURN(); - } - SAVE_OPLINE(); retval_ptr = opline-op1.zv; @@ -7760,17 +7757,6 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) zval *retval_ptr; zend_free_op free_op1; - if (EX(op_array)-fn_flags ZEND_ACC_GENERATOR) { - /* The generator object is stored in return_value_ptr_ptr */ - zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); - - /* Close the generator to free up resources */ - zend_generator_close(generator, 1 TSRMLS_CC); - - /* Pass execution back to handling code */ - ZEND_VM_RETURN(); - } - SAVE_OPLINE(); retval_ptr = _get_zval_ptr_tmp(opline-op1.var, EX_Ts(), free_op1 TSRMLS_CC); @@ -12982,17 +12968,6 @@ static int ZEND_FASTCALL ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
[PHP-CVS] com php-src: Finally with return now works in generators too: Zend/tests/generators/finally_with_return.phpt
Commit:7cdf6367a51a54fce8676aeb6fd32bf91b00f84b Author:Nikita Popov ni...@php.net Fri, 24 Aug 2012 13:52:16 +0200 Parents: 68c1e1cfe95b026086cacf40a005ea8f399e9595 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7cdf6367a51a54fce8676aeb6fd32bf91b00f84b Log: Finally with return now works in generators too Changed paths: A Zend/tests/generators/finally_with_return.phpt Diff: diff --git a/Zend/tests/generators/finally_with_return.phpt b/Zend/tests/generators/finally_with_return.phpt new file mode 100644 index 000..b26a49f --- /dev/null +++ b/Zend/tests/generators/finally_with_return.phpt @@ -0,0 +1,33 @@ +--TEST-- +Use of finally in generator with return +--FILE-- +?php + +function gen() { +try { +try { +echo before return\n; +return; +echo after return\n; +} finally { +echo before return in inner finally\n; +return; +echo after return in inner finally\n; +} +} finally { +echo outer finally run\n; +} + +echo code after finally\n; + +yield; // force generator +} + +$gen = gen(); +$gen-rewind(); // force run + +? +--EXPECTF-- +before return +before return in inner finally +outer finally run -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport: Zend/zend_compile.c Zend/zend_compile.h Zend/zend_opcode.c Zend/zend_vm_def.h Zend/zend_vm_execute.h
Commit:6517ed021520a608a18da4653cb9c6b414121f6f Author:Nikita Popov ni...@php.net Fri, 24 Aug 2012 13:29:40 +0200 Parents: f45a0f31c8354947c0e2b9ea44a63fc0a2c23a01 071580ea1f450513dba2dbf585a9498614f855e7 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6517ed021520a608a18da4653cb9c6b414121f6f Log: Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport Conflicts: Zend/zend_vm_def.h Zend/zend_vm_execute.h Changed paths: MM Zend/zend_compile.c MM Zend/zend_compile.h MM Zend/zend_opcode.c MM Zend/zend_vm_def.h MM Zend/zend_vm_execute.h diff --cc Zend/zend_vm_def.h index f8955c5,ce1674e..975a2a7 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@@ -1840,291 -1840,296 +1840,294 @@@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VA ZEND_VM_NEXT_OPCODE(); } - ZEND_VM_HANDLER(42, ZEND_JMP, ANY, ANY) + ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) { - USE_OPLINE - - #if DEBUG_ZEND=2 - printf(Jumping to %d\n, opline-op1.opline_num); - #endif - ZEND_VM_SET_OPCODE(opline-op1.jmp_addr); - ZEND_VM_CONTINUE(); /* CHECK_ME */ - } + zend_bool nested; + zend_op_array *op_array = EX(op_array); - ZEND_VM_HANDLER(43, ZEND_JMPZ, CONST|TMP|VAR|CV, ANY) - { - USE_OPLINE - zend_free_op free_op1; - zval *val; - int ret; ++ /* Generators go throw a different cleanup process */ ++ if (EX(op_array)-fn_flags ZEND_ACC_GENERATOR) { ++ /* The generator object is stored in return_value_ptr_ptr */ ++ zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + - SAVE_OPLINE(); - val = GET_OP1_ZVAL_PTR(BP_VAR_R); ++ /* Close the generator to free up resources */ ++ zend_generator_close(generator, 1 TSRMLS_CC); + - if (OP1_TYPE == IS_TMP_VAR EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { - ret = Z_LVAL_P(val); - } else { - ret = i_zend_is_true(val); - FREE_OP1(); - if (UNEXPECTED(EG(exception) != NULL)) { - HANDLE_EXCEPTION(); - } - } - if (!ret) { - #if DEBUG_ZEND=2 - printf(Conditional jmp to %d\n, opline-op2.opline_num); - #endif - ZEND_VM_SET_OPCODE(opline-op2.jmp_addr); - ZEND_VM_CONTINUE(); ++ /* Pass execution back to handling code */ ++ ZEND_VM_RETURN(); + } + - ZEND_VM_NEXT_OPCODE(); - } + EG(current_execute_data) = EX(prev_execute_data); + EG(opline_ptr) = NULL; + if (!EG(active_symbol_table)) { - zval ***cv = EX_CVs(); - zval ***end = cv + op_array-last_var; - while (cv != end) { - if (*cv) { - zval_ptr_dtor(*cv); - } - cv++; - } ++ zend_free_compiled_variables(EX_CVs(), op_array-last_var); + } - ZEND_VM_HANDLER(44, ZEND_JMPNZ, CONST|TMP|VAR|CV, ANY) - { - USE_OPLINE - zend_free_op free_op1; - zval *val; - int ret; + if ((op_array-fn_flags ZEND_ACC_CLOSURE) op_array-prototype) { + zval_ptr_dtor((zval**)op_array-prototype); + } - SAVE_OPLINE(); - val = GET_OP1_ZVAL_PTR(BP_VAR_R); + nested = EX(nested); - if (OP1_TYPE == IS_TMP_VAR EXPECTED(Z_TYPE_P(val) == IS_BOOL)) { - ret = Z_LVAL_P(val); - zend_vm_stack_free(execute_data TSRMLS_CC); ++ /* For generators the execute_data is stored on the heap, for everything ++ * else it is stored on the VM stack. */ ++ if (op_array-fn_flags ZEND_ACC_GENERATOR) { ++ efree(execute_data); + } else { - ret = i_zend_is_true(val); - FREE_OP1(); - if (UNEXPECTED(EG(exception) != NULL)) { - HANDLE_EXCEPTION(); - } ++ zend_vm_stack_free(execute_data TSRMLS_CC); + } - if (ret) { - #if DEBUG_ZEND=2 - printf(Conditional jmp to %d\n, opline-op2.opline_num); - #endif - ZEND_VM_SET_OPCODE(opline-op2.jmp_addr); - ZEND_VM_CONTINUE(); + + if (nested) { + execute_data = EG(current_execute_data); } + if (nested) { + USE_OPLINE - ZEND_VM_NEXT_OPCODE(); - } + LOAD_REGS(); + LOAD_OPLINE(); + if (UNEXPECTED(opline-opcode == ZEND_INCLUDE_OR_EVAL)) { - ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMP|VAR|CV, ANY) - { - USE_OPLINE - zend_free_op free_op1; - zval *val; - int retval; + EX(function_state).function = (zend_function *) EX(op_array); + EX(function_state).arguments = NULL; + EX(object) = EX(current_object); -
[PHP-CVS] com php-src: Disallow serialization and unserialization: Zend/tests/generators/errors/serialize_unserialize_error.phpt Zend/zend_generators.c
Commit:f45a0f31c8354947c0e2b9ea44a63fc0a2c23a01 Author:Nikita Popov ni...@php.net Mon, 20 Aug 2012 16:01:16 +0200 Parents: 1823b16fa15894f72fc01724766289dbecf5a62a Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f45a0f31c8354947c0e2b9ea44a63fc0a2c23a01 Log: Disallow serialization and unserialization Changed paths: A Zend/tests/generators/errors/serialize_unserialize_error.phpt M Zend/zend_generators.c Diff: diff --git a/Zend/tests/generators/errors/serialize_unserialize_error.phpt b/Zend/tests/generators/errors/serialize_unserialize_error.phpt new file mode 100644 index 000..a8470b0 --- /dev/null +++ b/Zend/tests/generators/errors/serialize_unserialize_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +Generators can't be serialized or unserialized +--FILE-- +?php + +function gen() { yield; } + +$gen = gen(); + +try { +serialize($gen); +} catch (Exception $e) { +echo $e, \n\n; +} + +try { +var_dump(unserialize('O:9:Generator:0:{}')); +} catch (Exception $e) { +echo $e, \n\n; +} + +try { +var_dump(unserialize('C:9:Generator:0:{}')); +} catch (Exception $e) { +echo $e; +} + +? +--EXPECTF-- +exception 'Exception' with message 'Serialization of 'Generator' is not allowed' in %s:%d +Stack trace: +#0 %s(%d): serialize(Object(Generator)) +#1 {main} + +exception 'Exception' with message 'Unserialization of 'Generator' is not allowed' in %s:%d +Stack trace: +#0 [internal function]: Generator-__wakeup() +#1 %s(%d): unserialize('O:9:Generator...') +#2 {main} + + +Notice: unserialize(): Error at offset 19 of 20 bytes in %s on line %d +exception 'Exception' with message 'Unserialization of 'Generator' is not allowed' in %s:%d +Stack trace: +#0 %s(%d): unserialize('C:9:Generator...') +#1 {main} diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 41c6dfc..b4d8932 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -590,6 +590,23 @@ ZEND_METHOD(Generator, send) } } + +/* {{{ proto void Generator::__wakeup + * Throws an Exception as generators can't be serialized */ +ZEND_METHOD(Generator, __wakeup) +{ + /* Just specifying the zend_class_unserialize_deny handler is not enough, +* because it is only invoked for C unserialization. For O the error has +* to be thrown in __wakeup. */ + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + zend_throw_exception(NULL, Unserialization of 'Generator' is not allowed, 0 TSRMLS_CC); +} +/* }}} */ + /* get_iterator implementation */ typedef struct _zend_generator_iterator { @@ -712,12 +729,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_generator_send, 0, 0, 1) ZEND_END_ARG_INFO() static const zend_function_entry generator_functions[] = { - ZEND_ME(Generator, rewind, arginfo_generator_void, ZEND_ACC_PUBLIC) - ZEND_ME(Generator, valid, arginfo_generator_void, ZEND_ACC_PUBLIC) - ZEND_ME(Generator, current, arginfo_generator_void, ZEND_ACC_PUBLIC) - ZEND_ME(Generator, key, arginfo_generator_void, ZEND_ACC_PUBLIC) - ZEND_ME(Generator, next,arginfo_generator_void, ZEND_ACC_PUBLIC) - ZEND_ME(Generator, send,arginfo_generator_send, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, rewind, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, valid,arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, current, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, key, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, next, arginfo_generator_void, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, send, arginfo_generator_send, ZEND_ACC_PUBLIC) + ZEND_ME(Generator, __wakeup, arginfo_generator_void, ZEND_ACC_PUBLIC) ZEND_FE_END }; @@ -729,6 +747,8 @@ void zend_register_generator_ce(TSRMLS_D) /* {{{ */ zend_ce_generator = zend_register_internal_class(ce TSRMLS_CC); zend_ce_generator-ce_flags |= ZEND_ACC_FINAL_CLASS; zend_ce_generator-create_object = zend_generator_create; + zend_ce_generator-serialize = zend_class_serialize_deny; + zend_ce_generator-unserialize = zend_class_unserialize_deny; /* get_iterator has to be assigned *after* implementing the inferface */ zend_class_implements(zend_ce_generator TSRMLS_CC, 1, zend_ce_iterator); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Drop Generator::close() method: Zend/tests/generators/clone_with_foreach.phpt Zend/tests/generators/clone_with_stack.phpt Zend/tests/generators/clone_with_symbol_table.phpt Zend
Commit:05f10480c556ebe52bbef52cb2da5a0aca8ee070 Author:Nikita Popov ni...@php.net Mon, 20 Aug 2012 12:53:18 +0200 Parents: 7195a5b3768e519b8f50d131a8c7041a0b57959e Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=05f10480c556ebe52bbef52cb2da5a0aca8ee070 Log: Drop Generator::close() method Changed paths: M Zend/tests/generators/clone_with_foreach.phpt M Zend/tests/generators/clone_with_stack.phpt M Zend/tests/generators/clone_with_symbol_table.phpt M Zend/tests/generators/clone_with_this.phpt D Zend/tests/generators/close_inside_generator.phpt D Zend/tests/generators/generator_close.phpt M Zend/tests/generators/yield_during_method_call.phpt M Zend/zend_generators.c M Zend/zend_generators.h Diff: diff --git a/Zend/tests/generators/clone_with_foreach.phpt b/Zend/tests/generators/clone_with_foreach.phpt index b887338..b05ed07 100644 --- a/Zend/tests/generators/clone_with_foreach.phpt +++ b/Zend/tests/generators/clone_with_foreach.phpt @@ -20,7 +20,7 @@ $g2-next(); var_dump($g1-current()); var_dump($g2-current()); -$g1-close(); +unset($g1); $g2-next(); var_dump($g2-current()); diff --git a/Zend/tests/generators/clone_with_stack.phpt b/Zend/tests/generators/clone_with_stack.phpt index 673c0e5..5a8e6d8 100644 --- a/Zend/tests/generators/clone_with_stack.phpt +++ b/Zend/tests/generators/clone_with_stack.phpt @@ -10,7 +10,7 @@ function gen() { $g1 = gen(); $g1-rewind(); $g2 = clone $g1; -$g1-close(); +unset($g1); $g2-send(10); ? diff --git a/Zend/tests/generators/clone_with_symbol_table.phpt b/Zend/tests/generators/clone_with_symbol_table.phpt index 0d1bd4e..e1fefeb 100644 --- a/Zend/tests/generators/clone_with_symbol_table.phpt +++ b/Zend/tests/generators/clone_with_symbol_table.phpt @@ -19,7 +19,7 @@ function gen() { $g1 = gen(); $g1-rewind(); $g2 = clone $g1; -$g1-close(); +unset($g1); $g2-next(); ? diff --git a/Zend/tests/generators/clone_with_this.phpt b/Zend/tests/generators/clone_with_this.phpt index 66efd02..b242d85 100644 --- a/Zend/tests/generators/clone_with_this.phpt +++ b/Zend/tests/generators/clone_with_this.phpt @@ -16,7 +16,7 @@ class Test { $g1 = (new Test)-gen(); $g1-rewind(); // goto yield $g2 = clone $g1; -$g1-close(); +unset($g1); $g2-next(); ? diff --git a/Zend/tests/generators/close_inside_generator.phpt b/Zend/tests/generators/close_inside_generator.phpt deleted file mode 100644 index 1df64bf..000 --- a/Zend/tests/generators/close_inside_generator.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Calling close() during the exectution of the generator ---FILE-- -?php - -function gen() { -/* Pass the generator object itself in */ -$gen = yield; - -/* Close generator while it is currently running */ -$gen-close(); - - echo Still running; -} - -$gen = gen(); -$gen-send($gen); - -? ---EXPECTF-- -Warning: A generator cannot be closed while it is running in %s on line %d -Still running diff --git a/Zend/tests/generators/generator_close.phpt b/Zend/tests/generators/generator_close.phpt deleted file mode 100644 index 3dec285..000 --- a/Zend/tests/generators/generator_close.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Generator can be closed by calling -close() ---FILE-- -?php - -function allNumbers() { -for ($i = 0; true; ++$i) { -yield $i; -} -} - -$numbers = allNumbers(); - -foreach ($numbers as $n) { -var_dump($n); -if ($n == 9) { -$numbers-close(); -} -} - -? ---EXPECT-- -int(0) -int(1) -int(2) -int(3) -int(4) -int(5) -int(6) -int(7) -int(8) -int(9) diff --git a/Zend/tests/generators/yield_during_method_call.phpt b/Zend/tests/generators/yield_during_method_call.phpt index e8859ac..5fbe84f 100644 --- a/Zend/tests/generators/yield_during_method_call.phpt +++ b/Zend/tests/generators/yield_during_method_call.phpt @@ -20,13 +20,13 @@ $gen-send('foo'); // test resource cleanup $gen = gen(); $gen-rewind(); -$gen-close(); +unset($gen); // test cloning $g1 = gen(); $g1-rewind(); $g2 = clone $g1; -$g1-close(); +unset($g1); $g2-send('bar'); ? diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 716b0a7..41c6dfc 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -301,8 +301,6 @@ static zend_object_value zend_generator_create(zend_class_entry *class_type TSRM /* The key will be incremented on first use, so it'll start at 0 */ generator-largest_used_integer_key = -1; - generator-is_currently_running = 0; - zend_object_std_init(generator-std, class_type TSRMLS_CC); object.handle = zend_objects_store_put(generator, NULL, @@ -391,8 +389,6 @@ static void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ zend_class_entry *original_scope = EG(scope); zend_class_entry *original_called_scope = EG(called_scope); - zend_bool original_is_currently_running = generator-is_currently_running;
[PHP-CVS] com php-src: Support trivial finally in generators (no yield, no return): Zend/zend_vm_def.h Zend/zend_vm_execute.h
Commit:ae716939eb500f962336d37b96069cb7452c25df Author:Nikita Popov ni...@php.net Mon, 13 Aug 2012 17:17:18 +0200 Parents: f4ce3646285fbdd3354ca86ae67857b6ee8f7e3a Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ae716939eb500f962336d37b96069cb7452c25df Log: Support trivial finally in generators (no yield, no return) The finally clause is now properly run when an exception is thrown in the try-block. It is not yet run on `return` and also not run when the generator is claused within a try block. I'll add those two things as soon as laruence refactored the finally code. Changed paths: M Zend/zend_vm_def.h M Zend/zend_vm_execute.h Diff: diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 83ae5c5..49ee314 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2513,6 +2513,18 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) zend_bool nested; zend_op_array *op_array = EX(op_array); + /* Generators go throw a different cleanup process */ + if (EX(op_array)-fn_flags ZEND_ACC_GENERATOR) { + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + /* Close the generator to free up resources */ + zend_generator_close(generator, 1 TSRMLS_CC); + + /* Pass execution back to handling code */ + ZEND_VM_RETURN(); + } + EG(current_execute_data) = EX(prev_execute_data); EG(opline_ptr) = NULL; if (!EG(active_symbol_table)) { @@ -5213,18 +5225,6 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) ZEND_VM_SET_OPCODE(EX(op_array)-opcodes[finally_op_num]); ZEND_VM_CONTINUE(); } else { - /* For generators skip the leave handler and return directly */ - if (EX(op_array)-fn_flags ZEND_ACC_GENERATOR) { - /* The generator object is stored in return_value_ptr_ptr */ - zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); - - /* Close the generator to free up resources */ - zend_generator_close(generator, 1 TSRMLS_CC); - - /* Pass execution back to handling code */ - ZEND_VM_RETURN(); - } - ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper); } } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 495b520..94c2a7c 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -496,6 +496,18 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) zend_bool nested; zend_op_array *op_array = EX(op_array); + /* Generators go throw a different cleanup process */ + if (EX(op_array)-fn_flags ZEND_ACC_GENERATOR) { + /* The generator object is stored in return_value_ptr_ptr */ + zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); + + /* Close the generator to free up resources */ + zend_generator_close(generator, 1 TSRMLS_CC); + + /* Pass execution back to handling code */ + ZEND_VM_RETURN(); + } + EG(current_execute_data) = EX(prev_execute_data); EG(opline_ptr) = NULL; if (!EG(active_symbol_table)) { @@ -1177,18 +1189,6 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER ZEND_VM_SET_OPCODE(EX(op_array)-opcodes[finally_op_num]); ZEND_VM_CONTINUE(); } else { - /* For generators skip the leave handler and return directly */ - if (EX(op_array)-fn_flags ZEND_ACC_GENERATOR) { - /* The generator object is stored in return_value_ptr_ptr */ - zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr); - - /* Close the generator to free up resources */ - zend_generator_close(generator, 1 TSRMLS_CC); - - /* Pass execution back to handling code */ - ZEND_VM_RETURN(); - } - return zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Fix implementation of Iterator interface: Zend/tests/generators/generator_in_multipleiterator.phpt Zend/zend_generators.c
Commit:268740d9848d435054ce73a8cfe36b2b732cd1f7 Author:Nikita Popov ni...@php.net Thu, 26 Jul 2012 17:07:24 +0200 Parents: 99f93dd9a846e3d615ec61c734aca2e7ee256600 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=268740d9848d435054ce73a8cfe36b2b732cd1f7 Log: Fix implementation of Iterator interface It looks like you have to implement the Iterator interface *before* assigning get_iterator. Otherwise the structure for user iterators isn't correctly zeroed out. Additionaly I'm setting class_entry-iterator_funcs.funcs now. Not sure if this is strictly necessary, but better safe than sorry ;) Changed paths: A Zend/tests/generators/generator_in_multipleiterator.phpt M Zend/zend_generators.c Diff: diff --git a/Zend/tests/generators/generator_in_multipleiterator.phpt b/Zend/tests/generators/generator_in_multipleiterator.phpt new file mode 100644 index 000..611dbc9 --- /dev/null +++ b/Zend/tests/generators/generator_in_multipleiterator.phpt @@ -0,0 +1,37 @@ +--TEST-- +Generators work properly in MultipleIterator +--FILE-- +?php + +function gen1() { +yield 'a'; +yield 'aa'; +} + +function gen2() { +yield 'b'; +yield 'bb'; +} + +$it = new MultipleIterator; +$it-attachIterator(gen1()); +$it-attachIterator(gen2()); + +foreach ($it as $values) { +var_dump($values); +} + +? +--EXPECT-- +array(2) { + [0]= + string(1) a + [1]= + string(1) b +} +array(2) { + [0]= + string(2) aa + [1]= + string(2) bb +} diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index d7ffb30..716b0a7 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -759,9 +759,11 @@ void zend_register_generator_ce(TSRMLS_D) /* {{{ */ zend_ce_generator = zend_register_internal_class(ce TSRMLS_CC); zend_ce_generator-ce_flags |= ZEND_ACC_FINAL_CLASS; zend_ce_generator-create_object = zend_generator_create; - zend_ce_generator-get_iterator = zend_generator_get_iterator; + /* get_iterator has to be assigned *after* implementing the inferface */ zend_class_implements(zend_ce_generator TSRMLS_CC, 1, zend_ce_iterator); + zend_ce_generator-get_iterator = zend_generator_get_iterator; + zend_ce_generator-iterator_funcs.funcs = zend_generator_iterator_functions; memcpy(zend_generator_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); zend_generator_handlers.get_constructor = zend_generator_get_constructor; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Throw error also for return occuring before yield: Zend/tests/generators/errors/generator_cannot_return_before_yield_error.phpt Zend/tests/generators/errors/generator_cannot_ret
Commit:134089372b94de2e3e8c2a1aba4cbc415c803d67 Author:Nikita Popov ni...@php.net Sun, 22 Jul 2012 20:11:09 +0200 Parents: 94b2ccae9ce95c4c71bb8db8ce75dcdf26df7d7a Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=134089372b94de2e3e8c2a1aba4cbc415c803d67 Log: Throw error also for return occuring before yield Previously only an error was thrown when return occured after yield. Also returns before the first yield would fail for by-ref generators. Now the error message is handled in pass_two, so all returns are checked. Changed paths: A Zend/tests/generators/errors/generator_cannot_return_before_yield_error.phpt M Zend/tests/generators/errors/generator_cannot_return_error.phpt M Zend/zend_compile.c M Zend/zend_opcode.c Diff: diff --git a/Zend/tests/generators/errors/generator_cannot_return_before_yield_error.phpt b/Zend/tests/generators/errors/generator_cannot_return_before_yield_error.phpt new file mode 100644 index 000..ad618d2 --- /dev/null +++ b/Zend/tests/generators/errors/generator_cannot_return_before_yield_error.phpt @@ -0,0 +1,13 @@ +--TEST-- +Generators cannot return values (even before yield) +--FILE-- +?php + +function gen() { +return $foo; +yield; +} + +? +--EXPECTF-- +Fatal error: Generators cannot return values using return in %s on line 4 diff --git a/Zend/tests/generators/errors/generator_cannot_return_error.phpt b/Zend/tests/generators/errors/generator_cannot_return_error.phpt index 9a46bff..5114906 100644 --- a/Zend/tests/generators/errors/generator_cannot_return_error.phpt +++ b/Zend/tests/generators/errors/generator_cannot_return_error.phpt @@ -10,4 +10,4 @@ function gen() { ? --EXPECTF-- -Fatal error: Generators cannot return values using return in %s on line %d +Fatal error: Generators cannot return values using return in %s on line 5 diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f0648a2..483ff30 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2611,14 +2611,9 @@ void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC) /* {{{ */ { zend_op *opline; int start_op_number, end_op_number; + zend_bool returns_reference = (CG(active_op_array)-fn_flags ZEND_ACC_RETURN_REFERENCE) != 0; - /* For generators the modifier applies to the yielded values, not the -* return value. */ - zend_bool returns_reference = (CG(active_op_array)-fn_flags ZEND_ACC_RETURN_REFERENCE) !(CG(active_op_array)-fn_flags ZEND_ACC_GENERATOR); - - if ((CG(active_op_array)-fn_flags ZEND_ACC_GENERATOR) expr != NULL) { - zend_error(E_COMPILE_ERROR, Generators cannot return values using \return\); - } + /* The error for use of return inside a generator is thrown in pass_two. */ if (do_end_vparse) { if (returns_reference !zend_is_function_or_method_call(expr)) { diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 65fa851..0042c37 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -532,6 +532,18 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC) case ZEND_JMP_SET_VAR: opline-op2.jmp_addr = op_array-opcodes[opline-op2.opline_num]; break; + case ZEND_RETURN: + case ZEND_RETURN_BY_REF: + if (op_array-fn_flags ZEND_ACC_GENERATOR) { + if (opline-op1_type != IS_CONST || Z_TYPE_P(opline-op1.zv) != IS_NULL) { + CG(zend_lineno) = opline-lineno; + zend_error(E_COMPILE_ERROR, Generators cannot return values using \return\); + } + if (opline-opcode == ZEND_RETURN_BY_REF) { + opline-opcode = ZEND_RETURN; + } + } + break; } ZEND_VM_SET_OPCODE_HANDLER(opline); opline++; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Add T_YIELD in tokenizer_data.c: ext/tokenizer/tests/token_get_all_variation11.phpt ext/tokenizer/tests/token_get_all_variation13.phpt ext/tokenizer/tests/token_get_all_variatio
Commit:99f93dd9a846e3d615ec61c734aca2e7ee256600 Author:Nikita Popov ni...@php.net Sun, 22 Jul 2012 20:19:07 +0200 Parents: 134089372b94de2e3e8c2a1aba4cbc415c803d67 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=99f93dd9a846e3d615ec61c734aca2e7ee256600 Log: Add T_YIELD in tokenizer_data.c Also had to fix up some tokenizer tests that were affected by the token number changes. Changed paths: M ext/tokenizer/tests/token_get_all_variation11.phpt M ext/tokenizer/tests/token_get_all_variation13.phpt M ext/tokenizer/tests/token_get_all_variation17.phpt M ext/tokenizer/tests/token_get_all_variation4.phpt M ext/tokenizer/tests/token_get_all_variation5.phpt M ext/tokenizer/tests/token_get_all_variation6.phpt M ext/tokenizer/tests/token_get_all_variation8.phpt M ext/tokenizer/tokenizer_data.c Diff: diff --git a/ext/tokenizer/tests/token_get_all_variation11.phpt b/ext/tokenizer/tests/token_get_all_variation11.phpt index ecc8617..98d8996 100644 --- a/ext/tokenizer/tests/token_get_all_variation11.phpt +++ b/ext/tokenizer/tests/token_get_all_variation11.phpt @@ -130,7 +130,7 @@ array(49) { [6]= array(3) { [0]= -int(283) +int(%d) [1]= string(2) == [2]= @@ -273,7 +273,7 @@ array(49) { [27]= array(3) { [0]= -int(283) +int(%d) [1]= string(2) == [2]= diff --git a/ext/tokenizer/tests/token_get_all_variation13.phpt b/ext/tokenizer/tests/token_get_all_variation13.phpt index 9b2f3bc..6f85492 100644 --- a/ext/tokenizer/tests/token_get_all_variation13.phpt +++ b/ext/tokenizer/tests/token_get_all_variation13.phpt @@ -1005,7 +1005,7 @@ array(145) { [122]= array(3) { [0]= -int(288) +int(%d) [1]= string(10) instanceof [2]= diff --git a/ext/tokenizer/tests/token_get_all_variation17.phpt b/ext/tokenizer/tests/token_get_all_variation17.phpt index dccc4c9..f71444b 100644 --- a/ext/tokenizer/tests/token_get_all_variation17.phpt +++ b/ext/tokenizer/tests/token_get_all_variation17.phpt @@ -145,7 +145,7 @@ array(81) { [14]= array(3) { [0]= -int(283) +int(%d) [1]= string(2) == [2]= diff --git a/ext/tokenizer/tests/token_get_all_variation4.phpt b/ext/tokenizer/tests/token_get_all_variation4.phpt index 45e6f8a..6bc111e 100644 --- a/ext/tokenizer/tests/token_get_all_variation4.phpt +++ b/ext/tokenizer/tests/token_get_all_variation4.phpt @@ -339,7 +339,7 @@ array(89) { [38]= array(3) { [0]= -int(279) +int(%d) [1]= string(2) [2]= @@ -518,7 +518,7 @@ array(89) { [60]= array(3) { [0]= -int(278) +int(%d) [1]= string(2) || [2]= diff --git a/ext/tokenizer/tests/token_get_all_variation5.phpt b/ext/tokenizer/tests/token_get_all_variation5.phpt index 0068f28..681fb48 100644 --- a/ext/tokenizer/tests/token_get_all_variation5.phpt +++ b/ext/tokenizer/tests/token_get_all_variation5.phpt @@ -181,7 +181,7 @@ array(94) { [18]= array(3) { [0]= -int(277) +int(%d) [1]= string(2) += [2]= @@ -238,7 +238,7 @@ array(94) { [25]= array(3) { [0]= -int(276) +int(%d) [1]= string(2) -= [2]= @@ -295,7 +295,7 @@ array(94) { [32]= array(3) { [0]= -int(275) +int(%d) [1]= string(2) *= [2]= @@ -352,7 +352,7 @@ array(94) { [39]= array(3) { [0]= -int(274) +int(%d) [1]= string(2) /= [2]= @@ -409,7 +409,7 @@ array(94) { [46]= array(3) { [0]= -int(272) +int(%d) [1]= string(2) %= [2]= @@ -466,7 +466,7 @@ array(94) { [53]= array(3) { [0]= -int(271) +int(%d) [1]= string(2) = [2]= @@ -523,7 +523,7 @@ array(94) { [60]= array(3) { [0]= -int(270) +int(%d) [1]= string(2) |= [2]= @@ -580,7 +580,7 @@ array(94) { [67]= array(3) { [0]= -int(269) +int(%d) [1]= string(2) ^= [2]= @@ -637,7 +637,7 @@ array(94) { [74]= array(3) { [0]= -int(267) +int(%d) [1]= string(3) = [2]= @@ -694,7 +694,7 @@ array(94) { [81]= array(3) { [0]= -int(268) +int(%d) [1]= string(3) = [2]= @@ -751,7 +751,7 @@ array(94) { [88]= array(3) { [0]= -int(273) +int(%d) [1]= string(2) .= [2]= diff --git a/ext/tokenizer/tests/token_get_all_variation6.phpt b/ext/tokenizer/tests/token_get_all_variation6.phpt index 54936d0..6213dab 100644 --- a/ext/tokenizer/tests/token_get_all_variation6.phpt +++ b/ext/tokenizer/tests/token_get_all_variation6.phpt @@ -191,7 +191,7 @@ array(50) { [21]= array(3) { [0]= -int(287) +int(%d) [1]= string(2) [2]= @@ -277,7 +277,7 @@ array(50) { [32]= array(3) { [0]= -int(286) +int(%d) [1]= string(2) [2]= diff --git a/ext/tokenizer/tests/token_get_all_variation8.phpt
[PHP-CVS] com php-src: Remove reference restrictions from foreach: Zend/tests/errmsg_043.phpt Zend/tests/foreach_temp_array_expr_with_refs.phpt Zend/tests/generators/yield_by_reference.phpt Zend/zend_
Commit:de80e3ce4b5b7a9ec0cfdd0778e77027a7ebfcc2 Author:Nikita Popov ni...@php.net Sun, 22 Jul 2012 14:33:25 +0200 Parents: 80748631aa1c4193cbc68f8854d82e7a57817fe2 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=de80e3ce4b5b7a9ec0cfdd0778e77027a7ebfcc2 Log: Remove reference restrictions from foreach foreach only allowed variables to be traversed by reference. This never really made sense because a) Expressions like array($a, $b) can be meaningfully iterated by-ref b) Function calls can return by-ref (so they can also be meaningfully iterated) c) Iterators could at least in theory also be iterated by-ref (not sure if any iterator makes use of this) With by-ref generators the restriction makes even less sense, so I removed it altogether. Changed paths: D Zend/tests/errmsg_043.phpt A Zend/tests/foreach_temp_array_expr_with_refs.phpt M Zend/tests/generators/yield_by_reference.phpt M Zend/zend_compile.c M Zend/zend_language_parser.y D tests/lang/foreachLoop.008.phpt Diff: diff --git a/Zend/tests/errmsg_043.phpt b/Zend/tests/errmsg_043.phpt deleted file mode 100644 index 3de8bc2..000 --- a/Zend/tests/errmsg_043.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -errmsg: cannot create references to temp array ---FILE-- -?php - -foreach (array(1,2,3) as $k=$v) { -} - -echo Done\n; -? ---EXPECTF-- -Fatal error: Cannot create references to elements of a temporary array expression in %s on line %d diff --git a/Zend/tests/foreach_temp_array_expr_with_refs.phpt b/Zend/tests/foreach_temp_array_expr_with_refs.phpt new file mode 100644 index 000..8978b7b --- /dev/null +++ b/Zend/tests/foreach_temp_array_expr_with_refs.phpt @@ -0,0 +1,18 @@ +--TEST-- +Temporary array expressions can be iterated by reference +--FILE-- +?php + +$a = 'a'; +$b = 'b'; + +foreach ([$a, $b] as $value) { +$value .= '-foo'; +} + +var_dump($a, $b); + +? +--EXPECT-- +string(5) a-foo +string(5) b-foo diff --git a/Zend/tests/generators/yield_by_reference.phpt b/Zend/tests/generators/yield_by_reference.phpt index 5a6c169..dba0791 100644 --- a/Zend/tests/generators/yield_by_reference.phpt +++ b/Zend/tests/generators/yield_by_reference.phpt @@ -9,24 +9,34 @@ function iter(array $array) { } } -$array = [1, 2, 3, 4, 5]; +$array = [1, 2, 3]; $iter = iter($array); foreach ($iter as $value) { $value *= -1; } var_dump($array); +$array = [1, 2, 3]; +foreach (iter($array) as $value) { +$value *= -1; +} +var_dump($array); + ? --EXPECT-- -array(5) { +array(3) { + [0]= + int(-1) + [1]= + int(-2) + [2]= + int(-3) +} +array(3) { [0]= int(-1) [1]= int(-2) [2]= - int(-3) - [3]= - int(-4) - [4]= - int(-5) + int(-3) } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 51fc8c3..f0648a2 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6317,9 +6317,7 @@ void zend_do_foreach_cont(znode *foreach_token, const znode *open_brackets_token if (value-EA ZEND_PARSED_REFERENCE_VARIABLE) { assign_by_ref = 1; - if (!(opline-1)-extended_value) { - zend_error(E_COMPILE_ERROR, Cannot create references to elements of a temporary array expression); - } + /* Mark extended_value for assign-by-reference */ opline-extended_value |= ZEND_FE_FETCH_BYREF; CG(active_op_array)-opcodes[foreach_token-u.op.opline_num].extended_value |= ZEND_FE_RESET_REFERENCE; diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index e5f31b5..4221752 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -312,7 +312,7 @@ unticked_statement: foreach_statement { zend_do_foreach_end($1, $4 TSRMLS_CC); } | T_FOREACH '(' expr_without_variable T_AS { zend_do_foreach_begin($1, $2, $3, $4, 0 TSRMLS_CC); } - variable foreach_optional_arg ')' { zend_check_writable_variable($6); zend_do_foreach_cont($1, $2, $4, $6, $7 TSRMLS_CC); } + foreach_variable foreach_optional_arg ')' { zend_do_foreach_cont($1, $2, $4, $6, $7 TSRMLS_CC); } foreach_statement { zend_do_foreach_end($1, $4 TSRMLS_CC); } | T_DECLARE { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_declare_begin(TSRMLS_C); } '(' declare_list ')' declare_statement { zend_do_declare_end($1 TSRMLS_CC); } | ';' /* empty statement */ diff --git a/tests/lang/foreachLoop.008.phpt b/tests/lang/foreachLoop.008.phpt deleted file mode 100644 index 787f43b..000 --- a/tests/lang/foreachLoop.008.phpt +++ /dev/null @@ -1,10 +0,0 @@ ---TEST-- -Foreach loop tests - error case: reference to constant array, with key. ---FILE-- -?php -foreach (array(1,2) as $k=$v) { - var_dump($v); -} -? ---EXPECTF-- -Fatal error: Cannot create references to elements of a temporary array
[PHP-CVS] com php-src: Add some more tests: Zend/tests/generators/fibonacci.phpt Zend/tests/generators/generator_closure.phpt Zend/tests/generators/generator_closure_with_this.phpt Zend/tests/generato
Commit:1f70a4c5fea97aa577aa5d9ee5f33d91d70e690d Author:Nikita Popov ni...@php.net Fri, 20 Jul 2012 17:40:04 +0200 Parents: 612c2490b7973d71d472860ade48d7ab342b5911 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1f70a4c5fea97aa577aa5d9ee5f33d91d70e690d Log: Add some more tests Changed paths: A Zend/tests/generators/fibonacci.phpt A Zend/tests/generators/generator_closure.phpt A Zend/tests/generators/generator_closure_with_this.phpt A Zend/tests/generators/generator_static_method.phpt Diff: diff --git a/Zend/tests/generators/fibonacci.phpt b/Zend/tests/generators/fibonacci.phpt new file mode 100644 index 000..35b3135 --- /dev/null +++ b/Zend/tests/generators/fibonacci.phpt @@ -0,0 +1,36 @@ +--TEST-- +Creating an infinite fibonacci list using a generator +--FILE-- +?php + +function fib() { +list($a, $b) = [1, 1]; +while (true) { +yield $b; +list($a, $b) = [$b, $a + $b]; +} +} + +foreach (fib() as $n) { +if ($n 1000) break; + +var_dump($n); +} + +? +--EXPECT-- +int(1) +int(2) +int(3) +int(5) +int(8) +int(13) +int(21) +int(34) +int(55) +int(89) +int(144) +int(233) +int(377) +int(610) +int(987) diff --git a/Zend/tests/generators/generator_closure.phpt b/Zend/tests/generators/generator_closure.phpt new file mode 100644 index 000..bf80066 --- /dev/null +++ b/Zend/tests/generators/generator_closure.phpt @@ -0,0 +1,20 @@ +--TEST-- +Closures can be generators +--FILE-- +?php + +$genFactory = function() { +yield 1; +yield 2; +yield 3; +}; + +foreach ($genFactory() as $value) { +var_dump($value); +} + +? +--EXPECT-- +int(1) +int(2) +int(3) diff --git a/Zend/tests/generators/generator_closure_with_this.phpt b/Zend/tests/generators/generator_closure_with_this.phpt new file mode 100644 index 000..d5a4861 --- /dev/null +++ b/Zend/tests/generators/generator_closure_with_this.phpt @@ -0,0 +1,20 @@ +--TEST-- +Non-static closures can be generators +--FILE-- +?php + +class Test { +public function getGenFactory() { +return function() { +yield $this; +}; +} +} + +$genFactory = (new Test)-getGenFactory(); +var_dump($genFactory()-current()); + +? +--EXPECT-- +object(Test)#1 (0) { +} diff --git a/Zend/tests/generators/generator_static_method.phpt b/Zend/tests/generators/generator_static_method.phpt new file mode 100644 index 000..cd9b450 --- /dev/null +++ b/Zend/tests/generators/generator_static_method.phpt @@ -0,0 +1,29 @@ +--TEST-- +A static method can be a generator +--FILE-- +?php + +class Test { +public static function gen() { +var_dump(get_class()); +var_dump(get_called_class()); +yield 1; +yield 2; +yield 3; +} +} + +class ExtendedTest extends Test { +} + +foreach (ExtendedTest::gen() as $i) { +var_dump($i); +} + +? +--EXPECT-- +string(4) Test +string(12) ExtendedTest +int(1) +int(2) +int(3) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Forgot to git add two tests: Zend/tests/generators/close_inside_generator.phpt Zend/tests/generators/func_get_args.phpt
Commit:5a9bddba6699d056383107728392048cd7ccb598 Author:Nikita Popov ni...@php.net Mon, 25 Jun 2012 21:41:50 +0200 Parents: ab75ed6ba9b5eace710976bf76d631728d4bb403 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5a9bddba6699d056383107728392048cd7ccb598 Log: Forgot to git add two tests Changed paths: A Zend/tests/generators/close_inside_generator.phpt A Zend/tests/generators/func_get_args.phpt Diff: diff --git a/Zend/tests/generators/close_inside_generator.phpt b/Zend/tests/generators/close_inside_generator.phpt new file mode 100644 index 000..41a91c9 --- /dev/null +++ b/Zend/tests/generators/close_inside_generator.phpt @@ -0,0 +1,22 @@ +--TEST-- +Calling close() during the exectution of the generator +--FILE-- +?php + +function *gen() { +/* Pass the generator object itself in */ +$gen = yield; + +/* Close generator while it is currently running */ +$gen-close(); + + echo Still running; +} + +$gen = gen(); +$gen-send($gen); + +? +--EXPECTF-- +Warning: A generator cannot be closed while it is running in %s on line %d +Still running diff --git a/Zend/tests/generators/func_get_args.phpt b/Zend/tests/generators/func_get_args.phpt new file mode 100644 index 000..7ce7fb0 --- /dev/null +++ b/Zend/tests/generators/func_get_args.phpt @@ -0,0 +1,20 @@ +--TEST-- +func_get_args() can be used inside generator functions +--FILE-- +?php + +function *gen() { +var_dump(func_get_args()); +} + +$gen = gen(foo, bar); +$gen-rewind(); + +? +--EXPECT-- +array(2) { + [0]= + string(3) foo + [1]= + string(3) bar +} -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Implement get_iterator: Zend/zend_generators.c
Commit:04e781f0e4a4ea879c5e85b8d209b9b44cc32f8d Author:Nikita Popov ni...@php.net Sat, 23 Jun 2012 01:28:16 +0200 Parents: 1d3f37ddedc931d700a4e1135f63e094df88dbc4 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=04e781f0e4a4ea879c5e85b8d209b9b44cc32f8d Log: Implement get_iterator This implements the get_iterator handler for Generator objects, thus making direct foreach() iteration significantly faster. Changed paths: M Zend/zend_generators.c Diff: diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index b7538e7..10d91f5 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -564,6 +564,114 @@ ZEND_METHOD(Generator, close) } /* }}} */ +/* get_iterator implementation */ + +typedef struct _zend_generator_iterator { + zend_object_iterator intern; + zend_generator *generator; +} zend_generator_iterator; + +static void zend_generator_iterator_dtor(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ +{ + zval_ptr_dtor((zval **) iterator-data); + efree(iterator); +} +/* }}} */ + +static int zend_generator_iterator_valid(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ +{ + zval *object = (zval *) iterator-data; + zend_generator *generator = ((zend_generator_iterator *) iterator)-generator; + + zend_generator_ensure_initialized(object, generator TSRMLS_CC); + + return generator-value != NULL ? SUCCESS : FAILURE; +} +/* }}} */ + +static void zend_generator_iterator_get_data(zend_object_iterator *iterator, zval ***data TSRMLS_DC) /* {{{ */ +{ + zval *object = (zval *) iterator-data; + zend_generator *generator = ((zend_generator_iterator *) iterator)-generator; + + zend_generator_ensure_initialized(object, generator TSRMLS_CC); + + if (generator-value) { + *data = generator-value; + } else { + *data = NULL; + } +} +/* }}} */ + +static int zend_generator_iterator_get_key(zend_object_iterator *iterator, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) /* {{{ */ +{ + zval *object = (zval *) iterator-data; + zend_generator *generator = ((zend_generator_iterator *) iterator)-generator; + + zend_generator_ensure_initialized(object, generator TSRMLS_CC); + + if (!generator-key) { + return HASH_KEY_NON_EXISTANT; + } + + if (Z_TYPE_P(generator-key) == IS_LONG) { + *int_key = Z_LVAL_P(generator-key); + return HASH_KEY_IS_LONG; + } + + if (Z_TYPE_P(generator-key) == IS_STRING) { + *str_key = estrndup(Z_STRVAL_P(generator-key), Z_STRLEN_P(generator-key)); + *str_key_len = Z_STRLEN_P(generator-key) + 1; + return HASH_KEY_IS_STRING; + } + + /* Waiting for Etienne's patch to allow arbitrary zval keys. Until then +* error out on non-int and non-string keys. */ + zend_error(E_ERROR, Currently only int and string keys can be yielded); +} +/* }}} */ + +static void zend_generator_iterator_move_forward(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */ +{ + zval *object = (zval *) iterator-data; + zend_generator *generator = ((zend_generator_iterator *) iterator)-generator; + + zend_generator_ensure_initialized(object, generator TSRMLS_CC); + + zend_generator_resume(object, generator TSRMLS_CC); +} +/* }}} */ + +static zend_object_iterator_funcs zend_generator_iterator_functions = { + zend_generator_iterator_dtor, + zend_generator_iterator_valid, + zend_generator_iterator_get_data, + zend_generator_iterator_get_key, + zend_generator_iterator_move_forward, + NULL +}; + +zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */ +{ + zend_generator_iterator *iterator; + + if (by_ref) { + zend_error(E_ERROR, By reference iteration of generators is currently not supported); + } + + iterator = emalloc(sizeof(zend_generator_iterator)); + iterator-intern.funcs = zend_generator_iterator_functions; + + Z_ADDREF_P(object); + iterator-intern.data = (void *) object; + + iterator-generator = zend_object_store_get_object(object TSRMLS_CC); + + return (zend_object_iterator *) iterator; +} +/* }}} */ + ZEND_BEGIN_ARG_INFO(arginfo_generator_void, 0) ZEND_END_ARG_INFO() @@ -590,6 +698,7 @@ void zend_register_generator_ce(TSRMLS_D) /* {{{ */ zend_ce_generator = zend_register_internal_class(ce TSRMLS_CC); zend_ce_generator-ce_flags |= ZEND_ACC_FINAL_CLASS; zend_ce_generator-create_object = zend_generator_create; + zend_ce_generator-get_iterator = zend_generator_get_iterator; zend_class_implements(zend_ce_generator TSRMLS_CC, 1, zend_ce_iterator); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Disallow closing a generator during its execution: Zend/zend_generators.c Zend/zend_generators.h
Commit:ab75ed6ba9b5eace710976bf76d631728d4bb403 Author:Nikita Popov ni...@php.net Sat, 23 Jun 2012 16:08:15 +0200 Parents: 14766e1417c721d9643f6a2a785db3e88b565814 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ab75ed6ba9b5eace710976bf76d631728d4bb403 Log: Disallow closing a generator during its execution If a generator is closed while it is running an E_WARNING is thrown and the call is ignored. Maybe a fatal error should be thrown instead? Changed paths: M Zend/zend_generators.c M Zend/zend_generators.h Diff: diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 487975e..bccbb48 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -300,6 +300,8 @@ static zend_object_value zend_generator_create(zend_class_entry *class_type TSRM /* The key will be incremented on first use, so it'll start at 0 */ generator-largest_used_integer_key = -1; + generator-is_currently_running = 0; + zend_object_std_init(generator-std, class_type TSRMLS_CC); object.handle = zend_objects_store_put(generator, NULL, @@ -339,6 +341,8 @@ static void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ zend_class_entry *original_scope = EG(scope); zend_class_entry *original_called_scope = EG(called_scope); + zend_bool original_is_currently_running = generator-is_currently_running; + /* Remember the current stack position so we can back up pushed args */ generator-original_stack_top = zend_vm_stack_top(TSRMLS_C); @@ -363,6 +367,8 @@ static void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ EG(scope) = generator-execute_data-current_scope; EG(called_scope) = generator-execute_data-current_called_scope; + generator-is_currently_running = 1; + /* We want the backtrace to look as if the generator function was * called from whatever method we are current running (e.g. next()). * The first prev_execute_data contains an additional stack frame, @@ -387,6 +393,8 @@ static void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ EG(scope) = original_scope; EG(called_scope) = original_called_scope; + generator-is_currently_running = original_is_currently_running; + /* The stack top before and after the execution differ, i.e. there are * arguments pushed to the stack. */ if (generator-original_stack_top != zend_vm_stack_top(TSRMLS_C)) { @@ -549,6 +557,11 @@ ZEND_METHOD(Generator, close) generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); + if (generator-is_currently_running) { + zend_error(E_WARNING, A generator cannot be closed while it is running); + return; + } + zend_generator_close(generator, 0 TSRMLS_CC); } /* }}} */ diff --git a/Zend/zend_generators.h b/Zend/zend_generators.h index 89193bb..73d85287 100644 --- a/Zend/zend_generators.h +++ b/Zend/zend_generators.h @@ -46,6 +46,10 @@ typedef struct _zend_generator { temp_variable *send_target; /* Largest used integer key for auto-incrementing keys */ long largest_used_integer_key; + + /* We need to know whether the generator is currently executed to avoid it +* being closed while still running */ + zend_bool is_currently_running; } zend_generator; extern ZEND_API zend_class_entry *zend_ce_generator; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] com php-src: Pass zend_generator directly to Zend VM: Zend/zend_generators.c Zend/zend_vm_def.h Zend/zend_vm_execute.h
Commit:14766e1417c721d9643f6a2a785db3e88b565814 Author:Nikita Popov ni...@php.net Sat, 23 Jun 2012 14:43:52 +0200 Parents: 04e781f0e4a4ea879c5e85b8d209b9b44cc32f8d Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=14766e1417c721d9643f6a2a785db3e88b565814 Log: Pass zend_generator directly to Zend VM Previously the zval* of the generator was passed into the VM by misusing EG(return_value_ptr_ptr). Now the zend_generator* itself is directly passed in. This saves us from always having to pass the zval* around everywhere. Changed paths: M Zend/zend_generators.c M Zend/zend_vm_def.h M Zend/zend_vm_execute.h diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 10d91f5..487975e 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -321,7 +321,7 @@ static zend_function *zend_generator_get_constructor(zval *object TSRMLS_DC) /* } /* }}} */ -static void zend_generator_resume(zval *object, zend_generator *generator TSRMLS_DC) /* {{{ */ +static void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{ */ { /* The generator is already closed, thus can't resume */ if (!generator-execute_data) { @@ -352,7 +352,7 @@ static void zend_generator_resume(zval *object, zend_generator *generator TSRMLS /* We (mis)use the return_value_ptr_ptr to provide the generator object * to the executor, so YIELD will be able to set the yielded value */ - EG(return_value_ptr_ptr) = object; + EG(return_value_ptr_ptr) = (zval **) generator; /* Set executor globals */ EG(current_execute_data) = generator-execute_data; @@ -399,10 +399,10 @@ static void zend_generator_resume(zval *object, zend_generator *generator TSRMLS } /* }}} */ -static void zend_generator_ensure_initialized(zval *object, zend_generator *generator TSRMLS_DC) /* {{{ */ +static void zend_generator_ensure_initialized(zend_generator *generator TSRMLS_DC) /* {{{ */ { if (!generator-value) { - zend_generator_resume(object, generator TSRMLS_CC); + zend_generator_resume(generator TSRMLS_CC); } } /* }}} */ @@ -411,17 +411,15 @@ static void zend_generator_ensure_initialized(zval *object, zend_generator *gene * Rewind the generator */ ZEND_METHOD(Generator, rewind) { - zval *object; zend_generator *generator; if (zend_parse_parameters_none() == FAILURE) { return; } - object = getThis(); - generator = (zend_generator *) zend_object_store_get_object(object TSRMLS_CC); + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); - zend_generator_ensure_initialized(object, generator TSRMLS_CC); + zend_generator_ensure_initialized(generator TSRMLS_CC); /* Generators aren't rewindable, so rewind() only has to make sure that * the generator is initialized, nothing more */ @@ -432,17 +430,15 @@ ZEND_METHOD(Generator, rewind) * Check whether the generator is valid */ ZEND_METHOD(Generator, valid) { - zval *object; zend_generator *generator; if (zend_parse_parameters_none() == FAILURE) { return; } - object = getThis(); - generator = (zend_generator *) zend_object_store_get_object(object TSRMLS_CC); + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); - zend_generator_ensure_initialized(object, generator TSRMLS_CC); + zend_generator_ensure_initialized(generator TSRMLS_CC); RETURN_BOOL(generator-value != NULL); } @@ -452,17 +448,15 @@ ZEND_METHOD(Generator, valid) * Get the current value */ ZEND_METHOD(Generator, current) { - zval *object; zend_generator *generator; if (zend_parse_parameters_none() == FAILURE) { return; } - object = getThis(); - generator = (zend_generator *) zend_object_store_get_object(object TSRMLS_CC); + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); - zend_generator_ensure_initialized(object, generator TSRMLS_CC); + zend_generator_ensure_initialized(generator TSRMLS_CC); if (generator-value) { RETURN_ZVAL(generator-value, 1, 0); @@ -474,17 +468,15 @@ ZEND_METHOD(Generator, current) * Get the current key */ ZEND_METHOD(Generator, key) { - zval *object; zend_generator *generator; if (zend_parse_parameters_none() == FAILURE) { return; } - object = getThis(); - generator = (zend_generator *) zend_object_store_get_object(object TSRMLS_CC); + generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); - zend_generator_ensure_initialized(object, generator TSRMLS_CC); +
[PHP-CVS] com php-src: Add sceleton for yield* expression: Zend/tests/generators/errors/yield_in_normal_function_error.phpt Zend/tests/generators/errors/yield_outside_function_error.phpt Zend/zend_com
Commit:d939d2dee58bf894ae9af631bdee173243157068 Author:Nikita Popov ni...@php.net Mon, 11 Jun 2012 23:59:46 +0200 Parents: f169b26dd7a4047996ab1284e649fda0cfb1a10b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d939d2dee58bf894ae9af631bdee173243157068 Log: Add sceleton for yield* expression This does not yet actually implement any delegation. Changed paths: M Zend/tests/generators/errors/yield_in_normal_function_error.phpt M Zend/tests/generators/errors/yield_outside_function_error.phpt M Zend/zend_compile.c M Zend/zend_compile.h M Zend/zend_generators.c M Zend/zend_language_parser.y M Zend/zend_language_scanner.c M Zend/zend_language_scanner_defs.h M Zend/zend_vm_def.h M Zend/zend_vm_execute.h M Zend/zend_vm_opcodes.h diff --git a/Zend/tests/generators/errors/yield_in_normal_function_error.phpt b/Zend/tests/generators/errors/yield_in_normal_function_error.phpt index 802510d..4670a41 100644 --- a/Zend/tests/generators/errors/yield_in_normal_function_error.phpt +++ b/Zend/tests/generators/errors/yield_in_normal_function_error.phpt @@ -9,4 +9,4 @@ function foo() { ? --EXPECTF-- -Fatal error: The yield statement can only be used inside a generator function in %s on line %d +Fatal error: The yield expression can only be used inside a generator function in %s on line %d diff --git a/Zend/tests/generators/errors/yield_outside_function_error.phpt b/Zend/tests/generators/errors/yield_outside_function_error.phpt index fd7169d..5f47e75 100644 --- a/Zend/tests/generators/errors/yield_outside_function_error.phpt +++ b/Zend/tests/generators/errors/yield_outside_function_error.phpt @@ -7,4 +7,4 @@ yield Test; ? --EXPECTF-- -Fatal error: The yield statement can only be used inside a generator function in %s on line %d +Fatal error: The yield expression can only be used inside a generator function in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index da61b76..35ff2bb 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2667,7 +2667,7 @@ void zend_do_yield(znode *result, const znode *value, const znode *key TSRMLS_DC zend_op *opline; if ((CG(active_op_array)-fn_flags ZEND_ACC_GENERATOR) == 0) { - zend_error(E_COMPILE_ERROR, The \yield\ statement can only be used inside a generator function); + zend_error(E_COMPILE_ERROR, The \yield\ expression can only be used inside a generator function); } opline = get_next_op(CG(active_op_array) TSRMLS_CC); @@ -2692,6 +2692,27 @@ void zend_do_yield(znode *result, const znode *value, const znode *key TSRMLS_DC } /* }}} */ +void zend_do_delegate_yield(znode *result, const znode *value TSRMLS_DC) /* {{{ */ +{ + zend_op *opline; + + if ((CG(active_op_array)-fn_flags ZEND_ACC_GENERATOR) == 0) { + zend_error(E_COMPILE_ERROR, The \yield*\ expression can only be used inside a generator function); + } + + opline = get_next_op(CG(active_op_array) TSRMLS_CC); + + opline-opcode = ZEND_DELEGATE_YIELD; + + SET_NODE(opline-op1, value); + SET_UNUSED(opline-op2); + + opline-result_type = IS_VAR; + opline-result.var = get_temporary_variable(CG(active_op_array)); + GET_NODE(result, opline-result); +} +/* }}} */ + void zend_do_suspend_if_generator(TSRMLS_D) /* {{{ */ { zend_op *opline; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index ec86ed8..d0587d1 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -491,6 +491,7 @@ int zend_do_begin_class_member_function_call(znode *class_name, znode *method_na void zend_do_end_function_call(znode *function_name, znode *result, const znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC); void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC); void zend_do_yield(znode *result, const znode *value, const znode *key TSRMLS_DC); +void zend_do_delegate_yield(znode *result, const znode *value TSRMLS_DC); void zend_do_suspend_if_generator(TSRMLS_D); void zend_do_handle_exception(TSRMLS_D); diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 6efa710..f8374b8 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -245,7 +245,7 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator ** } /* Update the send_target to use the temporary variable with the same -* offset as the original generator, but in out temporary variable +* offset as the original generator, but in our temporary variable * memory segment. */ if (orig-send_target) { size_t offset = (char *) orig-send_target - (char *) execute_data-Ts; @@ -536,7 +536,6 @@ ZEND_METHOD(Generator, send) /* The sent value was initialized to NULL, so dtor that */
[PHP-CVS] com php-src: Fix thread safe build: Zend/zend_execute.c Zend/zend_execute.h Zend/zend_generators.c Zend/zend_vm_def.h Zend/zend_vm_execute.h
Commit:6233408a2a51389a2bbd250c5900d395648e897f Author:Nikita Popov ni...@php.net Wed, 20 Jun 2012 21:31:23 +0200 Parents: d939d2dee58bf894ae9af631bdee173243157068 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6233408a2a51389a2bbd250c5900d395648e897f Log: Fix thread safe build Changed paths: M Zend/zend_execute.c M Zend/zend_execute.h M Zend/zend_generators.c M Zend/zend_vm_def.h M Zend/zend_vm_execute.h Diff: diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index c7ef212..0e40650 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1538,7 +1538,7 @@ ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const t return get_zval_ptr_ptr(op_type, node, Ts, should_free, type); } -void zend_clean_and_cache_symbol_table(HashTable *symbol_table) /* {{{ */ +void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) /* {{{ */ { if (EG(symtable_cache_ptr) = EG(symtable_cache_limit)) { zend_hash_destroy(symbol_table); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 48f46bb..92160b5 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -432,7 +432,7 @@ ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const t ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS); -void zend_clean_and_cache_symbol_table(HashTable *symbol_table); +void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC); void zend_free_compiled_variables(zval ***CVs, int num); void **zend_copy_arguments(void **arguments_end); diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index f8374b8..b7538e7 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -34,7 +34,7 @@ void zend_generator_close(zend_generator *generator, zend_bool finished_executio if (!execute_data-symbol_table) { zend_free_compiled_variables(execute_data-CVs, execute_data-op_array-last_var); } else { - zend_clean_and_cache_symbol_table(execute_data-symbol_table); + zend_clean_and_cache_symbol_table(execute_data-symbol_table TSRMLS_CC); } if (execute_data-current_this) { @@ -560,7 +560,7 @@ ZEND_METHOD(Generator, close) generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC); - zend_generator_close(generator, 0); + zend_generator_close(generator, 0 TSRMLS_CC); } /* }}} */ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index e5d8a76..fea1f40 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2572,7 +2572,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY) EG(active_op_array) = EX(op_array); EG(return_value_ptr_ptr) = EX(original_return_value); if (EG(active_symbol_table)) { - zend_clean_and_cache_symbol_table(EG(active_symbol_table)); + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } EG(active_symbol_table) = EX(symbol_table); @@ -2717,7 +2717,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY) EG(active_op_array) = EX(op_array); EG(return_value_ptr_ptr) = EX(original_return_value); if (EG(active_symbol_table)) { - zend_clean_and_cache_symbol_table(EG(active_symbol_table)); + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } EG(active_symbol_table) = EX(symbol_table); } else { /* ZEND_OVERLOADED_FUNCTION */ @@ -5265,7 +5265,7 @@ ZEND_VM_HANDLER(159, ZEND_SUSPEND_AND_RETURN_GENERATOR, ANY, ANY) if (!EG(active_symbol_table)) { zend_free_compiled_variables(EX_CVs(), execute_data-op_array-last_var); } else { - zend_clean_and_cache_symbol_table(EG(active_symbol_table)); + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); } efree(execute_data); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 6f1a885..0f965c5 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -556,7 +556,7 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS) EG(active_op_array) = EX(op_array); EG(return_value_ptr_ptr) = EX(original_return_value); if (EG(active_symbol_table)) { - zend_clean_and_cache_symbol_table(EG(active_symbol_table)); + zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC); }
[PHP-CVS] com php-src: Fix backtraces and func_get_args(): Zend/tests/generators/backtrace.phpt Zend/zend_execute.c Zend/zend_execute.h Zend/zend_generators.c Zend/zend_vm_def.h Zend/zend_vm_execute.h
Commit:f169b26dd7a4047996ab1284e649fda0cfb1a10b Author:Nikita Popov ni...@php.net Sat, 9 Jun 2012 00:40:47 +0200 Parents: 40760ecb90d1b024c76862e33d13d40137650af7 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f169b26dd7a4047996ab1284e649fda0cfb1a10b Log: Fix backtraces and func_get_args() To make the generator function show up in backtraces one has to insert an additional execute_data into the chain, as prev_execute_data-function_state is used to determine the called function. Adding the additional stack frame is also required for func_get_args(), as the arguments are fetched from there too. The arguments have to be copied in order to keep them around. Due to the way they are saved doing so is quite ugly, so I added another function zend_copy_arguments to zend_execute.c which handles this. Changed paths: M Zend/tests/generators/backtrace.phpt M Zend/zend_execute.c M Zend/zend_execute.h M Zend/zend_generators.c M Zend/zend_vm_def.h M Zend/zend_vm_execute.h diff --git a/Zend/tests/generators/backtrace.phpt b/Zend/tests/generators/backtrace.phpt index cbf8de1..77976f9 100644 --- a/Zend/tests/generators/backtrace.phpt +++ b/Zend/tests/generators/backtrace.phpt @@ -7,7 +7,7 @@ function f1() { debug_print_backtrace(); } -function *f2() { +function *f2($arg1, $arg2) { f1(); } @@ -15,11 +15,12 @@ function f3($gen) { $gen-rewind(); // trigger run } -$gen = f2(); +$gen = f2('foo', 'bar'); f3($gen); ? --EXPECTF-- #0 f1() called at [%s:%d] -#1 Generator-rewind() called at [%s:%d] -#2 f3(Generator Object ()) called at [%s:%d] +#1 f2(foo, bar) called at [%s:%d] +#2 Generator-rewind() called at [%s:%d] +#3 f3(Generator Object ()) called at [%s:%d] diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 9031fb5..c7ef212 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1563,6 +1563,25 @@ void zend_free_compiled_variables(zval ***CVs, int num) /* {{{ */ } /* }}} */ +void** zend_copy_arguments(void **arguments_end) /* {{{ */ +{ + int arguments_count = (int) (zend_uintptr_t) *arguments_end; + size_t arguments_size = (arguments_count + 1) * sizeof(void **); + void **arguments_start = arguments_end - arguments_count; + void **copied_arguments_start = emalloc(arguments_size); + void **copied_arguments_end = copied_arguments_start + arguments_count; + int i; + + memcpy(copied_arguments_start, arguments_start, arguments_size); + + for (i = 0; i arguments_count; i++) { + Z_ADDREF_P((zval *) arguments_start[i]); + } + + return copied_arguments_end; +} +/* }}} */ + /* * Local variables: * tab-width: 4 diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 6dfd607..48f46bb 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -434,6 +434,7 @@ ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS); void zend_clean_and_cache_symbol_table(HashTable *symbol_table); void zend_free_compiled_variables(zval ***CVs, int num); +void **zend_copy_arguments(void **arguments_end); #define CACHED_PTR(num) \ EG(active_op_array)-run_time_cache[(num)] diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index b5642dd..6efa710 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -94,6 +94,28 @@ void zend_generator_close(zend_generator *generator, zend_bool finished_executio efree(generator-backed_up_stack); } + /* We have added an additional stack frame in prev_execute_data, so we +* have to free it. It also contains the arguments passed to the +* generator (for func_get_args) so those have to be freed too. */ + { + zend_execute_data *prev_execute_data = execute_data-prev_execute_data; + void **arguments = prev_execute_data-function_state.arguments; + + if (arguments) { + int arguments_count = (int) (zend_uintptr_t) *arguments; + zval **arguments_start = (zval **) (arguments - arguments_count); + int i; + + for (i = 0; i arguments_count; ++i) { + zval_ptr_dtor(arguments_start + i); + } + + efree(arguments_start); + } + + efree(prev_execute_data); + } + efree(execute_data); generator-execute_data = NULL; } @@ -240,6 +262,18 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator ** if (execute_data-object) { Z_ADDREF_P(execute_data-object); } + + /* Prev execute data contains an additional stack frame (for proper)