cvs: ZendEngine2 / zend_closures.c /tests closure_015.phpt

"Dmitry Stogov" <[email protected]>
Newsgroups gmane.comp.php.cvs.zend
Message-ID <cvsdmitry1215676548@cvsserver>
dmitry		Thu Jul 10 07:55:48 2008 UTC

  Added files:                 
    /ZendEngine2/tests	closure_015.phpt 

  Modified files:              
    /ZendEngine2	zend_closures.c 
  Log:
  Fixed unicode support
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_closures.c?r1=1.2&r2=1.3&diff_format=u
Index: ZendEngine2/zend_closures.c
diff -u ZendEngine2/zend_closures.c:1.2 ZendEngine2/zend_closures.c:1.3
--- ZendEngine2/zend_closures.c:1.2	Tue Jul  8 16:15:08 2008
+++ ZendEngine2/zend_closures.c	Thu Jul 10 07:55:48 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_closures.c,v 1.2 2008/07/08 16:15:08 dmitry Exp $ */
+/* $Id: zend_closures.c,v 1.3 2008/07/10 07:55:48 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -27,6 +27,7 @@
 #include "zend_globals.h"
 
 #define ZEND_INVOKE_FUNC_NAME "__invoke"
+#define ZEND_CLOSURE_PRINT_NAME "Closure object"
 
 typedef struct _zend_closure {
 	zend_object    std;
@@ -88,9 +89,12 @@
 
 	switch (type) {
 		case IS_STRING:
+			INIT_PZVAL(writeobj);
+			ZVAL_STRINGL(writeobj, ZEND_CLOSURE_PRINT_NAME, sizeof(ZEND_CLOSURE_PRINT_NAME)-1, 1);
+			return SUCCESS;
 		case IS_UNICODE:
 			INIT_PZVAL(writeobj);
-			ZVAL_ASCII_STRINGL(writeobj, "Closure object", sizeof("Closure object")-1, ZSTR_DUPLICATE);
+			ZVAL_UNICODEL(writeobj, USTR_MAKE(ZEND_CLOSURE_PRINT_NAME), sizeof(ZEND_CLOSURE_PRINT_NAME)-1, 0);
 			return SUCCESS;
 		default:
 			ce = Z_OBJCE_P(readobj);

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/closure_015.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/closure_015.phpt
+++ ZendEngine2/tests/closure_015.phpt
--TEST--
Closure 015: converting to string/unicode
--FILE--
<?php
$x = function() { return 1; };
print (string) $x;
print "\n";
print (unicode) $x;
print "\n";
print $x;
print "\n";
?>
--EXPECT--
Closure object
Closure object
Closure object



-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.