Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong C/C++ Code highlighting #1166

Closed
Anteru opened this issue Aug 31, 2019 · 2 comments
Closed

Wrong C/C++ Code highlighting #1166

Anteru opened this issue Aug 31, 2019 · 2 comments
Labels
S-major severity: major T-bug type: a bug X-imported imported from Bitbucket

Comments

@Anteru
Copy link
Collaborator

Anteru commented Aug 31, 2019

(Original issue 1462 created by None on 2018-07-30T20:04:15.185615+00:00)

When I let Pygments process the following code, the first function in the block is not recognized as such.

Minimal Example:

#ifdef __cplusplus
extern "C" {
#endif

void foo(void);
void bar(void);

#ifdef __cplusplus
}
#endif

@Anteru Anteru added T-bug type: a bug X-imported imported from Bitbucket S-major severity: major labels Aug 31, 2019
@Anteru
Copy link
Collaborator Author

Anteru commented Aug 31, 2019

(Original comment by pgerell on 2018-11-26T16:13:51.149996+00:00)

This may be a duplicate of #1084

hgruniaux added a commit to hgruniaux/pygments that referenced this issue Jan 12, 2020
Anteru pushed a commit that referenced this issue May 22, 2020
* General improvement to the C/C++ lexer

* Add missing C11 keywords

Add '_Imaginary', '_Static_assert', '_Atomic' keywords.

* Highlight C11 std atomic types (#906)

Add support for C11 atomic types `atomic_*`.

* Extended character literals prefixes for C/C++

Add support for `u'a'`, `U'a'` (C++11, C11), and `u8'a'` (C++17, C2x).
[Reference](https://en.cppreference.com/w/cpp/language/character_literal).
[Reference](https://en.cppreference.com/w/c/language/character_constant).

* Fix bad floating point highlighting in C lexer

Fix bad highlighting for `5.`, where `.` was not highlighted.

* Fix hex floating literal highlighting in C

Hexadecimal floating point literals needs an exponent (`0x5p8`). Before this commit, event floating-point literals without an exponent were accepted (e.g. `0x5.5`).

* Support '$' in identifiers, C/C++

Some old C/C++ compilers have supported `$` (dollar sign) in identifiers, and some news continue to support this for legacy reasons. That is, some codes may use them, and it is therefore preferable to color them correctly.

* Cleaning and fixing some bugs in C/C++ lexer

- Add '_Pragma' keyword
- Recognize the identifier following 'typename' as Name.Class
- Do not tokenize 'class' or 'struct' following 'enum' as Name.Class, but instead as Keyword (C++ lexer)
- Move some C++ keywords to the generic lexer (`alignas`, `alignof`, etc...)
- Add some C keywords (`noreturn`, `imaginary`, `complex`)
- And others things...

* Fix building errors in C/C++ lexer

* Fix bug in C/C++

Now `class`, `struct`, `enum`, `union`, etc... can be used alone. Previously, the lexer do not recognizes them if they are not followed by an identifier. This regression was introduced in 013bf6a by me.

* Reuse old states names for C/C++

Some lexers depends on the old states names (e.g. `classname` state) to works. This commit, reintroduce these old names.

* Improve C/C++ lexer documentation

* Correct english errors in C lexer documentation

* Cleaning and Unicode literals for C

* Move Unicode literals from C++ to generic C

* Remove useless 'classname' state in ECLexer

* Revert "Remove useless 'classname' state in ECLexer"

This reverts commit 89a0c13.

* Revert "Revert "Remove useless 'classname' state in ECLexer""

This reverts commit 2d47343.

* Add support for UCNs in C and C++

* Apply correction from #1162

Solves #1162

* Correctly highlights negatives numbers in C++

* Revert some changes from 8fe8ed6

* Add unicode suffixes to C++ raw string literals

* Solves #1166

* Fix previous regression in C like lexer

* Fix invalid regex in C like lexer

* Fix #1396 and now are identifiers support UCNs in C and C++ lexer

* Update AUTHORS

* Add missing Python raw string prefix

Co-authored-by: Hubert Gruniaux <42495291+HubertGruniaux@users.noreply.github.com>
@Anteru
Copy link
Collaborator Author

Anteru commented May 22, 2020

Fixed by #1350

@Anteru Anteru closed this as completed May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-major severity: major T-bug type: a bug X-imported imported from Bitbucket
Projects
None yet
Development

No branches or pull requests

1 participant