Skip to content

Commit 57b867a

Browse files
committed
Improve tool/update_copyright.rb
1 parent 2512cc9 commit 57b867a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tool/update_copyright.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# GNU General Public License version 2, or
77
# GNU Lesser General Public License version 2.1.
88

9-
abort "USAGE: ruby #{$0} NEW_YEAR" unless ARGV.first
9+
abort "USAGE: [ADD_ONLY=1] ruby #{$0} NEW_YEAR" unless ARGV.first
1010
year = Integer(ARGV.first)
1111
new_copyright_year = year
1212

@@ -33,11 +33,13 @@
3333
*/
3434
EOS
3535

36+
C_COPYRIGHT = JAVA_COPYRIGHT + "\n"
37+
3638
NEW_COPYRIGHT = {
3739
'.rb' => RB_COPYRIGHT,
3840
'.java' => JAVA_COPYRIGHT,
39-
'.c' => JAVA_COPYRIGHT,
40-
'.h' => JAVA_COPYRIGHT,
41+
'.c' => C_COPYRIGHT,
42+
'.h' => C_COPYRIGHT,
4143
}
4244

4345
EXTENSIONS = %w[.java .rb .c .h .md]
@@ -52,11 +54,13 @@
5254
/Copyright \(c\) \d{4}-\d{4} The JRuby project/, # io/console
5355
/Copyright \(C\) \d{4}-\d{4} Wayne Meissner/, # FFI
5456
/Copyright \(c\) \d{4}, Brian Shirai/, # rubysl-socket
57+
/Copyright \(c\) \d{4}, \d{4} Todd C\. Miller <Todd\.Miller@courtesan\.com>/, # strlcpy.c
5558
/Ruby is copyrighted free software by Yukihiro Matsumoto/, # MRI license
5659
/Copyright(?:::)?\s+\(C\)\s+\d{4}\s+Network Applied Communication Laboratory, Inc\./, # MRI stdlibs: thread, timeout
5760
/\* BEGIN LICENSE BLOCK \**\s*\n\s*\*\s*Version: EPL 2\.0\/GPL 2\.0\/LGPL 2\.1/,
5861
/#+\s*BEGIN LICENSE BLOCK\s*#+\s*\n\s*#\s*Version: EPL 2\.0\/GPL 2\.0\/LGPL 2\.1/,
5962
/This file is part of ruby-ffi\./,
63+
/This is a public domain/,
6064
]
6165

6266
truffle_paths = %w[
@@ -81,7 +85,6 @@
8185
lib/truffle/pathname
8286
lib/truffle/securerandom
8387
src/main/c/bigdecimal
84-
src/main/c/cext/st.c
8588
src/main/c/date
8689
src/main/c/etc
8790
src/main/c/io-console
@@ -91,7 +94,9 @@
9194
src/main/c/rbconfig-sizeof
9295
src/main/c/ripper
9396
src/main/c/syslog
97+
src/main/c/yarp
9498
src/main/c/zlib
99+
src/yarp
95100
spec/truffle/fixtures/hello-world
96101
test/truffle/pack-real-usage.rb
97102
test/truffle/cexts
@@ -115,7 +120,7 @@
115120
excludes.none? { |prefix| path.start_with? prefix } &&
116121
!excluded_files.include?(File.basename(path)) &&
117122
File.exist?(path) &&
118-
File.readlines(path).size > 2
123+
File.readlines(path).size > 5
119124
}
120125

121126
paths.each do |file|
@@ -134,9 +139,12 @@
134139
next
135140
end
136141

142+
next if ENV["ADD_ONLY"]
143+
137144
copyright, year1, sep, year2 = $~[:copyright], $~[:year1], $~[:sep], $~[:year2]
138145
year1 = Integer(year1)
139146
year2 = Integer(year2 || year1)
147+
sep ||= md ? '-' : ', '
140148

141149
if year > year2
142150
contents = File.read(file)

0 commit comments

Comments
 (0)