blob: 2464c58aa2d1f8a0bab15e38ff24b2937ebf0446 [file] [log] [blame]
Shad Ansari2f7f9be2017-06-07 13:34:53 -07001#!/usr/bin/perl
2###############################################################################
3#
4# Copyright 2008-2014 Broadcom Corporation
5#
6# This program is the proprietary software of Broadcom Corporation
7# and/or its licensors, and may only be used, duplicated, modified or
8# distributed pursuant to the terms and conditions of a separate,
9# written license agreement executed between you and Broadcom (an
10# "Authorized License"). Except as set forth in an Authorized License,
11# Broadcom grants no license (express or implied), right to use, or
12# waiver of any kind with respect to the Software, and Broadcom
13# expressly reserves all rights in and to the Software and all
14# intellectual property rights therein. IF YOU HAVE NO AUTHORIZED
15# LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND
16# SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE
17# SOFTWARE.
18#
19# Except as expressly set forth in the Authorized License,
20#
21# 1. This program, including its structure, sequence and organization,
22# constitutes the valuable trade secrets of Broadcom, and you shall use
23# all reasonable efforts to protect the confidentiality thereof, and to
24# use this information only in connection with your use of Broadcom
25# integrated circuit products.
26#
27# 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
28# "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
29# REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR
30# OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
31# DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
32# NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
33# ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
34# CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
35# OF USE OR PERFORMANCE OF THE SOFTWARE.
36#
37# 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM
38# OR ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL,
39# INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY
40# RELATING TO YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF
41# BROADCOM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR (ii)
42# ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE SOFTWARE
43# ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY
44# NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED
45# REMEDY.
46#
47###############################################################################
48#
49# Script: strip_c_copyright.pl
50#
51# Purpose: This script removes a copyright header from a c/c++
52# file. The file is passed into the perl script via STDIN, so this
53# script must be used in conjunction with something like 'cat'.
54#
55# Usage: cat <file> | ./strip_c_copyright.pl
56#
57#
58# Previous attemps at c-style regular expressions...
59# s#(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/).*\n##;
60# s#(?:\/\*.*Copyright\(c\)(?:[^*]|(?:\*+[^*\/]))*\*+\/).*\n|(?:\/\*(?:[^*]|(?:\*+[^*\/]))*Copyright\(c\)(?:[^*]|(?:\*+[^*\/]))*\*+\/).*\n##;
61# good => s#(?:\/\*.*Copyright(?:[^*]|(?:\*+[^*\/]))*\*+\/).*\n|(?:\/\*(?:[^*]|(?:\*+[^*\/]))*Copyright(?:[^*]|(?:\*+[^*\/]))*\*+\/).*\n##;
62# good => s#(?:\/\*.*Copyright(?:[^*]|(?:\*+[^*\/]))*\*+\/).*(?:\s)+|(?:\/\*(?:[^*]|(?:\*+[^*\/]))*Copyright(?:[^*]|(?:\*+[^*\/]))*\*+\/).*(?:\s)+##;
63#
64# The following regex can be used for removing redundant C++
65# copyright header from libssd files...
66#
67# s#\/\/\*+[^*]*Copyright[^*]*\/\/\*+#//****************************************************************************#;
68#
69###############################################################################
70
71$/ = undef;
72$_ = <>;
73
74#
75# The following regex handles the old Teknovus-style copyright headers
76#
77# e.g. "/* Copyright(c) 2008-2012 Broadcom, Corp. */"
78#
79#s#(?:\/\*.*Copyright(?:[^*]|(?:\*+[^*\/]))*\*+\/).*(?:\s)+##;
80
81#
82# The following regex handles the new Broadcom standard copyright headers
83#
84s#(?:\/\*(?:[^*]|(?:\*+[^*\/]))*Copyright(?:[^*]|(?:\*+[^*\/]))*\*+\/).*(?:\s)+##;
85print;
86