mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
Corrected fix for bug #46844 to only trigger on the 1st line of CLI opened
files.
This commit is contained in:
parent
ae6b1d2216
commit
af28e3443f
5 changed files with 26 additions and 26 deletions
|
@ -574,6 +574,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;
|
||||
|
@ -584,6 +586,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…
Add table
Add a link
Reference in a new issue