System: dist version 1.0
Patch #: 2
Priority: MEDIUM-HIGH
Subject: various upgrades
From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall)

Description:
	Added ability to do patcil from subdirectory.
	Added ability for pat to find all files that are newer than last patch.
	Added ability for patcil to generate patches for brand new files.
	Added ability for patcil to add new files to MANIFEST.new.

	Added several new metaconfig units.

	One of these days I'm gonna document all this...

Fix:	From rn, say "| patch -p0 -d DIR", where DIR is your dist source
	directory.  Outside of rn, say "cd DIR; patch -p0 <thisarticle".
	If you don't have the patch program, apply the following by hand,
	or get patch.

>>>	YOU MUST INCLUDE -p0 TO PATCH OR IT WON'T WORK RIGHT      <<<

	If patch indicates that patchlevel is the wrong version, you may need
	to apply one or more previous patches, or the patch may already
	have been applied.  See the patchlevel.h file to find out what has or
	has not been applied.  In any event, don't continue with the patch.

	If you are missing previous patches they can be obtained from me:

	Larry Wall
	lwall@jpl-devvax.jpl.nasa.gov

	If you send a mail message of the following form it will greatly speed
	processing:

	Subject: Command
	@SH mailpatch PATH dist 1.0 LIST
		   ^ note the c

	where PATH is a return path FROM ME TO YOU in Internet notation, and
	LIST is the number of one or more patches you need, separated by spaces,
	commas, and/or hyphens.  Saying 35- says everything from 35 to the end.

	You can also get the patches via anonymous FTP from
	jpl-devvax.jpl.nasa.gov (128.149.8.43).

Index: patchlevel.h
Prereq: 1
1c1
< #define PATCHLEVEL 1
---
> #define PATCHLEVEL 2
 
Index: mcon/U/d_bcopy.U
*** mcon/U/d_bcopy.U.old	Thu Jan 28 12:44:14 1988
--- mcon/U/d_bcopy.U	Thu Jan 28 12:44:15 1988
***************
*** 0 ****
--- 1,31 ----
+ ?RCS:$Header: d_bcopy.U,v 1.0.1.1 88/01/28 12:30:27 lwall Exp $
+ ?RCS:$Log:	d_bcopy.U,v $
+ ?RCS: Revision 1.0.1.1  88/01/28  12:30:27  lwall
+ ?RCS: This unit wasn't checked out when kit was made.
+ ?RCS: 
+ ?RCS: Revision 1.0  87/05/22  12:32:25  lwall
+ ?RCS: Initial revision
+ ?RCS: 
+ ?MAKE:d_bcopy: contains Guess
+ ?MAKE:	-pick add $@ %*
+ ?S:d_bcopy:
+ ?S:	This variable conditionally defines the BCOPY symbol, which
+ ?S:	indicates to the C program that the bcopy() routine is available
+ ?S:	to copy blocks of memory.
+ ?S:.
+ ?C:BCOPY:
+ ?C:	This symbol, if defined, indicates that the bcopy routine is available
+ ?C:	to copy blocks of memory.  Otherwise you should probably use memcpy().
+ ?C:.
+ ?H:?%1:#$d_bcopy	BCOPY		/**/
+ ?H:?%1:
+ : see if bcopy exists
+ echo " "
+ if $contains bcopy libc.list >/dev/null 2>&1; then
+     echo 'bcopy() found.'
+     d_bcopy="$define"
+ else
+     echo 'bcopy() not found.'
+     d_bcopy="$undef"
+ fi
+ 
 
Index: mcon/U/d_statblks.U
*** mcon/U/d_statblks.U.old	Thu Jan 28 12:44:22 1988
--- mcon/U/d_statblks.U	Thu Jan 28 12:44:24 1988
***************
*** 0 ****
--- 1,35 ----
+ ?RCS:$Header: d_statblks.U,v 1.0.1.1 88/01/28 12:31:33 lwall Exp $
+ ?RCS:$Log:	d_statblks.U,v $
+ ?RCS: Revision 1.0.1.1  88/01/28  12:31:33  lwall
+ ?RCS: This unit looks for extra fields in the stat structure for fast filesystems.
+ ?RCS: 
+ ?RCS: Revision 1.0  87/05/22  12:30:34  lwall
+ ?RCS: Initial revision
+ ?RCS: 
+ ?MAKE:d_statblks: contains
+ ?MAKE:	-pick add $@ %*
+ ?S:d_statblks:
+ ?S:	This variable conditionally defines STATBLOCKS if this system
+ ?S:	has a stat structure declaring st_blksize and st_blocks.
+ ?S:.
+ ?C:STATBLOCKS:
+ ?C:	This symbol is defined if this system has a stat structure declaring
+ ?C:	st_blksize and st_blocks.
+ ?C:.
+ ?H:?%1:#$d_statblks	STATBLOCKS 	/**/
+ ?H:?%1:
+ : see if stat knows about block sizes
+ echo " "
+ if $contains 'st_blocks;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
+     if $contains 'st_blksize;' /usr/include/sys/stat.h >/dev/null 2>&1 ; then
+ 	echo "Your stat knows about block sizes."
+ 	d_statblks="$define"
+     else
+ 	echo "Your stat doesn't know about block sizes."
+ 	d_statblks="$undef"
+     fi
+ else
+     echo "Your stat doesn't know about block sizes."
+     d_statblks="$undef"
+ fi
+ 
 
