@@ -587,12 +587,9 @@ static const char *param_mode_conflict = "Either execute direct code, process st
587
587
588
588
/* {{{ cli_seek_file_begin
589
589
*/
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 )
591
591
{
592
- int c ;
593
-
594
- * lineno = 1 ;
595
-
592
+ // TODO: Is this still needed?
596
593
file_handle -> type = ZEND_HANDLE_FP ;
597
594
file_handle -> opened_path = NULL ;
598
595
file_handle -> free_filename = 0 ;
@@ -602,23 +599,7 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
602
599
}
603
600
file_handle -> filename = script_file ;
604
601
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 );
622
603
623
604
return SUCCESS ;
624
605
}
@@ -649,7 +630,6 @@ static int do_cli(int argc, char **argv) /* {{{ */
649
630
char * arg_free = NULL , * * arg_excp = & arg_free ;
650
631
char * script_file = NULL , * translated_path = NULL ;
651
632
int interactive = 0 ;
652
- int lineno = 0 ;
653
633
const char * param_error = NULL ;
654
634
int hide_argv = 0 ;
655
635
@@ -922,7 +902,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
922
902
php_optind ++ ;
923
903
}
924
904
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 ) {
926
906
goto err ;
927
907
} else {
928
908
char real_path [MAXPATHLEN ];
@@ -960,7 +940,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
960
940
goto err ;
961
941
}
962
942
request_started = 1 ;
963
- CG (start_lineno ) = lineno ;
943
+ CG (skip_shebang ) = 1 ;
964
944
965
945
zend_register_bool_constant (
966
946
ZEND_STRL ("PHP_CLI_PROCESS_TITLE" ),
@@ -1050,10 +1030,10 @@ static int do_cli(int argc, char **argv) /* {{{ */
1050
1030
}
1051
1031
} else {
1052
1032
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 ) {
1054
1034
exit_status = 1 ;
1055
1035
} else {
1056
- CG (start_lineno ) = lineno ;
1036
+ CG (skip_shebang ) = 1 ;
1057
1037
php_execute_script (& file_handle );
1058
1038
exit_status = EG (exit_status );
1059
1039
}
0 commit comments