Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753348AbdHJTIg (ORCPT ); Thu, 10 Aug 2017 15:08:36 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:7254 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753226AbdHJTIe (ORCPT ); Thu, 10 Aug 2017 15:08:34 -0400 X-IronPort-AV: E=Sophos;i="5.41,354,1498514400"; d="scan'208";a="286714410" Date: Thu, 10 Aug 2017 21:08:31 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Cihangir Akturk cc: Julia.Lawall@lip6.fr, Gilles.Muller@lip6.fr, nicolas.palix@imag.fr, mmarek@suse.com, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: Re: [PATCH] coccicheck: improve pattern for getting relative path In-Reply-To: <1502386825-363-1-git-send-email-cakturk@gmail.com> Message-ID: References: <1502386825-363-1-git-send-email-cakturk@gmail.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1610 Lines: 57 On Thu, 10 Aug 2017, Cihangir Akturk wrote: > When invoked with V=1, coccicheck script prints the information about > which semantic patch (*.cocci file) used for this operation. Actually, > it prints out the relative path of the related semantic patch. The > script uses sed to remove the source tree part from cocci file path like > so: > > FILE=`echo $COCCI | sed "s|$srctree/||"` > > This pattern works well most of the time. But in cases where $COCCI > doesn't start with "./" characters, it doesn't remove the right part. > > Consider the following scenario: > > $ make coccicheck COCCI=scripts/coccinelle/api/drm-get-put.cocci \ > MODE=patch M=drivers/staging V=1 > > where > > COCCI=scripts/coccinelle/api/drm-get-put.cocci and srctree=. > > In this case, out pattern matches the first "s/", and we end up > assigning "scriptcoccinelle/api/drm-get-put.cocci" to $FILE. > > Fix this by adding a caret ^ at the beginning of regex pattern, so that > it matches only start of the path. Nicolas, is this ok? julia > > Signed-off-by: Cihangir Akturk > --- > scripts/coccicheck | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/coccicheck b/scripts/coccicheck > index ec487b8..8de4245 100755 > --- a/scripts/coccicheck > +++ b/scripts/coccicheck > @@ -193,7 +193,7 @@ coccinelle () { > > if [ $VERBOSE -ne 0 -a $ONLINE -eq 0 ] ; then > > - FILE=`echo $COCCI | sed "s|$srctree/||"` > + FILE=`echo $COCCI | sed "s|^$srctree/||"` > > echo "Processing `basename $COCCI`" > echo "with option(s) \"$OPT\"" > -- > 2.7.4 > >