#!/bin/csh -f

# Update \cite commands in argument files to use four digit year
# number intead of two digits.  Assumes old citations have year
# in the range 30--99.  Must run the command multiple times
# if there are \cite commands that contain multiple sources.

foreach file ($*)
  cp $file $file.backup
  subst '+\(\\[in]*cite{[^}]*\)\([a-zA-Z]\)\([3-9]\)+\1\219\3+' $file
  grep '\\[in]*cite{[^}0-9]*[0-9][0-9][^0-9]' $file > /dev/null
  if (! $status) echo "y2kcites: Need to rerun on $file."
end
