4.2BSD APL correction

jdb%s1-c at sri-unix.UUCP jdb%s1-c at sri-unix.UUCP
Sat Feb 18 12:15:50 AEST 1984


The APL distributed with 4.2BSD is "my" APL (the version that was
extensively modified over a period of several years at Purdue/EE
by Tony Reeves, Jim Besemer, and myself).  Unfortunately, a change
was made to APL at Berkeley which makes the 4.2BSD-distributed
version incompatible with the one that we distributed from Purdue/EE.
The 4.2BSD version is incorrect -- the change at UCB was not
accompanied by a change in the workspace magic number; hence,
my earlier distributions are incompatible with the 4.2BSD-distributed
version.

To solve this problem, future 4.2BSD distributions will use a new
magic number for APL workspaces.  If you already have 4.2BSD then
the following changes are necessary:

In the source file "apl.h" there are four "#define MAGIC" statements
(for the different flavors of APL).  Currently the magic numbers are
in the range 0100554-0100557.  Add 01000 to each one so that the
magic numbers are 0101554-101557.  This change should also be made
to the source file "aplcvt.c" (the VAX/PDP-11 workspace converter).

If you have already used the 4.2BSD APL then you have some workspaces
in the new format with the incorrect magic number.  The easiest thing
to do is to patch APL to accept workspaces with either the incorrect
magic number or the new one.  In "aj.c" in the function "wsload" change:


		iz.i = 0;
	/* Check for correct magic number */
		READF(ffile,&iz,sizeof iz);
		iz.i &= 0177777;                        /* Zap high bits */
		if((iz.i|1) != (MAGIC|1)){
	barf:
---------
		iz.i = 0;
	/* Check for correct magic number */
		READF(ffile,&iz,sizeof iz);
		iz.i &= 0177777;                        /* Zap high bits */
     !		if((iz.i|01001) != (MAGIC|1)){
	barf:


If you received an earlier distribution from Tony Reeves or myself
(when I was at Purdue/EE), the following code may be added to APL
to load workspaces with the old magic number:

	In "apl.h":

	#define	NEWWSFLG 01000	/* magic number bit indicating new ws fmt */

	In "aj.c", function wsload():

		struct {
			int word;
		};

		iz.i = 0;
		READF(ffile,&iz,sizeof iz);
		iz.i &= 0177777;                        /* Zap high bits */
		if((iz.i|1) != (MAGIC|1)){
	barf:
			CLOSEF(ffile);
			if (((iz.i|1)^2) == (MAGIC|1))
				error(WSMESG);
			else
				error("bad ws file format");
		}
		if(iz.i > MAGIC){
			printf("single data converted to double\n");
			dconv = 2;
		} else if(iz.i < MAGIC){
			printf("double data converted to single\n");
			dconv = 1;
		} else
			dconv = 0;
		READF(ffile,&thread,sizeof thread);
	---------
		struct {
			int word;
		};
      !		int oldws;
      !		struct {
      !			double	fuzz;
      !			int	iorg;
      !			int	digits;
      !			int	width;
      !		} othread;

		iz.i = 0;
	/* Check for correct magic number */
		READF(ffile,&iz,sizeof iz);
		iz.i &= 0177777;                        /* Zap high bits */
      !		oldws = (iz.i&NEWWSFLG) == 0;
      !		iz.i |= NEWWSFLG;
		if((iz.i|1) != (MAGIC|1)){
	barf:
			CLOSEF(ffile);
			if (((iz.i|1)^2) == (MAGIC|1))
				error(WSMESG);
			else
				error("bad ws file format");
		}
		if(iz.i > MAGIC){
			printf("single data converted to double\n");
			dconv = 2;
		} else if(iz.i < MAGIC){
			printf("double data converted to single\n");
			dconv = 1;
		} else
			dconv = 0;
      !		if (oldws) {
      !			printf("note: old format workspace\n");
      !			READF(ffile, &othread, sizeof othread);
      !			thread.fuzz = othread.fuzz;
      !			thread.iorg = othread.iorg;
      !			thread.digits = othread.digits;
      !			thread.width = othread.width;
      !			thread.rl = 1;
      !		} else
      !			READF(ffile,&thread,sizeof thread);
      !		srand(thread.rl);
		while(READF(ffile,&iz,sizeof iz) == sizeof iz){


Once these changes are installed just )load the old workspace and
)save it out again.

There are corresponding fixes to "aplcvt.c"; I'll post them in a
couple of days.  (If there is anyone out there who is trying to use
the 4.2BSD-distributed version on [separated I/D] PDP-11's I'd be
interested in hearing from you.  I can give you a couple of pointers
on eliminating 4.2BSD dependencies from "apl.h" so the source will
run on V7 as well.)
--
  John Bruner (S-1 Project, Lawrence Livermore National Laboratory)
  MILNET: jdb at s1-c	UUCP: ...!decvax!decwrl!mordor!jdb



More information about the Comp.unix.wizards mailing list