#!/bin/csh
#
# Replace a string in all Sparky c++ code.
#
# Syntax: replace <from-string> <to-string>
#

# cd ${SPARKY}

set FILES = `grep -l -e "$1" *.cc *.h`

foreach file ($FILES)
  echo $file
  co -q -l $file >& /dev/null
  if ($status == 0) then
    echo "Checked out $file"
  endif
  sed "s/$1/$2/g" $file > $file.tmp
  if ($status == 0) then
    \mv -f $file $file.bak
    \mv -f $file.tmp $file
  else
    echo "replace failed."
    \rm -f $file.tmp
  endif
end