Index: mcon/U/d_tminsys.U
*** mcon/U/d_tminsys.U.old	Thu Jan 28 12:44:31 1988
--- mcon/U/d_tminsys.U	Thu Jan 28 12:44:32 1988
***************
*** 0 ****
--- 1,32 ----
+ ?RCS:$Header: d_tminsys.U,v 1.0.1.1 88/01/28 12:32:51 lwall Exp $
+ ?RCS:$Log:	d_tminsys.U,v $
+ ?RCS: Revision 1.0.1.1  88/01/28  12:32:51  lwall
+ ?RCS: This unit looks to see if struct tm is declared in <time.h> or <sys/time.h>.
+ ?RCS: 
+ ?RCS: Revision 1.0  87/05/22  12:30:34  lwall
+ ?RCS: Initial revision
+ ?RCS: 
+ ?MAKE:d_tminsys: contains
+ ?MAKE:	-pick add $@ %*
+ ?S:d_tminsys:
+ ?S:	This variable conditionally defines TMINSYS if this system
+ ?S:	declares "struct tm" in <sys/time.h> rather than <time.h>.
+ ?S:.
+ ?C:TMINSYS:
+ ?C:	This symbol is defined if this system declares "struct tm" in
+ ?C:	in <sys/time.h> rather than <time.h>.  We can't just say
+ ?C:	-I/usr/include/sys because some systems have both time files, and
+ ?C:	the -I trick gets the wrong one.
+ ?C:.
+ ?H:?%1:#$d_tminsys	TMINSYS 	/**/
+ ?H:?%1:
+ : see if struct tm is defined in sys/time.h
+ echo " "
+ if $contains 'struct tm' /usr/include/time.h >/dev/null 2>&1 ; then
+     echo "You have struct tm defined in <time.h> rather than <sys/time.h>."
+     d_tminsys="$undef"
+ else
+     echo "You have struct tm defined in <sys/time.h> rather than <time.h>."
+     d_tminsys="$define"
+ fi
+ 
 
Index: mcon/U/mallocsrc.U
*** mcon/U/mallocsrc.U.old	Thu Jan 28 12:44:38 1988
--- mcon/U/mallocsrc.U	Thu Jan 28 12:44:39 1988
***************
*** 0 ****
--- 1,51 ----
+ ?RCS:$Header: mallocsrc.U,v 1.0.1.1 88/01/28 12:34:15 lwall Exp $
+ ?RCS:$Log:	mallocsrc.U,v $
+ ?RCS: Revision 1.0.1.1  88/01/28  12:34:15  lwall
+ ?RCS: This unit checks to see if the installer wants to use our own malloc().
+ ?RCS: 
+ ?RCS: 
+ ?MAKE:mallocsrc mallocobj usemymalloc: echo n c Myread Oldconfig package Guess
+ ?MAKE:	-pick add $@ %*
+ ?S:usemymalloc:
+ ?S:	This variable contains y if the malloc that comes with this package
+ ?S:	is desired over the system's version of malloc.  People often include
+ ?S:	special versions of malloc for effiency, but such versions are often
+ ?S:	less portable.  See also mallocsrc and mallocobj.
+ ?S:.
+ ?S:mallocsrc:
+ ?S:	This variable contains the name of the malloc.c that comes with
+ ?S:	the package, if that malloc.c is preferred over the system malloc.
+ ?S:	Otherwise the value is null.  This variable is intended for generating
+ ?S:	Makefiles.
+ ?S:.
+ ?S:mallocobj:
+ ?S:	This variable contains the name of the malloc.o that this package
+ ?S:	generates, if that malloc.o is preferred over the system malloc.
+ ?S:	Otherwise the value is null.  This variable is intended for generating
+ ?S:	Makefiles.  See mallocsrc.
+ ?S:.
+ : determine which malloc to compile in
+ echo " "
+ case "$usemymalloc" in
+ '')
+     if bsd || v7; then
+ 	dflt='y'
+     else
+ 	dflt='n'
+     fi
+     ;;
+ *)  dflt="$usemymalloc"
+     ;;
+ esac
+ rp="Do you wish to attempt to use the malloc that comes with $package? [$dflt]"
+ $echo $n "$rp $c"
+ . myread
+ case "$ans" in
+ '') ans=$dflt;;
+ esac
+ usemymalloc="$ans"
+ case "$ans" in
+ y*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
+ *) mallocsrc=''; mallocobj='';;
+ esac
+ 
 
