changes to copyright messages

Fergus Henderson fjh at cs.mu.oz.au
Mon Jul 28 01:18:18 AEST 1997


Regarding the following change:

--------------------
Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne".
--------------------

I won't post a diff, since it is very long, very boring, and I've
reviewed it myself already.  Instead, for the record, I'll post the
scripts I used.

--- fix_the.sed ---
/Copyright/s/University of Melbourne/The University of Melbourne/
/Copyright/s/The The University of Melbourne/The University of Melbourne/

--- fix_dates ---
#!/bin/sh
debug=false
for file in "$@"; do
	override=no
	mode=auto
	oldcopyright=`fgrep "Copyright (C)" $file`
	oldyears_str=`expr "$oldcopyright" : '.*Copyright (C) \([0-9, -]*\) '`
	$debug && echo "$file: oldyears_str=$oldyears_str"
	case "$oldyears_str" in
	    1995)
		$debug && echo "$file: old year ignored"
		override=yes
		;;
	    [0-9][0-9][0-9][0-9])
		oldyears=$oldyears_str
		;;
	    [0-9][0-9][0-9][0-9],' '[0-9][0-9][0-9][0-9])
		firstyear=`expr $oldyears_str : '\(.*\), .*'`
		lastyear=`expr $oldyears_str : '.*, \(.*\)'`
		oldyears="$firstyear $lastyear"
		;;
	    [0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9])
		firstyear=`expr $oldyears_str : '\(.*\)-.*'`
		lastyear=`expr $oldyears_str : '.*-\(.*\)'`
		oldyears="$firstyear"
		while [ $firstyear -lt $lastyear ]; do
			firstyear=`expr $firstyear + 1`;
			oldyears="$oldyears $firstyear"
		done
		;;
	    *)
		echo "$file: manual intervention required"
		echo "$file" >> fix_dates.manual
		mode=manual
		;;
	esac
	$debug && echo "$file: oldyears=$oldyears"
	newyears=`
		cvs log $file |
		grep '^date: ' |
		sed -e 's/^date: //' -e 's^/.*^^'
	`
	$debug && echo "$file: newyears=`echo $newyears`"
	years=`
		echo $oldyears $newyears |
		tr ' ' '\n' |
		sort |
		uniq
	`
	# $debug && echo "$file: years=`echo $years`"
	years_str=''
	prev_year=''
	for year in $years; do
		case "$prev_year" in
		    "") years_str=$year ;;
		    *)	case "`expr $prev_year + 1`" in
			    $year)
				case "$years_str" in
				    *-)	;;
				    *)	years_str="$years_str-" ;;
				esac
				;;
			    *)
				case "$years_str" in
				    *-)	years_str="$years_str$prev_year" ;;
				esac
				years_str="$years_str, $year"
				;;
			esac
			;;
		esac
		prev_year=$year
	done
	case "$years_str" in
	    *-)	years_str="$years_str$prev_year" ;;
	esac
	$debug && echo "$file: years_str=$years_str"

	start=`expr "$oldcopyright" : '\(.*\)Copyright'`
	end=`expr "$oldcopyright" : '.*Copyright (C) [0-9, -]*\(.*\)'`
	exp_end="University of Melbourne."
	newcopyright="${start}Copyright (C) $years_str $end"
	if [ "$oldcopyright" != "$newcopyright" ]; then
		echo $file: -$oldcopyright
		echo $file: +$newcopyright
		if [ "$mode" != "manual" ]; then
			sed "s/$oldcopyright/$newcopyright/" < $file > $file.new
			# mv $file $file.old &&
			# mv $file.new $file
		fi
	else
		echo $file: no change
	fi
done
exit 0
-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list