#!/usr/bin/ruby # Copyright (C) 2004 Iowa State University # This file is part of JML # JML 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. # JML 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 JML; see the file COPYING. If not, write to # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. (STDERR.puts "usage: fix-copyright.rb yyyy filename..."; exit 1) if ARGV.size < 2 Copyright2Dig = /(Copyright.*)(\d\d\d\d)[^0-9]*(\d\d)([^0-9].*Iowa State University)/ CopyrightRE = /(Copyright.*)(\d\d\d\d)(.*Iowa State University)/ # RegExp that matches a CVS Id entry for a file that has been updated in # the given year: Updated = "\\$(Id|Date).*\\b" + ARGV[0] + "\\/\\d\\d\\/\\d\\d.*\\$" def updated(lines) lines.each do |l| return true if l =~ Updated end false end ARGV[1,ARGV.length-1].each do |a| f = File.open a contents = f.readlines f.close if updated(contents) output = File.new(a,"w") contents.each do |l| if (not Copyright2Dig =~ l and CopyrightRE =~ l) l2 = $` + $1 + ARGV[0] + $3 + $' output.puts l2 puts "Updated " + a if not l == l2 else output.puts l end end output.close end end