Index: pat/pat.SH
*** pat/pat.SH.old	Thu Jan 28 12:44:45 1988
--- pat/pat.SH	Thu Jan 28 12:44:46 1988
***************
*** 45,54 ****
  . .package
  
  case "$1" in
  -a) set `awk '{print $1}' MANIFEST.new`;;
  esac
  
! patcil $*
  patdiff $*
  if patmake; then
      bnum=`sed 's/#define PATCHLEVEL //' patchlevel.h`
--- 45,90 ----
  . .package
  
  case "$1" in
+ -n) find . -type f -newer patchlevel.h -print | sort | \
+     perl >.newer \
+ 	-e 'open(mani,"MANIFEST.new");' \
+ 	-e 'while (<mani>) {' \
+ 	-e '	($name,$foo) = split;' \
+ 	-e '	$mani{$name} = 1;' \
+ 	-e '}' \
+ 	-e 'while (<>) {' \
+ 	-e '	s|^\./||;' \
+ 	-e '	chop;' \
+ 	-e '	if (!$mani{$_}) {' \
+ 	-e '		next if m|^MANIFEST.new$|;' \
+ 	-e '		next if m|^bugs|;' \
+ 	-e '		next if m|^RCS/|;' \
+ 	-e '		next if m|/RCS/|;' \
+ 	-e '		next if m|^core$|;' \
+ 	-e '		next if m|/core$|;' \
+ 	-e '		next if m|^foo|;' \
+ 	-e '		next if m|/foo|;' \
+ 	-e '		next if m|^blurfl|;' \
+ 	-e '		next if m|/blurfl|;' \
+ 	-e '		next if m|^\.|;' \
+ 	-e '		next if m|/\.|;' \
+ 	-e '		next if m|\.o$|;' \
+ 	-e '		next if $mani{$_ . ".SH"};' \
+ 	-e '		next if m|(.*)\.c$| && $mani{$1 . ".y"};' \
+ 	-e '	}' \
+ 	-e '	print $_,"\n";' \
+ 	-e '}'
+     echo "Please remove unwanted files..."
+     sleep 2
+     ${EDITOR-vi} .newer
+     set `cat .newer`
+ esac
+ 
+ case "$1" in
  -a) set `awk '{print $1}' MANIFEST.new`;;
  esac
  
! patcil -p $*
  patdiff $*
  if patmake; then
      bnum=`sed 's/#define PATCHLEVEL //' patchlevel.h`
***************
*** 92,97 ****
--- 128,134 ----
  	esac
      ;;
      esac
+     touch patchlevel.h
  fi
  !NO!SUBS!
  chmod 755 pat
 
Index: pat/patcil.SH
*** pat/patcil.SH.old	Thu Jan 28 12:44:53 1988
--- pat/patcil.SH	Thu Jan 28 12:44:54 1988
***************
*** 1,6 ****
! case $CONFIG in
! '')
!     if test ! -f config.sh; then
  	ln ../config.sh . || \
  	ln ../../config.sh . || \
  	ln ../../../config.sh . || \
--- 1,5 ----
! case $CONFIG in 
! '') if test ! -f config.sh; then
  	ln ../config.sh . || \
  	ln ../../config.sh . || \
  	ln ../../../config.sh . || \
***************
*** 18,23 ****
--- 17,25 ----
  $spitshell >patcil <<!GROK!THIS!
  $startsh
  PT=`pwd`
+ c='$c'
+ n='$n'
+ echo='${echo-echo}'
  !GROK!THIS!
  
  : In the following dollars and backticks do not need the extra backslash.
***************
*** 26,44 ****
  0) echo patcil [files]; exit;;
  esac
  
  if test ! -f .package; then
!     if test -f ../.package -o -f ../../.package; then
! 	echo "Run in top level directory only."
      else
  	echo "No .package file!  Run packinit."
      fi
!     exit 1
  fi
  . .package
  
! if test ! -d RCS; then
!     mkdir RCS
! fi
  
  case "$1" in
  -f)
--- 28,75 ----
  0) echo patcil [files]; exit;;
  esac
  
+ if test ! -d RCS; then
+     mkdir RCS
+ fi
+ 
  if test ! -f .package; then
