diff options
author | Jean Abou-Samra <jean@abou-samra.fr> | 2022-08-15 11:45:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-15 11:45:13 +0200 |
commit | d6968f804ab817c29f9f0ca408279adf82b006f9 (patch) | |
tree | f3225a3b29dcc71d85b512767b436f7e7af9e6d5 /pygments | |
parent | bf1ea528193f6404d91372a7254913ea03baccac (diff) | |
download | pygments-git-d6968f804ab817c29f9f0ca408279adf82b006f9.tar.gz |
CFamilyLexer: refuse quotes between parentheses for function definitions and declarations (#2208)
Something like
id id2("){ ... }");
is no longer wrongly recognized as a "function"
id id2(") {
...
}
");
As the difference in the tests shows, this has the unfortunate side
effect that we no longer highlight something like
int f(param="default");
as a function declaration, but it is hard to imagine another way to
fix this (cf. “most vexing parse” problem).
Fixes #2207
Diffstat (limited to 'pygments')
-rw-r--r-- | pygments/lexers/c_cpp.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pygments/lexers/c_cpp.py b/pygments/lexers/c_cpp.py index 5d3b9c7d..59749fa6 100644 --- a/pygments/lexers/c_cpp.py +++ b/pygments/lexers/c_cpp.py @@ -132,9 +132,9 @@ class CFamilyLexer(RegexLexer): r'(' + _possible_comments + r')' # possible comments r'(' + _namespaced_ident + r')' # method name r'(' + _possible_comments + r')' # possible comments - r'(\([^;]*?\))' # signature + r'(\([^;"\']*?\))' # signature r'(' + _possible_comments + r')' # possible comments - r'([^;{/]*)(\{)', + r'([^;{/"\']*)(\{)', bygroups(using(this), using(this, state='whitespace'), Name.Function, using(this, state='whitespace'), using(this), using(this, state='whitespace'), using(this), Punctuation), 'function'), @@ -143,9 +143,9 @@ class CFamilyLexer(RegexLexer): r'(' + _possible_comments + r')' # possible comments r'(' + _namespaced_ident + r')' # method name r'(' + _possible_comments + r')' # possible comments - r'(\([^;]*?\))' # signature + r'(\([^;"\']*?\))' # signature r'(' + _possible_comments + r')' # possible comments - r'([^;/]*)(;)', + r'([^;/"\']*)(;)', bygroups(using(this), using(this, state='whitespace'), Name.Function, using(this, state='whitespace'), using(this), using(this, state='whitespace'), using(this), Punctuation)), include('types'), |