#1109790 nano: Highlighting for comments in c/c++ files incorrect if comment //*

Package:
nano
Source:
nano
Description:
small, friendly text editor inspired by Pico
Submitter:
Guillermo Reisch
Date:
2025-07-24 11:31:01 UTC
Severity:
normal
#1109790#5
Date:
2025-07-23 20:45:57 UTC
From:
To:
Some code (mame for example) is using this style of comments
where using //***** as separators ; nano is parsing  //* as multi-line comment
instead of one-line-comment, sow code highlighting is broken.

This is a simple c file for example

//***********************
// A nice extended comment
//***********************

int b = 20;

/* comment */

int main(){
    b += 40; //* new comment
    return b;
}

<EOF>

#1109790#10
Date:
2025-07-24 11:17:04 UTC
From:
To:
This cannot be fixed, because nano uses regexes for coloring things,
and always applies all coloring rules to any line -- there is no
mechanism to make a rule stop the processing of further rules.

So, '//' cannot prevent the recognition of '/*' on the same line.

You yourself can edit the c.nanorc file and make this change:


It should probably look like this:

//*************************
// A nice extended comment
//*************************


Benno