!     files="$*"
!     set `pwd | tr '/' ' '`
!     if test -f ../.package; then
! 	sh=1
! 	cd ..
!     elif test -f ../../.package; then
! 	sh=2
! 	cd ../..
!     elif test -f ../../../.package; then
! 	sh=3
! 	cd ../../..
!     elif test -f ../../../../.package; then
! 	sh=4
! 	cd ../../../..
      else
  	echo "No .package file!  Run packinit."
+ 	exit 1
      fi
!     while test $# -gt $sh; do
! 	shift
!     done
!     while test $# -gt 0; do
! 	prefix="$prefix$1/"
! 	shift
!     done
!     set $files
!     files=''
!     for file do
! 	files="$files $prefix$file"
!     done
!     set $files
  fi
  . .package
  
! case "$1" in
! -p) patching=yes; shift;;
! esac
  
  case "$1" in
  -f)
***************
*** 61,66 ****
--- 92,110 ----
  
  for file do
      files=`$PT/rcsargs $file`
+     foo=`grep "^$file[ 	]" MANIFEST.new`
+     case "$foo" in
+     '') $echo $n "$file does not appear to be in your MANIFEST.new--add? [y] $c"
+ 	read ans
+ 	case "$ans" in
+ 	n*) ;;
+ 	*)  $echo $n "MANIFEST.new comment? $c"
+ 	    read ans
+ 	    echo "$file	$ans" >>MANIFEST.new
+ 	    ;;
+ 	esac
+ 	;;
+     esac
      revs=0
      rlog -r$baserev -r$revbranch $files >.rlog$$ 2>/dev/null && \
      revs=`sed <.rlog$$ -n \
***************
*** 73,82 ****
--- 117,141 ----
  	case "$file" in
  	*.SH|Makefile*) rcs -i -c'# ' $files ;;
  	*.U) rcs -i -c'?RCS: ' $files ;;
+ 	*.man) rcs -i -c"''' " $files ;;
  	esac
+ 	case "$patching" in
+ 	yes) mv $file $file.xxx
+ 	    if test ! -f $file; then
+ 		cp /dev/null $file
+ 	    fi
+ 	    ;;
+ 	esac
  	ci -l$baserev $files || \
  	(echo Trying again && ci -r$baserev $files && rcs -u $files && co -l$baserev $files)
  	rcs -Nlastpat:$baserev $files
+ 	case "$patching" in
+ 	yes) mv $file.xxx $file
+ 	    ci -l$revbranch $files || \
+ 	    (echo Unlocking and trying again && \
+ 	     rcs -u $files && ci -l$revbranch $files)
+ 	    ;;
+ 	esac
  	;;
      1)
  	ci -l$revbranch $files || \
 
Index: pat/patdiff.SH
Prereq: 1.0.1.3
*** pat/patdiff.SH.old	Thu Jan 28 12:45:02 1988
--- pat/patdiff.SH	Thu Jan 28 12:45:03 1988
***************
*** 140,146 ****
  	    '')
  		(rcsdiff -c -rlastpat -r$new $files | \
  		    sed -e "1s|*** [^	]*	|*** $file.old	|" \
! 			-e "2s|--- [^	]*	|*** $file	|" \
  			  >> bugs/$fname.$bnum ) && \
  		rcs -Nlastpat:$new $files
  		;;
--- 140,146 ----
  	    '')
  		(rcsdiff -c -rlastpat -r$new $files | \
  		    sed -e "1s|*** [^	]*	|*** $file.old	|" \
! 			-e "2s|--- [^	]*	|--- $file	|" \
  			  >> bugs/$fname.$bnum ) && \
  		rcs -Nlastpat:$new $files
  		;;
***************
*** 149,155 ****
  		co -p -r$new $files >/tmp/pdn$$ && \
  		($mydiff /tmp/pdo$$ /tmp/pdn$$ | \
  		sed -e "1s|*** [^	]*	|*** $file.old	|" \
! 		    -e "2s|--- [^	]*	|*** $file	|" \
  		      >> bugs/$fname.$bnum ) && \
  		rm -f /tmp/pd[do]$$ && \
  		rcs -Nlastpat:$new $files
--- 149,155 ----
  		co -p -r$new $files >/tmp/pdn$$ && \
  		($mydiff /tmp/pdo$$ /tmp/pdn$$ | \
  		sed -e "1s|*** [^	]*	|*** $file.old	|" \
! 		    -e "2s|--- [^	]*	|--- $file	|" \
  		      >> bugs/$fname.$bnum ) && \
  		rm -f /tmp/pd[do]$$ && \
  		rcs -Nlastpat:$new $files
