2015-01-17 20:38:31 +01:00
|
|
|
eval '(exit $?0)' && eval 'exec perl -wS -i "$0" ${1+"$@"}'
|
|
|
|
& eval 'exec perl -wS -i "$0" $argv:q'
|
|
|
|
if 0;
|
|
|
|
|
2022-01-11 10:54:10 +01:00
|
|
|
# Copyright (C) 2015-2022 by
|
2015-01-17 20:38:31 +01:00
|
|
|
# Werner Lemberg.
|
|
|
|
#
|
|
|
|
# This file is part of the FreeType project, and may only be used, modified,
|
|
|
|
# and distributed under the terms of the FreeType project license,
|
|
|
|
# LICENSE.TXT. By continuing to use, modify, or distribute this file you
|
|
|
|
# indicate that you have read the license and understand and accept it
|
|
|
|
# fully.
|
|
|
|
|
|
|
|
# [Note: This script is expected to be called by the shell, which in turn
|
|
|
|
# calls perl automatically. The nifty start-up code above is based on
|
|
|
|
# gnulib's `update-copyright' script; it is a more portable replacement for
|
|
|
|
# the shebang, using the first `perl' program in the shell's path instead.]
|
|
|
|
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# update-copyright-year file1 [file2 ...]
|
|
|
|
|
|
|
|
|
|
|
|
# This script handles copyright entries like
|
|
|
|
#
|
|
|
|
# Copyright 2000 by
|
|
|
|
# foobar
|
|
|
|
#
|
|
|
|
# or
|
|
|
|
#
|
2021-01-17 08:44:00 +01:00
|
|
|
# /* Copyright (c) 2000, 2001, 2004-2007 by */
|
|
|
|
# /* foobar */
|
2015-01-17 20:38:31 +01:00
|
|
|
#
|
|
|
|
# and replaces them uniformly with
|
|
|
|
#
|
2021-01-17 08:44:00 +01:00
|
|
|
# Copyright (C) 2000-2021
|
2015-01-17 20:38:31 +01:00
|
|
|
# foobar
|
|
|
|
#
|
|
|
|
# and
|
|
|
|
#
|
2021-01-17 08:44:00 +01:00
|
|
|
# /* Copyright (C) 2000-2021 by */
|
|
|
|
# /* foobar */
|
2015-01-17 20:38:31 +01:00
|
|
|
#
|
2021-01-17 08:44:00 +01:00
|
|
|
# (assuming that the current year is 2021). As can be seen, the line length
|
2015-01-17 20:38:31 +01:00
|
|
|
# is retained if there is non-whitespace after the word `by' on the same
|
|
|
|
# line.
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
|
|
|
|
my (undef, undef, undef,
|
|
|
|
undef, undef, $year,
|
|
|
|
undef, undef, undef) = localtime(time);
|
|
|
|
$year += 1900;
|
|
|
|
|
|
|
|
my $replaced = 0;
|
|
|
|
|
|
|
|
|
|
|
|
# Loop over all input files; option `-i' (issued at the very beginning of
|
|
|
|
# this script) makes perl edit them in-place.
|
|
|
|
while (<>)
|
|
|
|
{
|
|
|
|
# Only handle the first copyright notice in a file.
|
|
|
|
if (!$replaced)
|
|
|
|
{
|
|
|
|
# First try: Search multiple copyright years.
|
|
|
|
s {
|
|
|
|
(?<begin>.*)
|
|
|
|
Copyright
|
2019-02-23 10:05:37 +01:00
|
|
|
(?<space1>(\ +
|
|
|
|
| \ +\(C\)\ +))
|
2015-01-17 20:38:31 +01:00
|
|
|
(?<first>[12][0-9][0-9][0-9])
|
|
|
|
(?<middle>.+)
|
|
|
|
(?<last>[12][0-9][0-9][0-9])
|
|
|
|
(?<space2>\ +)
|
|
|
|
by
|
|
|
|
(?<space3>\ *)
|
|
|
|
(?<end>.*)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
# Fill line to the same length (if appropriate); we skip the middle
|
2019-02-23 10:05:37 +01:00
|
|
|
# part but insert `(C)', three spaces, and `-'.
|
2021-01-17 08:44:00 +01:00
|
|
|
my $space = length($+{space1})
|
|
|
|
+ length($+{middle})
|
|
|
|
+ length($+{space2})
|
2019-02-23 10:05:37 +01:00
|
|
|
+ length($+{space3})
|
2021-01-17 08:44:00 +01:00
|
|
|
- (length("(C)") + 3 + 1);
|
2015-01-17 20:38:31 +01:00
|
|
|
|
|
|
|
print "$+{begin}";
|
2019-02-23 10:05:37 +01:00
|
|
|
print "Copyright\ (C)\ $+{first}-$year\ by";
|
2015-01-17 20:38:31 +01:00
|
|
|
print ' ' x $space if length($+{end});
|
|
|
|
print "$+{end}\n";
|
|
|
|
$replaced = 1;
|
|
|
|
}ex
|
|
|
|
||
|
|
|
|
# Second try: Search a single copyright year.
|
|
|
|
s {
|
|
|
|
(?<begin>.*)
|
|
|
|
Copyright
|
2019-02-23 10:05:37 +01:00
|
|
|
(?<space1>(\ +
|
|
|
|
| \ +\(C\)\ +))
|
2015-01-17 20:38:31 +01:00
|
|
|
(?<first>[12][0-9][0-9][0-9])
|
|
|
|
(?<space2>\ +)
|
|
|
|
by
|
|
|
|
(?<space3>\ *)
|
|
|
|
(?<end>.*)
|
|
|
|
}
|
|
|
|
{
|
2021-02-13 09:21:37 +01:00
|
|
|
if ($+{first} < $year)
|
|
|
|
{
|
|
|
|
# Fill line to the same length (if appropriate); we insert three
|
|
|
|
# spaces, the string `(C)', a `-', and the current year.
|
|
|
|
my $space = length($+{space1})
|
|
|
|
+ length($+{space2})
|
|
|
|
+ length($+{space3})
|
|
|
|
- (length($year) + length("(C)") + 3 + 1);
|
2015-01-17 20:38:31 +01:00
|
|
|
|
2021-02-13 09:21:37 +01:00
|
|
|
print "$+{begin}";
|
|
|
|
print "Copyright\ (C)\ $+{first}-$year\ by";
|
|
|
|
# If $space is negative this inserts nothing.
|
|
|
|
print ' ' x $space if length($+{end});
|
|
|
|
print "$+{end}\n";
|
|
|
|
$replaced = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# Fill line to the same length (if appropriate); we insert three
|
|
|
|
# spaces and the string `(C)'.
|
|
|
|
my $space = length($+{space1})
|
|
|
|
+ length($+{space2})
|
|
|
|
+ length($+{space3})
|
|
|
|
- (length("(C)") + 3);
|
|
|
|
|
|
|
|
print "$+{begin}";
|
|
|
|
print "Copyright\ (C)\ $+{first}\ by";
|
|
|
|
# If $space is negative this inserts nothing.
|
|
|
|
print ' ' x $space if length($+{end});
|
|
|
|
print "$+{end}\n";
|
|
|
|
$replaced = 1;
|
|
|
|
}
|
2015-01-17 20:38:31 +01:00
|
|
|
}ex
|
|
|
|
||
|
|
|
|
# Otherwise print line unaltered.
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
{
|
|
|
|
# Reset $replaced before processing the next file.
|
|
|
|
$replaced = 0 if eof;
|
|
|
|
}
|
|
|
|
|
|
|
|
# EOF
|