[PHP-DEV] Re: par/phar/jar (was zend_stream_fixup)
L0t3k wrote: In about a month or so, i'll start work on an extension implementing a file format which allows for bundling all resources related to a app (including I'd very much recommend using an already existing file format, e.g. PEAR::PHP_Archive (uses tar) or something based on zip. The disadvantage over Tar or other archive formats is that they are standardized, and have lots of available tools which can be used to The advantage of a proven format and being able to use standard tools are priority #1 IMHO. manipulate them. The advantage over other formats is that the resources can be used in-place using a custom PHP stream (i.e. run in place - no unzipping). Of course, anything can be stuffed into the files, so if Considering how fast current computers are and based on the fact that wrappers for current archive format can already hide the unzipping step I'd resist the temptation to create yet-another-archive-format. My 2 Rappen, - Chris -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] XML Bug #32001
Hello Moriyoshi, Friday, March 11, 2005, 4:44:19 AM, you wrote: On 2005/03/11, at 10:24, Marcus Boerger wrote: Hello moriyoshi or any other XMLer, please verify the --EXPECT-- data in test ext/xml/tests/bug32001.phpt i am quite sure there are several mistakes in it. Excuse me if I'm just missing something, what kind of mistake do you want to address? Somehow i have the feeling that most of the expected results are wrong by simply looking at file in hex format. So it would be nice if someone could confirm or decline that. -- Best regards, Marcusmailto:[EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] XML Bug #32001
The test works fine for me under linux. Only difference is on windows and there its to how windows performs php_strtoupper differently. If case folding is turned off under windows, the test passes. Rob Moriyoshi Koizumi wrote: On 2005/03/11, at 10:24, Marcus Boerger wrote: Hello moriyoshi or any other XMLer, please verify the --EXPECT-- data in test ext/xml/tests/bug32001.phpt i am quite sure there are several mistakes in it. Excuse me if I'm just missing something, what kind of mistake do you want to address? Moriyoshi -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] XML Bug #32001
On 2005/03/11, at 20:38, Rob Richards wrote: The test works fine for me under linux. Only difference is on windows and there its to how windows performs php_strtoupper differently. If case folding is turned off under windows, the test passes. It looks like the problem is due to the following facts. - php_strtoupper() depends on the locale settings. - toupper() works differently between platforms. Besides it isn't designed to handle multibyte strings like UTF-8. I was mostly testing on Linux so I couldn't replicate it (now verified on Mac OS X). I think case folding option doesn't make any sense if it doesn't work perfectly and we better deprecate it until some unicode-aware case folding function is available. Moriyoshi Rob Moriyoshi Koizumi wrote: On 2005/03/11, at 10:24, Marcus Boerger wrote: Hello moriyoshi or any other XMLer, please verify the --EXPECT-- data in test ext/xml/tests/bug32001.phpt i am quite sure there are several mistakes in it. Excuse me if I'm just missing something, what kind of mistake do you want to address? Moriyoshi -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] zend_stream_fixup
WFhttp://viewcvs.php.net/viewcvs.cgi/php-src/main/main.c.diff?r1=1.526r2=1.527 And? What this is supposed to explain? My questions are still unanswered. I still do not see how converting FP to STREAm helps anything. This patch has nothing to do with that - it deals with php_stream that I have no any problem with. -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ +972-3-6139665 ext.115 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] HALT Patch
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.l7 Mar 2005 16:48:49 - 1.124 +++ Zend/zend_language_scanner.l11 Mar 2005 19:30:47 - @@ -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) || yyleng2) { /* yyleng2 means it's not ? but script */ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: HALT Patch
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. +1 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
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 - 1.124 +++ Zend/zend_language_scanner.l 11 Mar 2005 19:30:47 - @@ -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) || yyleng2) { /* yyleng2 means it's not ? but script */ __ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] zend_stream_fixup
The point is that you associate the approprite methods with the file handle at the time you set it to STREAM. --Wez. On Fri, 11 Mar 2005 21:18:37 +0200 (IST), Stanislav Malyshev [EMAIL PROTECTED] wrote: WFhttp://viewcvs.php.net/viewcvs.cgi/php-src/main/main.c.diff?r1=1.526r2=1.527 And? What this is supposed to explain? My questions are still unanswered. I still do not see how converting FP to STREAm helps anything. This patch has nothing to do with that - it deals with php_stream that I have no any problem with. -- Stanislav Malyshev, Zend Products Engineer [EMAIL PROTECTED] http://www.zend.com/ +972-3-6139665 ext.115 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
Hi Ilia: On Fri, Mar 11, 2005 at 02:36:16PM -0500, 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. Would the data after that point be sent directly to STDOUT? Or would the present script somehow be able to use it? Thanks, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
Would the data after that point be sent directly to STDOUT? Or would the present script somehow be able to use it? The data will not be parsed or output. When you need it you would make the script open itself and read the (binary) data dump from the end of the file and use it various creative ways. Ilia -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
Hi Ilia: On Fri, Mar 11, 2005 at 04:27:53PM -0500, Ilia Alshanetsky wrote: The data will not be parsed or output. When you need it you would make the script open itself and read the (binary) data dump from the end of the file and use it various creative ways. Interesting. I'm wondering about the security implications of this. This makes it very easy to use PHP as a means to propogate all sorts of nasty things. Well, people could even do that today in one script by setting a variable to a base64 encoded string then decoding it. None the less, putting binary data in PHP scripts gives me pause. --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
Daniel Convissor wrote: Interesting. I'm wondering about the security implications of this. This makes it very easy to use PHP as a means to propogate all sorts of nasty things. You can already use PHP to propagate all sorts of nasty things, nothing changes in this respect. Well, people could even do that today in one script by setting a variable to a base64 encoded string then decoding it. Sure, BUT this approach makes the final file approximately %30 larger and any time it is executed this data dump as I like to refer to it will be parsed and stored in memory. Which makes this approach highly inefficient. Ilia -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
If you name the token __HALT_PHP_PARSER__ instead (or something equally unlikely to be used by accident and unambiguous in meaning), you'll get a +1 from me :-) --Wez. On Fri, 11 Mar 2005 14:36:16 -0500, Ilia Alshanetsky [EMAIL PROTECTED] 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.l7 Mar 2005 16:48:49 - 1.124 +++ Zend/zend_language_scanner.l11 Mar 2005 19:30:47 - @@ -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) || yyleng2) { /* yyleng2 means it's not ? but script */ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
On Fri, 2005-03-11 at 16:37, Daniel Convissor wrote: Interesting. I'm wondering about the security implications of this. This makes it very easy to use PHP as a means to propogate all sorts of nasty things. Well, people could even do that today in one script by setting a variable to a base64 encoded string then decoding it. None the less, putting binary data in PHP scripts gives me pause. There is no issue here. You can throw binary data at the end of a PHP script as it is now: ?php /* stuff */ exit; ? binary data here -- the halt token only makes it so PHP doesn't waste time processing something that doesn't need to be processed. John -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
1) while (fgets($fp) != '?php __HALT_PHP_PARSER__; ?')); Just a nudge about this code approach. #1 It doesn't detect EOF #2 It forgets about the newline returned by fgets() #3 It doesn't allow the HALT; to float within a line between other content (not that you'd do that anyway but... while (($tmp = fgets($fp)) (strpos($tmp, '?php __HALT_PHP_PARSER__; ?') !== false)); -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
On Fri, Mar 11, 2005 at 04:49:50PM -0500, John Coggeshall wrote: There is no issue here. You can throw binary data at the end of a PHP script as it is now: ?php /* stuff */ exit; ? binary data here True enough. Thanks, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
On Fri, Mar 11, 2005 at 04:43:21PM -0500, Ilia Alshanetsky wrote: Daniel Convissor wrote: Interesting. I'm wondering about the security implications of this. This makes it very easy to use PHP as a means to propogate all sorts of nasty things. You can already use PHP to propagate all sorts of nasty things, nothing changes in this respect. Well, people could even do that today in one script by setting a variable to a base64 encoded string then decoding it. Sure, BUT this approach makes the final file approximately %30 larger ... snip... No doubt. My second point was more to diminish my initial assertion, not to diminish the validity of your patch. Thanks, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] HALT Patch
Sara Golemon wrote: Just a nudge about this code approach. #1 It doesn't detect EOF Well, if you encounter EOF before the HALT tag, it means as a developer of the script you are trying to break your own code ;-) #2 It forgets about the newline returned by fgets( True, I suppose strncmp could be used here, since newline is not always constant. #3 It doesn't allow the HALT; to float within a line between other content (not that you'd do that anyway but... Going back to #1 ;-). Ilia -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: par/phar/jar (was zend_stream_fixup)
Christian Schneider [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The advantage of a proven format and being able to use standard tools are priority #1 IMHO. manipulate them. The advantage over other formats is that the resources can be used in-place using a custom PHP stream (i.e. run in place - no unzipping). Of course, anything can be stuffed into the files, so if Considering how fast current computers are and based on the fact that wrappers for current archive format can already hide the unzipping step I'd resist the temptation to create yet-another-archive-format. actually this extension was/is intended to provide a ResourceBundle class with proper fallback semantics. it will provide a robust and fast replacement for gettext, and has the additional benefit that practically anything can be stored in it, including localized images, code, a sqlite db g. locale data can be stored per-file, or aggregated into a single file containing all external app data. the code exists and currently works, with some limitations that im hoping to address. it just happens to be written in a way that can easily support a par/phar implementation - no that it has to. l0t3k My 2 Rappen, - Chris -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] mail() by SMTP on UNIX
Hi. I was wondered why mail() function couldn't use SMTP subroutines. In shared hosting environment where can't be used sendmail binary it is an only way. I've attached my dirty hack. I hope someone would help me to clean up the patch. -- .''`.Piotr Roszatycki, Netia SA : :' :mailto:[EMAIL PROTECTED] `. `' mailto:[EMAIL PROTECTED] `- diff -ru php-5.0.3.orig/ext/standard/config.m4 php-5.0.3/ext/standard/config.m4 --- php-5.0.3.orig/ext/standard/config.m4 2004-05-10 09:23:38 +0200 +++ php-5.0.3/ext/standard/config.m4 2005-03-11 22:14:01 +0100 @@ -469,6 +469,7 @@ incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \ http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \ var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \ -filters.c proc_open.c sunfuncs.c streamsfuncs.c http.c) +filters.c proc_open.c sunfuncs.c streamsfuncs.c http.c \ + ../../win32/sendmail.c) PHP_ADD_MAKEFILE_FRAGMENT diff -ru php-5.0.3.orig/ext/standard/mail.c php-5.0.3/ext/standard/mail.c --- php-5.0.3.orig/ext/standard/mail.c 2005-03-11 23:17:23 +0100 +++ php-5.0.3/ext/standard/mail.c 2005-03-11 23:11:12 +0100 @@ -39,9 +39,7 @@ #include exec.h #if HAVE_SENDMAIL -#ifdef PHP_WIN32 #include win32/sendmail.h -#endif #ifdef NETWARE #include netware/pipe.h/* For popen(), pclose() */ @@ -175,17 +173,14 @@ */ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_DC) { -#if (defined PHP_WIN32 || defined NETWARE) int tsm_err; char *tsm_errmsg = NULL; -#endif FILE *sendmail; int ret; char *sendmail_path = INI_STR(sendmail_path); char *sendmail_cmd = NULL; - if (!sendmail_path) { -#if (defined PHP_WIN32 || defined NETWARE) + if (!sendmail_path || !sendmail_path[0]) { /* handle old style win smtp sending */ if (TSendMail(INI_STR(SMTP), tsm_err, tsm_errmsg, headers, subject, to, message, NULL, NULL, NULL) == FAILURE) { if (tsm_errmsg) { @@ -197,9 +192,6 @@ return 0; } return 1; -#else - return 0; -#endif } if (extra_cmd != NULL) { sendmail_cmd = emalloc (strlen (sendmail_path) + strlen (extra_cmd) + 2); @@ -272,15 +264,11 @@ { char *sendmail_path = INI_STR(sendmail_path); -#ifdef PHP_WIN32 - if (!sendmail_path) { - php_info_print_table_row(2, Internal Sendmail Support for Windows, enabled); + if (!sendmail_path || !sendmail_path[0]) { + php_info_print_table_row(2, Internal Sendmail Support, enabled); } else { php_info_print_table_row(2, Path to sendmail, sendmail_path); } -#else - php_info_print_table_row(2, Path to sendmail, sendmail_path); -#endif } /* }}} */ diff -ru php-5.0.3.orig/win32/sendmail.c php-5.0.3/win32/sendmail.c --- php-5.0.3.orig/win32/sendmail.c 2003-12-08 23:10:42 +0100 +++ php-5.0.3/win32/sendmail.c 2005-03-11 23:01:28 +0100 @@ -22,19 +22,31 @@ #include php.h/*php specific */ #include stdio.h #include stdlib.h -#ifndef NETWARE +#ifdef PHP_WIN32 #include winsock2.h -#else /* NETWARE */ +#elifdef NETWARE #include netware\sendmail_nw.h -#endif /* NETWARE */ +#endif +#if PHP_WIN32 || NETWARE #include time.h +#else +#include time.h +#define _timezone __timezone +#include resolv.h +#include sys/socket.h +#include netinet/in.h +#include arpa/inet.h +#include net/if.h +#include netdb.h +#define INVALID_SOCKET -1 +#endif #include string.h #include math.h -#ifndef NETWARE +#ifdef PHP_WIN32 #include malloc.h #include memory.h #include winbase.h -#endif /* NETWARE */ +#endif #include sendmail.h #include php_ini.h @@ -79,12 +91,20 @@ char Buffer[MAIL_BUFFER_SIZE]; /* socket related data */ -SOCKET sc; -#ifndef NETWARE +#if PHP_WIN32 || NETWARE +typedef SOCKET sc; +#else +int sc; +#endif +#ifdef PHP_WIN32 WSADATA Data; struct hostent *adr; #endif /* NETWARE */ +#if PHP_WIN32 || NETWARE SOCKADDR_IN sock_in; +#else +struct sockaddr_in sock_in; +#endif #ifndef NETWARE int WinsockStarted; /* values set by the constructor */ @@ -94,11 +114,7 @@ char LocalHost[HOST_NAME_LEN]; #endif char seps[] = ,\t\n; -#ifndef NETWARE -char *php_mailer = PHP 4 WIN32; -#else -char *php_mailer = PHP 4 NetWare; -#endif /* NETWARE */ +char *php_mailer = PHP; char *get_header(char *h, char *headers); @@ -227,7 +243,7 @@ char *headers_lc = NULL; /* headers_lc is only created if we've a header at all */ TSRMLS_FETCH(); -#ifndef NETWARE +#ifdef PHP_WIN32 WinsockStarted = FALSE; #endif @@ -333,7 +349,7 @@ */ shutdown(sc, 0); -#ifndef NETWARE +#ifdef PHP_WIN32 closesocket(sc); #else /* closesocket commented out since it was giving undefined symbol linker error @@ -805,9 +821,17 @@ /* Connect to server */ sock_in.sin_family = AF_INET; sock_in.sin_port = htons(portnum); +#if PHP_WIN32 || NETWARE sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost); +#else + sock_in.sin_addr.s_addr = GetAddr(MailHost); +#endif
Re: [PHP-DEV] HALT Patch
Hi, I modified your patch so it can capture the position where the supposed data begins into the constant __HALT_PHP_PARSER__. There may be a problem with my patch if more than one require()'d / include()'d script contain __HALT_PHP_PARSER__, but it'd be quite handy if such an issue is resolved. ?php $fp = fopen(__FILE__, 'rb'); fseek($fp, __HALT_PHP_PARSER__, SEEK_SET); fpassthru($fp); ? ?php __HALT_PHP_PARSER__; ? abc def Moriyoshi Index: Zend/zend_language_scanner.l === RCS file: /repository/ZendEngine2/zend_language_scanner.l,v retrieving revision 1.124 diff -u -r1.124 zend_language_scanner.l --- Zend/zend_language_scanner.l7 Mar 2005 16:48:49 - 1.124 +++ Zend/zend_language_scanner.l11 Mar 2005 23:47:11 - @@ -1342,6 +1342,13 @@ return T_INLINE_HTML; } +INITIAL?php __HALT_PHP_PARSER__; ?{NEWLINE}? { + long fpos = (yyin ? zend_stream_ftell(yyin TSRMLS_CC): 0) + (long)(yy_c_buf_p - (YY_CURRENT_BUFFER)-yy_ch_buf); + REGISTER_MAIN_LONG_CONSTANT(__HALT_PHP_PARSER__, fpos, CONST_CS); + + yyterminate(); +} + INITIAL?|script{WHITESPACE}+language{WHITESPACE}*={WHITESPACE}*(php|\php\|\'php\'){WHITESPACE}* { HANDLE_NEWLINES(yytext, yyleng); if (CG(short_tags) || yyleng2) { /* yyleng2 means it's not ? but script */ Index: Zend/zend_stream.c === RCS file: /repository/ZendEngine2/zend_stream.c,v retrieving revision 1.9 diff -u -r1.9 zend_stream.c --- Zend/zend_stream.c 27 Sep 2004 09:03:40 - 1.9 +++ Zend/zend_stream.c 11 Mar 2005 23:47:12 - @@ -35,6 +35,11 @@ fclose((FILE*)handle); } +static long zend_stream_stdio_fteller(void *handle TSRMLS_DC) +{ + return ftell((FILE*)handle); +} + ZEND_API int zend_stream_open(const char *filename, zend_file_handle *handle TSRMLS_DC) { if (zend_stream_open_function) { @@ -80,9 +85,10 @@ } /* promote to stream */ - file_handle-handle.stream.handle = file_handle-handle.fp; - file_handle-handle.stream.reader = zend_stream_stdio_reader; - file_handle-handle.stream.closer = zend_stream_stdio_closer; + file_handle-handle.stream.handle = file_handle-handle.fp; + file_handle-handle.stream.reader = zend_stream_stdio_reader; + file_handle-handle.stream.closer = zend_stream_stdio_closer; + file_handle-handle.stream.fteller = zend_stream_stdio_fteller; file_handle-type = ZEND_HANDLE_STREAM; file_handle-handle.stream.interactive = isatty(fileno((FILE *)file_handle-handle.stream.handle)); @@ -121,4 +127,7 @@ return 0; } - +ZEND_API long zend_stream_ftell(zend_file_handle *file_handle TSRMLS_DC) +{ + return file_handle-handle.stream.fteller(file_handle-handle.stream.handle TSRMLS_CC); +} Index: Zend/zend_stream.h === RCS file: /repository/ZendEngine2/zend_stream.h,v retrieving revision 1.6 diff -u -r1.6 zend_stream.h --- Zend/zend_stream.h 25 Jun 2004 12:55:11 - 1.6 +++ Zend/zend_stream.h 11 Mar 2005 23:47:12 - @@ -27,11 +27,13 @@ typedef size_t (*zend_stream_reader_t)(void *handle, char *buf, size_t len TSRMLS_DC); typedef void (*zend_stream_closer_t)(void *handle TSRMLS_DC); +typedef long (*zend_stream_fteller_t)(void *handle TSRMLS_DC); typedef struct _zend_stream { void *handle; zend_stream_reader_t reader; zend_stream_closer_t closer; + zend_stream_fteller_t fteller; int interactive; } zend_stream; @@ -52,6 +54,7 @@ ZEND_API int zend_stream_ferror(zend_file_handle *file_handle TSRMLS_DC); ZEND_API int zend_stream_getc(zend_file_handle *file_handle TSRMLS_DC); ZEND_API size_t zend_stream_read(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC); +ZEND_API long zend_stream_ftell(zend_file_handle *file_handle TSRMLS_DC); ZEND_API int zend_stream_fixup(zend_file_handle *file_handle TSRMLS_DC); END_EXTERN_C() Index: main/main.c === RCS file: /repository/php-src/main/main.c,v retrieving revision 1.619 diff -u -r1.619 main.c --- main/main.c 8 Mar 2005 21:42:10 - 1.619 +++ main/main.c 11 Mar 2005 23:47:20 - @@ -838,6 +838,11 @@ php_stream_close((php_stream*)handle); } +static long stream_fteller_for_zend(void *handle TSRMLS_DC) +{ + return (long)php_stream_tell((php_stream*)handle); +} + static int php_stream_open_for_zend(const char *filename, zend_file_handle *handle TSRMLS_DC) { php_stream *stream; @@ -851,6 +856,7 @@ handle-handle.stream.handle = stream; handle-handle.stream.reader = (zend_stream_reader_t)_php_stream_read; handle-handle.stream.closer =