From: foobar Date: Wed, 14 May 2003 00:05:12 +0000 (+0000) Subject: - Fixed bug #23584 (error line numbers off by one when using #!php). X-Git-Tag: php-4.3.2RC3~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2cd08683c8e666348e0b1c8ca0312a7cbaf0f517;p=php - Fixed bug #23584 (error line numbers off by one when using #!php). # already fixed in php5 --- diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 235f52157f..d0550d9ebc 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -447,7 +447,7 @@ int main(int argc, char *argv[]) char *arg_free=NULL, **arg_excp=&arg_free; char *script_file=NULL; zend_llist global_vars; - int interactive=0; + int interactive=0, is_hashbang=0; int module_started = 0; char *exec_direct=NULL; char *param_error=NULL; @@ -748,7 +748,7 @@ int main(int argc, char *argv[]) fseek(file_handle.handle.fp, pos - 1, SEEK_SET); } } - CG(zend_lineno) = -2; + is_hashbang = 1; } else { lseek(file_handle.handle.fd, 0, SEEK_SET); } @@ -779,6 +779,12 @@ int main(int argc, char *argv[]) PUTS("Could not startup.\n"); goto err; } + + /* Correct line numbers when #!php is used. This is reset in php_request_startup(). */ + if (is_hashbang) { + CG(zend_lineno) = -2; + } + *arg_excp = arg_free; /* reconstuct argv */ if (no_headers) { SG(headers_sent) = 1; diff --git a/tests/lang/bug23584.phpt b/tests/lang/bug23584.phpt new file mode 100644 index 0000000000..417cfb0856 --- /dev/null +++ b/tests/lang/bug23584.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #23584 (error line numbers off by one when using #!php) +--FILE-- +#!php + +--EXPECTREGEX-- +Notice: Undefined variable:.*foo in .* on line 6