Re: HALT Patch

From: Date: Fri, 11 Mar 2005 20:22:56 +0000
Subject: Re: HALT Patch
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-15377@lists.php.net to get a copy of this message
We've been talking about this on IRC for awhile now and I think it's a nice patch to minimize memory usage when you want to create these sorts of "bundled" PHP/data hybrid scripts. John On Fri, 2005-03-11 at 14:36, Ilia Alshanetsky wrote: > The attach patch implements a special "token" <?php HALT; ?> that can be > used to stop the Zend lexical parser from parsing any data after this > token. > > The idea behind this patch is to allow tucking on of any data (binary > and otherwise) to the PHP script without having to encode it. It also > saves on memory/cpu that normally be used/needed to parse the data. > Memory is particularly important point, since many systems run with > default memory limit (8 megs) and would easily hit it when a script had > a 2-4 megs of data tacked on. > > The patch would be extremely helpful for application distribution where > the entire install/upgrade script can be just a single script. > > The syntax chosen for the patch was design specifically in such a way as > to not cause parser errors in older PHPs without the support for this > feature. > > Ilia > > ______________________________________________________________________ > Index: Zend/zend_language_scanner.l > =================================================================== > RCS file: /repository/ZendEngine2/zend_language_scanner.l,v > retrieving revision 1.124 > diff -u -a -p -r1.124 zend_language_scanner.l > --- Zend/zend_language_scanner.l 7 Mar 2005 16:48:49 -0000 1.124 > +++ Zend/zend_language_scanner.l 11 Mar 2005 19:30:47 -0000 > @@ -1342,6 +1342,10 @@ NEWLINE ("\r"|"\n"|"\r\n") > return T_INLINE_HTML; > } > > +<INITIAL>"<?php"{WHITESPACE}"HALT;"{WHITESPACE}*"?>" > { > + yyterminate(); > +} > + > > <INITIAL>"<?"|"<script"{WHITESPACE}+"language"{WHITESPACE}*"="{WHITESPACE}*("php"|"\"php\""|"\'php\'"){WHITESPACE}*">" > { > HANDLE_NEWLINES(yytext, yyleng); > if (CG(short_tags) || yyleng>2) { /* yyleng>2 means it's not <? but > <script> */ > > > ______________________________________________________________________ > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.internals (#15377) next »