[libvirt] [PATCH] syntax-check: ignore all quoted strings in bracket-spacing
Ignore strings with an escaped double quote too. This removes the need for special handling of quotes in the semicolon check. --- build-aux/bracket-spacing.pl | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/build-aux/bracket-spacing.pl b/build-aux/bracket-spacing.pl index fbe..a99edeb 100755 --- a/build-aux/bracket-spacing.pl +++ b/build-aux/bracket-spacing.pl @@ -31,8 +31,8 @@ foreach my $file (@ARGV) { while (defined (my $line = FILE)) { my $data = $line; -# Kill any quoted strongs -$data =~ s,.*?,XXX,g; +# Kill any quoted strings +$data =~ s,([^\\\]|\\.)+,XXX,g; # Kill any C++ style comments $data =~ s,//.*$,//,; @@ -120,14 +120,9 @@ foreach my $file (@ARGV) { # errno == EINTR) # ; # -# 3) ; is inside double-quote, I.e, as part of const string. E.g. -# printf(%s, a ; b\n); while ($data =~ /[^;\s]\s+;/) { -# Inside the double-quote -if ($data !~ /[^]*\s;/) { -print $file:$.: $line; -$ret = 1; -} +print $file:$.: $line; +$ret = 1; last; } } -- 1.8.1.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] syntax-check: ignore all quoted strings in bracket-spacing
On 05/24/2013 03:26 AM, Ján Tomko wrote: Ignore strings with an escaped double quote too. This removes the need for special handling of quotes in the semicolon check. --- build-aux/bracket-spacing.pl | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/build-aux/bracket-spacing.pl b/build-aux/bracket-spacing.pl index fbe..a99edeb 100755 --- a/build-aux/bracket-spacing.pl +++ b/build-aux/bracket-spacing.pl @@ -31,8 +31,8 @@ foreach my $file (@ARGV) { while (defined (my $line = FILE)) { my $data = $line; -# Kill any quoted strongs -$data =~ s,.*?,XXX,g; +# Kill any quoted strings +$data =~ s,([^\\\]|\\.)+,XXX,g; Nice. I've used that trick in cfg.mk as well. You used '+' instead of '*'; that gives us a chance of a false positive, if we have both an empty string and another string on the same line: str = cond ? : ; ; because your replacement would result in a rewrite to: str = cond ? XXX ; ; With *, the rewrite would be: str = cond ? XXX : XXX; ACK if you fix the regex. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] syntax-check: ignore all quoted strings in bracket-spacing
On 05/24/2013 03:53 PM, Eric Blake wrote: On 05/24/2013 03:26 AM, Ján Tomko wrote: Ignore strings with an escaped double quote too. This removes the need for special handling of quotes in the semicolon check. --- build-aux/bracket-spacing.pl | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/build-aux/bracket-spacing.pl b/build-aux/bracket-spacing.pl index fbe..a99edeb 100755 --- a/build-aux/bracket-spacing.pl +++ b/build-aux/bracket-spacing.pl @@ -31,8 +31,8 @@ foreach my $file (@ARGV) { while (defined (my $line = FILE)) { my $data = $line; -# Kill any quoted strongs -$data =~ s,.*?,XXX,g; +# Kill any quoted strings +$data =~ s,([^\\\]|\\.)+,XXX,g; Nice. I've used that trick in cfg.mk as well. You used '+' instead of '*'; that gives us a chance of a false positive, if we have both an empty string and another string on the same line: str = cond ? : ; ; because your replacement would result in a rewrite to: str = cond ? XXX ; ; With *, the rewrite would be: str = cond ? XXX : XXX; ACK if you fix the regex. Thanks, fixed and pushed now. Jan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] syntax-check: ignore all quoted strings in bracket-spacing
On 05/24/2013 03:26 AM, Ján Tomko wrote: Ignore strings with an escaped double quote too. This removes the need for special handling of quotes in the semicolon check. --- build-aux/bracket-spacing.pl | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) Hmm, our semicolon check enforces no leading spaces, but we could probably improve it to also enforce trailing space in a for loop. For example, this looks odd: src/conf/interface_conf.c:for (i = 0; i nbItf;i++) { compared to for (i = 0; i nbItf; i++) { -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list