-
Notifications
You must be signed in to change notification settings - Fork 0
/
morph.diff
106 lines (96 loc) · 3.57 KB
/
morph.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
diff --git a/morph.pl b/morph.pl
index 183147a..413ccc9 100755
--- a/morph.pl
+++ b/morph.pl
@@ -24,8 +24,7 @@ sub notice
my @buffer = ('Copyright');
push(@buffer, @range);
push(@buffer, 'Open Networking Foundation (ONF) and the ONF Contributors');
- push(@buffer, '\n');
- return join(' ', @buffer);
+ return join(' ', @buffer) . "\n";
}
## -----------------------------------------------------------------------
@@ -37,7 +36,9 @@ sub replace_copyright
my ($line, @range) = @_;
my $loc = index($line, 'opyright');
- substr($line, $loc-1, length($line), notice($start));
+ my $span = join('-', @range);
+
+ substr($line, $loc-1, length($line), notice($span));
return $line;
}
@@ -56,47 +57,60 @@ while (<>)
}
# ---------------------------------------------------
- # Copyright (c) 2011, 2012 Open Networking Foundation
+ # Copyright (c) Open Networking Foundation
# - Change non-standard notice into standard.
# ---------------------------------------------------
if (!/Copyright\s*\(c\)/oi) {}
elsif ($line =~ /Open\s+Networking\s+Foundation/oi) {
- my ($start) = $line =~ /(\d{4})/;
+ my @range = $line =~ /(\d{4})/;
+ if ($range[0] != $year)
+ {
+ # Create a range from single legacy date
+ push(@range, $year);
+ }
+ $line = replace_copyright($line, @range);
+ print $line;
+ next LINE;
+ }
+
+ # -------------------------------------------------------------------------------------------
+ # SPDX-FileCopyrightText: 2023-2024 Open Networking Foundation (ONF) and the ONF Contributors
+ # -------------------------------------------------------------------------------------------
+ if (my ($span) = /SPDX-FileCopyrightText: .*(\d{4}) Open Networking Foundation/i)
+ {
+ my @range = ($span);
+ push(@range, $year) if ($range[0] ne $year);
- $line = replace_copyright($line, $start);
+ my $loc = index($line, 'SPDX-FileCopyrightText');
+ my $span = join('-', @range);
+ my $notice = notice($span);
+ substr($notice, 0, length('Copyright'), 'SPDX-FileCopyrightText:');
+ substr($line, $loc, length($line), $notice);
print $line;
next LINE;
}
-
+
# ----------------------------------------
# Augment ending date to span current year
# ----------------------------------------
- if (my ($val) = m/Copyright (.+) Open Networking Foundation/)
+ if (my ($val) = m/Copyright (.+) Open Networking FOundation/)
{
my $loc = index($line, $val);
my $len = length($val);
- $val =~ s/\s+//;
- my @fields = split(/-/, $val);
- if (2 > 0+@fields)
- {
- next LINE if ($fields[0] > $year); # End date is wonky (year > now)
- push(@fields, $year) if ($fields[0] != $year);
- }
- else
- {
- pop(@fields);
- push(@fields, $year);
- }
+ my ($start) = $val =~ /(\d{4})/;
+ next LINE if ($start > $year); # Notice date is wonky (year > now)
+
+ my @fields = ($start);
+ push(@fields, $year) if ($fields[0] ne $year);
my $span = join('-', @fields);
- $span = $year if ($span eq "$year-$year"); # {year}-present
- $_ = replace_copyright($line, $start);
+ $_ = replace_copyright($line, $span);
}
print;
}
-# Copyright 2019-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors
# [EOF]