]> granicus.if.org Git - php/commitdiff
Fixed bug #44575 (parse_ini_file comment # line problems)
authorArnaud Le Blanc <lbarnaud@php.net>
Sun, 2 Nov 2008 23:36:10 +0000 (23:36 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Sun, 2 Nov 2008 23:36:10 +0000 (23:36 +0000)
[DOC] parse_ini_file(): comments starting with # are deprecated in PHP 5.3
      (comments starting with ; should be used instead)

NEWS
Zend/zend_ini_scanner.l
ext/standard/tests/general_functions/parse_ini_file.phpt

diff --git a/NEWS b/NEWS
index bc30206e8b8dd34a186c36d3ca2dae11883ebf62..fbd8c05dbc9b601c59b96df9df11e502dc9f98d0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -59,6 +59,7 @@ PHP                                                                        NEWS
 - Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Ilia)
 - Fixed bug #45382 (timeout bug in stream_socket_enable_crypto).
   (vnegrier at optilian dot com, Ilia)
+- Fixed bug #44575 (parse_ini_file comment # line problems). (Arnaud)
 - Fixed bug #44135 (PDO MySQL does not support CLIENT_FOUND_ROWS). (Johannes,
   chx1975 at gmail dot com)
 
index d901522ca6ee710683146295df5f42aa488bdd8e..22228837c91ffdbc04e253a26258dc6d621bfc09 100644 (file)
@@ -480,6 +480,13 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"[^"])|{LITERAL_DOLLAR}|"\\"["][^\r\n])
        return END_OF_LINE;
 }
 
+<INITIAL>{TABS_AND_SPACES}*[#][^\r\n]*{NEWLINE} { /* #Comment */
+       zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", ini_filename, SCNG(lineno));
+       BEGIN(INITIAL);
+       SCNG(lineno)++;
+       return END_OF_LINE;
+}
+
 <ST_VALUE,ST_RAW>[^] { /* End of option value (if EOF is reached before EOL */
        BEGIN(INITIAL);
        return END_OF_LINE;
index 65a29e0022ddad4ca8dc43f269dedb95cd57e9ca..8523c83cf098d2880a31d4dde4e85b53d664272e 100644 (file)
@@ -105,6 +105,18 @@ INI;
 file_put_contents($filename, $ini);
 var_dump(parse_ini_file($filename, true));
 
+/* #44575, comments starting with '#' */
+$ini = <<<'INI'
+foo=bar1
+; comment
+_foo=bar2
+# comment
+foo_=bar3
+INI;
+file_put_contents($filename, $ini);
+var_dump(parse_ini_file($filename, true));
+
+
 @unlink($filename);
 echo "Done\n";
 ?>
@@ -193,4 +205,14 @@ array(3) {
   ["foo_"]=>
   string(4) "bar3"
 }
+
+Deprecated: Comments starting with '#' are deprecated in %s
+array(3) {
+  ["foo"]=>
+  string(4) "bar1"
+  ["_foo"]=>
+  string(4) "bar2"
+  ["foo_"]=>
+  string(4) "bar3"
+}
 Done