Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1278755pxy; Sat, 1 May 2021 08:47:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAVpzujAQ2Gi3RB+ObnMXog69b5LGOI9kf0wwpJzXPuklo8td9E3otE7PeFT4cYGqVN2X7 X-Received: by 2002:a17:902:ec87:b029:ee:910d:acf5 with SMTP id x7-20020a170902ec87b02900ee910dacf5mr10988909plg.66.1619884075976; Sat, 01 May 2021 08:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619884075; cv=none; d=google.com; s=arc-20160816; b=tr7ymrsMkWhzfkhrkV93onS1N5giqAL0IZndUvBnRd01YnLrUHA6DQO6AVO2OXzCOE x7toAgz7EDw4AsE/aJBdKCXSrL98ulKI0I9xJq/kFNHCr/hcsJBGeFXnnF3SlV85vwL4 cUag8VllSq6rmApsBMRHqhU3vOThAYGegHGz0PZR7D3AphbJnoCNPVGg9PugRj8janNA Q7o31ig3Gg/df0LRYS30HHlGIC6TNaP+J8jKj/oNCC19hrJhuCsRfxm7W0rNw8ZV7Spe zi94fnhN1udQqSNznph9gXjaCmXhKgCHor/XANwqa/eoMgUCBAwRBmki9m9MC6hxYHPS zc3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZZhukaabMwhJaioIS34CyIDiXMBC3VOAahF1TCfxWX4=; b=h8pMndYyC5T5+S1ujhVguWsn3Tb0pl4hCIaDT4vduNdiAspReybCAaQfrWyUeO6kfL R8rZswnsYzLTki4+XgLQcrc/msrg9hnWvwkeRUflqX9RQJWNnrR27lJuFBubIADeURF4 xHxuqxbU8SHkewvcPUzplgIwNCt7/FVYqUH/MB1K67p+DcZBZq9N9ppQmKAQlnUyEb41 Yfvb0q2+nEDiaA65hRCVEEB8BiI1LnMQthl88MMhp11F/iw44gu/goBc9S678uCJIK7j rneSRg7/vxEFEagyLvdCeGcJrQV1KMVixJJ7RafHH0i4mnwPSQapKJz6z5YwDXQiQzm8 /SEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=frrztHdb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n19si1275626pgl.253.2021.05.01.08.47.43; Sat, 01 May 2021 08:47:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=frrztHdb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231796AbhEAPoq (ORCPT + 99 others); Sat, 1 May 2021 11:44:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbhEAPoq (ORCPT ); Sat, 1 May 2021 11:44:46 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B79C06174A; Sat, 1 May 2021 08:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ZZhukaabMwhJaioIS34CyIDiXMBC3VOAahF1TCfxWX4=; b=frrztHdbGuIO8+KQ2rDoaxbb5m ryap20MO+uUGBEiNmbi7azgpwpDy8qWbH9fduTdK5/i8tjOm+ninaiSF0D263wB2sAgHWqnFTs+Tw QSk3ZERiIE3yFOmhMXrIH2fCUG+knoC2Ef98iiuch3VhuFJfIAnNWbF2HzPXEWsYihau/+HSw0gRs qG99pNbVSwWpVstV/nqEi9RhdNMDFLNZeqX+zq+f7gYlaJm1f1HnrqY6tl7NtdAzP6gawknsrWSu6 66lCud+6bZg7JAXRb76yh1RWFA0WrWTwXNscSKSuXZGJzeUgiiVOOnCdrVF1vWO60CAJsHalMCvJo xRjMN9+w==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lcrmK-00CX5G-HU; Sat, 01 May 2021 15:43:42 +0000 Date: Sat, 1 May 2021 16:43:36 +0100 From: Matthew Wilcox To: Aditya Srivastava Cc: corbet@lwn.net, lukas.bulwahn@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC v3] scripts: kernel-doc: reduce repeated regex expressions into variables Message-ID: <20210501154336.GS1847222@casper.infradead.org> References: <20210427165633.GA235567@casper.infradead.org> <20210429063729.8144-1-yashsri421@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429063729.8144-1-yashsri421@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 29, 2021 at 12:07:29PM +0530, Aditya Srivastava wrote: > + my $name = qr{[a-zA-Z0-9_~:]+}; > + my $prototype_end1 = qr{[^\(]*}; > + my $prototype_end2 = qr{[^\{]*}; > + my $prototype_end = qr{\(($prototype_end1|$prototype_end2)\)}; Would this be better written as: my $prototype_end = qr{\([^\(\{]*\)} And now that I look at the whole thing, doesn't this fail to parse a function declared as: int f(void (*g)(long)); (that is, f takes a single argument, which is a pointer to a function which takes a long argument and returns void) Still, I don't think this was parsed correctly before, so it's not an argument against this patch, just something to take care of later. > + my $type1 = qr{[\w\s]+}; > + my $type2 = qr{$type1\*+}; > + > + if ($define && $prototype =~ m/^()($name)\s+/) { > # This is an object-like macro, it has no return type and no parameter > # list. > # Function-like macros are not allowed to have spaces between > @@ -1817,23 +1828,9 @@ sub dump_function($$) { > $return_type = $1; > $declaration_name = $2; > $noret = 1; > - } elsif ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || > - $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || > - $prototype =~ m/^(\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || > - $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s+\w+\s+\w+\s*\*+)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/ || > - $prototype =~ m/^(\w+\s+\w+\s*\*+\s*\w+\s*\*+\s*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\{]*)\)/) { > + } elsif ($prototype =~ m/^()($name)\s*$prototype_end/ || > + $prototype =~ m/^($type1)\s+($name)\s*$prototype_end/ || > + $prototype =~ m/^($type2)+\s*($name)\s*$prototype_end/) { > $return_type = $1; > $declaration_name = $2; > my $args = $3;