* [Qemu-devel] [PATCH] checkpatch: Escape left braces in regex
@ 2015-09-11 11:07 Fam Zheng
2015-09-11 11:11 ` Peter Maydell
2015-09-14 16:41 ` Paolo Bonzini
0 siblings, 2 replies; 4+ messages in thread
From: Fam Zheng @ 2015-09-11 11:07 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, stefanha, mreitz
Latest perl now deprecates "{" literal in regex and print warnings like
"unescaped left brace in regex is deprecated". Add escape to keep it
happy.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
scripts/checkpatch.pl | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7f0aae9..14985be 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -633,7 +633,7 @@ sub statement_block_size {
my ($stmt) = @_;
$stmt =~ s/(^|\n)./$1/g;
- $stmt =~ s/^\s*{//;
+ $stmt =~ s/^\s*\{//;
$stmt =~ s/}\s*$//;
$stmt =~ s/^\s*//;
$stmt =~ s/\s*$//;
@@ -1644,7 +1644,7 @@ sub process {
# 79 or 80 characters, it is no longer possible to add a space and an
# opening brace there)
if ($#ctx == 0 && $ctx !~ /{\s*/ &&
- defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/ &&
+ defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*\{/ &&
defined($lines[$ctx_ln - 2]) && length($lines[$ctx_ln - 2]) < 80) {
ERROR("that open brace { should be on the previous line\n" .
"$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
@@ -1684,7 +1684,7 @@ sub process {
my $continuation = 0;
my $check = 0;
$s =~ s/^.*\bdo\b//;
- $s =~ s/^\s*{//;
+ $s =~ s/^\s*\{//;
if ($s =~ s/^\s*\\//) {
$continuation = 1;
}
@@ -1783,7 +1783,7 @@ sub process {
}
# check for initialisation to aggregates open brace on the next line
- if ($line =~ /^.\s*{/ &&
+ if ($line =~ /^.\s*\{/ &&
$prevline =~ /(?:^|[^=])=\s*$/) {
ERROR("that open brace { should be on the previous line\n" . $hereprev);
}
@@ -1936,13 +1936,13 @@ sub process {
# function brace can't be on same line, except for #defines of do while,
# or if closed on same line
- if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
- !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
+ if (($line=~/$Type\s*$Ident\(.*\).*\s\{/) and
+ !($line=~/\#\s*define.*do\s\{/) and !($line=~/}/)) {
ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
}
# open braces for enum, union and struct go on the same line.
- if ($line =~ /^.\s*{/ &&
+ if ($line =~ /^.\s*\{/ &&
$prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
ERROR("open brace '{' following $1 go on the same line\n" . $hereprev);
}
@@ -2091,7 +2091,7 @@ sub process {
# not required when having a single },{ on one line
} elsif ($op eq ',') {
if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/ &&
- ($elements[$n] . $elements[$n + 2]) !~ " *}{") {
+ ($elements[$n] . $elements[$n + 2]) !~ " *}\\{") {
ERROR("space required after that '$op' $at\n" . $hereptr);
}
@@ -2211,8 +2211,8 @@ sub process {
## }
#need space before brace following if, while, etc
- if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
- $line =~ /do{/) {
+ if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
+ $line =~ /do\{/) {
ERROR("space required before the open brace '{'\n" . $herecurr);
}
@@ -2551,7 +2551,7 @@ sub process {
my $spaced_block = $block;
$spaced_block =~ s/\n\+/ /g;
- $seen++ if ($spaced_block =~ /^\s*{/);
+ $seen++ if ($spaced_block =~ /^\s*\{/);
print "APW: cond<$cond> block<$block> allowed<$allowed>\n"
if $dbg_adv_apw;
--
2.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] checkpatch: Escape left braces in regex
2015-09-11 11:07 [Qemu-devel] [PATCH] checkpatch: Escape left braces in regex Fam Zheng
@ 2015-09-11 11:11 ` Peter Maydell
2015-09-14 16:41 ` Paolo Bonzini
1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2015-09-11 11:11 UTC (permalink / raw)
To: Fam Zheng
Cc: Paolo Bonzini, Bastian Koppelmann, QEMU Developers,
Stefan Hajnoczi, Max Reitz
On 11 September 2015 at 12:07, Fam Zheng <famz@redhat.com> wrote:
> Latest perl now deprecates "{" literal in regex and print warnings like
> "unescaped left brace in regex is deprecated". Add escape to keep it
> happy.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
Looks like https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg01134.html
but catching more cases?
thanks
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] checkpatch: Escape left braces in regex
2015-09-11 11:07 [Qemu-devel] [PATCH] checkpatch: Escape left braces in regex Fam Zheng
2015-09-11 11:11 ` Peter Maydell
@ 2015-09-14 16:41 ` Paolo Bonzini
2015-09-14 16:53 ` Peter Maydell
1 sibling, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2015-09-14 16:41 UTC (permalink / raw)
To: Fam Zheng, qemu-devel; +Cc: stefanha, mreitz
On 11/09/2015 13:07, Fam Zheng wrote:
> Latest perl now deprecates "{" literal in regex and print warnings like
> "unescaped left brace in regex is deprecated". Add escape to keep it
> happy.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> scripts/checkpatch.pl | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7f0aae9..14985be 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -633,7 +633,7 @@ sub statement_block_size {
> my ($stmt) = @_;
>
> $stmt =~ s/(^|\n)./$1/g;
> - $stmt =~ s/^\s*{//;
> + $stmt =~ s/^\s*\{//;
> $stmt =~ s/}\s*$//;
> $stmt =~ s/^\s*//;
> $stmt =~ s/\s*$//;
> @@ -1644,7 +1644,7 @@ sub process {
> # 79 or 80 characters, it is no longer possible to add a space and an
> # opening brace there)
> if ($#ctx == 0 && $ctx !~ /{\s*/ &&
> - defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/ &&
> + defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*\{/ &&
> defined($lines[$ctx_ln - 2]) && length($lines[$ctx_ln - 2]) < 80) {
> ERROR("that open brace { should be on the previous line\n" .
> "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
> @@ -1684,7 +1684,7 @@ sub process {
> my $continuation = 0;
> my $check = 0;
> $s =~ s/^.*\bdo\b//;
> - $s =~ s/^\s*{//;
> + $s =~ s/^\s*\{//;
> if ($s =~ s/^\s*\\//) {
> $continuation = 1;
> }
> @@ -1783,7 +1783,7 @@ sub process {
> }
>
> # check for initialisation to aggregates open brace on the next line
> - if ($line =~ /^.\s*{/ &&
> + if ($line =~ /^.\s*\{/ &&
> $prevline =~ /(?:^|[^=])=\s*$/) {
> ERROR("that open brace { should be on the previous line\n" . $hereprev);
> }
> @@ -1936,13 +1936,13 @@ sub process {
>
> # function brace can't be on same line, except for #defines of do while,
> # or if closed on same line
> - if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
> - !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
> + if (($line=~/$Type\s*$Ident\(.*\).*\s\{/) and
> + !($line=~/\#\s*define.*do\s\{/) and !($line=~/}/)) {
> ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
> }
>
> # open braces for enum, union and struct go on the same line.
> - if ($line =~ /^.\s*{/ &&
> + if ($line =~ /^.\s*\{/ &&
> $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
> ERROR("open brace '{' following $1 go on the same line\n" . $hereprev);
> }
> @@ -2091,7 +2091,7 @@ sub process {
> # not required when having a single },{ on one line
> } elsif ($op eq ',') {
> if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/ &&
> - ($elements[$n] . $elements[$n + 2]) !~ " *}{") {
> + ($elements[$n] . $elements[$n + 2]) !~ " *}\\{") {
> ERROR("space required after that '$op' $at\n" . $hereptr);
> }
>
> @@ -2211,8 +2211,8 @@ sub process {
> ## }
>
> #need space before brace following if, while, etc
> - if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
> - $line =~ /do{/) {
> + if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) ||
> + $line =~ /do\{/) {
> ERROR("space required before the open brace '{'\n" . $herecurr);
> }
>
> @@ -2551,7 +2551,7 @@ sub process {
> my $spaced_block = $block;
> $spaced_block =~ s/\n\+/ /g;
>
> - $seen++ if ($spaced_block =~ /^\s*{/);
> + $seen++ if ($spaced_block =~ /^\s*\{/);
>
> print "APW: cond<$cond> block<$block> allowed<$allowed>\n"
> if $dbg_adv_apw;
>
Applied to my queue, but I wouldn't be surprised Peter commits it directly.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] checkpatch: Escape left braces in regex
2015-09-14 16:41 ` Paolo Bonzini
@ 2015-09-14 16:53 ` Peter Maydell
0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2015-09-14 16:53 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Fam Zheng, QEMU Developers, Stefan Hajnoczi, Max Reitz
On 14 September 2015 at 17:41, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 11/09/2015 13:07, Fam Zheng wrote:
>> Latest perl now deprecates "{" literal in regex and print warnings like
>> "unescaped left brace in regex is deprecated". Add escape to keep it
>> happy.
> Applied to my queue, but I wouldn't be surprised Peter commits it directly.
None of my systems have the offending Perl version yet, so I'm
happy to let it go via your queue...
thanks
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-14 16:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-11 11:07 [Qemu-devel] [PATCH] checkpatch: Escape left braces in regex Fam Zheng
2015-09-11 11:11 ` Peter Maydell
2015-09-14 16:41 ` Paolo Bonzini
2015-09-14 16:53 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).