@@ -587,12 +587,9 @@ static const char *param_mode_conflict = "Either execute direct code, process st
587587
588588/* {{{ cli_seek_file_begin
589589 */
590- static int cli_seek_file_begin (zend_file_handle * file_handle , char * script_file , int * lineno )
590+ static int cli_seek_file_begin (zend_file_handle * file_handle , char * script_file )
591591{
592- int c ;
593-
594- * lineno = 1 ;
595-
592+ // TODO: Is this still needed?
596593 file_handle -> type = ZEND_HANDLE_FP ;
597594 file_handle -> opened_path = NULL ;
598595 file_handle -> free_filename = 0 ;
@@ -602,23 +599,7 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
602599 }
603600 file_handle -> filename = script_file ;
604601
605- /* #!php support */
606- c = fgetc (file_handle -> handle .fp );
607- if (c == '#' && (c = fgetc (file_handle -> handle .fp )) == '!' ) {
608- while (c != '\n' && c != '\r' && c != EOF ) {
609- c = fgetc (file_handle -> handle .fp ); /* skip to end of line */
610- }
611- /* handle situations where line is terminated by \r\n */
612- if (c == '\r' ) {
613- if (fgetc (file_handle -> handle .fp ) != '\n' ) {
614- zend_long pos = zend_ftell (file_handle -> handle .fp );
615- zend_fseek (file_handle -> handle .fp , pos - 1 , SEEK_SET );
616- }
617- }
618- * lineno = 2 ;
619- } else {
620- rewind (file_handle -> handle .fp );
621- }
602+ rewind (file_handle -> handle .fp );
622603
623604 return SUCCESS ;
624605}
@@ -649,7 +630,6 @@ static int do_cli(int argc, char **argv) /* {{{ */
649630 char * arg_free = NULL , * * arg_excp = & arg_free ;
650631 char * script_file = NULL , * translated_path = NULL ;
651632 int interactive = 0 ;
652- int lineno = 0 ;
653633 const char * param_error = NULL ;
654634 int hide_argv = 0 ;
655635
@@ -922,7 +902,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
922902 php_optind ++ ;
923903 }
924904 if (script_file ) {
925- if (cli_seek_file_begin (& file_handle , script_file , & lineno ) != SUCCESS ) {
905+ if (cli_seek_file_begin (& file_handle , script_file ) != SUCCESS ) {
926906 goto err ;
927907 } else {
928908 char real_path [MAXPATHLEN ];
@@ -960,7 +940,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
960940 goto err ;
961941 }
962942 request_started = 1 ;
963- CG (start_lineno ) = lineno ;
943+ CG (skip_shebang ) = 1 ;
964944
965945 zend_register_bool_constant (
966946 ZEND_STRL ("PHP_CLI_PROCESS_TITLE" ),
@@ -1050,10 +1030,10 @@ static int do_cli(int argc, char **argv) /* {{{ */
10501030 }
10511031 } else {
10521032 if (script_file ) {
1053- if (cli_seek_file_begin (& file_handle , script_file , & lineno ) != SUCCESS ) {
1033+ if (cli_seek_file_begin (& file_handle , script_file ) != SUCCESS ) {
10541034 exit_status = 1 ;
10551035 } else {
1056- CG (start_lineno ) = lineno ;
1036+ CG (skip_shebang ) = 1 ;
10571037 php_execute_script (& file_handle );
10581038 exit_status = EG (exit_status );
10591039 }
0 commit comments