Document the big regex

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-07-26 19:30:08 +02:00
parent a3974435ea
commit 8978c5b057

View File

@ -68,9 +68,17 @@ foreach my $file (@files) {
close FILE; close FILE;
my $found = 0; my $found = 0;
while ($content =~ m[ while ($content =~ m[
(?:/\*[*!]([^<](?:[^*]|\*+[^*/])*)\*/)? # Both the before-comment and the after-comment are optional.
\s*\#\s*define\s+(MBEDTLS_ERR_\w+)\s+\-(0[Xx][0-9A-Fa-f]+)\s* # Only the comment content is a regex capture group. The comment
(?:/\*[*!]<((?:[^*]|\*+[^*/])*)\*/)? # start and end parts are outside the capture group.
(?:/\*[*!](?!<) # Doxygen before-comment start
((?:[^*]|\*+[^*/])*) # $1: Comment content (no */ inside)
\*/)? # Comment end
\s*\#\s*define\s+(MBEDTLS_ERR_\w+) # $2: name
\s+\-(0[Xx][0-9A-Fa-f]+)\s* # $3: value (without the sign)
(?:/\*[*!]< # Doxygen after-comment start
((?:[^*]|\*+[^*/])*) # $4: Comment content (no */ inside)
\*/)? # Comment end
]gsx) { ]gsx) {
my ($before, $name, $value, $after) = ($1, $2, $3, $4); my ($before, $name, $value, $after) = ($1, $2, $3, $4);
# Discard Doxygen comments that are coincidentally present before # Discard Doxygen comments that are coincidentally present before