From patchwork Wed Jul 3 14:12:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 11029681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C05C1138B for ; Wed, 3 Jul 2019 14:12:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0FC9289D8 for ; Wed, 3 Jul 2019 14:12:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5664289E8; Wed, 3 Jul 2019 14:12:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2760428477 for ; Wed, 3 Jul 2019 14:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726490AbfGCOMO (ORCPT ); Wed, 3 Jul 2019 10:12:14 -0400 Received: from gofer.mess.org ([88.97.38.141]:48283 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725830AbfGCOMO (ORCPT ); Wed, 3 Jul 2019 10:12:14 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id D6E2060A67; Wed, 3 Jul 2019 15:12:12 +0100 (BST) From: Sean Young To: linux-media@vger.kernel.org Cc: Bastien Nocera Subject: [PATCH v4l-utils 1/2] gen_keytables.pl: strip comments from C files Date: Wed, 3 Jul 2019 15:12:11 +0100 Message-Id: <20190703141212.31719-1-sean@mess.org> X-Mailer: git-send-email 2.11.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some keymaps contain mappings in comments which should have not been included. Cc: Bastien Nocera Signed-off-by: Sean Young --- utils/keytable/gen_keytables.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/utils/keytable/gen_keytables.pl b/utils/keytable/gen_keytables.pl index 4124e366..8f3a87e6 100755 --- a/utils/keytable/gen_keytables.pl +++ b/utils/keytable/gen_keytables.pl @@ -82,7 +82,17 @@ sub parse_file($$) printf "processing file $filename\n" if ($debug); open IN, "<$filename" or die "couldn't find $filename"; - while () { + # read the entire file + my $file = do { local $/ = undef; }; + close IN; + + # remove comments + $file =~ s,/\*.*?\*/,,sg; + $file =~ s,//[^\n]*,,sg; + + my @lines = split /\n/, $file; + + foreach (@lines) { if (m/struct\s+rc_map_table\s+(\w[\w\d_]+)/) { flush($filename, $legacy); @@ -140,7 +150,6 @@ sub parse_file($$) } } } - close IN; flush($filename, $legacy);