]> granicus.if.org Git - php/commitdiff
- Fixed bug #23584 (error line numbers off by one when using #!php).
authorfoobar <sniper@php.net>
Wed, 14 May 2003 00:05:12 +0000 (00:05 +0000)
committerfoobar <sniper@php.net>
Wed, 14 May 2003 00:05:12 +0000 (00:05 +0000)
# already fixed in php5

sapi/cli/php_cli.c
tests/lang/bug23584.phpt [new file with mode: 0644]

index 235f52157fb6f55d10855c0573ac1f5022c54310..d0550d9ebcb6f3124684d3e82ae28bce636d54cf 100644 (file)
@@ -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 (file)
index 0000000..417cfb0
--- /dev/null
@@ -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