php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26629 Inconsistent handle of \n in highlight_string and highlight_file
Submitted: 2003-12-15 05:57 UTC Modified: 2003-12-19 06:39 UTC
From: vrana@php.net Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.4 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vrana@php.net
New email:
PHP Version: OS:

 

 [2003-12-15 05:57 UTC] vrana@php.net
Description:
------------
highlight.keyword isn't used in strings without variables for \n and similar. It is used in strings with variables (e.g. "$a\n").

(The problem is in file /ZendEngine2/zend_highlight.c.)

Reproduce code:
---------------
highlight_string('<?php echo "a\n"; ?>');


Expected result:
----------------
<code><font color="#000000">
<font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"a</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">; </font><font color="#0000BB">?&gt;</font>
</font>
</code>

Actual result:
--------------
<code><font color="#000000">
<font color="#0000BB">&lt;?php </font><font color="#007700">echo </font><font color="#DD0000">"a\n"</font><font color="#007700">; </font><font color="#0000BB">?&gt;</font>
</font>
</code>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-15 09:09 UTC] sniper@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


And is this with PHP 5 or 4 ??? You're referring to ZendEngine 2 but the version in this report is 4.3.3 ????

(I would expect that people who have @php.net address should know HOW to report bugs..)

 [2003-12-16 12:08 UTC] vrana@php.net
Sorry for mismatch. The bug report is for PHP 4. I looked for highlighting code and I found it in /ZendEngine2 but I didn't realized that this code is for PHP 5 only. I don't know where this part of code for PHP 4 is. Just ignore the sentence in bracket, the provided version information is correct.
 [2003-12-16 12:22 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is how it supposed to work, "a\n" is 1 string.
 [2003-12-16 17:01 UTC] vrana@php.net
I don't know what "1 string" is. Is "$a\n" also "1 string"? If it is, there should not be \n highlighted in it.

The problem is that in "$a\n" is \n highlighted and in "a\n" isn't. I believe that it should be consistent.
 [2003-12-16 17:11 UTC] derick@php.net
You're wrong. The current behavior is correct.
 [2003-12-17 03:51 UTC] vrana@php.net
Tell me a reason why \n should be highlighted as keyword in "$a\n" and in "a\n" not.
 [2003-12-17 04:31 UTC] derick@php.net
Because the lexer in PHP handles those cases different.

"$a\n" = quote + variable + newline character + quote

"a\n"  = string

Try this script:
<pre>
<?php
    highlight_string('<?php "a\n"; ?>');
    var_dump(token_get_all('<?php "a\n"; ?>'));
                                                                                
    highlight_string('<?php "$a\n"; ?>');
    var_dump(token_get_all('<?php "$a\n"; ?>'));
?>
</pre>


(and leave this bug bogus)
 [2003-12-19 06:15 UTC] vrana@php.net
So the newline character should be highlighted as a string and not as a keyword.

If you will not fix this, change the state to Wont fix and not to Bogus.
 [2003-12-19 06:39 UTC] derick@php.net
The current behavior is CORRECT, so your report is BOGUS. highlight_* uses the lexical analyer to highlight and this is the perfectly good behavior as I told you atleast 5 times now. Please keep the status to bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC