Path: utzoo!utgpu!water!watmath!uunet!lll-winken!lll-tis!pacbell!att!ihnp4!ihopa!ihop3!booboo!ihtlt!ethos!pcid!gizzmo!fthood!egray From: egray@fthood.UUCP Newsgroups: unix-pc.sources Subject: Larry Wall's patch v2.0-11 (1 of 3) Message-ID: <6800070@fthood> Date: 7 Jun 88 16:42:00 GMT Lines: 2010 Nf-ID: #N:fthood:6800070:000:49220 Nf-From: fthood.UUCP!egray Jun 7 11:42:00 1988 Hello netlanders... This is a *reposting* of Larry Wall's patch v2.0 source thru patchlevel 11. Since most of the unix-pc.source sites don't routinely get comp.sources.unix or comp.sources.bugs, I believe a repost is appropriate. (If you think otherwise, it's too late!) This posting also contains a makefile that is specific to the AT&T Unix PC 7300/3b1 called "7300make". Emmet P. Gray US Army, HQ III Corps & Fort Hood ...!ihnp4!uiucuxc!fthood!egray Attn: AFZF-DE-ENV Directorate of Engineering & Housing Environmental Management Office Fort Hood, TX 76544-5057 ------------------------------------------------------------------------------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # 7300make # Configure # EXTERN.h # INTERN.h # MANIFEST # Makefile.SH # README # common.h # config.H # This archive created: Tue Jun 7 11:32:42 1988 export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting '7300make'" '(1048 characters)' if test -f '7300make' then echo shar: "will not over-write existing file '7300make'" else sed 's/^X//' << \SHAR_EOF > '7300make' X# modified makefile for Unix PC and shared libraries X XLDFLAGS = -s XBIN = /usr/local/bin XMANDIR = /usr/man/man1 XSHAREDLIB = /lib/crt0s.o /lib/shlib.ifile XLINT = lint -hax X XSRC = patch.c pch.c inp.c version.c util.c XOBJ = patch.o pch.o inp.o version.o util.o X Xall: patch X Xpatch: $(OBJ) X $(LD) $(LDFLAGS) $(OBJ) $(SHAREDLIB) -o patch X Xinstall: patch X cp patch $(BIN)/patch X rm patch X# cp patch.man $(MANDIR)/patch.1 X Xclean: X rm -f *.o core X Xlint: X $(LINT) $(SRC) X Xshar: X shar -a 7300make Configure EXTERN.h INTERN.h MANIFEST Makefile.SH \ X README common.h config.H > patch_sh.1 X shar -a config.h.SH inp.c inp.h malloc.c patch.c util.h version.c \ X version.h > patch_sh.2 X shar -a patch.man patchlevel.h pch.c pch.h util.c > patch_sh.3 X X# assert.o is now in the shared library, yeah! X#assert.o: X# ar x /lib/libc.a assert.o X Xpatch.o: config.h common.h inp.h pch.h util.h version.h Xpch.o: config.h common.h pch.h util.h Xinp.o: config.h common.h inp.h util.h Xutil.o: config.h common.h util.h Xversion.o: config.h common.h version.h patchlevel.h util.h SHAR_EOF if test 1048 -ne "`wc -c < '7300make'`" then echo shar: "error transmitting '7300make'" '(should have been 1048 characters)' fi fi echo shar: "extracting 'Configure'" '(30911 characters)' if test -f 'Configure' then echo shar: "will not over-write existing file 'Configure'" else sed 's/^X//' << \SHAR_EOF > 'Configure' X#! /bin/sh X# X# If these # comments don't work, trim them. Don't worry about any other X# shell scripts, Configure will trim # comments from them for you. X# X# (If you are trying to port this package to a machine without sh, I would X# suggest you cut out the prototypical config.h from the end of Configure X# and edit it to reflect your system. Some packages may include samples X# of config.h for certain machines, so you might look for one of those.) X# X# $Header: Configure,v 2.0.1.1 88/06/03 15:00:13 lwall Locked $ X# X# Yes, you may rip this off to use in other distribution packages. X# (Note: this Configure script was generated automatically. Rather than X# working with this copy of Configure, you may wish to get metaconfig.) X X: sanity checks XPATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc' Xexport PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$) X Xif test ! -t 0; then X echo "Say 'sh Configure', not 'sh /dev/null 2>&1 && \ X echo "(I see you are using the Korn shell. Some ksh's blow up on Configure," && \ X echo "especially on exotic machines. If yours does, try the Bourne shell instead.)" X Xif test ! -d ../UU; then X if test ! -d UU; then X mkdir UU X fi X cd UU Xfi X Xcase "$1" in X-d) shift; fastread='yes';; Xesac X Xd_eunice='' Xeunicefix='' Xdefine='' Xloclist='' Xexpr='' Xsed='' Xecho='' Xcat='' Xrm='' Xmv='' Xcp='' Xtail='' Xtr='' Xmkdir='' Xsort='' Xuniq='' Xgrep='' Xtrylist='' Xtest='' Xinews='' Xegrep='' Xmore='' Xpg='' XMcc='' Xvi='' Xmailx='' Xmail='' Xcpp='' XLog='' XHeader='' Xbin='' Xcc='' Xcontains='' Xcppstdin='' Xcppminus='' Xd_charsprf='' Xd_flexfnam='' Xd_index='' Xd_voidsig='' Xlibc='' Xmansrc='' Xmanext='' Xmodels='' Xsplit='' Xsmall='' Xmedium='' Xlarge='' Xhuge='' Xccflags='' Xldflags='' Xn='' Xc='' Xpackage='' Xregisters='' Xreg1='' Xreg2='' Xreg3='' Xreg4='' Xreg5='' Xreg6='' Xreg7='' Xreg8='' Xreg9='' Xreg10='' Xreg11='' Xreg12='' Xreg13='' Xreg14='' Xreg15='' Xreg16='' Xspitshell='' Xshsharp='' Xsharpbang='' Xstartsh='' Xvoidflags='' Xdefvoidused='' XCONFIG='' X X: set package name Xpackage=patch X Xecho " " Xecho "Beginning of configuration questions for $package kit." X: Eunice requires " " instead of "", can you believe it Xecho " " X Xdefine='define' Xundef='/*undef' Xlibpth='/usr/lib /usr/local/lib /lib' Xsmallmach='pdp11 i8086 z8000 i80286 iAPX286' Xrmlist='kit[1-9]isdone kit[1-9][0-9]isdone' Xtrap 'echo " "; rm -f $rmlist; exit 1' 1 2 3 X X: We must find out about Eunice early Xeunicefix=':' Xif test -f /etc/unixtovms; then X eunicefix=/etc/unixtovms Xfi Xif test -f /etc/unixtovms.exe; then X eunicefix=/etc/unixtovms.exe Xfi X Xattrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr" Xattrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200" Xattrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc" Xattrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX" Xattrlist="$attrlist $mc68k __STDC__" Xpth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /lib" Xd_newshome="../../NeWS" Xdefvoidused=7 X X: some greps do not return status, grrr. Xecho "grimblepritz" >grimble Xif grep blurfldyick grimble >/dev/null 2>&1 ; then X contains=contains Xelif grep grimblepritz grimble >/dev/null 2>&1 ; then X contains=grep Xelse X contains=contains Xfi Xrm -f grimble X: the following should work in any shell Xcase "$contains" in Xcontains*) X echo " " X echo "AGH! Grep doesn't return a status. Attempting remedial action." X cat >contains <<'EOSS' Xgrep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp XEOSS Xchmod +x contains Xesac X X: first determine how to suppress newline on echo command Xecho "Checking echo to see how to suppress newlines..." X(echo "hi there\c" ; echo " ") >.echotmp Xif $contains c .echotmp >/dev/null 2>&1 ; then X echo "...using -n." X n='-n' X c='' Xelse X cat <<'EOM' X...using \c XEOM X n='' X c='\c' Xfi Xecho $n "Type carriage return to continue. Your cursor should be here-->$c" Xread ans Xrm -f .echotmp X X: now set up to do reads with possible shell escape and default assignment Xcat <myread Xcase "\$fastread" in Xyes) ans=''; echo " " ;; X*) ans='!';; Xesac Xwhile expr "X\$ans" : "X!" >/dev/null; do X read ans X case "\$ans" in X !) X sh X echo " " X echo $n "\$rp $c" X ;; X !*) X set \`expr "X\$ans" : "X!\(.*\)\$"\` X sh -c "\$*" X echo " " X echo $n "\$rp $c" X ;; X esac Xdone Xrp='Your answer:' Xcase "\$ans" in X'') ans="\$dflt";; Xesac XEOSC X X: general instructions Xcat <loc X$startsh Xcase \$# in X0) exit 1;; Xesac Xthing=\$1 Xshift Xdflt=\$1 Xshift Xfor dir in \$*; do X case "\$thing" in X .) X if test -d \$dir/\$thing; then X echo \$dir X exit 0 X fi X ;; X *) X if test -f \$dir/\$thing; then X echo \$dir/\$thing X exit 0 X elif test -f \$dir/\$thing.exe; then X : on Eunice apparently X echo \$dir/\$thing X exit 0 X fi X ;; X esac Xdone Xecho \$dflt Xexit 1 XEOSC Xchmod +x loc X$eunicefix loc Xloclist=" Xexpr Xsed Xecho Xcat Xrm Xtr Xgrep X" Xtrylist=" Xtest XMcc Xcpp X" Xfor file in $loclist; do X xxx=`loc $file $file $pth` X eval $file=$xxx X eval _$file=$xxx X case "$xxx" in X /*) X echo $file is in $xxx. X ;; X *) X echo "I don't know where $file is. I hope it's in everyone's PATH." X ;; X esac Xdone Xecho " " Xecho "Don't worry if any of the following aren't found..." Xans=offhand Xfor file in $trylist; do X xxx=`loc $file $file $pth` X eval $file=$xxx X eval _$file=$xxx X case "$xxx" in X /*) X echo $file is in $xxx. X ;; X *) X echo "I don't see $file out there, $ans." X ans=either X ;; X esac Xdone Xcase "$egrep" in Xegrep) X echo "Substituting grep for egrep." X egrep=$grep X ;; Xesac Xcase "$test" in Xtest) X echo "Hopefully test is built into your sh." X ;; X/bin/test) X echo " " X dflt=n X rp="Is your "'"'"test"'"'" built into sh? [$dflt] (OK to guess)" X echo $n "$rp $c" X . myread X case "$ans" in X y*) test=test ;; X esac X ;; X*) X test=test X ;; Xesac Xcase "$echo" in Xecho) X echo "Hopefully echo is built into your sh." X ;; X/bin/echo) X echo " " X echo "Checking compatibility between /bin/echo and builtin echo (if any)..." X $echo $n "hi there$c" >foo1 X echo $n "hi there$c" >foo2 X if cmp foo1 foo2 >/dev/null 2>&1; then X echo "They are compatible. In fact, they may be identical." X else X case "$n" in X '-n') n='' c='\c' ans='\c' ;; X *) n='-n' c='' ans='-n' ;; X esac X cat </dev/null | sed -n -e 's/^.* T _//p' -e 's/^.* T //p' > libc.list Xif $contains '^printf$' libc.list >/dev/null 2>&1; then X echo "done" Xelse X nm $libc 2>/dev/null | sed -n -e 's/^.* D _//p' -e 's/^.* D //p' > libc.list X if $contains '^printf$' libc.list >/dev/null 2>&1; then X echo "done" X else X echo " " X echo "nm didn't seem to work right." X echo "Trying ar instead..." X if ar t $libc | sed -e 's/\.o$//' > libc.list; then X echo "Ok." X else X echo "That didn't work either. Giving up." X exit 1 X fi X fi Xfi Xrmlist="$rmlist libc.list" X X: make some quick guesses about what we are up against Xecho " " X$echo $n "Hmm... $c" Xif $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then X echo "Looks kind of like a BSD system, but we'll see..." X echo exit 0 >bsd X echo exit 1 >usg X echo exit 1 >v7 Xelif $contains '^fcntl$' libc.list >/dev/null 2>&1 ; then X echo "Looks kind of like a USG system, but we'll see..." X echo exit 1 >bsd X echo exit 0 >usg X echo exit 1 >v7 Xelse X echo "Looks kind of like a version 7 system, but we'll see..." X echo exit 1 >bsd X echo exit 1 >usg X echo exit 0 >v7 Xfi Xif $contains '^vmssystem$' libc.list >/dev/null 2>&1 ; then X cat <<'EOI' XThere is, however, a strange, musty smell in the air that reminds me of Xsomething...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit. XEOI X echo "exit 0" >eunice X eunicefix=unixtovms X d_eunice="$define" X: it so happens the Eunice I know will not run shell scripts in Unix format Xelse X echo " " X echo "Congratulations. You aren't running Eunice." X eunicefix=':' X d_eunice="$undef" X echo "exit 1" >eunice Xfi Xif test -f /xenix; then X echo "Actually, this looks more like a XENIX system..." X echo "exit 0" >xenix Xelse X echo " " X echo "It's not Xenix..." X echo "exit 1" >xenix Xfi Xchmod +x xenix X$eunicefix xenix Xif test -f /venix; then X echo "Actually, this looks more like a VENIX system..." X echo "exit 0" >venix Xelse X echo " " X if xenix; then X : null X else X echo "Nor is it Venix..." X fi X echo "exit 1" >venix Xfi Xchmod +x bsd usg v7 eunice venix X$eunicefix bsd usg v7 eunice venix Xrmlist="$rmlist bsd usg v7 eunice venix xenix" X X: see if sh knows # comments Xecho " " Xecho "Checking your sh to see if it knows about # comments..." Xif sh -c '#' >/dev/null 2>&1 ; then X echo "Your sh handles # comments correctly." X shsharp=true X spitshell=cat X echo " " X echo "Okay, let's see if #! works on this system..." X echo "#!/bin/echo hi" > try X $eunicefix try X chmod +x try X try > today X if $contains hi today >/dev/null 2>&1; then X echo "It does." X sharpbang='#!' X else X echo "#! /bin/echo hi" > try X $eunicefix try X chmod +x try X try > today X if test -s today; then X echo "It does." X sharpbang='#! ' X else X echo "It doesn't." X sharpbang=': use ' X fi X fi Xelse X echo "Your sh doesn't grok # comments--I will strip them later on." X shsharp=false X echo "exec grep -v '^#'" >spitshell X chmod +x spitshell X $eunicefix spitshell X spitshell=`pwd`/spitshell X echo "I presume that if # doesn't work, #! won't work either!" X sharpbang=': use ' Xfi X X: figure out how to guarantee sh startup Xecho " " Xecho "Checking out how to guarantee sh startup..." Xstartsh=$sharpbang'/bin/sh' Xecho "Let's see if '$startsh' works..." Xcat >try <.ucbsprf.c <<'EOF' Xmain() { char buf[10]; exit((unsigned long)sprintf(buf,"%s","foo") > 10L); } XEOF Xif cc .ucbsprf.c -o .ucbsprf >/dev/null 2>&1 && .ucbsprf; then X echo "Your sprintf() returns (int)." X d_charsprf="$undef" Xelse X echo "Your sprintf() returns (char*)." X d_charsprf="$define" Xfi X/bin/rm -f .ucbsprf.c .ucbsprf X X: see if we can have long filenames Xecho " " Xrm -f 123456789abcde Xif (echo hi >123456789abcdef) 2>/dev/null; then X : not version 8 X if test -f 123456789abcde; then X echo 'You cannot have filenames longer than 14 characters. Sigh.' X d_flexfnam="$undef" X else X echo 'You can have filenames longer than 14 characters.' X d_flexfnam="$define" X fi Xelse X : version 8 probably X echo "You can't have filenames longer than 14 chars. V8 can't even think about them!" X d_flexfnam="$undef" Xfi X: index or strcpy Xecho " " Xcase "$d_index" in Xn) dflt=n;; X*) dflt=y;; Xesac Xif $contains '^index$' libc.list >/dev/null 2>&1 ; then X if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then X echo "Your system has both index() and strchr(). Shall I use" X rp="index() rather than strchr()? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X n*) d_index="$define" ;; X *) d_index="$undef" ;; X esac X else X d_index="$undef" X echo "index() found." X fi Xelse X if $contains '^strchr$' libc.list >/dev/null 2>&1 ; then X d_index="$define" X echo "strchr() found." X else X echo "No index() or strchr() found!" X d_index="$undef" X fi Xfi X X: see if signal is declared as pointer to function returning int or void Xecho " " Xif $contains 'void.*signal' /usr/include/signal.h >/dev/null 2>&1 ; then X echo "You have void (*signal())() instead of int." X d_voidsig="$define" Xelse X echo "You have int (*signal())() instead of void." X d_voidsig="$undef" Xfi X X: check for void type Xecho " " X$cat <try.c <<'EOCP' X#if TRY & 1 Xvoid main() { X#else Xmain() { X#endif X extern void *moo(); X void *(*goo)(); X#if TRY & 2 X void (*foo[10])(); X#endif X X#if TRY & 4 X if(*goo == moo) { X exit(0); X } X#endif X exit(0); X} XEOCP X if cc -S -DTRY=7 try.c >.out 2>&1 ; then X voidflags=7 X echo "It appears to support void fully." X if $contains warning .out >/dev/null 2>&1; then X echo "However, you might get some warnings that look like this:" X $cat .out X fi X else X echo "Hmm, you compiler has some difficulty with void. Checking further..." X if cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then X echo "It supports 1..." X if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then X voidflags=3 X echo "And it supports 2 but not 4." X else X echo "It doesn't support 2..." X if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then X voidflags=5 X echo "But it supports 4." X else X voidflags=1 X echo "And it doesn't support 4." X fi X fi X else X echo "There is no support at all for void." X voidflags=0 X fi X fi Xesac Xdflt="$voidflags"; Xrp="Your void support flags add up to what? [$dflt]" X$echo $n "$rp $c" X. myread Xvoidflags="$ans" X$rm -f try.* .out X X: see how we invoke the C preprocessor Xecho " " Xecho "Now, how can we feed standard input to your C preprocessor..." Xcat <<'EOT' >testcpp.c X#define ABC abc X#define XYZ xyz XABC.XYZ XEOT Xecho 'Maybe "'$cpp'" will work...' X$cpp testcpp.out 2>&1 Xif $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, it does." X cppstdin="$cpp" X cppminus=''; Xelse X echo 'Nope, maybe "'$cpp' -" will work...' X $cpp - testcpp.out 2>&1 X if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, it does." X cppstdin="$cpp" X cppminus='-'; X else X echo 'No such luck...maybe "cc -E" will work...' X cc -E testcpp.out 2>&1 X if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "It works!" X cppstdin='cc -E' X cppminus=''; X else X echo 'Nixed again...maybe "cc -E -" will work...' X cc -E - testcpp.out 2>&1 X if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Hooray, it works! I was beginning to wonder." X cppstdin='cc -E' X cppminus='-'; X else X echo 'Nope...maybe "cc -P" will work...' X cc -P testcpp.out 2>&1 X if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, that does." X cppstdin='cc -P' X cppminus=''; X else X echo 'Nope...maybe "cc -P -" will work...' X cc -P - testcpp.out 2>&1 X if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Yup, that does." X cppstdin='cc -P' X cppminus='-'; X else X echo 'Hmm...perhaps you already told me...' X case "$cppstdin" in X '') ;; X *) $cppstdin $cppminus testcpp.out 2>&1;; X esac X if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Hooray, you did! I was beginning to wonder." X else X echo 'Uh-uh. Time to get fancy...' X echo 'Trying (cat >/tmp/$$.c; cc -E /tmp/$$.c; rm /tmp/$$.c)' X cppstdin='(cat >/tmp/$$.c; cc -E /tmp/$$.c; rm /tmp/$$.c)' X cppminus=''; X $cppstdin testcpp.out 2>&1 X if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "Eureka!." X else X dflt=blurfl X $echo $n "No dice. I can't find a C preprocessor. Name one: $c" X rp='Name a C preprocessor:' X . myread X cppstdin="$ans" X $cppstdin testcpp.out 2>&1 X if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then X echo "OK, that will do." X else X echo "Sorry, I can't get that to work. Go find one." X exit 1 X fi X fi X fi X fi X fi X fi X fi X fi Xfi Xrm -f testcpp.c testcpp.out X X: get C preprocessor symbols handy Xecho " " Xecho $attrlist | $tr '[ - ]' '[\012-\012]' >Cppsym.know X$cat <Cppsym X$startsh Xcase "\$1" in X-l) list=true X shift X ;; Xesac Xunknown='' Xcase "\$list\$#" in X1|2) X for sym do X if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then X exit 0 X elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then X : X else X unknown="\$unknown \$sym" X fi X done X set X \$unknown X shift X ;; Xesac Xcase \$# in X0) exit 1;; Xesac Xecho \$* | $tr '[ - ]' '[\012-\012]' | $sed -e 's/\(.*\)/\\ X#ifdef \1\\ Xexit 0; _ _ _ _\1\\ \1\\ X#endif\\ X/' >/tmp/Cppsym\$\$ Xecho exit 1 >>/tmp/Cppsym\$\$ X$cppstdin $cppminus /tmp/Cppsym2\$\$ Xcase "\$list" in Xtrue) awk 'NF > 5 {print substr(\$6,2,100)}' Cppsym.true Xcat Cppsym.true Xrmlist="$rmlist Cppsym Cppsym.know Cppsym.true" X X: see how many register declarations we want to use Xcase "$registers" in X'') X if Cppsym vax; then X dflt=6 X elif Cppsym sun mc68000; then X dflt=10 X elif Cppsym pyr; then X dflt=14 X elif Cppsym ns32000 ns16000; then X dflt=5 X elif Cppsym $smallmach; then X dflt=3 X else X : if you have any other numbers for me, send them in X dflt=6 X fi X ;; X*) dflt=$registers ;; Xesac Xcat <.foo X. .foo Xawk "BEGIN { for (i=1; i<=$registers; i++) printf \"reg%d=register\n\", i}" \ X .foo X. .foo Xrm -f .foo X X: preserve RCS keywords in files with variable substitution, grrr XLog='$Log' XHeader='$Header' X X: set up shell script to do ~ expansion Xcat >filexp <&2 X exit 1 X fi X case "\$1" in X */*) X echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\` X ;; X *) X echo \$dir X ;; X esac X fi X ;; X*) X echo \$1 X ;; Xesac XEOSS Xchmod +x filexp X$eunicefix filexp X X: determine where public executables go Xcase "$bin" in X'') X dflt=`loc . /bin /usr/local/bin /usr/lbin /usr/local /usr/bin` X ;; X*) dflt="$bin" X ;; Xesac Xcont=true Xwhile $test "$cont" ; do X echo " " X rp="Where do you want to put the public executables? [$dflt]" X $echo $n "$rp $c" X . myread X bin="$ans" X bin=`filexp $bin` X if test -d $bin; then X cont='' X else X dflt=n X rp="Directory $bin doesn't exist. Use that name anyway? [$dflt]" X $echo $n "$rp $c" X . myread X dflt='' X case "$ans" in X y*) cont='';; X esac X fi Xdone X X: determine where manual pages go Xcase "$mansrc" in X'') X dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1` X ;; X*) dflt="$mansrc" X ;; Xesac Xcont=true Xwhile $test "$cont" ; do X echo " " X rp="Where do the manual pages (source) go? [$dflt]" X $echo $n "$rp $c" X . myread X mansrc=`filexp "$ans"` X if test -d $mansrc; then X cont='' X else X dflt=n X rp="Directory $mansrc doesn't exist. Use that name anyway? [$dflt]" X $echo $n "$rp $c" X . myread X dflt='' X case "$ans" in X y*) cont='';; X esac X fi Xdone Xcase "$mansrc" in X*l) X manext=l X ;; X*n) X manext=n X ;; X*C) X manext=C X ;; X*) X manext=1 X ;; Xesac X X: see what memory models we can support Xcase "$models" in X'') X if Cppsym pdp11; then X dflt='unsplit split' X else X ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge` X case "$ans" in X X) dflt='none';; X *) if $test -d /lib/small || $test -d /usr/lib/small; then X dflt='small' X else X dflt='' X fi X if $test -d /lib/medium || $test -d /usr/lib/medium; then X dflt="$dflt medium" X fi X if $test -d /lib/large || $test -d /usr/lib/large; then X dflt="$dflt large" X fi X if $test -d /lib/huge || $test -d /usr/lib/huge; then X dflt="$dflt huge" X fi X esac X fi X ;; X*) dflt="$models" ;; Xesac X$cat </dev/null 2>&1 || \ X $contains '-i' $mansrc/cc.1 >/dev/null 2>&1; then X dflt='-i' X else X dflt='none' X fi X ;; X *) dflt="$split";; X esac X rp="What flag indicates separate I and D space? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans='';; X esac X split="$ans" X unsplit='' X ;; X*large*|*small*|*medium*|*huge*) X case "$model" in X *large*) X case "$large" in X '') dflt='-Ml';; X *) dflt="$large";; X esac X rp="What flag indicates large model? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans=''; X esac X large="$ans" X ;; X *) large='';; X esac X case "$model" in X *huge*) X case "$huge" in X '') dflt='-Mh';; X *) dflt="$huge";; X esac X rp="What flag indicates huge model? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans=''; X esac X huge="$ans" X ;; X *) huge="$large";; X esac X case "$model" in X *medium*) X case "$medium" in X '') dflt='-Mm';; X *) dflt="$medium";; X esac X rp="What flag indicates medium model? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans=''; X esac X medium="$ans" X ;; X *) medium="$large";; X esac X case "$model" in X *small*) X case "$small" in X '') dflt='none';; X *) dflt="$small";; X esac X rp="What flag indicates small model? [$dflt]" X $echo $n "$rp $c" X . myread X case "$ans" in X none) ans=''; X esac X small="$ans" X ;; X *) small='';; X esac X ;; X*) X echo "Unrecognized memory models--you may have to edit Makefile.SH" X ;; Xesac X Xcase "$ccflags" in X'') dflt='none';; X*) dflt="$ccflags";; Xesac Xecho " " Xrp="Any additional cc flags? [$dflt]" X$echo $n "$rp $c" X. myread Xcase "$ans" in Xnone) ans=''; Xesac Xccflags="$ans" X Xcase "$ldflags" in X'') if venix; then X dflt='-i -z' X else X dflt='none' X fi X ;; X*) dflt="$ldflags";; Xesac Xecho " " Xrp="Any additional ld flags? [$dflt]" X$echo $n "$rp $c" X. myread Xcase "$ans" in Xnone) ans=''; Xesac Xldflags="$ans" X X: see if we need a special compiler Xecho " " Xif usg; then X case "$cc" in X '') X case "$Mcc" in X /*) dflt='Mcc' X ;; X *) X case "$large" in X -M*) X dflt='cc' X ;; X *) X if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then X dflt='cc -M' X else X dflt='cc' X fi X ;; X esac X ;; X esac X ;; X *) dflt="$cc";; X esac X $cat <<'EOM' X XOn some systems the default C compiler will not resolve multiple global Xreferences that happen to have the same name. On some such systems the X"Mcc" command may be used to force these to be resolved. On other systems Xa "cc -M" command is required. (Note that the -M flag on other systems Xindicates a memory model to use!) What command will force resolution on XEOM X $echo $n "this system? [$dflt] $c" X rp="Command to resolve multiple refs? [$dflt]" X . myread X cc="$ans" Xelse X echo "Not a USG system--assuming cc can resolve multiple definitions." X cc=cc Xfi X Xecho " " Xecho "End of configuration questions." Xecho " " X X: create config.sh file Xecho " " Xif test -d ../UU; then X cd .. Xfi Xecho "Creating config.sh..." X$spitshell <config.sh X$startsh X# config.sh X# This file was produced by running the Configure script. X Xd_eunice='$d_eunice' Xeunicefix='$eunicefix' Xdefine='$define' Xloclist='$loclist' Xexpr='$expr' Xsed='$sed' Xecho='$echo' Xcat='$cat' Xrm='$rm' Xmv='$mv' Xcp='$cp' Xtail='$tail' Xtr='$tr' Xmkdir='$mkdir' Xsort='$sort' Xuniq='$uniq' Xgrep='$grep' Xtrylist='$trylist' Xtest='$test' Xinews='$inews' Xegrep='$egrep' Xmore='$more' Xpg='$pg' XMcc='$Mcc' Xvi='$vi' Xmailx='$mailx' Xmail='$mail' Xcpp='$cpp' XLog='$Log' XHeader='$Header' Xbin='$bin' Xcc='$cc' Xcontains='$contains' Xcppstdin='$cppstdin' Xcppminus='$cppminus' Xd_charsprf='$d_charsprf' Xd_flexfnam='$d_flexfnam' Xd_index='$d_index' Xd_voidsig='$d_voidsig' Xlibc='$libc' Xmansrc='$mansrc' Xmanext='$manext' Xmodels='$models' Xsplit='$split' Xsmall='$small' Xmedium='$medium' Xlarge='$large' Xhuge='$huge' Xccflags='$ccflags' Xldflags='$ldflags' Xn='$n' Xc='$c' Xpackage='$package' Xregisters='$registers' Xreg1='$reg1' Xreg2='$reg2' Xreg3='$reg3' Xreg4='$reg4' Xreg5='$reg5' Xreg6='$reg6' Xreg7='$reg7' Xreg8='$reg8' Xreg9='$reg9' Xreg10='$reg10' Xreg11='$reg11' Xreg12='$reg12' Xreg13='$reg13' Xreg14='$reg14' Xreg15='$reg15' Xreg16='$reg16' Xspitshell='$spitshell' Xshsharp='$shsharp' Xsharpbang='$sharpbang' Xstartsh='$startsh' Xvoidflags='$voidflags' Xdefvoidused='$defvoidused' XCONFIG=true XEOT X XCONFIG=true X Xecho " " Xdflt='' Xfastread='' Xecho "If you didn't make any mistakes, then just type a carriage return here." Xrp="If you need to edit config.sh, do it as a shell escape here:" X$echo $n "$rp $c" X. UU/myread Xcase "$ans" in X'') ;; X*) : in case they cannot read X eval $ans;; Xesac X. ./config.sh X Xecho " " Xecho "Doing variable substitutions on .SH files..." Xset x `awk '{print $1}' /dev/null 2>&1; then X dflt=n X $cat < makedepend.out &" XIt can take a while, so you might not want to run it right now. X XEOM X rp="Run make depend now? [$dflt]" X $echo $n "$rp $c" X . UU/myread X case "$ans" in X y*) make depend X echo "Now you must run a make." X ;; X *) echo "You must run 'make depend' then 'make'." X ;; X esac Xelif test -f Makefile; then X echo " " X echo "Now you must run a make." Xelse X echo "Done." Xfi X X$rm -f kit*isdone Xcd UU && $rm -f $rmlist X: end of Configure SHAR_EOF if test 30911 -ne "`wc -c < 'Configure'`" then echo shar: "error transmitting 'Configure'" '(should have been 30911 characters)' fi chmod +x 'Configure' fi echo shar: "extracting 'EXTERN.h'" '(241 characters)' if test -f 'EXTERN.h' then echo shar: "will not over-write existing file 'EXTERN.h'" else sed 's/^X//' << \SHAR_EOF > 'EXTERN.h' X/* $Header: EXTERN.h,v 2.0 86/09/17 15:35:37 lwall Exp $ X * X * $Log: EXTERN.h,v $ X * Revision 2.0 86/09/17 15:35:37 lwall X * Baseline for netwide release. X * X */ X X#undef EXT X#define EXT extern X X#undef INIT X#define INIT(x) X X#undef DOINIT SHAR_EOF if test 241 -ne "`wc -c < 'EXTERN.h'`" then echo shar: "error transmitting 'EXTERN.h'" '(should have been 241 characters)' fi fi echo shar: "extracting 'INTERN.h'" '(239 characters)' if test -f 'INTERN.h' then echo shar: "will not over-write existing file 'INTERN.h'" else sed 's/^X//' << \SHAR_EOF > 'INTERN.h' X/* $Header: INTERN.h,v 2.0 86/09/17 15:35:58 lwall Exp $ X * X * $Log: INTERN.h,v $ X * Revision 2.0 86/09/17 15:35:58 lwall X * Baseline for netwide release. X * X */ X X#undef EXT X#define EXT X X#undef INIT X#define INIT(x) = x X X#define DOINIT SHAR_EOF if test 239 -ne "`wc -c < 'INTERN.h'`" then echo shar: "error transmitting 'INTERN.h'" '(should have been 239 characters)' fi fi echo shar: "extracting 'MANIFEST'" '(1196 characters)' if test -f 'MANIFEST' then echo shar: "will not over-write existing file 'MANIFEST'" else sed 's/^X//' << \SHAR_EOF > 'MANIFEST' XAfter all the patch kits are run you should have the following files: X XFilename Kit Description X-------- --- ----------- XConfigure 1 A shell script that installs everything system dependent. XEXTERN.h 1 Toggle .h files to look foreign. XINTERN.h 3 Toggle .h files to look domestic. XMANIFEST 3 This list of files. XMakefile.SH 3 The makefile. XREADME 3 Installation instructions. Xcommon.h 3 Common definitions. Xconfig.H 3 Sample config.h, in case Configure won't run. Xinp.c 2 Input file abstract data type routines. Xinp.h 3 Public defs for above. Xpatch.c 2 The patch program. Xpatch.man 2 Manual page for patch. Xpatchlevel.h 3 The patch level of the patch program. Xpch.c 1 Patch abstract data type routines. Xpch.h 3 Public defs for above. Xutil.c 2 Utility routines. Xutil.h 1 Public defs for above. Xversion.c 3 Version number routine. Xversion.h 3 Public defs for above. SHAR_EOF if test 1196 -ne "`wc -c < 'MANIFEST'`" then echo shar: "error transmitting 'MANIFEST'" '(should have been 1196 characters)' fi fi echo shar: "extracting 'Makefile.SH'" '(2183 characters)' if test -f 'Makefile.SH' then echo shar: "will not over-write existing file 'Makefile.SH'" else sed 's/^X//' << \SHAR_EOF > 'Makefile.SH' Xcase $CONFIG in X '') . config.sh ;; Xesac Xecho "Extracting Makefile (with variable substitutions)" Xcat >Makefile <>Makefile <<'!NO!SUBS!' X Xpublic = patch Xprivate = Xmanpages = patch.man Xutil = Makefile X Xc = patch.c pch.c inp.c version.c util.c X Xobj = patch.o pch.o inp.o util.o version.o X Xlintflags = -phbvxac X Xaddedbyconf = Makefile.old bsd config.h config.sh eunice loc pdp11 usg v7 X X# grrr XSHELL = /bin/sh X X.c.o: X $(CC) -c $(CFLAGS) $(LARGE) $*.c X Xall: $(public) $(private) $(util) X touch all X Xpatch: $(obj) X $(CC) $(LDFLAGS) $(obj) $(libs) -o patch X X# won't work with csh Xinstall: patch X export PATH || exit 1 X - mv $(bin)/patch $(bin)/patch.old X - if test `pwd` != $(bin); then cp $(public) $(bin); fi X cd $(bin); chmod 755 $(public) X - if test `pwd` != $(mansrc); then \ Xfor page in $(manpages); do \ Xrm -f $(mansrc)/../cat$(manext)/`basename $$page .man`.$(manext); \ Xcp $$page $(mansrc)/`basename $$page .man`.$(manext); \ Xdone; \ Xfi X Xclean: X rm -f *.o *.orig core X Xrealclean: X rm -f patch *.o *.orig core $(addedbyconf) X X# The following lint has practically everything turned on. Unfortunately, X# you have to wade through a lot of mumbo jumbo that can't be suppressed. X# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message X# for that spot. X Xlint: X lint $(lintflags) $(defs) $(c) > patch.fuzz X Xpatch.o: config.h common.h patch.c inp.h pch.h util.h version.h Xpch.o: config.h common.h pch.c pch.h util.h Xinp.o: config.h common.h inp.c inp.h util.h Xutil.o: config.h common.h util.c util.h Xversion.o: config.h common.h version.c version.h patchlevel.h util.h X X!NO!SUBS! X$eunicefix Makefile SHAR_EOF if test 2183 -ne "`wc -c < 'Makefile.SH'`" then echo shar: "error transmitting 'Makefile.SH'" '(should have been 2183 characters)' fi fi echo shar: "extracting 'README'" '(2963 characters)' if test -f 'README' then echo shar: "will not over-write existing file 'README'" else sed 's/^X//' << \SHAR_EOF > 'README' X Patch Kit, Version 2.0 X X Copyright (c) 1986, Larry Wall X XYou may copy the patch kit in whole or in part as long as you don't try to Xmake money off it, or pretend that you wrote it. X-------------------------------------------------------------------------- X XPlease read all the directions below before you proceed any further, and Xthen follow them carefully. Failure to do so may void your warranty. :-) X XAfter you have unpacked your kit, you should have all the files listed Xin MANIFEST. X XInstallation X X1) Run Configure. This will figure out various things about your system. X Some things Configure will figure out for itself, other things it will X ask you about. It will then proceed to make config.h, config.sh, and X Makefile. X X You might possibly have to trim # comments from the front of Configure X if your sh doesn't handle them, but all other # comments will be taken X care of. X X If you don't have sh, you'll have to rip the prototype of config.h out X of Configure and generate the defines by hand. X X2) Glance through config.h to make sure system dependencies are correct. X Most of them should have been taken care of by running the Configure script. X X If you have any additional changes to make to the C definitions, they X can be done in the Makefile, or in config.h. Bear in mind that they may X get undone next time you run Configure. X X3) make X X This will attempt to make patch in the current directory. X X4) make install X X This will put patch into a public directory (normally /usr/local/bin). X It will also try to put the man pages in a reasonable place. It will not X nroff the man page, however. X X5) Read the manual entry before running patch. X X6) IMPORTANT! Help save the world! Communicate any problems and X suggested patches to me, lwall@sdcrdcf.UUCP (Larry Wall), so we can X keep the world in sync. If you have a problem, there's someone else X out there who either has had or will have the same problem. X X If possible, send in patches such that the patch program will apply them. X Context diffs are the best, then normal diffs. Don't send ed scripts-- X I've probably changed my copy since the version you have. X X Watch for patch patches in net.sources.bugs. Patches will generally be X in a form usable by the patch program. If you are just now bringing up X patch and aren't sure how many patches there are, write to me and I'll X send any you don't have. Your current patch level is shown in patchlevel.h. X X XNEW FEATURES IN THIS RELEASE X X(Correct) support for 4.3bsd-style context diffs. XFiles can be created from scratch. XYou can specify a fuzz-factor for context matching. XYou can force patch to ask no questions. XYou can specify how much of the leading pathname to strip off filenames. XUses a Configure script for greater portability. XYou are now asked if you want to apply a reversed patch. XNo limit (apart from memory) on the size of hunks. SHAR_EOF if test 2963 -ne "`wc -c < 'README'`" then echo shar: "error transmitting 'README'" '(should have been 2963 characters)' fi fi echo shar: "extracting 'common.h'" '(3873 characters)' if test -f 'common.h' then echo shar: "will not over-write existing file 'common.h'" else sed 's/^X//' << \SHAR_EOF > 'common.h' X/* $Header: common.h,v 2.0.1.1 88/06/03 15:01:56 lwall Locked $ X * X * $Log: common.h,v $ X * Revision 2.0.1.1 88/06/03 15:01:56 lwall X * patch10: support for shorter extensions. X * X * Revision 2.0 86/09/17 15:36:39 lwall X * Baseline for netwide release. X * X */ X X#define DEBUGGING X X#include "config.h" X X/* shut lint up about the following when return value ignored */ X X#define Signal (void)signal X#define Unlink (void)unlink X#define Lseek (void)lseek X#define Fseek (void)fseek X#define Fstat (void)fstat X#define Pclose (void)pclose X#define Close (void)close X#define Fclose (void)fclose X#define Fflush (void)fflush X#define Sprintf (void)sprintf X#define Mktemp (void)mktemp X#define Strcpy (void)strcpy X#define Strcat (void)strcat X X#include X#include X#include X#include X#include X#include X X/* constants */ X X#define TRUE (1) X#define FALSE (0) X X#define MAXHUNKSIZE 100000 /* is this enough lines? */ X#define INITHUNKMAX 125 /* initial dynamic allocation size */ X#define MAXLINELEN 1024 X#define BUFFERSIZE 1024 X#define SCCSPREFIX "s." X#define GET "get -e %s" X#define RCSSUFFIX ",v" X#define CHECKOUT "co -l %s" X X#ifdef FLEXFILENAMES X#define ORIGEXT ".orig" X#define REJEXT ".rej" X#else X#define ORIGEXT "~" X#define REJEXT "#" X#endif X X/* handy definitions */ X X#define Null(t) ((t)0) X#define Nullch Null(char *) X#define Nullfp Null(FILE *) X#define Nulline Null(LINENUM) X X#define Ctl(ch) ((ch) & 037) X X#define strNE(s1,s2) (strcmp(s1, s2)) X#define strEQ(s1,s2) (!strcmp(s1, s2)) X#define strnNE(s1,s2,l) (strncmp(s1, s2, l)) X#define strnEQ(s1,s2,l) (!strncmp(s1, s2, l)) X X/* typedefs */ X Xtypedef char bool; Xtypedef long LINENUM; /* must be signed */ Xtypedef unsigned MEM; /* what to feed malloc */ X X/* globals */ X XEXT int Argc; /* guess */ XEXT char **Argv; XEXT int Argc_last; /* for restarting plan_b */ XEXT char **Argv_last; X XEXT struct stat filestat; /* file statistics area */ XEXT int filemode INIT(0644); X XEXT char buf[MAXLINELEN]; /* general purpose buffer */ XEXT FILE *ofp INIT(Nullfp); /* output file pointer */ XEXT FILE *rejfp INIT(Nullfp); /* reject file pointer */ X XEXT bool using_plan_a INIT(TRUE); /* try to keep everything in memory */ XEXT bool out_of_mem INIT(FALSE); /* ran out of memory in plan a */ X X#define MAXFILEC 2 XEXT int filec INIT(0); /* how many file arguments? */ XEXT char *filearg[MAXFILEC]; XEXT bool ok_to_create_file INIT(FALSE); XEXT char *bestguess INIT(Nullch); /* guess at correct filename */ X XEXT char *outname INIT(Nullch); XEXT char rejname[128]; X XEXT char *origext INIT(Nullch); XEXT char *origprae INIT(Nullch); X XEXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX"); XEXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */ XEXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX"); XEXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX"); XEXT bool toutkeep INIT(FALSE); XEXT bool trejkeep INIT(FALSE); X XEXT LINENUM last_offset INIT(0); X#ifdef DEBUGGING XEXT int debug INIT(0); X#endif XEXT LINENUM maxfuzz INIT(2); XEXT bool force INIT(FALSE); XEXT bool verbose INIT(TRUE); XEXT bool reverse INIT(FALSE); XEXT bool noreverse INIT(FALSE); XEXT bool skip_rest_of_patch INIT(FALSE); XEXT int strippath INIT(957); XEXT bool canonicalize INIT(FALSE); X X#define CONTEXT_DIFF 1 X#define NORMAL_DIFF 2 X#define ED_DIFF 3 X#define NEW_CONTEXT_DIFF 4 XEXT int diff_type INIT(0); X XEXT bool do_defines INIT(FALSE); /* patch using ifdef, ifndef, etc. */ XEXT char if_defined[128]; /* #ifdef xyzzy */ XEXT char not_defined[128]; /* #ifndef xyzzy */ XEXT char else_defined[] INIT("#else\n");/* #else */ XEXT char end_defined[128]; /* #endif xyzzy */ X XEXT char *revision INIT(Nullch); /* prerequisite revision, if any */ X Xchar *malloc(); Xchar *realloc(); Xchar *strcpy(); Xchar *strcat(); Xlong atol(); Xlong lseek(); Xchar *mktemp(); X#ifdef CHARSPRINTF Xchar *sprintf(); X#else Xint *sprintf(); X#endif SHAR_EOF if test 3873 -ne "`wc -c < 'common.h'`" then echo shar: "error transmitting 'common.h'" '(should have been 3873 characters)' fi fi echo shar: "extracting 'config.H'" '(657 characters)' if test -f 'config.H' then echo shar: "will not over-write existing file 'config.H'" else sed 's/^X//' << \SHAR_EOF > 'config.H' X/* config.h X * This file was produced by running the Configure script. X * Feel free to modify any of this as the need arises. X */ X X X#/*undef EUNICE /* no file linking? */ X#/*undef VMS X X#/*undef index strchr /* cultural */ X#/*undef rindex strrchr /* differences? */ X X#/*undef void int /* is void to be avoided? */ X X/* How many register declarations are paid attention to? */ X X#define Reg1 register X#define Reg2 register X#define Reg3 register X#define Reg4 register X#define Reg5 register X#define Reg6 register X#define Reg7 X#define Reg8 X#define Reg9 X#define Reg10 X#define Reg11 X#define Reg12 X#define Reg13 X#define Reg14 X#define Reg15 X#define Reg16 X SHAR_EOF if test 657 -ne "`wc -c < 'config.H'`" then echo shar: "error transmitting 'config.H'" '(should have been 657 characters)' fi fi exit 0 # End of shell archive