mirror of
https://github.com/php/php-src.git
synced 2025-01-26 21:54:16 +08:00
MFH: Corrected fix for bug #46844 to only trigger on the 1st line of CLI
opened files.
This commit is contained in:
parent
2538bd21e7
commit
71ea95354b
File diff suppressed because it is too large
Load Diff
@ -843,27 +843,6 @@ yymore_restart:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ignore first line when it's started with a #! */
|
||||
if (YYCURSOR == SCNG(yy_start) && *YYCURSOR == '#' && *(YYCURSOR + 1) == '!') {
|
||||
while (++YYCURSOR < YYLIMIT) {
|
||||
if (*YYCURSOR == '\n') {
|
||||
++YYCURSOR;
|
||||
CG(zend_lineno)++;
|
||||
goto restart;
|
||||
}
|
||||
|
||||
if (*YYCURSOR == '\r') {
|
||||
if (++YYCURSOR < YYLIMIT && *YYCURSOR == '\n') { /* match \r\n as single newline */
|
||||
++YYCURSOR;
|
||||
}
|
||||
CG(zend_lineno)++;
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* EOF */
|
||||
}
|
||||
|
||||
/*!re2c
|
||||
re2c:yyfill:check = 0;
|
||||
LNUM [0-9]+
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Generated by re2c 0.13.6.dev on Tue Nov 4 01:40:34 2008 */
|
||||
/* Generated by re2c 0.13.5 on Fri Jan 9 12:08:49 2009 */
|
||||
#line 3 "Zend/zend_language_scanner_defs.h"
|
||||
|
||||
enum YYCONDTYPE {
|
||||
|
@ -214,7 +214,7 @@ ZEND_API int zend_stream_fixup(zend_file_handle *file_handle, char **buf, size_t
|
||||
#if HAVE_MMAP
|
||||
if (file_handle->handle.fp) {
|
||||
/* *buf[size] is zeroed automatically by the kernel */
|
||||
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), 0);
|
||||
*buf = mmap(0, size + ZEND_MMAP_AHEAD, PROT_READ, MAP_PRIVATE, fileno(file_handle->handle.fp), ftell(file_handle->handle.fp));
|
||||
if (*buf != MAP_FAILED) {
|
||||
file_handle->handle.stream.mmap.len = size;
|
||||
file_handle->handle.stream.mmap.map = *buf;
|
||||
|
@ -570,6 +570,8 @@ static const char *param_mode_conflict = "Either execute direct code, process st
|
||||
*/
|
||||
static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file, int *lineno TSRMLS_DC)
|
||||
{
|
||||
char c;
|
||||
|
||||
*lineno = 1;
|
||||
|
||||
file_handle->type = ZEND_HANDLE_FP;
|
||||
@ -580,6 +582,25 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
|
||||
return FAILURE;
|
||||
}
|
||||
file_handle->filename = script_file;
|
||||
|
||||
/* #!php support */
|
||||
c = fgetc(file_handle->handle.fp);
|
||||
if (c == '#' && (c = fgetc(file_handle->handle.fp)) == '!') {
|
||||
while (c != '\n' && c != '\r' && c != EOF) {
|
||||
c = fgetc(file_handle->handle.fp); /* skip to end of line */
|
||||
}
|
||||
/* handle situations where line is terminated by \r\n */
|
||||
if (c == '\r') {
|
||||
if (fgetc(file_handle->handle.fp) != '\n') {
|
||||
long pos = ftell(file_handle->handle.fp);
|
||||
fseek(file_handle->handle.fp, pos - 1, SEEK_SET);
|
||||
}
|
||||
}
|
||||
*lineno = 2;
|
||||
} else {
|
||||
rewind(file_handle->handle.fp);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
Loading…
Reference in New Issue
Block a user