From nobody Sun Feb 8 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537346320511342.46958765863803; Wed, 19 Sep 2018 01:38:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89C1A8831E; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 565C417B68; Wed, 19 Sep 2018 08:38:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E4BC24A464; Wed, 19 Sep 2018 08:38:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8J8cUJJ006611 for ; Wed, 19 Sep 2018 04:38:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D0F07FCB7; Wed, 19 Sep 2018 08:38:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 948117FCBD for ; Wed, 19 Sep 2018 08:38:28 +0000 (UTC) Received: from m97135.mail.qiye.163.com (m97135.mail.qiye.163.com [220.181.97.135]) by mx1.redhat.com (Postfix) with ESMTP id 8F27E3091D4E for ; Wed, 19 Sep 2018 08:38:26 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp1 (Coremail) with SMTP id h+CowACH6K8AC6Jb9vM3Ag--.63S5; Wed, 19 Sep 2018 16:38:25 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Wed, 19 Sep 2018 16:38:16 +0800 Message-Id: <20180919083819.11042-4-shi_lei@massclouds.com> In-Reply-To: <20180919083819.11042-1-shi_lei@massclouds.com> References: <20180919083819.11042-1-shi_lei@massclouds.com> X-CM-TRANSID: h+CowACH6K8AC6Jb9vM3Ag--.63S5 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTR_BMKDUUUU X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiegHGT1qrhjYcBwAAso X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 19 Sep 2018 08:38:27 +0000 (UTC) for IP:'220.181.97.135' DOMAIN:'m97135.mail.qiye.163.com' HELO:'m97135.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 220.181.97.135 m97135.mail.qiye.163.com 220.181.97.135 m97135.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] build-aux:check-spacing: Add wrapper function of KillComments X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 19 Sep 2018 08:38:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds KillComments to simplifies check-spacing. Signed-off-by: Shi Lei --- build-aux/check-spacing.pl | 56 ++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl index c5d5a69..75bcfd9 100755 --- a/build-aux/check-spacing.pl +++ b/build-aux/check-spacing.pl @@ -62,8 +62,41 @@ sub CheckFunctionBody { return $ret; } =20 +# +# KillComments: +# $_[0]: $data(inout) +# $_[1]: $incomment(inout) +# +# Remove all content of comments +# (Also, the @incomment could be declared with *state* and move it in.) +# +sub KillComments { + my ($data, $incomment) =3D @_; + + # Kill contents of multi-line comments + # and detect end of multi-line comments + if ($$incomment) { + if ($$data =3D~ m,\*/,) { + $$incomment =3D 0; + $$data =3D~ s,^.*\*/,*/,; + } else { + $$data =3D ""; + } + } + + # Kill single line comments, and detect + # start of multi-line comments + if ($$data =3D~ m,/\*.*\*/,) { + $$data =3D~ s,/\*.*\*/,/* */,; + } elsif ($$data =3D~ m,/\*,) { + $$incomment =3D 1; + $$data =3D~ s,/\*.*,/*,; + } + + return; +} + my $ret =3D 0; -my $incomment =3D 0; =20 foreach my $file (@ARGV) { # Per-file variables for multiline Curly Bracket (cb_) check @@ -71,6 +104,7 @@ foreach my $file (@ARGV) { my $cb_code =3D ""; my $cb_scolon =3D 0; my $fn_linenum =3D 0; + my $incomment =3D 0; =20 open FILE, $file; =20 @@ -93,25 +127,7 @@ foreach my $file (@ARGV) { =20 $ret =3D 1 if CheckFunctionBody(\$data, \$location, \$fn_linenum); =20 - # Kill contents of multi-line comments - # and detect end of multi-line comments - if ($incomment) { - if ($data =3D~ m,\*/,) { - $incomment =3D 0; - $data =3D~ s,^.*\*/,*/,; - } else { - $data =3D ""; - } - } - - # Kill single line comments, and detect - # start of multi-line comments - if ($data =3D~ m,/\*.*\*/,) { - $data =3D~ s,/\*.*\*/,/* */,; - } elsif ($data =3D~ m,/\*,) { - $incomment =3D 1; - $data =3D~ s,/\*.*,/*,; - } + KillComments(\$data, \$incomment); =20 # We need to match things like # --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list