[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c

2011-10-18 Thread Rui Hirokawa
hirokawa Tue, 18 Oct 2011 14:03:44 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318183

Log:
fixed byte length of utf-8.

Changed paths:
U   php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c

Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c
===
--- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c  
2011-10-18 11:38:47 UTC (rev 318182)
+++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c  
2011-10-18 14:03:44 UTC (rev 318183)
@@ -52,7 +52,7 @@
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-   4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1
+   4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
 };

 static const char *mbfl_encoding_utf8_aliases[] = {utf8, NULL};

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c

2011-10-18 Thread Rui Hirokawa
hirokawa Tue, 18 Oct 2011 14:04:13 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318184

Log:
MFH: fixed byte length of utf-8.

Changed paths:
U   
php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c

Modified: 
php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c
===
--- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c   
2011-10-18 14:03:44 UTC (rev 318183)
+++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c   
2011-10-18 14:04:13 UTC (rev 318184)
@@ -52,7 +52,7 @@
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-   4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1
+   4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
 };

 static const char *mbfl_encoding_utf8_aliases[] = {utf8, NULL};

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/ext/mysqlnd/ mysqlnd.c

2011-10-18 Thread Andrey Hristov
andrey   Tue, 18 Oct 2011 14:10:44 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318185

Log:
move change_user closer to connect

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c	2011-10-18 14:04:13 UTC (rev 318184)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c	2011-10-18 14:10:44 UTC (rev 318185)
@@ -886,6 +886,144 @@
 /* }}} */


