Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33666 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37531 invoked by uid 1010); 4 Dec 2007 18:12:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 37516 invoked from network); 4 Dec 2007 18:12:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2007 18:12:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:36627] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/E5-27173-87895574 for ; Tue, 04 Dec 2007 13:12:10 -0500 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id B2258C0EB98 for ; Tue, 4 Dec 2007 11:12:03 -0700 (MST) Received: from [192.168.0.106] (CPE-76-84-15-179.neb.res.rr.com [76.84.15.179]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 6FF27C0EB92 for ; Tue, 4 Dec 2007 11:12:03 -0700 (MST) Message-ID: <47559876.3060803@chiaraquartet.net> Date: Tue, 04 Dec 2007 12:12:06 -0600 User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 To: internals Mailing List X-Enigmail-Version: 0.95.0 Content-Type: multipart/mixed; boundary="------------070905050908060409090301" X-Virus-Scanned: ClamAV using ClamSMTP Subject: multiple namespace per file patch From: greg@chiaraquartet.net (Gregory Beaver) --------------070905050908060409090301 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, There's been enough confusion, here's the patch again, this time against 5.3, no tests for clarity http://pear.php.net/~greg/multi.5.3.patch.txt This patch allows: It doesn't allow: so all code must have a namespace declaration. The sole purpose is to combine files containing namespace declarations. Greg --------------070905050908060409090301 Content-Type: text/plain; name="multi.5.3.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="multi.5.3.patch.txt" Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.647.2.27.2.41.2.28 diff -u -r1.647.2.27.2.41.2.28 zend_compile.c --- Zend/zend_compile.c 4 Dec 2007 12:38:42 -0000 1.647.2.27.2.41.2.28 +++ Zend/zend_compile.c 4 Dec 2007 17:24:34 -0000 @@ -4722,13 +4722,10 @@ CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) { --num; } - if (num > 0) { + if (!CG(current_namespace) && num > 0) { zend_error(E_COMPILE_ERROR, "Namespace declaration statement has to be the very first statement in the script"); } } - if (CG(current_namespace)) { - zend_error(E_COMPILE_ERROR, "Namespace cannot be declared twice"); - } lcname = zend_str_tolower_dup(Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant)); if (((Z_STRLEN(name->u.constant) == sizeof("self")-1) && !memcmp(lcname, "self", sizeof("self")-1)) || @@ -4738,6 +4735,16 @@ } efree(lcname); + if (CG(current_namespace)) { + zval_dtor(CG(current_namespace)); + efree(CG(current_namespace)); + } + if (CG(current_import)) { + zend_hash_destroy(CG(current_import)); + efree(CG(current_import)); + } + CG(current_import) = NULL; + ALLOC_ZVAL(CG(current_namespace)); *CG(current_namespace) = name->u.constant; } --------------070905050908060409090301--