From: Sean Young <sean@mess.org> To: linux-media@vger.kernel.org Cc: Bastien Nocera <hadess@hadess.net> Subject: [PATCH v4l-utils 1/2] gen_keytables.pl: strip comments from C files Date: Wed, 3 Jul 2019 15:12:11 +0100 [thread overview] Message-ID: <20190703141212.31719-1-sean@mess.org> (raw) Some keymaps contain mappings in comments which should have not been included. Cc: Bastien Nocera <hadess@hadess.net> Signed-off-by: Sean Young <sean@mess.org> --- 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 (<IN>) { + # read the entire file + my $file = do { local $/ = undef; <IN> }; + 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); -- 2.21.0
next reply other threads:[~2019-07-03 14:12 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-03 14:12 Sean Young [this message] 2019-07-03 14:12 ` [PATCH v4l-utils 2/2] gen_keytables.pl: remove duplicate scancodes from keymap Sean Young
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190703141212.31719-1-sean@mess.org \ --to=sean@mess.org \ --cc=hadess@hadess.net \ --cc=linux-media@vger.kernel.org \ --subject='Re: [PATCH v4l-utils 1/2] gen_keytables.pl: strip comments from C files' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).