summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2003-05-14 00:05:12 +0000
committerfoobar <sniper@php.net>2003-05-14 00:05:12 +0000
commit2cd08683c8e666348e0b1c8ca0312a7cbaf0f517 (patch)
tree9fc7449f45cdd10ec5eda019f1ff216ba15665bb
parent0e47b9242de85736e7cc5f94d10b9b38b01b6707 (diff)
downloadphp-git-2cd08683c8e666348e0b1c8ca0312a7cbaf0f517.tar.gz
- Fixed bug #23584 (error line numbers off by one when using #!php).
# already fixed in php5
-rw-r--r--sapi/cli/php_cli.c10
-rw-r--r--tests/lang/bug23584.phpt13
2 files changed, 21 insertions, 2 deletions
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
+<?php
+
+error_reporting(E_ALL);
+
+echo $foo;
+
+?>
+--EXPECTREGEX--
+Notice: Undefined variable:.*foo in .* on line 6