bugGNU nano - Bugs: bug #50355, "/*" inside a string is...

 
 

bug #50355: "/*" inside a string is treated as start of comment block

Submitted by:  None
Submitted on:  Sun 19 Feb 2017 06:57:04 PM UTC  
 
Severity: 2 - MinorStatus: Wont Fix
Assigned to: NoneOpen/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 21 Feb 2017 12:46:58 PM UTC, comment #1:

Sorry, can't be helped. Nano applies the color regexes one after the other, to the whole text of the file. So either strings inside comments would get colored as strings, or comments inside strings get colored as comments. The latter case seems to occur the least frequently (it does not occur in nano's source, whereas the former occurs some fifty times), so that is why the order is as it is. If you don't mind strings inside comments standing out, you could swap the order of the regexes in c.nanorc and javascript.nanorc.

Maybe someday the coloring code will be retwritten to understand that some things are strings and that there contents should not be interpreted in any way. But that is a long way off.

Benno Schulenberg <bens>
Project Administrator
Sun 19 Feb 2017 06:57:04 PM UTC, original submission:

When opening the following minimal example in nano (representing a string containing "/*", followed by an empty comment block), it is highlighted incorrectly, as if the comment block began in the middle of the string.

The minimal example is `"/"/*/` (not including the backticks), and triggers incorrect behaviour when treated as C or JavaScript syntax.

A related issue happens with line comments, as in the example `"//"` (a string containing two slash characters).

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bens (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 24 Feb 2017 11:43:02 AM UTCbensSeverity3 - Normal=>2 - Minor
      Open/ClosedOpen=>Closed
    Tue 21 Feb 2017 12:46:58 PM UTCbensStatusNone=>Wont Fix
      Summary"/*" in string is treated as comment block=>"/*" inside a string is treated as start of comment block

    Back to the top


    Powered by Savane 3.1-cleanup1