#!/bin/bash # $Id: update-copyright,v 1.9 2003/08/23 13:39:59 ceder Exp $ # Copyright (C) 1994-1996, 1999, 2003 Lysator Academic Computer Association. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Please report bugs at http://bugzilla.lysator.liu.se/. # This file updates the copyright lines found in the programs, making # sure that every year that the file is edited appears in the # copyright line. while read file do if grep '[C]opyright' $file > /tmp/$$.yc ; then : ; else echo "$file:1: no Copy"right" line found" >&2 ; continue; fi tr , '\012' < /tmp/$$.yc \ | sed -n \ -e 's/.*\([12][0-9][0-9][0-9]\)-\([12][0-9][0-9][0-9]\).*/\1 \2/p' \ -e 's/.*\([12][0-9][0-9][0-9]\).*/\1/p' \ | awk 'NF == 2 { for(i=$1; i<=$2; ++i) print i } NF == 1' \ > /tmp/$$.year if cvs log $file > /tmp/$$.yc ; then : ; else echo "$file:1: cvs log failed" >&2 ; continue; fi cat /tmp/$$.yc \ | sed -n 's/^date: \([0-9][0-9][0-9][0-9]\).*author.*state.*$/\1/p' \ | sort | uniq >> /tmp/$$.year y=`sort /tmp/$$.year \ | uniq \ | (read first ; echo -n $first; next=\`expr $first + 1\`; rest=; \ while read second; \ do \ if [ $second = $next ]; \ then \ rest="-$next"; \ else \ echo -n $rest, $second; \ rest=; \ fi; \ next=\`expr $second + 1\`; \ done; \ echo -n $rest)` sed 's/\([C]opyright[^0-9]*\)[---0-9 ,]*[0-9]\([^0-9]*\)/\1'"$y"'\2/' \ < $file > /tmp/$$.file cmp /tmp/$$.file $file >/dev/null if [ $? = 1 ]; then if [ -x $file ]; then cat /tmp/$$.file > $file; chmod +x $file else cat /tmp/$$.file > $file; fi echo $file updated fi rm /tmp/$$.file /tmp/$$.yc /tmp/$$.year done