#!/bin/sh
# The next line restarts using tclsh8.0 \
exec tclsh8.0 $0 ${1+"$@"}

set dirs ". ./generic ./doc ./tests ./xlib ./mac ./win ./unix ./library"
set package "dash"
set version "8.0.3"
set date "9/18/98"

#
# This is a tcl-script that will search a list of directories
# for ".orig"-files. For all of these it will make a "diff",
# and create a patch-file.
#
#	Written by:	Jan Nijtmans
#			CMG (Computer Management Group) Arnhem B.V.
#			email: Jan.Nijtmans@wxs.nl (private)
#			       Jan.Nijtmans@cmg.nl (work)
#			url:   http://home.wxs.nl/~nijtmans/

set patchlevel ""
set dfiles ""

set file [open dashpatch.orig w]
close $file
set file [open README.DASH.orig w]
close $file
set file [open TCLX_HELP_PATCHES.orig w]
close $file

set file [open tk${version}${package}.patch w]
puts $file "
tk${version}${package}.patch -   $date

This patch file updates from Tk ${version} to Tk ${version}${package}. It should be applied
by running the \"patch\" program in the top-level directory of a clean Tk ${version}
(or Tk ${version}+) release, using the command \"patch -p0 <tk${version}${package}.patch\"

If you are using Solaris, don't be surprised if the patch utility does not
work. This is a known problem. Better install GNU patch version 2.1 or later.
"
close $file

foreach dir $dirs {
    set files [eval exec ls $dir]
    foreach file $files {
	if {[regexp ".*\.orig" $file]} {
	    set file $dir/[string range $file 0 [expr [string length $file]-6]]
	    set file [string range $file 2 [string length $file]]
	    puts stdout "diff -c $file.orig $file"
	    catch "exec diff -c $file.orig $file >>tk${version}${package}.patch"
	}
    }
}

file delete dashpatch.orig README.DASH.orig TCLX_HELP_PATCHES.orig

puts stdout "tk${version}${package}.patch created"
