]>
Commit | Line | Data |
---|---|---|
677e2298 GKH |
1 | From 673bb2dfc36488abfdbbfc2ce2631204eaf682f2 Mon Sep 17 00:00:00 2001 |
2 | From: Ben Hutchings <ben@decadent.org.uk> | |
3 | Date: Sun, 5 Aug 2018 17:41:09 +0100 | |
4 | Subject: scripts/kernel-doc: Escape all literal braces in regexes | |
5 | ||
6 | From: Ben Hutchings <ben@decadent.org.uk> | |
7 | ||
8 | commit 673bb2dfc36488abfdbbfc2ce2631204eaf682f2 upstream. | |
9 | ||
10 | Commit 701b3a3c0ac4 ("PATCH scripts/kernel-doc") fixed the two | |
11 | instances of literal braces that Perl 5.28 warns about, but there are | |
12 | still more than it doesn't warn about. | |
13 | ||
14 | Escape all left braces that are treated as literal characters. Also | |
15 | escape literal right braces, for consistency and to avoid confusing | |
16 | bracket-matching in text editors. | |
17 | ||
18 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | |
19 | Signed-off-by: Jonathan Corbet <corbet@lwn.net> | |
20 | Cc: Nathan Chancellor <natechancellor@gmail.com> | |
21 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
22 | ||
23 | --- | |
24 | scripts/kernel-doc | 20 ++++++++++---------- | |
25 | 1 file changed, 10 insertions(+), 10 deletions(-) | |
26 | ||
27 | --- a/scripts/kernel-doc | |
28 | +++ b/scripts/kernel-doc | |
29 | @@ -1062,7 +1062,7 @@ sub dump_struct($$) { | |
30 | my $x = shift; | |
31 | my $file = shift; | |
32 | ||
33 | - if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) { | |
34 | + if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}/) { | |
35 | my $decl_type = $1; | |
36 | $declaration_name = $2; | |
37 | my $members = $3; | |
38 | @@ -1148,20 +1148,20 @@ sub dump_struct($$) { | |
39 | } | |
40 | } | |
41 | } | |
42 | - $members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)}([^\{\}\;]*)\;/$newmember/; | |
43 | + $members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*)\;/$newmember/; | |
44 | } | |
45 | ||
46 | # Ignore other nested elements, like enums | |
47 | - $members =~ s/(\{[^\{\}]*})//g; | |
48 | + $members =~ s/(\{[^\{\}]*\})//g; | |
49 | ||
50 | create_parameterlist($members, ';', $file, $declaration_name); | |
51 | check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual); | |
52 | ||
53 | # Adjust declaration for better display | |
54 | - $declaration =~ s/([{;])/$1\n/g; | |
55 | - $declaration =~ s/}\s+;/};/g; | |
56 | + $declaration =~ s/([\{;])/$1\n/g; | |
57 | + $declaration =~ s/\}\s+;/};/g; | |
58 | # Better handle inlined enums | |
59 | - do {} while ($declaration =~ s/(enum\s+{[^}]+),([^\n])/$1,\n$2/); | |
60 | + do {} while ($declaration =~ s/(enum\s+\{[^\}]+),([^\n])/$1,\n$2/); | |
61 | ||
62 | my @def_args = split /\n/, $declaration; | |
63 | my $level = 1; | |
64 | @@ -1171,12 +1171,12 @@ sub dump_struct($$) { | |
65 | $clause =~ s/\s+$//; | |
66 | $clause =~ s/\s+/ /; | |
67 | next if (!$clause); | |
68 | - $level-- if ($clause =~ m/(})/ && $level > 1); | |
69 | + $level-- if ($clause =~ m/(\})/ && $level > 1); | |
70 | if (!($clause =~ m/^\s*#/)) { | |
71 | $declaration .= "\t" x $level; | |
72 | } | |
73 | $declaration .= "\t" . $clause . "\n"; | |
74 | - $level++ if ($clause =~ m/(\{)/ && !($clause =~m/}/)); | |
75 | + $level++ if ($clause =~ m/(\{)/ && !($clause =~m/\}/)); | |
76 | } | |
77 | output_declaration($declaration_name, | |
78 | 'struct', | |
79 | @@ -1244,7 +1244,7 @@ sub dump_enum($$) { | |
80 | # strip #define macros inside enums | |
81 | $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos; | |
82 | ||
83 | - if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { | |
84 | + if ($x =~ /enum\s+(\w+)\s*\{(.*)\}/) { | |
85 | $declaration_name = $1; | |
86 | my $members = $2; | |
87 | my %_members; | |
88 | @@ -1785,7 +1785,7 @@ sub process_proto_type($$) { | |
89 | } | |
90 | ||
91 | while (1) { | |
92 | - if ( $x =~ /([^{};]*)([{};])(.*)/ ) { | |
93 | + if ( $x =~ /([^\{\};]*)([\{\};])(.*)/ ) { | |
94 | if( length $prototype ) { | |
95 | $prototype .= " " | |
96 | } |