#!/bin/csh -f

# (C) Copyright International Business Machines Corporation 23 January 
# 1990.  All Rights Reserved. 
#  
# See the file USERAGREEMENT distributed with this software for full 
# terms and conditions of use. 

# Check each of the files mentioned on the command line to see whether
# it has changed since last checked in to SCCS.  If so, do a delget to
# check in the changes and leave it writable.  Otherwise, do nothing.
# Full pathnames are handled properly.

foreach x ($*)
  if (! -e $x) then
    echo File $x does not exist
    goto next
  endif
  set dir=$x:h
  if ($dir == $x) then
    set dir="."
    set file=$x
  else
    set file=$x:t
  endif
  if (! -e $dir/SCCS/s.$file) then
    echo File $x not under SCCS control
    goto next
  endif
  if ( "$dir" != "" ) then
    set dirflag=-d$dir
  else
    set dirflag=""
  endif
  sccs $dirflag get -s -p $file > /tmp/update_sccs.$$
  if ( ! { cmp -s $x /tmp/update_sccs.$$ } ) then
    echo Updating file $x
    (cd $dir ; sccs deledit -s -y"Generated source file changed" $file)
  endif
  rm -f /tmp/update_sccs.$$
next:
end
