scripts/spdxcheck.py: Handle special quotation mark comments

The SuperH boot code files use a magic format for the SPDX identifier
comment:

  LIST "SPDX-License-Identifier: .... "

The trailing quotation mark is not stripped before the token parser is
invoked and causes the scan to fail. Handle it gracefully.

Fixes: 6a0abce4c4 ("sh: include: convert to SPDX identifiers")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Simon Horman <horms+renesas@verge.net.au>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
Thomas Gleixner 2019-01-16 11:26:53 +01:00 committed by Jonathan Corbet
parent 6e6c61d3e3
commit 959b496878

View File

@ -175,7 +175,13 @@ class id_parser(object):
self.lines_checked += 1 self.lines_checked += 1
if line.find("SPDX-License-Identifier:") < 0: if line.find("SPDX-License-Identifier:") < 0:
continue continue
expr = line.split(':')[1].replace('*/', '').strip() expr = line.split(':')[1].strip()
# Remove trailing comment closure
if line.startswith('/*'):
expr = expr.rstrip('*/').strip()
# Special case for SH magic boot code files
if line.startswith('LIST \"'):
expr = expr.rstrip('\"').strip()
self.parse(expr) self.parse(expr)
self.spdx_valid += 1 self.spdx_valid += 1
# #