From 24f9a93872eb572bbe1574669c40c9b003e8c473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20T=C3=A9tar?= Date: Sat, 4 Jan 2014 21:16:57 +0100 Subject: [PATCH] etc: licenseck: don't hardcode a specific year --- src/compiletest/common.rs | 4 +- src/compiletest/header.rs | 4 +- src/compiletest/runtest.rs | 4 +- src/etc/licenseck.py | 63 ++++++-------------------------- src/libsyntax/ext/source_util.rs | 4 +- 5 files changed, 20 insertions(+), 59 deletions(-) diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 6a365ae05dd..b76238ca388 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -1,5 +1,5 @@ -// Copyright 2012-2013 The Rust Project Developers. See the -// COPYRIGHT file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -""" - -license1 = """\ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +license1 = """// Copyright """ +license2 = """ The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -32,20 +20,8 @@ license1 = """\ // except according to those terms. """ -license2 = """\ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -""" - -license3 = """\ -# Copyright 2013 The Rust Project Developers. See the COPYRIGHT +license3 = """# Copyright """ +license4 = """ The Rust Project Developers. See the COPYRIGHT # file at the top-level directory of this distribution and at # http://rust-lang.org/COPYRIGHT. # @@ -56,20 +32,6 @@ license3 = """\ # except according to those terms. """ -license4 = """\ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -""" - -licenses = [license0, license1, license2, license3, license4] - exceptions = [ "rt/rust_android_dummy.cpp", # BSD, chromium "rt/rust_android_dummy.h", # BSD, chromium @@ -82,20 +44,19 @@ exceptions = [ ] def check_license(name, contents): - valid_license = False - for a_valid_license in licenses: - if contents.startswith(a_valid_license): - valid_license = True - break - if valid_license: - return True - + # Whitelist check for exception in exceptions: if name.endswith(exception): return True + # Xfail check firstlineish = contents[:100] if firstlineish.find("xfail-license") != -1: return True - return False + # License check + boilerplate = contents[:500] + if (boilerplate.find(license1) == -1 or boilerplate.find(license2) == -1) and \ + (boilerplate.find(license3) == -1 or boilerplate.find(license4) == -1): + return False + return True \ No newline at end of file diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 5f634f7f054..57da01ccad0 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -1,5 +1,5 @@ -// Copyright 2012-2013 The Rust Project Developers. See the -// COPYRIGHT file at the top-level directory of this distribution and at +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0