mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
maint: clean up update-b4-copyright code
* build-aux/update-b4-copyright: Do not accept 2-digit UPDATE_COPYRIGHT_YEAR, which was not handled correctly. Don't accept a `[' in a b4_copyright argument. Format code more consistently. Don't assume b4*copyright never occurs.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2009-08-05 Joel E. Denny <jdenny@clemson.edu>
|
||||||
|
|
||||||
|
maint: clean up update-b4-copyright code
|
||||||
|
* build-aux/update-b4-copyright: Do not accept 2-digit
|
||||||
|
UPDATE_COPYRIGHT_YEAR, which was not handled correctly.
|
||||||
|
Don't accept a `[' in a b4_copyright argument.
|
||||||
|
Format code more consistently.
|
||||||
|
Don't assume b4*copyright never occurs.
|
||||||
|
|
||||||
2009-08-04 Joel E. Denny <jdenny@clemson.edu>
|
2009-08-04 Joel E. Denny <jdenny@clemson.edu>
|
||||||
|
|
||||||
maint: automate b4_copyright updates.
|
maint: automate b4_copyright updates.
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/perl -0777 -pi
|
#!/usr/bin/perl -0777 -pi
|
||||||
# Update an b4_copyright invocation to include the current year.
|
|
||||||
|
# Update b4_copyright invocations or b4_copyright_years definitions to
|
||||||
|
# include the current year.
|
||||||
|
|
||||||
# Copyright (C) 2009 Free Software Foundation, Inc.
|
# Copyright (C) 2009 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
@@ -19,20 +21,23 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
my $margin = 72;
|
||||||
|
|
||||||
my $this_year = $ENV{UPDATE_COPYRIGHT_YEAR};
|
my $this_year = $ENV{UPDATE_COPYRIGHT_YEAR};
|
||||||
if (!$this_year || $this_year !~ m/^\d\d(\d\d)?$/)
|
if (!$this_year || $this_year !~ m/^\d{4}$/)
|
||||||
{
|
{
|
||||||
my ($sec, $min, $hour, $mday, $month, $year) = localtime (time ());
|
my ($sec, $min, $hour, $mday, $month, $year) = localtime (time ());
|
||||||
$this_year = $year + 1900;
|
$this_year = $year + 1900;
|
||||||
}
|
}
|
||||||
my $margin = 72;
|
|
||||||
my $old_re = <<'EOF'
|
my $old_re = <<'EOF'
|
||||||
(
|
(
|
||||||
(?:^|\n)
|
(?:^|\n)
|
||||||
|
#BEFORE
|
||||||
(?:
|
(?:
|
||||||
b4_copyright\(\[[^]]*]
|
b4_copyright\(\[[^][]*]
|
||||||
| m4_(?:push|pop)def\(\[b4_copyright_years]
|
| m4_(?:push|pop)def\(\[b4_copyright_years]
|
||||||
)
|
)
|
||||||
|
#AFTER
|
||||||
)
|
)
|
||||||
(?:
|
(?:
|
||||||
,\s*
|
,\s*
|
||||||
@@ -44,17 +49,15 @@ my $old_re = <<'EOF'
|
|||||||
EOF
|
EOF
|
||||||
;
|
;
|
||||||
|
|
||||||
while (/$old_re/x)
|
while (/($old_re)/gx)
|
||||||
{
|
{
|
||||||
my $b4_copyright_line = $1;
|
my $start = pos() - length ($1);
|
||||||
my $year_lines = $2;
|
my $b4_copyright_line = $2;
|
||||||
my $sep = $3 ? $3 : "";
|
my $year_lines = $3;
|
||||||
my $final_year = $4;
|
my $sep = $4 ? $4 : "";
|
||||||
|
my $final_year = $5;
|
||||||
$year_lines .= ')';
|
$year_lines .= ')';
|
||||||
|
|
||||||
# Mark it completed.
|
|
||||||
$b4_copyright_line =~ s/b4_/b4*/g;
|
|
||||||
|
|
||||||
# If there was a second argument, it contains years, so update them.
|
# If there was a second argument, it contains years, so update them.
|
||||||
if ($final_year)
|
if ($final_year)
|
||||||
{
|
{
|
||||||
@@ -103,22 +106,40 @@ while (/$old_re/x)
|
|||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$year_lines = $year_lines_new;
|
|
||||||
|
# Replace the old invocation. Should never die.
|
||||||
|
die if (!s/$old_re\G/$b4_copyright_line$year_lines_new/x);
|
||||||
|
|
||||||
|
# Prepare for the next search.
|
||||||
|
pos () = $start + length ("$b4_copyright_line$year_lines_new");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Replace the old invocation.
|
while (/(\bb4_copyright\()/g)
|
||||||
s/$old_re/$b4_copyright_line$year_lines/x;
|
{
|
||||||
}
|
my $pos = pos ();
|
||||||
|
pos () -= length ($1);
|
||||||
if (/\bb4_copyright\(/)
|
my $re = $old_re;
|
||||||
|
$re =~ s/\#BEFORE/\\G/;
|
||||||
|
if (!/$re/x)
|
||||||
{
|
{
|
||||||
print STDERR
|
print STDERR
|
||||||
"$ARGV: warning: failed to update a b4_copyright invocation\n";
|
"$ARGV: warning: failed to update a b4_copyright before char"
|
||||||
|
. " $pos\n";
|
||||||
}
|
}
|
||||||
if (/\[b4_copyright_years]/)
|
pos () = $pos;
|
||||||
{
|
|
||||||
print STDERR
|
|
||||||
"$ARGV: warning: failed to update a b4_copyright_years use\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s/b4\*copyright/b4_copyright/g;
|
while (/\[b4_copyright_years]/g)
|
||||||
|
{
|
||||||
|
my $pos = pos ();
|
||||||
|
my $re = $old_re;
|
||||||
|
$re =~ s/\#AFTER/\\G/;
|
||||||
|
if (!/$re/x)
|
||||||
|
{
|
||||||
|
print STDERR
|
||||||
|
"$ARGV: warning: failed to update a b4_copyright_years before"
|
||||||
|
. " char $pos\n";
|
||||||
|
}
|
||||||
|
pos () = $pos;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user