Subject: Object file symbols limited to 8 characters [+FIX] (#173 - #16 of 19)
Index:	cc,as,ld,ar,ranlib,nm,nlist,adb,... (2.11BSD)

Description:
	For some time now (seem like eons;-)) the object file format used 
	by Unix for the PDP-11 has restricted symbols to 8 significant 
	characters (actually 7 due to the C compiler prefixing symbols with 
	a leading tilde (~) or underscore (_)).

	Aside from the "creative constraints" this imposes on the programmer
	there was the continuing problem of 'name collisions', especially
	when porting applications from machines whose object file format
	permitted longer symbol names.

	Numerous workarounds have been employed in the past.  The
	most common one relied on a combination of a name collision
	detection program ('shortc') and the flexname capability of the
	C preprocessor ('cpp').  This served to mask the problem while
	making debugging difficult due to mangled/synthetic symbol names.

Repeat-By:
	Attempt to compile the following program:

		int	this_is_a_long_name;
		int	this_is_a_long_name_too;

		main() { exit(0)};

Fix:
	This section is repeated in each of the 19 parts which make up
	the update kit.  You should read it perhaps once or twice, but
	then skip over it (how to do that is mentioned below).

	Taking a "hint" from the a.out(5) man page:

"The compiler will note name collisions when they occur within a single file...
There is really little that can be done about this.  Some thought is being
given to modifying the loader to flag detectable collisions, but the real
solution would be to change over to the 4BSD a.out format.  This would 
involve modifying the compiler, assembler and adb and then simply porting 
the 4.3BSD ld, nm, ranlib, strip and nlist.  Or perhaps simply porting the 
entire 4.3BSD suite might be best ...  Anyone interested in a project?"

	This I have done.  No more volunteers for the project need apply ;-)

	The new limit on symbol length is 32 characters!  There is still
	a limit (but it is _much_ more reasonable now) simply because of
	address space constraints - it needs to be possible to hold 
	at least one of the 'symbol' or 'string' tables in memory in many
	cases (nice to hold both, but - i know, get a 486;-)).

	It must be noted though that it is almost trivial now to raise
	the limit if that is desired - the programs which need to know
	the maximum length of a symbol string all have an easily changed
	#define statement now (usually MAXSYMLEN but there are a couple
	exceptions).  The 'string table' format itself doesn't care how 
	long the strings are.  The actual a.out format won't have to 
	change again to accomodate a higher limit on symbol name length!

	The "string table" object file format has been ported and all
	the necessary changes made throughout the entire system.

	The changes were *massive* and widespread.  Programs affected
	of course included the assembler and compiler.  Other programs
	affected were anything which accessed a symbol table entry either
	via nlist(3) [ps, pstat, fstat, vmstat, etc] or by reading
	object files [ld, ranlib, nm, adb, strip, etc].

	The actual changes to the compiler and assembler were minor
	because those programs had already been modified earlier 
	(updates #142, 143, 152, 153).  The compiler only needed to have
	the maximum size of a symbol name raised.  The assembler
	already knew how to generate 'string table' object files - all
	that needed to be done in 'as' was to flip a bit telling it
	to generate the new object format instead of the old style.

	+++++++++++++++
	And now for a bit of a narrative about what was done.   The
	detailed instructions for applying this part (#16 of 19) of the
	update kit follow the 'story' below.  This started out as
	a semi-organized accounting of what was done but then devolved
	into a semi-rambling tale due to the sheer bulk of the changes.

	You can skip to the details for applying #173 by searching for
	the string "=======" below - this header is replicated in all
	parts of this kit.
	+++++++++++++++

	Alas, the remaining changes were not so simple.  Complete
	replacements for ranlib(1), ar(1), nlist(3) were ported from
	the Net-2 release.  Other programs such as symorder(1) and
	two new programs 'symcompact' and 'strcompact' (used to
	compress/compact symbol and string tables) were written from
	scratch.

	Perhaps the two hardest parts of the whole effort were
	rewriting the linker 'ld' and making *large* modifications
	to the debugger 'adb'.  This was a very difficult job.
	'ld needed to scan new style ranlib archives, as well as
	using the "virtual memory" facility (the 'libvmf' routines 
	posted earlier) for symbol table management and so on.  'adb'
	was a MESS (having been written in a pseudo block structured
	macro language).  Since the new symbol table entry could be
	so much larger than the old it was no longer possible for adb
	to hold as much of the symbol table in memory - an alternate 
	method took a while to develope and implement, more on that
	in the patch which deals with adb (actually the changes to
	adb are so large there are two substantial parts of this update
	kit just for adb!).

	After the basic programs (ar, ld, ranlib, etc) were running
	the system had to be completely recompiled from sources, beginning
	with the object libraries.  After those were done the process
	of recompiling the rest of the system could proceed.

	Guess what happens when you recreate libc.a with a buggy linker?
	Yep - the system is rendered useless until backup copies of
	everything can be reloaded.  Don't let this happen to you - be
	sure (and i'll repeat the point later) to back up the system
	(or at least key executables and .a files) before installing
	this upgrade.

	In all there were about 330 files modified during the change of
	object file format.  Some of these were not directly related
	to the new object file format.  There were a number of (obsolete)
	references to "BSD2_10" lingering in the system.  Those 
	have been replaced with "pdp11" and the 'BSD2_10' define has
	been removed from the C preprocessor (cpp).  DO NOT use 'BSD2_10'
	to #ifdef pdp-11 sensitive code, use "pdp11" instead.

	During the recompile of the libraries a fairly large number of
	"shortened" names were lengthened - these included syscall routines
	such as "gethostname" which no longer had to be munged into
	"gethname".  Also a surprising number of typographical errors
	were uncovered (mainly in the Fortran libraries) where an extra
	character (beyond the 7th character) was left off or accidentally
	added.  These were all fixed and eventually, after a couple
	evenings, the libraries were built and installed.

	After the libraries were done it was the application programs'
	turn to be recompiled.  This took the better part of a couple 
	weeks to finally make it thru due to (as it turned out) the iterative 
	nature of the task.  A symbol would come up undefined and have
	to be tracked down exactly where the wrong definition/use was
	coming from.  Finally, however, the task was done and it was
	time to move on to the kernel.

	The kernel proved to be suprisingly easy - no real complications
	arose except when it came time to reboot, a bug had been introduced
	into 'autoconfig' (who uses 'nlist' to scan the kernel symbol table).
	Ouch!  That was another couple late nights.  Since the compiler
	supports unsigned longs now a number of small changes which
	ifdef'd 'u_long' to 'long' were removed.

	REMEMBER - you need to recompile 'autoconfig' and install it
	before rebooting the new kernel ;-)

	The performance of 'ps' though (and anything else which used
	nlist(3), 'fstat', 'w' are good examples) was unacceptably slow.

	So, amidst other delays (real work, the earthquake - which almost
	tossed the disc drive to the floor, etc) the "symorder" program
	was written (with ideas borrowed from the Net-2 version).  The
	symorder(1) program rather insists on holding both the symbol
	and string tables in memory - this was a problem (or could be
	if the kernel symbol table grows much more) so two new and 
	original programs were written:  'symcompact' and 'strcompact'.

	The first program compacts the symbol table by removing 
	'register' local variables (they're of no use to anyone - the debugger
	doesn't/can't do anything with them) and redundant global text
	symbols (symbols in an overlaid program which are in the root
	segment do not need both the '~' and '_' symbols present).

	The second program 'strcompact' is one that any 'string table'
	based object file system can use.  It implements "shared strings"
	for symbols - if a program has many references to 'error' as a
	local symbol, why store the string 'error' more than once?  Simply
	store one instance and then update the symbol table entries to
	all point to the same string!

	Using both 'strcompact' and 'symcompact' on the /unix image
	resulted in a file that was 15kb smaller.  Running 'symorder'
	then puts the most frequently used symbols at the front of the
	symbol table, the performance of 'w', 'pstat', and other programs
	which nlist(3) the kernel was now acceptable.

	Some of the parts of this kit are large.  The large patch files have
	been split into pieces which the 'patch' will handle, other parts
	(the replacement 'ar' sources) were left as a single 'shar' file
	rather than split them up.

	Each part of this kit consists of:

		a 'patchfile' - this is used with the "patch" program to
		update files.

		an optional 'script' - this is run ("sh script") to perform
		initialization, remove files, create directories and so on.

		an optional 'new.sources' - this is a "shar" file containing
		complete sources for a program.

	ALL pathnames are _absolute_ - this way you do not have to "cd"
	around the system, you should be able to apply all the patches
	while you are in /tmp (or /usr/tmp - wherever you have the most
	free space).

	Be sure that you have at least 40mb free on /usr before 
	rebuilding the system - if you do not then building in stages
	will be necessary.

	Part 19 contains the detailed instructions for rebuilding the
	system _after_ the previous 18 patches have been applied.

	The patches (#158 thru #175) should be applied in order following
	the directions in each part.

	DO NOT recompile anything once the patching has begun until requested
	to do so in part 19.  Many of the system include files are modified
	and the object file format is being changed - recompilation will not
	be possible until the transformation of the system and object libraries
	is complete.

	AT A MINIMUM you will want to back up the following files (unless
	you have a known good backup already made) in case you need to
	recompile something before part 19 is done:

		/bin/ar
		/bin/ld
		/bin/nm
		/bin/as
		/usr/bin/ranlib
		/lib/c0
		/lib/crt0.o
		/lib/mcrt0.o
		/lib/libc.a
		/bin/nm
		/usr/include/*.h
		/usr/include/sys/*.h

	In part 19 there is a *complete* list of all files affected
	(all 336 of them) - you may wish to back those up also.

	And now the common header ('boilerplate') is over (at last ;-)),
	let the installation guide begin.

	As always, the complete 2.11BSD updates are available via 
	anonymous FTP to 'ftp.iipo.gtegsc.com' in the directory /pub/2.11BSD

==========  #173 (Part #16 of 19)

	This part updates the following files.  BACK THESE UP if you
	have any worries about the proceedure or do not have a bootable
	backup already at hand.

/usr/src/usr.bin/diff3/diff3.c
/usr/src/usr.bin/tbl/t..c
/usr/src/usr.bin/refer/glue5.c
/usr/src/usr.bin/refer/refer..c
/usr/src/usr.bin/refer/refer5.c
/usr/src/usr.bin/refer/lookbib.c
/usr/src/usr.bin/uucp/aculib/bsdtcp.c
/usr/src/usr.bin/uucp/uucp.h
/usr/src/usr.bin/uucp/acucntrl.c
/usr/src/usr.bin/uucp/condevs.h
/usr/src/usr.bin/uucp/uucpd.c
/usr/src/usr.bin/tip/aculib/courier.c
/usr/src/usr.bin/tip/aculib/Makefile
/usr/src/usr.bin/tip/tip.h
/usr/src/usr.bin/f77/proc.c
/usr/src/usr.bin/f77/gram.dcl
/usr/src/usr.bin/prof/prof.c
/usr/src/usr.bin/find/find.c
/usr/src/usr.bin/ranlib.c
/usr/src/usr.bin/Makefile
/usr/src/usr.bin/fgrep.c
/usr/src/usr.bin/install.c
/usr/src/usr.bin/bc.y

	0) Be in a temp directory ("cd /tmp" or "cd /usr/tmp")

	1) Save the following shar archive to a file (/tmp/173 for example)

	2) Unpack the archive:  sh 173

	3) Run the script:  ./script

	4) Patch the files:  patch -p0 < patchfile

	5) Unpack the new source replacements:  sh new.sources

	6) rm 173 script patchfile new.sources

	Part 16 of 19 is done.  DO NOT rebuild or compile _anything_
	at this point!

===== cut here
#! /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:
#	script
#	patchfile
#	new.sources
# This archive created: Fri Feb  4 23:29:58 1994
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'script'
then
	echo shar: "will not over-write existing file 'script'"
else
sed 's/^X//' << \SHAR_EOF > 'script'
X#! /bin/sh
X
Xrm -f /usr/src/usr.bin/ranlib.c
Xrm -rf /usr/src/usr.bin/ranlib
Xmkdir /usr/src/usr.bin/ranlib
Xchmod 755 /usr/src/usr.bin/ranlib
SHAR_EOF
chmod 755 'script'
fi
if test -f 'patchfile'
then
	echo shar: "will not over-write existing file 'patchfile'"
else
sed 's/^X//' << \SHAR_EOF > 'patchfile'
X*** /usr/src/usr.bin/diff3/diff3.c.old	Mon Feb 16 16:49:22 1987
X--- /usr/src/usr.bin/diff3/diff3.c	Mon Jan 10 22:40:37 1994
X***************
X*** 1,5 ****
X! #ifndef lint
X! static char sccsid[] = "@(#)diff3.c	4.4 (Berkeley) 8/27/85";
X  #endif
X  
X  #include <stdio.h>
X--- 1,5 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char sccsid[] = "@(#)diff3.c	4.4.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  
X  #include <stdio.h>
X***************
X*** 37,45 ****
X  */
X  struct diff de[NC];
X  char overlap[NC];
X- #ifdef BSD2_10
X- #define overlapcnt	ovlpcnt
X- #endif BSD2_10
X  int  overlapcnt =0;
X  
X  char line[256];
X--- 37,42 ----
X*** /usr/src/usr.bin/tbl/t..c.old	Mon Feb 16 18:39:24 1987
X--- /usr/src/usr.bin/tbl/t..c	Sat Jan  1 02:16:34 1994
X***************
X*** 1,4 ****
X! /*	t..c	4.3	85/09/14	*/
X  
X  /* t..c : external declarations */
X  
X--- 1,4 ----
X! /*	t..c	4.4	1/1/94	*/
X  
X  /* t..c : external declarations */
X  
X***************
X*** 6,16 ****
X  # include "ctype.h"
X  
X  # define MAXLIN 200
X! #ifdef BSD2_10
X  # define MAXHEAD 30
X! #else !BSD2_10
X  # define MAXHEAD 100
X! #endif BSD2_10
X  # define MAXCOL 20
X  # define MAXCHS 2000
X  # define MAXRPT 100
X--- 6,16 ----
X  # include "ctype.h"
X  
X  # define MAXLIN 200
X! #ifdef pdp11
X  # define MAXHEAD 30
X! #else
X  # define MAXHEAD 100
X! #endif
X  # define MAXCOL 20
X  # define MAXCHS 2000
X  # define MAXRPT 100
X*** /usr/src/usr.bin/refer/glue5.c.old	Tue Jun 14 12:10:06 1988
X--- /usr/src/usr.bin/refer/glue5.c	Mon Jan 10 22:45:57 1994
X***************
X*** 1,5 ****
X! #ifndef lint
X! static char *sccsid = "@(#)glue5.c	4.2 (Berkeley) 1/9/85";
X  #endif
X  
X  #include <stdio.h>
X--- 1,5 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char *sccsid = "@(#)glue5.c	4.2.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  
X  #include <stdio.h>
X***************
X*** 12,18 ****
X   *		1 - ok, but no matches
X   *		2 - some error
X   */
X! #ifdef BSD2_10
X  #define	MAXSIZ 350
X  #define QSIZE 200
X  #else
X--- 12,18 ----
X   *		1 - ok, but no matches
X   *		2 - some error
X   */
X! #ifdef pdp11
X  #define	MAXSIZ 350
X  #define QSIZE 200
X  #else
X*** /usr/src/usr.bin/refer/refer..c.old	Tue Jun 14 12:20:28 1988
X--- /usr/src/usr.bin/refer/refer..c	Sat Jan  1 02:17:34 1994
X***************
X*** 1,4 ****
X! /*	refer..c	4.3	86/04/23	*/
X  
X  #include <stdio.h>
X  #include <ctype.h>
X--- 1,4 ----
X! /*	refer..c	4.4	1/1/94	*/
X  
X  #include <stdio.h>
X  #include <ctype.h>
X***************
X*** 6,12 ****
X  
X  #define FLAG 003
X  #define AFLAG 007
X! #ifdef BSD2_10
X  #define NRFTXT 5000
X  #define NRFTBL 250
X  #else
X--- 6,12 ----
X  
X  #define FLAG 003
X  #define AFLAG 007
X! #ifdef pdp11
X  #define NRFTXT 5000
X  #define NRFTBL 250
X  #else
X*** /usr/src/usr.bin/refer/refer5.c.old	Tue Jun 14 12:34:33 1988
X--- /usr/src/usr.bin/refer/refer5.c	Mon Jan 10 22:46:40 1994
X***************
X*** 1,10 ****
X! #ifndef lint
X! static char *sccsid = "@(#)refer5.c	4.7 (Berkeley) 4/23/86";
X  #endif
X  
X  #include "refer..c"
X  #define SAME 0
X! #ifdef BSD2_10
X  #define NFLAB 1500		/* number of bytes to record all labels */
X  #define NLABC 500		/* max number of labels */
X  #else
X--- 1,10 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char *sccsid = "@(#)refer5.c	4.7.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  
X  #include "refer..c"
X  #define SAME 0
X! #ifdef pdp11
X  #define NFLAB 1500		/* number of bytes to record all labels */
X  #define NLABC 500		/* max number of labels */
X  #else
X*** /usr/src/usr.bin/refer/lookbib.c.old	Mon Feb 16 18:14:03 1987
X--- /usr/src/usr.bin/refer/lookbib.c	Mon Jan 10 22:46:58 1994
X***************
X*** 1,13 ****
X! #ifndef lint
X! static char *sccsid = "@(#)lookbib.c	4.4 (Berkeley) 2/15/84";
X  #endif
X  
X  #include <stdio.h>
X  #include <ctype.h>
X- 
X- #ifdef BSD2_10
X- #define instructions	instrs
X- #endif BSD2_10
X  
X  main(argc, argv)	/* look in biblio for record matching keywords */
X  int argc;
X--- 1,9 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char *sccsid = "@(#)lookbib.c	4.4.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  
X  #include <stdio.h>
X  #include <ctype.h>
X  
X  main(argc, argv)	/* look in biblio for record matching keywords */
X  int argc;
X*** /usr/src/usr.bin/uucp/aculib/bsdtcp.c.old	Mon Feb 16 16:21:34 1987
X--- /usr/src/usr.bin/uucp/aculib/bsdtcp.c	Mon Jan 10 22:47:48 1994
X***************
X*** 1,5 ****
X! #ifndef lint
X! static char sccsid[] = "@(#)bsdtcp.c	4.3 (Berkeley) 6/7/86";
X  #endif
X  
X  #include "../condevs.h"
X--- 1,5 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char sccsid[] = "@(#)bsdtcp.c	4.3.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  
X  #include "../condevs.h"
X*** /usr/src/usr.bin/uucp/uucp.h.old	Tue Aug 22 20:49:29 1989
X--- /usr/src/usr.bin/uucp/uucp.h	Fri Dec 31 23:02:50 1993
X***************
X*** 1,9 ****
X! /*	uucp.h	5.11	86/02/12	*/
X  
X  #include <stdio.h>
X- #ifdef BSD2_10
X- #include <short_names.h>
X- #endif
X  
X  /*
X   * Determine local uucp name of this machine.
X--- 1,6 ----
X! /*	uucp.h	5.11.1	93/12/31	*/
X  
X  #include <stdio.h>
X  
X  /*
X   * Determine local uucp name of this machine.
X*** /usr/src/usr.bin/uucp/acucntrl.c.old	Mon Dec 26 13:10:13 1988
X--- /usr/src/usr.bin/uucp/acucntrl.c	Mon Jan 10 22:48:07 1994
X***************
X*** 1,5 ****
X! #ifndef lint
X! static char sccsid[] = "@(#)acucntrl.c	5.8 (Berkeley) 2/12/86";
X  #endif
X  
X  /*  acucntrl - turn around tty line between dialin and dialout
X--- 1,5 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char sccsid[] = "@(#)acucntrl.c	5.8.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  
X  /*  acucntrl - turn around tty line between dialin and dialout
X***************
X*** 49,55 ****
X  #include <sys/buf.h>
X  #include <signal.h>
X  #include <sys/conf.h>
X! #ifdef BSD2_10
X  #include <pdpuba/ubavar.h>
X  #else
X  #ifdef BSD4_2
X--- 49,55 ----
X  #include <sys/buf.h>
X  #include <signal.h>
X  #include <sys/conf.h>
X! #ifdef pdp11
X  #include <pdpuba/ubavar.h>
X  #else
X  #ifdef BSD4_2
X***************
X*** 671,677 ****
X  		devtype = DZ11;
X  		unit = minor(dev) / NDZLINE;
X  		line = minor(dev) % NDZLINE;
X! #ifdef BSD2_10
X  		ubinfo = &(((struct uba_device *)NLVALUE(DZINFO))[unit]);
X  #else
X  		addr = (int) &(((int *)NLVALUE(DZINFO))[unit]);
X--- 671,677 ----
X  		devtype = DZ11;
X  		unit = minor(dev) / NDZLINE;
X  		line = minor(dev) % NDZLINE;
X! #ifdef pdp11
X  		ubinfo = &(((struct uba_device *)NLVALUE(DZINFO))[unit]);
X  #else
X  		addr = (int) &(((int *)NLVALUE(DZINFO))[unit]);
X***************
X*** 681,687 ****
X  		devtype = DH11;
X  		unit = minor(dev) / NDHLINE;
X  		line = minor(dev) % NDHLINE;
X! #ifdef BSD2_10
X  		ubinfo = &(((struct uba_device *)NLVALUE(DHINFO))[unit]);
X  #else
X  		addr = (int) &(((int *)NLVALUE(DHINFO))[unit]);
X--- 681,687 ----
X  		devtype = DH11;
X  		unit = minor(dev) / NDHLINE;
X  		line = minor(dev) % NDHLINE;
X! #ifdef pdp11
X  		ubinfo = &(((struct uba_device *)NLVALUE(DHINFO))[unit]);
X  #else
X  		addr = (int) &(((int *)NLVALUE(DHINFO))[unit]);
X***************
X*** 691,697 ****
X  		devtype = DMF;
X  		unit = minor(dev) / NDMFLINE;
X  		line = minor(dev) % NDMFLINE;
X! #ifdef BSD2_10
X  		ubinfo = &(((struct uba_device *)NLVALUE(DMFINFO))[unit]);
X  #else
X  		addr = (int) &(((int *)NLVALUE(DMFINFO))[unit]);
X--- 691,697 ----
X  		devtype = DMF;
X  		unit = minor(dev) / NDMFLINE;
X  		line = minor(dev) % NDMFLINE;
X! #ifdef pdp11
X  		ubinfo = &(((struct uba_device *)NLVALUE(DMFINFO))[unit]);
X  #else
X  		addr = (int) &(((int *)NLVALUE(DMFINFO))[unit]);
X***************
X*** 710,716 ****
X  		return(-1);
X  	}
X  
X! #ifndef BSD2_10
X  	(void)lseek(kmem, (off_t)addr, 0);
X  	(void)read(kmem, (char *) &ubinfo, sizeof ubinfo);
X  #endif
X--- 710,716 ----
X  		return(-1);
X  	}
X  
X! #ifndef pdp11
X  	(void)lseek(kmem, (off_t)addr, 0);
X  	(void)read(kmem, (char *) &ubinfo, sizeof ubinfo);
X  #endif
X***************
X*** 726,732 ****
X  	flags = enable ? (flags & ~tflags) : (flags | tflags);
X  	(void)lseek(kmem, (off_t) &(ubinfo->ui_flags), 0);
X  	(void)write(kmem, (char *) &flags, sizeof flags);
X! #ifndef BSD2_10
X  	switch(devtype) {
X  		case DZ11:
X  			if((addr = NLVALUE(DZSCAR)) == 0) {
X--- 726,732 ----
X  	flags = enable ? (flags & ~tflags) : (flags | tflags);
X  	(void)lseek(kmem, (off_t) &(ubinfo->ui_flags), 0);
X  	(void)write(kmem, (char *) &flags, sizeof flags);
X! #ifndef pdp11
X  	switch(devtype) {
X  		case DZ11:
X  			if((addr = NLVALUE(DZSCAR)) == 0) {
X***************
X*** 759,765 ****
X  			fprintf(stderr, "Unknown device type\n");
X  			return(-1);
X  	}
X! #endif /* !BSD2_10 */
X  	return(0);
X  }
X  
X--- 759,765 ----
X  			fprintf(stderr, "Unknown device type\n");
X  			return(-1);
X  	}
X! #endif
X  	return(0);
X  }
X  
X*** /usr/src/usr.bin/uucp/condevs.h.old	Sat Jul 11 13:17:11 1987
X--- /usr/src/usr.bin/uucp/condevs.h	Sat Jan  1 02:22:01 1994
X***************
X*** 1,4 ****
X! /*	condevs.h	4.6	86/02/13	*/
X  
X  #include "uucp.h"
X  #include <errno.h>
X--- 1,4 ----
X! /*	condevs.h	4.7	1/1/94	*/
X  
X  #include "uucp.h"
X  #include <errno.h>
X***************
X*** 11,26 ****
X  #define SS$_NORMAL	0x00000001
X  #define IO$_SETMODE	0x00000023
X  #define IO$_SENSEMODE	0x00000027
X- #endif
X- 
X- #ifdef BSD2_10
X- /*
X-  * Disambiguate "HAYES" and "HAYES2400" names.
X-  */
X- #define	hystopn		_hysto
X- #define	hyspopn		_hyspo
X- #define	hystopn24	_hysto2
X- #define	hyspopn24	_hyspo2
X  #endif
X  
X  extern char devSel[];	/* name to pass to delock() in close */
X--- 11,16 ----
X*** /usr/src/usr.bin/uucp/uucpd.c.old	Thu Jan  5 23:51:13 1989
X--- /usr/src/usr.bin/uucp/uucpd.c	Mon Jan 10 22:51:28 1994
X***************
X*** 1,5 ****
X! #ifndef lint
X! static char sccsid[] = "@(#)uucpd.c	5.4 (Berkeley) 6/23/85";
X  #endif
X  
X  /*
X--- 1,5 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char sccsid[] = "@(#)uucpd.c	5.4.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  
X  /*
X*** /usr/src/usr.bin/tip/aculib/courier.c.old	Fri Sep 16 13:48:42 1988
X--- /usr/src/usr.bin/tip/aculib/courier.c	Mon Jan 10 22:52:03 1994
X***************
X*** 4,11 ****
X   * specifies the terms and conditions for redistribution.
X   */
X  
X! #ifndef lint
X! static char sccsid[] = "@(#)courier.c	5.2 (Berkeley) 2/17/87";
X  #endif
X  
X  #define write cour_write
X--- 4,11 ----
X   * specifies the terms and conditions for redistribution.
X   */
X  
X! #if	defined(DOSCCS) && !defined(lint)
X! static char sccsid[] = "@(#)courier.c	5.2.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  
X  #define write cour_write
X***************
X*** 15,27 ****
X   */
X  #include "tip.h"
X  #include <stdio.h>
X- 
X- #ifdef BSD2_10
X- #define	cour_nap	_cournp
X- #define	cour_napx	_cournx
X- #define	connected	_cnnctd
X- #define	connected	_cnnctd
X- #endif
X  
X  #define	MAXRETRY	5
X  
X--- 15,20 ----
X*** /usr/src/usr.bin/tip/aculib/Makefile.old	Tue Aug 30 19:47:34 1988
X--- /usr/src/usr.bin/tip/aculib/Makefile	Thu Jan  6 23:36:02 1994
X***************
X*** 3,9 ****
X  # All rights reserved.  The Berkeley software License Agreement
X  # specifies the terms and conditions for redistribution.
X  #
X! #	@(#)Makefile	5.3	(Berkeley)	6/18/87
X  #
X  # make file for tip device drivers
X  #
X--- 3,9 ----
X  # All rights reserved.  The Berkeley software License Agreement
X  # specifies the terms and conditions for redistribution.
X  #
X! #	@(#)Makefile	5.3.1	(2.11BSD GTE)	1/06/94
X  #
X  # make file for tip device drivers
X  #
X***************
X*** 27,33 ****
X  all: aculib.a
X  
X  aculib.a: ${OBJS}
X! 	ar cu aculib.a ${OBJS}
X  	ranlib aculib.a
X  
X  clean: FRC
X--- 27,33 ----
X  all: aculib.a
X  
X  aculib.a: ${OBJS}
X! 	ar ru aculib.a ${OBJS}
X  	ranlib aculib.a
X  
X  clean: FRC
X*** /usr/src/usr.bin/tip/tip.h.old	Tue Aug 30 19:50:13 1988
X--- /usr/src/usr.bin/tip/tip.h	Mon Jan 10 22:52:19 1994
X***************
X*** 3,9 ****
X   * All rights reserved.  The Berkeley software License Agreement
X   * specifies the terms and conditions for redistribution.
X   *
X!  *	@(#)tip.h	5.3 (Berkeley) 10/19/86
X   */
X  
X  /*
X--- 3,9 ----
X   * All rights reserved.  The Berkeley software License Agreement
X   * specifies the terms and conditions for redistribution.
X   *
X!  *	@(#)tip.h	5.3.1 (2.11BSD GTE) 1/1/94
X   */
X  
X  /*
X***************
X*** 20,36 ****
X  #include <ctype.h>
X  #include <setjmp.h>
X  #include <errno.h>
X- 
X- #ifdef BSD2_10
X- #define	cour_dialer		_courda
X- #define	cour_disconnect		_courds
X- #define	v3451_dialer		_v345di
X- #define	v3451_disconnect	_v345ds
X- #define	v831_dialer		_v831da
X- #define	v831_disconnect		_v831ds
X- #define	timeout			_tmout
X- #define	timeoutbuf		_tmoutb
X- #endif BSD2_10
X  
X  /*
X   * Remote host attributes
X--- 20,25 ----
X*** /usr/src/usr.bin/f77/proc.c.old	Sun Jun 12 16:24:59 1988
X--- /usr/src/usr.bin/f77/proc.c	Mon Jan  3 22:18:51 1994
X***************
X*** 183,189 ****
X  		}
X  	else	{
X  		putlabel(retlabel);
X! 		if(multitypes)
X  			{
X  			typeaddr = autovar(1, TYADDR, NULL);
X  			putbranch( cpexpr(typeaddr) );
X--- 183,189 ----
X  		}
X  	else	{
X  		putlabel(retlabel);
X! 		if(multitype)
X  			{
X  			typeaddr = autovar(1, TYADDR, NULL);
X  			putbranch( cpexpr(typeaddr) );
X*** /usr/src/usr.bin/f77/gram.dcl.old	Mon Feb 16 16:57:38 1987
X--- /usr/src/usr.bin/f77/gram.dcl	Mon Jan  3 22:23:18 1994
X***************
X*** 189,195 ****
X  	;
X  
X  var:	  name dims
X! 		{ if(ndim>0) setbounds($1, ndim, dims); }
X  	;
X  
X  datavar:	  lhs
X--- 189,195 ----
X  	;
X  
X  var:	  name dims
X! 		{ if(ndim>0) setbound($1, ndim, dims); }
X  	;
X  
X  datavar:	  lhs
X*** /usr/src/usr.bin/prof/prof.c.old	Thu Jun 25 22:11:14 1992
X--- /usr/src/usr.bin/prof/prof.c	Fri Jan 21 23:27:32 1994
X***************
X*** 1,5 ****
X! #ifndef lint
X! static	char *sccsid = "@(#)prof.c	4.4 (Berkeley) 3/24/85";
X  #endif
X  /*
X   * prof
X--- 1,5 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static	char *sccsid = "@(#)prof.c	4.4.1 (2.11BSD GTE) 1/1/94";
X  #endif
X  /*
X   * prof
X***************
X*** 9,20 ****
X  #include <sys/stat.h>
X  #include <a.out.h>
X  #include <sys/time.h>
X! #ifdef BSD2_10
X! #include <sys/localopts.h>
X  #endif
X  
X  typedef	short UNIT;		/* unit of profiling */
X! #ifdef BSD2_10
X  #define	PCFUDGE		0
X  #else
X  #define	PCFUDGE		11
X--- 9,20 ----
X  #include <sys/stat.h>
X  #include <a.out.h>
X  #include <sys/time.h>
X! #ifdef pdp11
X! #include <sys/localopts.h>	/* For LINEHZ */
X  #endif
X  
X  typedef	short UNIT;		/* unit of profiling */
X! #ifdef pdp11
X  #define	PCFUDGE		0
X  #else
X  #define	PCFUDGE		11
X***************
X*** 30,40 ****
X   * its address, the number of calls and compute its share of cpu time.
X   */
X  struct nl {
X- #ifdef BSD2_10
X- 	char	name[8+1];
X- #else
X  	char	*name;
X- #endif
X  	unsigned value;
X  	float	time;
X  	long	ncall;
X--- 30,36 ----
X***************
X*** 78,88 ****
X  double	maxtime;		/* maximum time of any routine (for plot) */
X  double	scale;			/* scale factor converting samples to pc
X  				   values: each sample covers scale bytes */
X- #ifndef BSD2_10
X  char	*strtab;		/* string table in core */
X  off_t	ssiz;			/* size of the string table */
X! #endif
X! struct	exec xbuf;		/* exec header of a.out */
X  
X  int	aflg;
X  int	nflg;
X--- 74,82 ----
X  double	maxtime;		/* maximum time of any routine (for plot) */
X  double	scale;			/* scale factor converting samples to pc
X  				   values: each sample covers scale bytes */
X  char	*strtab;		/* string table in core */
X  off_t	ssiz;			/* size of the string table */
X! struct	xexec xbuf;		/* exec header of a.out */
X  
X  int	aflg;
X  int	nflg;
X***************
X*** 196,202 ****
X  
X  /*
X   * Set up string and symbol tables from a.out.
X-  * (no string table for BSD2_10)
X   * On return symbol table is sorted by value.
X   */
X  getnfile()
X--- 190,195 ----
X***************
X*** 208,245 ****
X  		done();
X  	}
X  	fread(&xbuf, 1, sizeof(xbuf), nfile);
X! 	if (N_BADMAG(xbuf)) {
X  		fprintf(stderr, "%s: bad format\n", namfil);
X  		done();
X  	}
X- #ifndef BSD2_10
X  	getstrtab();
X- #endif
X  	getsymtab();
X  	qsort(nl, nname, sizeof(struct nl), valcmp);
X  }
X  
X- #ifndef BSD2_10
X  getstrtab()
X  {
X  
X! 	fseek(nfile, N_SYMOFF(xbuf) + xbuf.a_syms, 0);
X  	if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) {
X  		fprintf(stderr, "%s: no string table (old format?)\n", namfil);
X  		done();
X  	}
X! 	strtab = (char *)calloc(ssiz, 1);
X! 	if (strtab == NULL) {
X! 		fprintf(stderr, "%s: no room for %d bytes of string table",
X  		    namfil, ssiz);
X  		done();
X  	}
X! 	if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1) {
X  		fprintf(stderr, "%s: error reading string table\n", namfil);
X  		done();
X  	}
X  }
X- #endif !BSD2_10
X  
X  /*
X   * Read in symbol table
X--- 201,234 ----
X  		done();
X  	}
X  	fread(&xbuf, 1, sizeof(xbuf), nfile);
X! 	if (N_BADMAG(xbuf.e)) {
X  		fprintf(stderr, "%s: bad format\n", namfil);
X  		done();
X  	}
X  	getstrtab();
X  	getsymtab();
X  	qsort(nl, nname, sizeof(struct nl), valcmp);
X  }
X  
X  getstrtab()
X  {
X  
X! 	fseek(nfile, N_STROFF(xbuf), 0);
X  	if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) {
X  		fprintf(stderr, "%s: no string table (old format?)\n", namfil);
X  		done();
X  	}
X! 	strtab = (char *)malloc((int)ssiz);
X! 	if (strtab == NULL || ssiz > 48 * 1024L) {
X! 		fprintf(stderr, "%s: no room for %ld bytes of string table",
X  		    namfil, ssiz);
X  		done();
X  	}
X! 	if (fread(strtab+sizeof(ssiz), (int)ssiz-sizeof(ssiz), 1, nfile) != 1) {
X  		fprintf(stderr, "%s: error reading string table\n", namfil);
X  		done();
X  	}
X  }
X  
X  /*
X   * Read in symbol table
X***************
X*** 246,280 ****
X   */
X  getsymtab()
X  {
X! 	long i;
X! #ifdef BSD2_10
X! 	long symoff;
X! #endif
X  
X  	/* pass1 - count symbols */
X- #ifdef BSD2_10
X- 	symoff = (long)xbuf.a_text + xbuf.a_data;
X- 	if (xbuf.a_magic == A_MAGIC5 || xbuf.a_magic == A_MAGIC6) {
X- 		register int ovlcnt;
X- 		struct ovlhdr ovlbuf;
X- 
X- 		fseek(nfile, (long)sizeof(xbuf), 0);
X- 		fread((char *)&ovlbuf, sizeof(ovlbuf), 1, nfile);
X- 		for (ovlcnt = 0; ovlcnt < NOVL; ovlcnt++)
X- 			symoff += ovlbuf.ov_siz[ovlcnt];
X- 	}
X- 	if (!(xbuf.a_flag & 01))
X- 		symoff *= 2;
X- 	symoff += sizeof(xbuf);
X- 	if (xbuf.a_magic == A_MAGIC5 || xbuf.a_magic == A_MAGIC6)
X- 		symoff += sizeof(struct ovlhdr);
X- 	fseek(nfile, symoff, 0);
X- #else !BSD2_10
X  	fseek(nfile, N_SYMOFF(xbuf), 0);
X- #endif BSD2_10
X  	nname = 0;
X! 	for (i = xbuf.a_syms; i > 0; i -= sizeof(struct nlist)) {
X! 		struct nlist nbuf;
X  		fread(&nbuf, sizeof(nbuf), 1, nfile);
X  		if (nbuf.n_type!=N_TEXT && nbuf.n_type!=N_TEXT+N_EXT)
X  			continue;
X--- 235,249 ----
X   */
X  getsymtab()
X  {
X! 	register u_int i;
X! 	register u_int nsyms;
X! 	struct nlist nbuf;
X  
X  	/* pass1 - count symbols */
X  	fseek(nfile, N_SYMOFF(xbuf), 0);
X  	nname = 0;
X! 	nsyms = xbuf.e.a_syms / sizeof (struct nlist);
X! 	for (i = 0; i < nsyms; i++) {
X  		fread(&nbuf, sizeof(nbuf), 1, nfile);
X  		if (nbuf.n_type!=N_TEXT && nbuf.n_type!=N_TEXT+N_EXT)
X  			continue;
X***************
X*** 288,308 ****
X  	}
X  	nl = (struct nl *)calloc((nname+1), sizeof (struct nl));
X  	if (nl == 0) {
X! 		fprintf(stderr, "prof: No room for %d bytes of symbol table\n",
X  		    (nname+1) * sizeof (struct nlist));
X  		done();
X  	}
X  
X  	/* pass2 - read symbols */
X- #ifdef BSD2_10
X- 	fseek(nfile, symoff, 0);
X- #else
X  	fseek(nfile, N_SYMOFF(xbuf), 0);
X- #endif
X  	npe = nl;
X! 	nname = 0;
X! 	for (i = xbuf.a_syms; i > 0; i -= sizeof(struct nlist)) {
X! 		struct nlist nbuf;
X  		fread(&nbuf, sizeof(nbuf), 1, nfile);
X  		if (nbuf.n_type!=N_TEXT && nbuf.n_type!=N_TEXT+N_EXT)
X  			continue;
X--- 257,271 ----
X  	}
X  	nl = (struct nl *)calloc((nname+1), sizeof (struct nl));
X  	if (nl == 0) {
X! 		fprintf(stderr, "prof: No room for %u bytes of symbol table\n",
X  		    (nname+1) * sizeof (struct nlist));
X  		done();
X  	}
X  
X  	/* pass2 - read symbols */
X  	fseek(nfile, N_SYMOFF(xbuf), 0);
X  	npe = nl;
X! 	for (i = 0; i < nsyms; i++) {
X  		fread(&nbuf, sizeof(nbuf), 1, nfile);
X  		if (nbuf.n_type!=N_TEXT && nbuf.n_type!=N_TEXT+N_EXT)
X  			continue;
X***************
X*** 309,322 ****
X  		if (aflg==0 && nbuf.n_type!=N_TEXT+N_EXT)
X  			continue;
X  		npe->value = nbuf.n_value/sizeof(UNIT);
X- #ifdef BSD2_10
X- 		bcopy(nbuf.n_name, npe->name, 8);
X- 		npe->name[8] = '\0';
X- #else
X  		npe->name = strtab+nbuf.n_un.n_strx;
X- #endif
X  		npe++;
X- 		nname++;
X  	}
X  	npe->value = -1;
X  	npe++;
X--- 272,279 ----
X***************
X*** 407,414 ****
X   */
X  asgncntrs()
X  {
X! 	register int i;
X! 	struct cnt *kp;
X  
X  	kp = &cbuf[h.ncount-1];
X  	np = npe;
X--- 364,370 ----
X   */
X  asgncntrs()
X  {
X! 	register struct cnt *kp;
X  
X  	kp = &cbuf[h.ncount-1];
X  	np = npe;
X***************
X*** 504,512 ****
X  putprof()
X  {
X  	FILE *sfile;
X! 	struct nl *np;
X  	struct cnt kp;
X- 	int i;
X  
X  	sfile = fopen(MON_SUMNAME, "w");
X  	if (sfile == NULL) {
X--- 460,467 ----
X  putprof()
X  {
X  	FILE *sfile;
X! 	register struct nl *np;
X  	struct cnt kp;
X  
X  	sfile = fopen(MON_SUMNAME, "w");
X  	if (sfile == NULL) {
X***************
X*** 545,551 ****
X   */
X  hertz()
X  {
X! #ifdef BSD2_10
X  	return(LINEHZ);
X  #else
X  	struct itimerval tim;
X--- 500,506 ----
X   */
X  hertz()
X  {
X! #ifdef pdp11
X  	return(LINEHZ);
X  #else
X  	struct itimerval tim;
X*** /usr/src/usr.bin/find/find.c.old	Tue May 16 21:37:16 1989
X--- /usr/src/usr.bin/find/find.c	Mon Jan 10 22:53:30 1994
X***************
X*** 1,5 ****
X! #ifndef	lint
X! static char *sccsid = "@(#)find.c	4.17 (Berkeley) 1/31/86";
X  #endif
X  
X  #include <stdio.h>
X--- 1,5 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char *sccsid = "@(#)find.c	4.17.1 (2.11BSD GTE) 1/1/93";
X  #endif
X  
X  #include <stdio.h>
X***************
X*** 944,956 ****
X  #define NUID	64
X  #define NGID	300
X  
X- #ifdef BSD2_10
X- #define outrangename	Oname
X- #define outrangeuid	Ouid
X- #define outrangegroup	Ogroup
X- #define outrangegid	Ogid
X- #endif BSD2_10
X- 
X  struct ncache {
X  	int	uid;
X  	char	name[NMAX+1];
X--- 944,949 ----
X***************
X*** 1193,1199 ****
X  	else
X  		sprintf(ftime, "%-12.12s", cp + 4);
X  
X! #ifdef BSD2_10
X  	printf("%5u %4ld %s %2d %s%s%s %s %s%s%s\n",
X  #else
X  	printf("%5lu %4ld %s %2d %s%s%s %s %s%s%s\n",
X--- 1186,1192 ----
X  	else
X  		sprintf(ftime, "%-12.12s", cp + 4);
X  
X! #ifdef pdp11
X  	printf("%5u %4ld %s %2d %s%s%s %s %s%s%s\n",
X  #else
X  	printf("%5lu %4ld %s %2d %s%s%s %s %s%s%s\n",
X*** /usr/src/usr.bin/Makefile.old	Mon Jan 18 09:36:45 1993
X--- /usr/src/usr.bin/Makefile	Fri Dec 31 19:38:55 1993
X***************
X*** 7,13 ****
X  # Programs that live in subdirectories, and have makefiles of their own.
X  #
X  SUBDIR=	at calendar dc diction diff3 eqn f77 find graph learn lex lint \
X! 	m4 neqn plot prof ratfor refer roff spell struct tbl tip uucp \
X  	yacc
X  
X  # Shell scripts that need only be installed and are never removed.
X--- 7,13 ----
X  # Programs that live in subdirectories, and have makefiles of their own.
X  #
X  SUBDIR=	at calendar dc diction diff3 eqn f77 find graph learn lex lint \
X! 	m4 neqn plot prof ranlib ratfor refer roff spell struct tbl tip uucp \
X  	yacc
X  
X  # Shell scripts that need only be installed and are never removed.
X***************
X*** 18,24 ****
X  #
X  SRCS=	basename.c cal.c cb.c checkeq.c col.c comm.c crypt.c deroff.c \
X  	fgrep.c file.c install.c iostat.c join.c look.c mesg.c ptx.c \
X! 	ranlib.c rev.c sleep.c sort.c spline.c split.c sum.c tabs.c \
X  	tc.c tk.c touch.c tr.c tsort.c tty.c uniq.c units.c
X  
X  # C programs that live in the current directory and do not need
X--- 18,24 ----
X  #
X  SRCS=	basename.c cal.c cb.c checkeq.c col.c comm.c crypt.c deroff.c \
X  	fgrep.c file.c install.c iostat.c join.c look.c mesg.c ptx.c \
X! 	rev.c sleep.c sort.c spline.c split.c sum.c tabs.c \
X  	tc.c tk.c touch.c tr.c tsort.c tty.c uniq.c units.c
X  
X  # C programs that live in the current directory and do not need
X***************
X*** 25,31 ****
X  # explicit make lines.
X  #
X  STD=	basename cal cb checkeq col comm crypt deroff fgrep file join look \
X! 	mesg ptx ranlib rev sleep sort spline split sum tabs tc tk touch tr \
X  	tsort tty uniq units
X  
X  # C programs that live in the current directory and need explicit make lines.
X--- 25,31 ----
X  # explicit make lines.
X  #
X  STD=	basename cal cb checkeq col comm crypt deroff fgrep file join look \
X! 	mesg ptx rev sleep sort spline split sum tabs tc tk touch tr \
X  	tsort tty uniq units
X  
X  # C programs that live in the current directory and need explicit make lines.
X*** /usr/src/usr.bin/fgrep.c.old	Wed Mar 11 17:43:39 1987
X--- /usr/src/usr.bin/fgrep.c	Mon Jan 10 22:53:58 1994
X***************
X*** 1,4 ****
X! static char *sccsid = "@(#)fgrep.c	4.3 (Berkeley) 5/30/85";
X  /*
X   * fgrep -- print all lines containing any of a set of keywords
X   *
X--- 1,6 ----
X! #if	defined(DOSCCS) && !defined(lint)
X! static char *sccsid = "@(#)fgrep.c	4.3.1 (2.11BSD) 1/1/94";
X! #endif
X  /*
X   * fgrep -- print all lines containing any of a set of keywords
X   *
X***************
X*** 13,19 ****
X  #include <sys/param.h>
X  #include <sys/stat.h>
X  
X! #ifdef BSD2_10
X  #define BLKSIZE 1024
X  #else
X  #define BLKSIZE 8192
X--- 15,21 ----
X  #include <sys/param.h>
X  #include <sys/stat.h>
X  
X! #ifdef pdp11
X  #define BLKSIZE 1024
X  #else
X  #define BLKSIZE 8192
X*** /usr/src/usr.bin/install.c.old	Mon Dec 26 00:43:39 1988
X--- /usr/src/usr.bin/install.c	Mon Jan 10 22:54:29 1994
X***************
X*** 15,34 ****
X   * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X   */
X  
X! #ifndef lint
X  char copyright[] =
X  "@(#) Copyright (c) 1987 Regents of the University of California.\n\
X   All rights reserved.\n";
X- #endif /* not lint */
X  
X! #ifndef lint
X! static char sccsid[] = "@(#)install.c	5.12 (Berkeley) 7/6/88";
X! #endif /* not lint */
X  
X  #include <sys/param.h>
X  #include <sys/stat.h>
X  #include <sys/file.h>
X- #include <a.out.h>
X  #include <grp.h>
X  #include <pwd.h>
X  #include <stdio.h>
X--- 15,31 ----
X   * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X   */
X  
X! #if	defined(DOSCCS) && !defined(lint)
X  char copyright[] =
X  "@(#) Copyright (c) 1987 Regents of the University of California.\n\
X   All rights reserved.\n";
X  
X! static char sccsid[] = "@(#)install.c	5.12.1 (2.11BSD GTE) 1/3/94";
X! #endif
X  
X  #include <sys/param.h>
X  #include <sys/stat.h>
X  #include <sys/file.h>
X  #include <grp.h>
X  #include <pwd.h>
X  #include <stdio.h>
X***************
X*** 173,275 ****
X  			PERROR("install: open: ", from_name);
X  			exit(1);
X  		}
X! 		if (dostrip)
X! 			strip(from_fd, from_name, to_fd, to_name);
X! 		else
X! 			copy(from_fd, from_name, to_fd, to_name);
X  		(void)close(from_fd);
X- 		if (!docopy)
X- 			(void)unlink(from_name);
X  	}
X! 	/* set owner, group, mode for target */
X! 	if (fchmod(to_fd, mode)) {
X! 		PERROR("install: fchmod: ", to_name);
X  		bad();
X  	}
X- 	if ((group || owner) && fchown(to_fd, owner ? pp->pw_uid : -1,
X- 	    group ? gp->gr_gid : -1)) {
X- 		PERROR("install: fchown: ", to_name);
X- 		bad();
X- 	}
X  	(void)close(to_fd);
X  }
X  
X  /*
X   * strip --
X!  *	copy file, strip(1)'ing it at the same time
X   */
X! static
X! strip(from_fd, from_name, to_fd, to_name)
X! 	register int from_fd, to_fd;
X! 	char *from_name, *to_name;
X  {
X! 	typedef struct exec EXEC;
X! 	register long size;
X! 	register int n;
X! 	EXEC head;
X! 	char buf[MAXBSIZE];
X! 	off_t lseek();
X  
X! 	if (read(from_fd, (char *)&head, sizeof(head)) < 0 || N_BADMAG(head)) {
X! 		fprintf(stderr, "install: %s not in a.out format.\n", from_name);
X  		bad();
X! 	}
X! #ifdef BSD2_10
X! 	if (head.a_syms || !(head.a_flag & 1)) {
X! 		size = (long)head.a_text + head.a_data;
X! 		head.a_syms = 0;
X! 		head.a_flag |= 1;
X! 		if (write(to_fd, (char *)&head, sizeof(EXEC)) != sizeof(EXEC)) {
X! 			PERROR("install: write: ", to_name);
X  			bad();
X- 		}
X- 		if (head.a_magic == A_MAGIC5 || head.a_magic == A_MAGIC6) {
X- 			typedef struct ovlhdr	OVLHDR;
X- 			register int	ovlcnt;
X- 			OVLHDR	ovlhdr;
X- 
X- 			if (read(from_fd, (char *)&ovlhdr, sizeof (ovlhdr)) < 0) {
X- 				fprintf(stderr, "install: %s not in a.out format.\n", from_name);
X- 				bad();
X- 			}
X- 			for (ovlcnt = 0; ovlcnt < NOVL; ovlcnt++)
X- 				size += ovlhdr.ov_siz[ovlcnt];
X- 			if (write(to_fd, (char *)&ovlhdr, sizeof(OVLHDR)) != sizeof(OVLHDR)) {
X- 				PERROR("install: write: ", to_name);
X- 				bad();
X- 			}
X- 		}
X- #else
X- 	if (head.a_syms || head.a_trsize || head.a_drsize) {
X- 		size = (long)head.a_text + head.a_data;
X- 		head.a_syms = head.a_trsize = head.a_drsize = 0;
X- 		if (head.a_magic == ZMAGIC)
X- 			size += getpagesize() - sizeof(EXEC);
X- 		if (write(to_fd, (char *)&head, sizeof(EXEC)) != sizeof(EXEC)) {
X- 			PERROR("install: write: ", to_name);
X- 			bad();
X- 		}
X- #endif
X- 		for (; size; size -= n)
X- 			/* sizeof(buf) guaranteed to fit in an int */
X- 			if ((n = read(from_fd, buf, (int)MIN(size, sizeof(buf)))) <= 0)
X- 				break;
X- 			else if (write(to_fd, buf, n) != n) {
X- 				PERROR("install: write: ", to_name);
X- 				bad();
X- 			}
X- 		if (size) {
X- 			fprintf(stderr, "install: read: %s: premature EOF.\n", from_name);
X- 			bad();
X- 		}
X- 		if (n == -1) {
X- 			PERROR("install: read: ", from_name);
X- 			bad();
X- 		}
X- 	}
X- 	else {
X- 		(void)lseek(from_fd, 0L, L_SET);
X- 		copy(from_fd, from_name, to_fd, to_name);
X  	}
X  }
X  
X--- 170,217 ----
X  			PERROR("install: open: ", from_name);
X  			exit(1);
X  		}
X! 		copy(from_fd, from_name, to_fd, to_name);
X  		(void)close(from_fd);
X  	}
X! 	if (dostrip)
X! 		strip(to_name);
X! 	/*
X! 	 * set owner, group, mode for target; do the chown first,
X! 	 * chown may lose the setuid bits.
X! 	 */
X! 	if ((group || owner) &&
X! 	    fchown(to_fd, owner ? pp->pw_uid : -1, group ? gp->gr_gid : -1) ||
X! 	    fchmod(to_fd, mode)) {
X! 		PERROR("install: chown/chmod", to_name);
X  		bad();
X  	}
X  	(void)close(to_fd);
X+ 	if (!docopy && !devnull && unlink(from_name)) {
X+ 		PERROR("install: unlink", from_name);
X+ 		exit(1);
X+ 	}
X  }
X  
X  /*
X   * strip --
X!  *	use strip(1) to strip the target file
X   */
X! strip(to_name)
X! 	char *to_name;
X  {
X! 	int status;
X  
X! 	switch (vfork()) {
X! 	case -1:
X! 		PERROR("install: fork", "");
X  		bad();
X! 	case 0:
X! 		execl("/bin/strip", "strip", to_name, (char *)NULL);
X! 		PERROR("install: execl", "strip");
X! 		_exit(1);
X! 	default:
X! 		if (wait(&status) == -1 || status)
X  			bad();
X  	}
X  }
X  
X*** /usr/src/usr.bin/bc.y.old	Mon Feb 16 16:22:28 1987
X--- /usr/src/usr.bin/bc.y	Sun Jan  9 00:10:07 1994
X***************
X*** 17,23 ****
X  
X  %{
X  #include <stdio.h>
X! int in;
X  char cary[1000], *cp = { cary };
X  char string[1000], *str = {string};
X  int crs = '0';
X--- 17,23 ----
X  
X  %{
X  #include <stdio.h>
X! FILE *in;
X  char cary[1000], *cp = { cary };
X  char string[1000], *str = {string};
X  int crs = '0';
SHAR_EOF
chmod 640 'patchfile'
fi
if test -f 'new.sources'
then
	echo shar: "will not over-write existing file 'new.sources'"
else
sed 's/^X//' << \SHAR_EOF > 'new.sources'
X#! /bin/sh
X# This is a shell archive, meaning:
X# 1. Remove everything above the #! /bin/sh line.
X# 2. Save the resulting text in a file.
X# 3. Execute the file with /bin/sh (not csh) to create:
X#	/usr/src/usr.bin/ranlib/Makefile
X#	/usr/src/usr.bin/ranlib/build.c
X#	/usr/src/usr.bin/ranlib/misc.c
X#	/usr/src/usr.bin/ranlib/pathnames.h
X#	/usr/src/usr.bin/ranlib/ranlib.1
X#	/usr/src/usr.bin/ranlib/ranlib.5.5
X#	/usr/src/usr.bin/ranlib/ranlib.c
X#	/usr/src/usr.bin/ranlib/touch.c
X# This archive created: Fri Jan 28 21:21:58 1994
Xexport PATH; PATH=/bin:/usr/bin:$PATH
Xif test -f '/usr/src/usr.bin/ranlib/Makefile'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/usr.bin/ranlib/Makefile'"
Xelse
Xsed 's/^X//' << \SHAR_EOF > '/usr/src/usr.bin/ranlib/Makefile'
XXSRCS=	../../bin/ar/archive.c build.c misc.c ranlib.c touch.c
XXOBJS=	archive.o build.o ./misc.o ranlib.o touch.o
XXCFLAGS=	-O -I. -I../../bin/ar
XXVPATH= ../../bin/ar
XX
XXall:	ranlib.0 ranlib.5.0 ranlib
XX
XXranlib.0: ranlib.1
XX	/usr/man/manroff ranlib.1 > ranlib.0
XX
XXranlib.5.0: ranlib.5.5
XX	/usr/man/manroff ranlib.5.5 > ranlib.5.0
XX
XXranlib: ${OBJS}
XX	cc -z -o ranlib ${OBJS}
XX
XXinstall:
XX	install -c -o bin -g bin -m 444 ranlib.5.0 \
XX		${DESTDIR}/usr/man/cat5/ranlib.0
XX	install -c -o bin -g bin -m 444 ranlib.0 \
XX		${DESTDIR}/usr/man/cat1/ranlib.0
XX	install -c -s -o bin -g bin -m 755 ranlib ${DESTDIR}/usr/bin/ranlib
XX
XXlint:
XX	lint -havx -I. -I../../bin/ar ${SRCS}
XX
XXclean:
XX	rm -f *.o *.0 ranlib
XSHAR_EOF
Xchmod 644 '/usr/src/usr.bin/ranlib/Makefile'
Xfi
Xif test -f '/usr/src/usr.bin/ranlib/build.c'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/usr.bin/ranlib/build.c'"
Xelse
Xsed 's/^X//' << \SHAR_EOF > '/usr/src/usr.bin/ranlib/build.c'
XX/*-
XX * Copyright (c) 1990 The Regents of the University of California.
XX * All rights reserved.
XX *
XX * This code is derived from software contributed to Berkeley by
XX * Hugh Smith at The University of Guelph.
XX *
XX * Redistribution and use in source and binary forms, with or without
XX * modification, are permitted provided that the following conditions
XX * are met:
XX * 1. Redistributions of source code must retain the above copyright
XX *    notice, this list of conditions and the following disclaimer.
XX * 2. Redistributions in binary form must reproduce the above copyright
XX *    notice, this list of conditions and the following disclaimer in the
XX *    documentation and/or other materials provided with the distribution.
XX * 3. All advertising materials mentioning features or use of this software
XX *    must display the following acknowledgement:
XX *	This product includes software developed by the University of
XX *	California, Berkeley and its contributors.
XX * 4. Neither the name of the University nor the names of its contributors
XX *    may be used to endorse or promote products derived from this software
XX *    without specific prior written permission.
XX *
XX * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
XX * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
XX * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
XX * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
XX * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
XX * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
XX * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
XX * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
XX * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
XX * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
XX * SUCH DAMAGE.
XX */
XX
XX#if	!defined(lint) && defined(DOSCCS)
XXstatic char sccsid[] = "@(#)build.c	5.3.1 (Berkeley) 5/17/93";
XX#endif
XX
XX#include <sys/types.h>
XX#include <sys/errno.h>
XX#include <sys/stat.h>
XX#include <fcntl.h>
XX#include <a.out.h>
XX#include <sys/dir.h>
XX#include <sys/file.h>
XX#include <ar.h>
XX#include <ranlib.h>
XX#include <stdio.h>
XX#include <archive.h>
XX
XXextern	off_t	lseek();
XXextern CHDR chdr;			/* converted header */
XXextern char *archive;			/* archive name */
XXextern char *tname;			/* temporary file "name" */
XX
XXtypedef struct _rlib {
XX	struct _rlib *next;		/* next structure */
XX	off_t pos;			/* offset of defining archive file */
XX	char *sym;			/* symbol */
XX	int symlen;			/* strlen(sym) */
XX} RLIB;
XXRLIB *rhead, **pnext;
XX
XXFILE *fp;
XXstatic void rexec(), symobj();
XXvoid error(), badfmt();
XXlong symcnt;				/* symbol count */
XXlong tsymlen;				/* total string length */
XX
XXbuild()
XX{
XX	CF cf;
XX	int afd, tfd;
XX	off_t size;
XX
XX	afd = open_archive(O_RDWR);
XX	fp = fdopen(afd, "r+");
XX	tfd = tmp();
XX
XX	SETCF(afd, archive, tfd, tname, RPAD|WPAD);
XX
XX	/* Read through the archive, creating list of symbols. */
XX	pnext = &rhead;
XX	symcnt = tsymlen = 0;
XX	while(get_arobj(afd)) {
XX		if (!strcmp(chdr.name, RANLIBMAG)) {
XX			skip_arobj(afd);
XX			continue;
XX		}
XX		rexec(afd, tfd);
XX		put_arobj(&cf, (struct stat *)NULL);
XX	}
XX	*pnext = NULL;
XX
XX	/* Create the symbol table. */
XX	symobj();
XX
XX	/* Copy the saved objects into the archive. */
XX	size = lseek(tfd, (off_t)0, L_INCR);
XX	(void)lseek(tfd, (off_t)0, L_SET);
XX	SETCF(tfd, tname, afd, archive, RPAD|WPAD);
XX	copy_ar(&cf, size);
XX	(void)ftruncate(afd, lseek(afd, (off_t)0, L_INCR));
XX	(void)close(tfd);
XX
XX	/* Set the time. */
XX	settime(afd);
XX	close_archive(afd);
XX	return(0);
XX}
XX
XX/*
XX * rexec
XX *	Read the exec structure; ignore any files that don't look
XX *	exactly right.
XX */
XXstatic void
XXrexec(rfd, wfd)
XX	int rfd;
XX	int wfd;
XX{
XX	register RLIB *rp;
XX	RLIB **savnext;
XX	long nsyms;
XX	register int nr, symlen;
XX	char sym[512];		/* XXX - more than enough (we hope) */
XX	struct exec ebuf;
XX	struct nlist nl;
XX	off_t r_off, w_off, sympos;
XX	void *emalloc();
XX
XX	/* Get current offsets for original and tmp files. */
XX	r_off = lseek(rfd, (off_t)0, L_INCR);
XX	w_off = lseek(wfd, (off_t)0, L_INCR);
XX
XX	/* Read in exec structure. */
XX	nr = read(rfd, (char *)&ebuf, sizeof(struct exec));
XX	if (nr != sizeof(struct exec))
XX		goto bad1;
XX
XX	/* Check magic number and symbol count. */
XX	if (N_BADMAG(ebuf) || ebuf.a_syms == 0)
XX		goto bad1;
XX
XX	/* First four bytes are the table size. */
XX	sympos = N_STROFF(ebuf) + r_off;
XX
XX	/* Seek to symbol table. */
XX	if (fseek(fp, (off_t)N_SYMOFF(ebuf) + r_off, L_SET) == (off_t)-1)
XX		goto bad1;
XX
XX	/* Save starting point in symbol chain */
XX	savnext = pnext;
XX
XX	/* For each symbol read the nlist entry and save it as necessary. */
XX	nsyms = ebuf.a_syms / sizeof(struct nlist);
XX	while (nsyms--) {
XX		if (!fread((char *)&nl, sizeof(struct nlist), 1, fp)) {
XX			if (feof(fp))
XX				badfmt();
XX			error(archive);
XX		}
XX
XX		/* Ignore if no name or local. */
XX		if (!nl.n_un.n_strx || !(nl.n_type & N_EXT))
XX			continue;
XX
XX		/*
XX		 * If the symbol is an undefined external and the n_value
XX		 * field is non-zero, keep it.
XX		 */
XX		if ((nl.n_type & N_TYPE) == N_UNDF && !nl.n_value)
XX			continue;
XX
XX		rp = (RLIB *)emalloc(sizeof(RLIB));
XX		rp->pos = sympos + nl.n_un.n_strx;
XX		rp->next = NULL;
XX
XX		/* Build in forward order for "ar -m" command. */
XX		*pnext = rp;
XX		pnext = &rp->next;
XX		++symcnt;
XX	}
XX	for (rp = *savnext; rp; rp = rp->next) {
XX		fseek(fp, rp->pos, L_SET);
XX		symlen = sgets(sym, sizeof (sym), fp);
XX		rp->sym = (char *)emalloc(symlen);
XX		bcopy(sym, rp->sym, symlen);
XX		rp->symlen = symlen;
XX		rp->pos = w_off;
XX		tsymlen += symlen;
XX	}
XXbad1:	(void)lseek(rfd, (off_t)r_off, L_SET);
XX}
XX
XX/*
XX * symobj --
XX *	Write the symbol table into the archive, computing offsets as
XX *	writing.
XX */
XXstatic void
XXsymobj()
XX{
XX	register RLIB *rp, *next;
XX	struct ranlib rn;
XX	char hb[sizeof(struct ar_hdr) + 1], pad;
XX	long ransize, size, stroff;
XX	gid_t getgid();
XX	uid_t getuid();
XX
XX	/* Rewind the archive, leaving the magic number. */
XX	if (fseek(fp, (off_t)SARMAG, L_SET) == (off_t)-1)
XX		error(archive);
XX
XX	/* Size of the ranlib archive file, pad if necessary. */
XX	ransize = sizeof(long) +
XX	    symcnt * sizeof(struct ranlib) + sizeof(long) + tsymlen;
XX	if (ransize & 01) {
XX		++ransize;
XX		pad = '\n';
XX	} else
XX		pad = '\0';
XX
XX	/* Put out the ranlib archive file header. */
XX	(void)sprintf(hb, HDR2, RANLIBMAG, 0L, getuid(), getgid(),
XX	    0666 & ~umask(0), ransize, ARFMAG);
XX	if (!fwrite(hb, sizeof(struct ar_hdr), 1, fp))
XX		error(tname);
XX
XX	/* First long is the size of the ranlib structure section. */
XX	size = symcnt * sizeof(struct ranlib);
XX	if (!fwrite((char *)&size, sizeof(size), 1, fp))
XX		error(tname);
XX
XX	/* Offset of the first archive file. */
XX	size = SARMAG + sizeof(struct ar_hdr) + ransize;
XX
XX	/*
XX	 * Write out the ranlib structures.  The offset into the string
XX	 * table is cumulative, the offset into the archive is the value
XX	 * set in rexec() plus the offset to the first archive file.
XX	 */
XX	for (rp = rhead, stroff = 0; rp; rp = rp->next) {
XX		rn.ran_un.ran_strx = stroff;
XX		stroff += rp->symlen;
XX		rn.ran_off = size + rp->pos;
XX		if (!fwrite((char *)&rn, sizeof(struct ranlib), 1, fp))
XX			error(archive);
XX	}
XX
XX	/* Second long is the size of the string table. */
XX	if (!fwrite((char *)&tsymlen, sizeof(tsymlen), 1, fp))
XX		error(tname);
XX
XX	/* Write out the string table. */
XX	for (rp = rhead; rp; ) {
XX		if (!fwrite(rp->sym, rp->symlen, 1, fp))
XX			error(tname);
XX		(void)free(rp->sym);
XX		next = rp->next;
XX		free(rp);
XX		rp = next;
XX	}
XX
XX	if (pad && !fwrite(&pad, sizeof(pad), 1, fp))
XX		error(tname);
XX
XX	(void)fflush(fp);
XX}
XX
XXsgets(buf, n, fp)
XX	char *buf;
XX	int n;
XX	register FILE *fp;
XX	{
XX	register int i, c;
XX
XX	n--;				/* room for null */
XX	for	(i = 0; i < n; i++)
XX		{
XX		c = getc(fp);
XX		if	(c == EOF || c == 0)
XX			break;
XX		*buf++ = c;
XX		}
XX	*buf = '\0';
XX	return(i + 1);
XX	}
XSHAR_EOF
Xchmod 644 '/usr/src/usr.bin/ranlib/build.c'
Xfi
Xif test -f '/usr/src/usr.bin/ranlib/misc.c'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/usr.bin/ranlib/misc.c'"
Xelse
Xsed 's/^X//' << \SHAR_EOF > '/usr/src/usr.bin/ranlib/misc.c'
XX/*-
XX * Copyright (c) 1990 The Regents of the University of California.
XX * All rights reserved.
XX *
XX * This code is derived from software contributed to Berkeley by
XX * Hugh Smith at The University of Guelph.
XX *
XX * Redistribution and use in source and binary forms, with or without
XX * modification, are permitted provided that the following conditions
XX * are met:
XX * 1. Redistributions of source code must retain the above copyright
XX *    notice, this list of conditions and the following disclaimer.
XX * 2. Redistributions in binary form must reproduce the above copyright
XX *    notice, this list of conditions and the following disclaimer in the
XX *    documentation and/or other materials provided with the distribution.
XX * 3. All advertising materials mentioning features or use of this software
XX *    must display the following acknowledgement:
XX *	This product includes software developed by the University of
XX *	California, Berkeley and its contributors.
XX * 4. Neither the name of the University nor the names of its contributors
XX *    may be used to endorse or promote products derived from this software
XX *    without specific prior written permission.
XX *
XX * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
XX * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
XX * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
XX * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
XX * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
XX * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
XX * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
XX * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
XX * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
XX * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
XX * SUCH DAMAGE.
XX */
XX
XX#if	!defined(lint) && defined(DOSCCS)
XXstatic char sccsid[] = "@(#)misc.c	5.2 (Berkeley) 2/26/91";
XX#endif
XX
XX#include <sys/param.h>
XX#include <sys/signal.h>
XX#include <errno.h>
XX#include <stdio.h>
XX#include <string.h>
XX#include "pathnames.h"
XX
XXextern int errno;
XXextern char *archive, *malloc();	/* archive name */
XXvoid error();
XXchar *tname = "temporary file";		/* temporary file "name" */
XX
XXtmp()
XX{
XX	long set, oset;
XX	int fd;
XX	char path[MAXPATHLEN];
XX
XX	bcopy(_PATH_RANTMP, path, sizeof(_PATH_RANTMP));
XX
XX	set = sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGTERM);
XX	oset = sigsetmask(set);
XX	if ((fd = mkstemp(path)) == -1)
XX		error(tname);
XX        (void)unlink(path);
XX	(void)sigsetmask(oset);
XX	return(fd);
XX}
XX
XXvoid *
XXemalloc(len)
XX	int len;
XX{
XX	char *p;
XX
XX	if (!(p = malloc((u_int)len)))
XX		error(archive);
XX	return((void *)p);
XX}
XX
XXchar *
XXrname(path)
XX	char *path;
XX{
XX	register char *ind;
XX
XX	return((ind = rindex(path, '/')) ? ind + 1 : path);
XX}
XX
XXvoid
XXbadfmt()
XX{
XX	errno = EINVAL;
XX	error(archive);
XX}
XX
XXvoid
XXerror(name)
XX	char *name;
XX{
XX	(void)fprintf(stderr, "ranlib: %s: %s\n", name, strerror(errno));
XX	exit(1);
XX}
XSHAR_EOF
Xchmod 644 '/usr/src/usr.bin/ranlib/misc.c'
Xfi
Xif test -f '/usr/src/usr.bin/ranlib/pathnames.h'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/usr.bin/ranlib/pathnames.h'"
Xelse
Xsed 's/^X//' << \SHAR_EOF > '/usr/src/usr.bin/ranlib/pathnames.h'
XX/*-
XX * Copyright (c) 1990 The Regents of the University of California.
XX * All rights reserved.
XX *
XX * Redistribution and use in source and binary forms, with or without
XX * modification, are permitted provided that the following conditions
XX * are met:
XX * 1. Redistributions of source code must retain the above copyright
XX *    notice, this list of conditions and the following disclaimer.
XX * 2. Redistributions in binary form must reproduce the above copyright
XX *    notice, this list of conditions and the following disclaimer in the
XX *    documentation and/or other materials provided with the distribution.
XX * 3. All advertising materials mentioning features or use of this software
XX *    must display the following acknowledgement:
XX *	This product includes software developed by the University of
XX *	California, Berkeley and its contributors.
XX * 4. Neither the name of the University nor the names of its contributors
XX *    may be used to endorse or promote products derived from this software
XX *    without specific prior written permission.
XX *
XX * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
XX * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
XX * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
XX * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
XX * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
XX * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
XX * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
XX * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
XX * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
XX * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
XX * SUCH DAMAGE.
XX *
XX *	@(#)pathnames.h	5.2 (Berkeley) 4/16/91
XX */
XX
XX#define _PATH_RANTMP	"/tmp/ranlib.XXXXXX"
XSHAR_EOF
Xchmod 644 '/usr/src/usr.bin/ranlib/pathnames.h'
Xfi
Xif test -f '/usr/src/usr.bin/ranlib/ranlib.1'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/usr.bin/ranlib/ranlib.1'"
Xelse
Xsed 's/^X//' << \SHAR_EOF > '/usr/src/usr.bin/ranlib/ranlib.1'
XX.\" Copyright (c) 1990 Regents of the University of California.
XX.\" All rights reserved.
XX.\"
XX.\" Redistribution and use in source and binary forms, with or without
XX.\" modification, are permitted provided that the following conditions
XX.\" are met:
XX.\" 1. Redistributions of source code must retain the above copyright
XX.\"    notice, this list of conditions and the following disclaimer.
XX.\" 2. Redistributions in binary form must reproduce the above copyright
XX.\"    notice, this list of conditions and the following disclaimer in the
XX.\"    documentation and/or other materials provided with the distribution.
XX.\" 3. All advertising materials mentioning features or use of this software
XX.\"    must display the following acknowledgement:
XX.\"	This product includes software developed by the University of
XX.\"	California, Berkeley and its contributors.
XX.\" 4. Neither the name of the University nor the names of its contributors
XX.\"    may be used to endorse or promote products derived from this software
XX.\"    without specific prior written permission.
XX.\"
XX.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
XX.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
XX.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
XX.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
XX.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
XX.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
XX.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
XX.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
XX.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
XX.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
XX.\" SUCH DAMAGE.
XX.\"
XX.\"     @(#)ranlib.1	6.7 (Berkeley) 5/9/91
XX.\"
XX.TH RANLIB 1 "May 9, 1991"
XX.AT 3
XX.UC 6
XX.SH NAME
XXranlib \- table-of-contents for archive libraries
XX.SH SYNOPSIS
XX.nf
XX.ft B
XXranlib [-t] file ...
XX.fi
XX.ft R
XX.SH DESCRIPTION
XX.I Ranlib
XXcreates a table of external references for archive libraries,
XXnormally used by the loader,
XX.IR ld (1) .
XXThis table is is named ``__.SYMDEF'' and is prepended to the archive.
XXFiles in the archive which are not executable and symbols which are
XXuninteresting to the loader are ignored.
XX.PP
XXThe options are as follows:
XX.TP
XX\-t
XXSet the modification time of the __.SYMDEF file.
XXThis time is compared by the loader with the modification time of the
XXarchive to verify that the table is up-to-date with respect to the
XXarchive.
XXIf the modification time has been changed without any change to the
XXarchive (for example, by a
XX.IR cp (1) ) ,
XXthe
XX.I \-t
XXoption can be used to ``touch'' the modification time so that it
XXappears that the table is up-to-date.
XX.SH FILES
XX.TP 14
XX/tmp
XXdefault temporary file directory
XX.TP 14
XXranlib.XXXXXX
XXtemporary file names
XX.SH SEE ALSO
XX.IR ar (1) ,
XX.IR ld (1) ,
XX.IR lorder (1) ,
XX.IR nm (1) ,
XX.IR ranlib (5)
XX.SH HISTORY
XXA
XX.I ranlib
XXcommand appeared in Version 7 AT&T UNIX.
XSHAR_EOF
Xchmod 644 '/usr/src/usr.bin/ranlib/ranlib.1'
Xfi
Xif test -f '/usr/src/usr.bin/ranlib/ranlib.5.5'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/usr.bin/ranlib/ranlib.5.5'"
Xelse
Xsed 's/^X//' << \SHAR_EOF > '/usr/src/usr.bin/ranlib/ranlib.5.5'
XX.\" Copyright (c) 1990, 1991 The Regents of the University of California.
XX.\" All rights reserved.
XX.\"
XX.\" Redistribution and use in source and binary forms, with or without
XX.\" modification, are permitted provided that the following conditions
XX.\" are met:
XX.\" 1. Redistributions of source code must retain the above copyright
XX.\"    notice, this list of conditions and the following disclaimer.
XX.\" 2. Redistributions in binary form must reproduce the above copyright
XX.\"    notice, this list of conditions and the following disclaimer in the
XX.\"    documentation and/or other materials provided with the distribution.
XX.\" 3. All advertising materials mentioning features or use of this software
XX.\"    must display the following acknowledgement:
XX.\"	This product includes software developed by the University of
XX.\"	California, Berkeley and its contributors.
XX.\" 4. Neither the name of the University nor the names of its contributors
XX.\"    may be used to endorse or promote products derived from this software
XX.\"    without specific prior written permission.
XX.\"
XX.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
XX.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
XX.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
XX.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
XX.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
XX.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
XX.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
XX.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
XX.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
XX.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
XX.\" SUCH DAMAGE.
XX.\"
XX.\"     @(#)ranlib.5.5	5.2 (Berkeley) 5/10/91
XX.\"
XX.TH RANLIB 5 "May 10, 1991"
XX.AT 3
XX.UC 6
XX.SH NAME
XXranlib \- archive (library) table-of-contents format
XX.SH SYNOPSIS
XX.nf
XX.ft B
XX#include <ranlib.h>
XX.fi
XX.ft R
XX.SH DESCRIPTION
XXThe archive table-of-contents command
XX.I ranlib
XXcreates a table of contents for archives, containing object files, to
XXbe used by the link-editor
XX.IR ld (1) .
XXIt operates on archives created with the utility
XX.IR ar (1) .
XX.PP
XXThe
XX.I Ranlib
XXfunction
XXprepends a new file to the archive which has three separate parts.
XXThe first part is a standard archive header, which has a special name
XXfield,  "__.SYMDEF".
XX.PP
XXThe second part is a ``long'' followed by a list of ranlib structures.
XXThe long is the size, in bytes, of the list of ranlib structures.
XXEach of the ranlib structures consists of a zero based offset into the
XXnext section (a string table of symbols) and an offset from the beginning
XXof the archive to the start of the archive file which defines the symbol.
XXThe actual number of ranlib structures is this number divided by the size
XXof an individual ranlib structure.
XX.PP
XXThe third part is a ``long'' followed by a string table.
XXThe long is the size, in bytes of the string table.
XX.SH SEE ALSO
XX.IR ar (1) ,
XX.IR ranlib (1)
XSHAR_EOF
Xchmod 644 '/usr/src/usr.bin/ranlib/ranlib.5.5'
Xfi
Xif test -f '/usr/src/usr.bin/ranlib/ranlib.c'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/usr.bin/ranlib/ranlib.c'"
Xelse
Xsed 's/^X//' << \SHAR_EOF > '/usr/src/usr.bin/ranlib/ranlib.c'
XX/*-
XX * Copyright (c) 1990 The Regents of the University of California.
XX * All rights reserved.
XX *
XX * This code is derived from software contributed to Berkeley by
XX * Hugh Smith at The University of Guelph.
XX *
XX * Redistribution and use in source and binary forms, with or without
XX * modification, are permitted provided that the following conditions
XX * are met:
XX * 1. Redistributions of source code must retain the above copyright
XX *    notice, this list of conditions and the following disclaimer.
XX * 2. Redistributions in binary form must reproduce the above copyright
XX *    notice, this list of conditions and the following disclaimer in the
XX *    documentation and/or other materials provided with the distribution.
XX * 3. All advertising materials mentioning features or use of this software
XX *    must display the following acknowledgement:
XX *	This product includes software developed by the University of
XX *	California, Berkeley and its contributors.
XX * 4. Neither the name of the University nor the names of its contributors
XX *    may be used to endorse or promote products derived from this software
XX *    without specific prior written permission.
XX *
XX * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
XX * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
XX * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
XX * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
XX * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
XX * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
XX * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
XX * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
XX * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
XX * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
XX * SUCH DAMAGE.
XX */
XX
XX#if	!defined(lint) && defined(DOSCCS)
XXchar copyright[] =
XX"@(#) Copyright (c) 1990 The Regents of the University of California.\n\
XX All rights reserved.\n";
XX
XXstatic char sccsid[] = "@(#)ranlib.c	5.6 (Berkeley) 2/26/91";
XX#endif
XX
XX#include <sys/types.h>
XX#include <sys/dir.h>
XX#include <stdio.h>
XX#include <archive.h>
XX
XXCHDR chdr;
XXu_int options;				/* UNUSED -- keep open_archive happy */
XXchar *archive;
XX
XXmain(argc, argv)
XX	int argc;
XX	char **argv;
XX{
XX	extern int optind;
XX	int ch, eval, tflag;
XX
XX	tflag = 0;
XX	while ((ch = getopt(argc, argv, "t")) != EOF)
XX		switch(ch) {
XX		case 't':
XX			tflag = 1;
XX			break;
XX		case '?':
XX		default:
XX			usage();
XX		}
XX	argc -= optind;
XX	argv += optind;
XX
XX	if (!*argv)
XX		usage();
XX
XX	for (eval = 0; archive = *argv++;)
XX		eval |= tflag ? touch() : build();
XX	exit(eval);
XX}
XX
XXusage()
XX{
XX	(void)fprintf(stderr, "usage: ranlib [-t] archive ...\n");
XX	exit(1);
XX}
XSHAR_EOF
Xchmod 644 '/usr/src/usr.bin/ranlib/ranlib.c'
Xfi
Xif test -f '/usr/src/usr.bin/ranlib/touch.c'
Xthen
X	echo shar: "will not over-write existing file '/usr/src/usr.bin/ranlib/touch.c'"
Xelse
Xsed 's/^X//' << \SHAR_EOF > '/usr/src/usr.bin/ranlib/touch.c'
XX/*-
XX * Copyright (c) 1990 The Regents of the University of California.
XX * All rights reserved.
XX *
XX * This code is derived from software contributed to Berkeley by
XX * Hugh Smith at The University of Guelph.
XX *
XX * Redistribution and use in source and binary forms, with or without
XX * modification, are permitted provided that the following conditions
XX * are met:
XX * 1. Redistributions of source code must retain the above copyright
XX *    notice, this list of conditions and the following disclaimer.
XX * 2. Redistributions in binary form must reproduce the above copyright
XX *    notice, this list of conditions and the following disclaimer in the
XX *    documentation and/or other materials provided with the distribution.
XX * 3. All advertising materials mentioning features or use of this software
XX *    must display the following acknowledgement:
XX *	This product includes software developed by the University of
XX *	California, Berkeley and its contributors.
XX * 4. Neither the name of the University nor the names of its contributors
XX *    may be used to endorse or promote products derived from this software
XX *    without specific prior written permission.
XX *
XX * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
XX * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
XX * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
XX * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
XX * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
XX * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
XX * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
XX * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
XX * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
XX * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
XX * SUCH DAMAGE.
XX */
XX
XX#if	!defined(lint) && defined(DOSCCS)
XXstatic char sccsid[] = "@(#)touch.c	5.3 (Berkeley) 3/12/91";
XX#endif
XX
XX#include <sys/types.h>
XX#include <sys/dir.h>
XX#include <sys/file.h>
XX#include <fcntl.h>
XX#include <ranlib.h>
XX#include <ar.h>
XX#include <time.h>
XX#include <stdio.h>
XX#include <string.h>
XX#include <archive.h>
XX
XXextern	time_t	time();
XXextern	off_t	lseek();
XXextern CHDR chdr;			/* converted header */
XXextern char *archive;			/* archive name */
XXvoid error();
XX
XXtouch()
XX{
XX	int afd;
XX
XX	afd = open_archive(O_RDWR);
XX
XX	if (!get_arobj(afd) ||
XX	    strncmp(RANLIBMAG, chdr.name, sizeof(RANLIBMAG) - 1)) {
XX		(void)fprintf(stderr,
XX		    "ranlib: %s: no symbol table.\n", archive);
XX		return(1);
XX	}
XX	settime(afd);
XX	return(0);
XX}
XX
XXsettime(afd)
XX	int afd;
XX{
XX	struct ar_hdr *hdr;
XX	off_t size;
XX	char buf[50];
XX
XX	size = SARMAG + sizeof(hdr->ar_name);
XX	if (lseek(afd, size, L_SET) == (off_t)-1)
XX		error(archive);
XX	(void)sprintf(buf, "%-12ld", time((time_t *)NULL) + RANLIBSKEW);
XX	if (write(afd, buf, sizeof(hdr->ar_date)) != sizeof(hdr->ar_date))
XX		error(archive);
XX}
XSHAR_EOF
Xchmod 644 '/usr/src/usr.bin/ranlib/touch.c'
Xfi
Xexit 0
X#	End of shell archive
SHAR_EOF
chmod 640 'new.sources'
fi
exit 0
#	End of shell archive
