| 1 |
#!/bin/bash |
| 2 |
# $Id: update-copyright,v 1.9 2003/08/23 13:39:59 ceder Exp $ |
| 3 |
# Copyright (C) 1994-1996, 1999, 2003 Lysator Academic Computer Association. |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 2, or (at your option) |
| 8 |
# any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program; if not, write to the Free Software |
| 17 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
# |
| 19 |
# Please report bugs at http://bugzilla.lysator.liu.se/. |
| 20 |
|
| 21 |
# This file updates the copyright lines found in the programs, making |
| 22 |
# sure that every year that the file is edited appears in the |
| 23 |
# copyright line. |
| 24 |
|
| 25 |
while read file |
| 26 |
do |
| 27 |
if grep '[C]opyright' $file > /tmp/$$.yc ; then : ; |
| 28 |
else echo "$file:1: no Copy"right" line found" >&2 ; continue; |
| 29 |
fi |
| 30 |
tr , '\012' < /tmp/$$.yc \ |
| 31 |
| sed -n \ |
| 32 |
-e 's/.*\([12][0-9][0-9][0-9]\)-\([12][0-9][0-9][0-9]\).*/\1 \2/p' \ |
| 33 |
-e 's/.*\([12][0-9][0-9][0-9]\).*/\1/p' \ |
| 34 |
| awk 'NF == 2 { for(i=$1; i<=$2; ++i) print i } NF == 1' \ |
| 35 |
> /tmp/$$.year |
| 36 |
if cvs log $file > /tmp/$$.yc ; then : ; |
| 37 |
else echo "$file:1: cvs log failed" >&2 ; continue; |
| 38 |
fi |
| 39 |
cat /tmp/$$.yc \ |
| 40 |
| sed -n 's/^date: \([0-9][0-9][0-9][0-9]\).*author.*state.*$/\1/p' \ |
| 41 |
| sort | uniq >> /tmp/$$.year |
| 42 |
y=`sort /tmp/$$.year \ |
| 43 |
| uniq \ |
| 44 |
| (read first ; echo -n $first; next=\`expr $first + 1\`; rest=; \ |
| 45 |
while read second; \ |
| 46 |
do \ |
| 47 |
if [ $second = $next ]; \ |
| 48 |
then \ |
| 49 |
rest="-$next"; \ |
| 50 |
else \ |
| 51 |
echo -n $rest, $second; \ |
| 52 |
rest=; \ |
| 53 |
fi; \ |
| 54 |
next=\`expr $second + 1\`; \ |
| 55 |
done; \ |
| 56 |
echo -n $rest)` |
| 57 |
sed 's/\([C]opyright[^0-9]*\)[---0-9 ,]*[0-9]\([^0-9]*\)/\1'"$y"'\2/' \ |
| 58 |
< $file > /tmp/$$.file |
| 59 |
cmp /tmp/$$.file $file >/dev/null |
| 60 |
if [ $? = 1 ]; then |
| 61 |
if [ -x $file ]; then |
| 62 |
cat /tmp/$$.file > $file; |
| 63 |
chmod +x $file |
| 64 |
else |
| 65 |
cat /tmp/$$.file > $file; |
| 66 |
fi |
| 67 |
echo $file updated |
| 68 |
fi |
| 69 |
rm /tmp/$$.file /tmp/$$.yc /tmp/$$.year |
| 70 |
done |