One function

extract_comments in jeanralphaviles/comment_parser

The author described this change as comment_parser: Fix escaped quote handling in string literals.. It counts as a record because the check below fails on the code as it stood at 0e4cf91cb and passes on 7048f63f9, with nothing else changed between the two runs.

Fix saved2020-09-02
Sharing licenceMIT · LICENSE
Change size+1 2

What the code was meant to do, written into the code itself as a docstring

Extracts a list of comments from the given C family source code. Comments are represented with the Comment class found in the common module. C family comments come in two forms, single and multi-line comments. - Single-line comments begin with '//' and continue to the end of line. - Multi-line comments begin with '/*' and end with '*/' and can span multiple lines of code. If a multi-line comment does not terminate before EOF is reached, then an exception is raised. Note that this doesn't take language-specific preprocessor directives into consideration. Args: code: String containing code to extract comments from. Returns: Python list of common.Comment in the order that they appear in the code. Raises: common.UnterminatedCommentError: Encountered an unterminated multi-line comment.

The change

2020 comment.
2121 """
2222 pattern = r"""
23- (?P<literal> (\"([^\"\n])*\")+) |
23+ (?P<literal> \"(?:[^\"\\]*(?:\\\"|\\[^\"])*)*\") |
2424 (?P<single> //(?P<single_content>.*)?$) |
2525 (?P<multi> /\*(?P<multi_content>(.|\n)*?)?\*/) |
2626 (?P<error> /\*(.*)?)
2727 """
28-
2928 compiled = re.compile(pattern, re.VERBOSE | re.MULTILINE)
3029
3130 lines_indexes = []

The check that tells the two apart

failpass·comment_parser/parsers/tests/c_parser_test.py::CParserTest::testCommentStartInsideEscapedQuotesInStringLiteral

Check file comment_parser/parsers/tests/c_parser_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it0e4cf91cb1d44b1876050de6457513d31e0fa963
Broken version dated2020-09-01
Modulecomment_parser.parsers.c_parser
Units changedextract_comments
Fingerprintb90b04c12db0784f
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.