+/* {{{ mysqlnd_conn::change_user */
+static enum_func_status
+MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
+		  const char *user,
+		  const char *passwd,
+		  const char *db,
+		  zend_bool silent TSRMLS_DC)
+{
+	size_t user_len;
+	enum_func_status ret = FAIL;
+	MYSQLND_PACKET_CHG_USER_RESPONSE * chg_user_resp;
+	char buffer[MYSQLND_MAX_ALLOWED_USER_LEN + 1 + 1 + SCRAMBLE_LENGTH + MYSQLND_MAX_ALLOWED_DB_LEN + 1 + 2 /* charset*/ + 2];
+	char *p = buffer;
+	const MYSQLND_CHARSET * old_cs = conn-charset;
+
+	DBG_ENTER(mysqlnd_conn::change_user);
+	DBG_INF_FMT(conn=%llu user=%s passwd=%s db=%s silent=%u,
+conn-thread_id, user?user:, passwd?***:null, db?db:, (silent == TRUE)?1:0 );
+
+	SET_ERROR_AFF_ROWS(conn);
+
+	if (!user) {
+		user = ;
+	}
+	if (!passwd) {
+		passwd = ;
+	}
+	if (!db) {
+		db = ;
+	}
+
+	/* 1. user ASCIIZ */
+	user_len = MIN(strlen(user), MYSQLND_MAX_ALLOWED_USER_LEN);
+	memcpy(p, user, user_len);
+	p += user_len;
+	*p++ = '\0';
+
+	/* 2. password SCRAMBLE_LENGTH followed by the scramble or \0 */
+	if (passwd[0]) {
+		*p++ = SCRAMBLE_LENGTH;
+		php_mysqlnd_scramble((unsigned char *)p, conn-scramble, (unsigned char *)passwd);
+		p += SCRAMBLE_LENGTH;
+	} else {
+		*p++ = '\0';
+	}
+
+	/* 3. db ASCIIZ */
+	if (db[0]) {
+		size_t db_len = MIN(strlen(db), MYSQLND_MAX_ALLOWED_DB_LEN);
+		memcpy(p, db, db_len);
+		p += db_len;
+	}
+	*p++ = '\0';
+
+	/*
+	  4. request the current charset, or it will be reset to the system one.
+	  5.0 doesn't support it. Support added in 5.1.23 by fixing the following bug :
+	  Bug #30472 libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call
+	*/
+	if (mysqlnd_get_server_version(conn) = 50123) {
+		int2store(p, conn-charset-nr);
+		p+=2;
+	}
+
+	if (PASS != conn-m-simple_command(conn, COM_CHANGE_USER, buffer, p - buffer,
+	   PROT_LAST /* we will handle the OK packet*/,
+	   silent, TRUE TSRMLS_CC)) {
+		DBG_RETURN(FAIL);
+	}
+
+	chg_user_resp = conn-protocol-m.get_change_user_response_packet(conn-protocol, FALSE TSRMLS_CC);
+	if (!chg_user_resp) {
+		SET_OOM_ERROR(conn-error_info);
+		goto end;
+	}
+	ret = PACKET_READ(chg_user_resp, conn);
+	conn-error_info = chg_user_resp-error_info;
+
+	if (conn-error_info.error_no) {
+		ret = FAIL;
+		/*
+		  COM_CHANGE_USER is broken in 5.1. At least in 5.1.15 and 5.1.14, 5.1.11 is immune.
+		  bug#25371 mysql_change_user() triggers packets out of sync
+		  When it gets fixed, there should be one more check here
+		*/
+		if (mysqlnd_get_server_version(conn)  50113L  mysqlnd_get_server_version(conn)  50118L) {
+			MYSQLND_PACKET_OK * redundant_error_packet = conn-protocol-m.get_ok_packet(conn-protocol, FALSE TSRMLS_CC);
+			if (redundant_error_packet) {
+PACKET_READ(redundant_error_packet, conn);
+PACKET_FREE(redundant_error_packet);
+DBG_INF_FMT(Server is %u, buggy, sends two ERR messages, mysqlnd_get_server_version(conn));
+			} else {
+SET_OOM_ERROR(conn-error_info);
+			}
+		}
+	}
+	if (ret == PASS) {
+		char * tmp = NULL;
+		/* if we get conn-user as parameter and then we first free it, then estrndup it, we will crash */
+		tmp = mnd_pestrndup(user, user_len, conn-persistent);
+		if (conn-user) {
+			mnd_pefree(conn-user, conn-persistent);
+		}
+		conn-user = tmp;
+
+		tmp = mnd_pestrdup(passwd, conn-persistent);
+		if (conn-passwd) {
+			mnd_pefree(conn-passwd, conn-persistent);
+		}
+		conn-passwd = tmp;
+
+		if (conn-last_message) {
+			mnd_pefree(conn-last_message, conn-persistent);
+			conn-last_message = NULL;
+		}
+		memset(conn-upsert_status, 0, sizeof(conn-upsert_status));
+		/* set charset for old servers */
+		if (mysqlnd_get_server_version(conn)  50123) {
+			ret = conn-m-set_charset(conn, old_cs-name TSRMLS_CC);
+		}
+	} else if (ret == FAIL  chg_user_resp-server_asked_323_auth == TRUE) {
+		/* old authentication with new server  !*/
+		DBG_ERR(mysqlnd_old_passwd);
+		SET_CLIENT_ERROR(conn-error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd);
+	}
+end:
+	PACKET_FREE(chg_user_resp);
+
+	/*
+	  Here we should close all statements. Unbuffered queries should not be a
+	  problem as we won't allow sending COM_CHANGE_USER.
+	*/
+	DBG_INF(ret == PASS? PASS:FAIL);
+	DBG_RETURN(ret);
+}
+/* }}} */
+
+
 /* {{{ mysqlnd_conn::query */
 /*
   If conn-error_info.error_no is not zero, then we had an 

[PHP-CVS] svn: /php/php-src/trunk/ext/mysqlnd/ mysqlnd_charset.c

2011-10-18 Thread Rui Hirokawa
hirokawa Tue, 18 Oct 2011 14:28:01 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318186

Log:
fixed maximum byte length of utf8mb4.

Changed paths:
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_charset.c

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_charset.c
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_charset.c 2011-10-18 14:10:44 UTC 
(rev 318185)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_charset.c 2011-10-18 14:28:01 UTC 
(rev 318186)
@@ -495,8 +495,8 @@
{  42, latin7, latin7_general_cs, 1, 1, , NULL, NULL},
{  43, macce, macce_bin, 1, 1, , NULL, NULL},
{  44, cp1250, cp1250_croatian_ci, 1, 1, , NULL, NULL},
-   {  45, UTF8_MB4, UTF8_MB4_general_ci, 1, 3, UTF-8 Unicode, 
mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
-   {  46, UTF8_MB4, UTF8_MB4_bin, 1, 3, UTF-8 Unicode, 
mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
+   {  45, UTF8_MB4, UTF8_MB4_general_ci, 1, 4, UTF-8 Unicode, 
mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
+   {  46, UTF8_MB4, UTF8_MB4_bin, 1, 4, UTF-8 Unicode, 
mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
{  47, latin1, latin1_bin, 1, 1, , NULL, NULL},
{  48, latin1, latin1_general_ci, 1, 1, , NULL, NULL},
{  49, latin1, latin1_general_cs, 1, 1, , NULL, NULL},

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mysqlnd/ mysqlnd_charset.c

2011-10-18 Thread Rui Hirokawa
hirokawa Tue, 18 Oct 2011 14:28:21 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318187

Log:
fixed maximum byte length of utf8mb4.

Changed paths:
U   php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_charset.c

Modified: php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_charset.c
===
--- php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_charset.c  2011-10-18 
14:28:01 UTC (rev 318186)
+++ php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd_charset.c  2011-10-18 
14:28:21 UTC (rev 318187)
@@ -495,8 +495,8 @@
{  42, latin7, latin7_general_cs, 1, 1, , NULL, NULL},
{  43, macce, macce_bin, 1, 1, , NULL, NULL},
{  44, cp1250, cp1250_croatian_ci, 1, 1, , NULL, NULL},
-   {  45, UTF8_MB4, UTF8_MB4_general_ci, 1, 3, UTF-8 Unicode, 
mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
-   {  46, UTF8_MB4, UTF8_MB4_bin, 1, 3, UTF-8 Unicode, 
mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
+   {  45, UTF8_MB4, UTF8_MB4_general_ci, 1, 4, UTF-8 Unicode, 
mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
+   {  46, UTF8_MB4, UTF8_MB4_bin, 1, 4, UTF-8 Unicode, 
mysqlnd_mbcharlen_utf8,  check_mb_utf8_valid},
{  47, latin1, latin1_bin, 1, 1, , NULL, NULL},
{  48, latin1, latin1_general_ci, 1, 1, , NULL, NULL},
{  49, latin1, latin1_general_cs, 1, 1, , NULL, NULL},

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_4/NEWS branches/PHP_5_4/Zend/micro_bench.php branches/PHP_5_4/Zend/zend_compile.c branches/PHP_5_4/Zend/zend_execute_API.c branches/PHP_5_4/Zend/zend_opcode

2011-10-18 Thread Arnaud Le Blanc
lbarnaud Tue, 18 Oct 2011 19:42:42 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318191

Log:
Improved ternary operator performance when returning arrays

Changed paths:
U   php/php-src/branches/PHP_5_4/NEWS
U   php/php-src/branches/PHP_5_4/Zend/micro_bench.php
U   php/php-src/branches/PHP_5_4/Zend/zend_compile.c
U   php/php-src/branches/PHP_5_4/Zend/zend_execute_API.c
U   php/php-src/branches/PHP_5_4/Zend/zend_opcode.c
U   php/php-src/branches/PHP_5_4/Zend/zend_vm_def.h
U   php/php-src/branches/PHP_5_4/Zend/zend_vm_execute.h
U   php/php-src/branches/PHP_5_4/Zend/zend_vm_opcodes.h
U   php/php-src/trunk/Zend/micro_bench.php
U   php/php-src/trunk/Zend/zend_compile.c
U   php/php-src/trunk/Zend/zend_execute_API.c
U   php/php-src/trunk/Zend/zend_opcode.c
U   php/php-src/trunk/Zend/zend_vm_def.h
U   php/php-src/trunk/Zend/zend_vm_execute.h
U   php/php-src/trunk/Zend/zend_vm_opcodes.h

Modified: php/php-src/branches/PHP_5_4/NEWS
===
--- php/php-src/branches/PHP_5_4/NEWS	2011-10-18 14:54:32 UTC (rev 318190)
+++ php/php-src/branches/PHP_5_4/NEWS	2011-10-18 19:42:42 UTC (rev 318191)
@@ -3,6 +3,7 @@
 ?? ??? 2011, PHP 5.4.0 RC1
 - General improvements:
   . Improve the warning message of incompatible arguments. (Laruence)
+  . Improve ternary operator performance when returning arrays. (Arnaud, Dmitry)


 - Core:

Modified: php/php-src/branches/PHP_5_4/Zend/micro_bench.php
===
--- php/php-src/branches/PHP_5_4/Zend/micro_bench.php	2011-10-18 14:54:32 UTC (rev 318190)
+++ php/php-src/branches/PHP_5_4/Zend/micro_bench.php	2011-10-18 19:42:42 UTC (rev 318191)
@@ -202,6 +202,35 @@
 	}
 }

+function issetor($n) {
+	$val = array(0,1,2,3,4,5,6,7,8,9);
+	for ($i = 0; $i  $n; ++$i) {
+		$x = $val ?: null;
+	}
+}
+
+function issetor2($n) {
+	$f = false; $j = 0;
+	for ($i = 0; $i  $n; ++$i) {
+		$x = $f ?: $j + 1;
+	}
+}
+
+function ternary($n) {
+	$val = array(0,1,2,3,4,5,6,7,8,9);
+	$f = false;
+	for ($i = 0; $i  $n; ++$i) {
+		$x = $f ? null : $val;
+	}
+}
+
+function ternary2($n) {
+	$f = false; $j = 0;
+	for ($i = 0; $i  $n; ++$i) {
+		$x = $f ? $f : $j + 1;
+	}
+}
+
 /*/

 function empty_loop($n) {
@@ -318,4 +347,12 @@
 $t = end_test($t, '$x = $hash[\'v\']', $overhead);
 read_str_offset(N);
 $t = end_test($t, '$x = $str[0]', $overhead);
+issetor(N);
+$t = end_test($t, '$x = $a ?: null', $overhead);
+issetor2(N);
+$t = end_test($t, '$x = $f ?: tmp', $overhead);
+ternary(N);
+$t = end_test($t, '$x = $f ? $f : $a', $overhead);
+ternary2(N);
+$t = end_test($t, '$x = $f ? $f : tmp', $overhead);
 total($t0, Total);

Modified: php/php-src/branches/PHP_5_4/Zend/zend_compile.c
===
--- php/php-src/branches/PHP_5_4/Zend/zend_compile.c	2011-10-18 14:54:32 UTC (rev 318190)
+++ php/php-src/branches/PHP_5_4/Zend/zend_compile.c	2011-10-18 19:42:42 UTC (rev 318191)
@@ -1469,7 +1469,8 @@
 			 opline-result.var == op1-u.op.var) {
 			if (opline-opcode == ZEND_FETCH_R ||
 			opline-opcode == ZEND_FETCH_DIM_R ||
-			opline-opcode == ZEND_FETCH_OBJ_R) {
+			opline-opcode == ZEND_FETCH_OBJ_R ||
+			opline-opcode == ZEND_QM_ASSIGN_VAR) {
 /* It's very rare and useless case. It's better to use
    additional FREE opcode and simplify the FETCH handlers
    their selves */
@@ -6308,8 +6309,13 @@
 	int op_number = get_next_op_number(CG(active_op_array));
 	zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);

-	opline-opcode = ZEND_JMP_SET;
-	opline-result_type = IS_TMP_VAR;
+	if (value-op_type == IS_VAR || value-op_type == IS_CV) {
+		opline-opcode = ZEND_JMP_SET_VAR;
+		opline-result_type = IS_VAR;
+	} else {
+		opline-opcode = ZEND_JMP_SET;
+		opline-result_type = IS_TMP_VAR;
+	}
 	opline-result.var = get_temporary_variable(CG(active_op_array));
 	SET_NODE(opline-op1, value);
 	SET_UNUSED(opline-op2);
@@ -6326,9 +6332,20 @@
 {
 	zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);

-	opline-opcode = ZEND_QM_ASSIGN;
+	SET_NODE(opline-result, colon_token);
+	if (colon_token-op_type == IS_TMP_VAR) {
+		if (false_value-op_type == IS_VAR || false_value-op_type == IS_CV) {
+			CG(active_op_array)-opcodes[jmp_token-u.op.opline_num].opcode = ZEND_JMP_SET_VAR;
+			CG(active_op_array)-opcodes[jmp_token-u.op.opline_num].result_type = IS_VAR;
+			opline-opcode = ZEND_QM_ASSIGN_VAR;
+			opline-result_type = IS_VAR;
+		} else {
+			opline-opcode = ZEND_QM_ASSIGN;
+		}
+	} else {
+		opline-opcode = ZEND_QM_ASSIGN_VAR;
+	}
 	opline-extended_value = 0;
-	SET_NODE(opline-result, colon_token);
 	SET_NODE(opline-op1, false_value);
 	SET_UNUSED(opline-op2);

@@ -6363,8 +6380,13 @@

 	CG(active_op_array)-opcodes[qm_token-u.op.opline_num].op2.opline_num = get_next_op_number(CG(active_op_array))+1; /* jmp over the ZEND_JMP 

[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/ext/spl/tests/ bug60082.phpt

2011-10-18 Thread Xinchen Hui
laruence Wed, 19 Oct 2011 02:28:53 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=318204

Log:
Test for #60082

Bug: https://bugs.php.net/60082 (Assigned) 100% CPU / when using references 
with ArrayObject($ref).
  
Changed paths:
A   php/php-src/branches/PHP_5_3/ext/spl/tests/bug60082.phpt

Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug60082.phpt
===
--- php/php-src/branches/PHP_5_3/ext/spl/tests/bug60082.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug60082.phpt2011-10-19 
02:28:53 UTC (rev 318204)
@@ -0,0 +1,14 @@
+--TEST--
+Bug #60082 (100% CPU / when using references with ArrayObject($ref))
+--FILE--
+?php
+$test = array();
+$test = new ArrayObject($test);
+$test['a'] = $test['b'];
+?
+===DONE===
+?php exit(0); ?
+--EXPECTF--
+Deprecated: Call-time pass-by-reference has been deprecated in %sbug60082.php 
on line %d
+
+Fatal error: main(): Array was modified outside object and made a recursive 
object in %sbug60082.php on line %d


Property changes on: php/php-src/branches/PHP_5_3/ext/spl/tests/bug60082.phpt
___
Added: svn:executable
   + *

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php