fix copyright checker

properly handle files starting with #include or #pragma

Change-Id: I89b438ef36d796c2e005bb2241a97bf5e4d9e48c
Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:
Artur Harasimiuk
2018-09-20 14:27:16 +02:00
committed by sys_ocldev
parent 7de297763f
commit 23b6896f5f
5 changed files with 43 additions and 5 deletions

View File

@ -53,6 +53,11 @@ banned_paths = [
'scripts/tests/copyright/out'
]
cpp_sharp_lines = [
'#pragma',
'#include'
]
def isBanned(path):
path_ok = False
for banned_path in banned_paths:
@ -120,11 +125,18 @@ for path in sys.argv:
line = f.readline()
# check whether comment type is '#'
if first_line or line.startswith('#'):
header_start = '#'
header_end = '\n'
header = header_bash_style
comment_char = "#"
try:
if first_line or line.startswith('#'):
for a in cpp_sharp_lines:
print "a: %s ~ %s" % (a, line)
if line.startswith(a):
raise "c++"
header_start = '#'
header_end = '\n'
header = header_bash_style
comment_char = "#"
except:
pass
curr_comment = list()

View File

@ -0,0 +1,3 @@
#pragma once
// header file with # in first line

View File

@ -0,0 +1,3 @@
#include <cstdint>
// header file with # in first line

View File

@ -0,0 +1,10 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
// header file with # in first line

View File

@ -0,0 +1,10 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include <cstdint>
// header file with # in first line