All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] scripts/kernel-doc: Escape all literal braces in regexes
@ 2018-08-05 16:41 Ben Hutchings
  2018-08-06 13:14 ` Jonathan Corbet
  2018-08-06 19:37 ` Jonathan Corbet
  0 siblings, 2 replies; 4+ messages in thread
From: Ben Hutchings @ 2018-08-05 16:41 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: linux-doc, valdis.kletnieks, 905116

[-- Attachment #1: Type: text/plain, Size: 3016 bytes --]

Commit 720ac2ef479d ("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.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
v2: Rebase on top of commit 720ac2ef479d; reword accordingly

 scripts/kernel-doc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 31a34ced55a3..8f0f508a78e9 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1062,7 +1062,7 @@ sub dump_struct($$) {
     my $x = shift;
     my $file = shift;
 
-    if ($x =~ /(struct|union)\s+(\w+)\s*{(.*)}/) {
+    if ($x =~ /(struct|union)\s+(\w+)\s*\{(.*)\}/) {
 	my $decl_type = $1;
 	$declaration_name = $2;
 	my $members = $3;
@@ -1148,20 +1148,20 @@ sub dump_struct($$) {
 				}
 			}
 		}
-		$members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)}([^\{\}\;]*)\;/$newmember/;
+		$members =~ s/(struct|union)([^\{\};]+)\{([^\{\}]*)\}([^\{\}\;]*)\;/$newmember/;
 	}
 
 	# Ignore other nested elements, like enums
-	$members =~ s/(\{[^\{\}]*})//g;
+	$members =~ s/(\{[^\{\}]*\})//g;
 
 	create_parameterlist($members, ';', $file, $declaration_name);
 	check_sections($file, $declaration_name, $decl_type, $sectcheck, $struct_actual);
 
 	# Adjust declaration for better display
-	$declaration =~ s/([{;])/$1\n/g;
-	$declaration =~ s/}\s+;/};/g;
+	$declaration =~ s/([\{;])/$1\n/g;
+	$declaration =~ s/\}\s+;/};/g;
 	# Better handle inlined enums
-	do {} while ($declaration =~ s/(enum\s+{[^}]+),([^\n])/$1,\n$2/);
+	do {} while ($declaration =~ s/(enum\s+\{[^\}]+),([^\n])/$1,\n$2/);
 
 	my @def_args = split /\n/, $declaration;
 	my $level = 1;
@@ -1171,12 +1171,12 @@ sub dump_struct($$) {
 		$clause =~ s/\s+$//;
 		$clause =~ s/\s+/ /;
 		next if (!$clause);
-		$level-- if ($clause =~ m/(})/ && $level > 1);
+		$level-- if ($clause =~ m/(\})/ && $level > 1);
 		if (!($clause =~ m/^\s*#/)) {
 			$declaration .= "\t" x $level;
 		}
 		$declaration .= "\t" . $clause . "\n";
-		$level++ if ($clause =~ m/(\{)/ && !($clause =~m/}/));
+		$level++ if ($clause =~ m/(\{)/ && !($clause =~m/\}/));
 	}
 	output_declaration($declaration_name,
 			   'struct',
@@ -1244,7 +1244,7 @@ sub dump_enum($$) {
     # strip #define macros inside enums
     $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
 
-    if ($x =~ /enum\s+(\w+)\s*{(.*)}/) {
+    if ($x =~ /enum\s+(\w+)\s*\{(.*)\}/) {
 	$declaration_name = $1;
 	my $members = $2;
 	my %_members;
@@ -1785,7 +1785,7 @@ sub process_proto_type($$) {
     }
 
     while (1) {
-	if ( $x =~ /([^{};]*)([{};])(.*)/ ) {
+	if ( $x =~ /([^\{\};]*)([\{\};])(.*)/ ) {
             if( length $prototype ) {
                 $prototype .= " "
             }

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scripts/kernel-doc: Escape all literal braces in regexes
  2018-08-05 16:41 [PATCH v2] scripts/kernel-doc: Escape all literal braces in regexes Ben Hutchings
@ 2018-08-06 13:14 ` Jonathan Corbet
  2018-08-06 15:43   ` Bug#905116: " Ben Hutchings
  2018-08-06 19:37 ` Jonathan Corbet
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Corbet @ 2018-08-06 13:14 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: linux-doc, valdis.kletnieks, 905116

On Sun, 5 Aug 2018 17:41:09 +0100
Ben Hutchings <ben@decadent.org.uk> wrote:

> Commit 720ac2ef479d ("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.

So where can I find this commit of which you speak?  I can't find it in
mainline, -next, or -stable...  

The patch looks good, I'd like to get it in this coming merge window if
possible.

Thanks,

jon
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug#905116: [PATCH v2] scripts/kernel-doc: Escape all literal braces in regexes
  2018-08-06 13:14 ` Jonathan Corbet
@ 2018-08-06 15:43   ` Ben Hutchings
  0 siblings, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2018-08-06 15:43 UTC (permalink / raw)
  To: Jonathan Corbet, 905116; +Cc: linux-doc, valdis.kletnieks

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

On Mon, 2018-08-06 at 07:14 -0600, Jonathan Corbet wrote:
> On Sun, 5 Aug 2018 17:41:09 +0100
> Ben Hutchings <ben@decadent.org.uk> wrote:
> 
> > Commit 720ac2ef479d ("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.
> 
> So where can I find this commit of which you speak?  I can't find it in
> mainline, -next, or -stable...  
> 
> The patch looks good, I'd like to get it in this coming merge window if
> possible.

Sorry, that was the wrong commit hash.  I mean commit 701b3a3c0ac4.

Ben.

-- 
Ben Hutchings
Larkinson's Law: All laws are basically false.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scripts/kernel-doc: Escape all literal braces in regexes
  2018-08-05 16:41 [PATCH v2] scripts/kernel-doc: Escape all literal braces in regexes Ben Hutchings
  2018-08-06 13:14 ` Jonathan Corbet
@ 2018-08-06 19:37 ` Jonathan Corbet
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Corbet @ 2018-08-06 19:37 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: linux-doc, valdis.kletnieks, 905116

On Sun, 5 Aug 2018 17:41:09 +0100
Ben Hutchings <ben@decadent.org.uk> wrote:

> Commit 720ac2ef479d ("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.
> 
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Applied (with the commit hash corrected), thanks.

jon
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-06 19:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-05 16:41 [PATCH v2] scripts/kernel-doc: Escape all literal braces in regexes Ben Hutchings
2018-08-06 13:14 ` Jonathan Corbet
2018-08-06 15:43   ` Bug#905116: " Ben Hutchings
2018-08-06 19:37 ` Jonathan Corbet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.