History

scripts/kernel-doc: Escape all literal braces in regexes

Commit 701b3a3c0ac4 ("PATCH scripts/kernel-doc") fixed the two instances of literal braces that Perl 5.28 warns about, but there are still more than it doesn't warn about. Escape all left braces that are treated as literal characters. Also escape literal right braces, for consistency and to avoid confusing bracket-matching in text editors.

Ben Hutchings committed 8 years ago

Commit 673bb2d1 parent 0bf1bd81 file · +10 −10Browse files

Unified · Split

scripts/kernel-doc+10−10
@@ -1062,7 +1062,7 @@ sub dump_struct($$) { · 1061 unmodified lines
10621062 my $x = shift;
10631063 my $file = shift;
10641064
1065− if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) {
1065+ if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}/) {
10661066 my $decl_type = $1;
10671067 $declaration_name = $2;
10681068 my $members = $3;
@@ -1148,20 +1148,20 @@ sub dump_struct($$) { · 79 unmodified lines
11481148 }
11491149 }
11501150 }
1151− $members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)}([^\{\}\;]*)\;/$newmember/;
1151+ $members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*)\;/$newmember/;
11521152 }
11531153
11541154 # Ignore other nested elements, like enums
1155− $members =~ s/(\{[^\{\}]*})//g;
1155+ $members =~ s/(\{[^\{\}]*\})//g;
11561156
11571157 create_parameterlist($members, ';', $file, $declaration_name);
11581158 check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
11591159
11601160 # Adjust declaration for better display
1161− $declaration =~ s/([{;])/$1\n/g;
1162− $declaration =~ s/}\s+;/};/g;
1161+ $declaration =~ s/([\{;])/$1\n/g;
1162+ $declaration =~ s/\}\s+;/};/g;
11631163 # Better handle inlined enums
1164− do {} while ($declaration =~ s/(enum\s+{[^}]+),([^\n])/$1,\n$2/);
1164+ do {} while ($declaration =~ s/(enum\s+\{[^\}]+),([^\n])/$1,\n$2/);
11651165
11661166 my @def_args = split /\n/, $declaration;
11671167 my $level = 1;
@@ -1171,12 +1171,12 @@ sub dump_struct($$) { · 3 unmodified lines
11711171 $clause =~ s/\s+$//;
11721172 $clause =~ s/\s+/ /;
11731173 next if (!$clause);
1174− $level-- if ($clause =~ m/(})/ && $level > 1);
1174+ $level-- if ($clause =~ m/(\})/ && $level > 1);
11751175 if (!($clause =~ m/^\s*#/)) {
11761176 $declaration .= "\t" x $level;
11771177 }
11781178 $declaration .= "\t" . $clause . "\n";
1179− $level++ if ($clause =~ m/(\{)/ && !($clause =~m/}/));
1179+ $level++ if ($clause =~ m/(\{)/ && !($clause =~m/\}/));
11801180 }
11811181 output_declaration($declaration_name,
11821182 'struct',
@@ -1244,7 +1244,7 @@ sub dump_enum($$) { · 61 unmodified lines
12441244 # strip #define macros inside enums
12451245 $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
12461246
1247− if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
1247+ if ($x =~ /enum\s+(\w+)\s*\{(.*)\}/) {
12481248 $declaration_name = $1;
12491249 my $members = $2;
12501250 my %_members;
@@ -1785,7 +1785,7 @@ sub process_proto_type($$) { · 534 unmodified lines
17851785 }
17861786
17871787 while (1) {
1788− if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
1788+ if ( $x =~ /([^\{\};]*)([\{\};])(.*)/ ) {
17891789 if( length $prototype ) {
17901790 $prototype .= " "
17911791 }