This patch cleans up the problems with compiling perl 4 on FreeBSD,
specifically (1) the AF_LOCAL clash, (2) warnings in doio.c,
(3) broken dbm & cpp tests, (4) the ALIGNBYTES clash, (5) the
bogus declaration for setenv() in x2p/util.h.

When configuring perl 4 you must avoid using the built-in malloc()
because it won't compile and it isn't better than FreeBSD's malloc().

--- perl4.036/arg.h	Wed Jun 19 17:07:04 1996
+++ perl4.036_FreeBSD/arg.h	Mon Oct  4 18:47:46 1999
@@ -682,7 +682,7 @@
 #define AF_COMMON 16		/* left and right have symbols in common */
 #define AF_DEPR 32		/* an older form of the construct */
 #define AF_LISTISH 64		/* turn into list if important */
-#define AF_LOCAL 128		/* list of local variables */
+#define AF_LOCALVARS 128	/* list of local variables */
 
 /*
  * Most of the ARG pointers are used as pointers to arrays of ARG.  When
--- perl4.036/config_h.SH	Wed Jun 19 17:07:03 1996
+++ perl4.036_FreeBSD/config_h.SH	Mon Oct  4 18:36:48 1999
@@ -50,7 +50,7 @@
  *	This symbol contains the number of bytes required to align a double.
  *	Usual values are 2, 4, and 8.
  */
-#define ALIGNBYTES $alignbytes		/**/
+/* #define ALIGNBYTES $alignbytes		/**/
 
 /* BIN
  *	This symbol holds the name of the directory in which the user wants
--- perl4.036/consarg.c	Wed Jun 19 17:06:56 1996
+++ perl4.036_FreeBSD/consarg.c	Mon Oct  4 18:48:11 1999
@@ -704,8 +704,8 @@
 		if (nothing_in_common(arg1,arg2))
 		    arg->arg_flags &= ~AF_COMMON;
 		if (arg->arg_type == O_ASSIGN) {
-		    if (arg1->arg_flags & AF_LOCAL)
-			arg->arg_flags |= AF_LOCAL;
+		    if (arg1->arg_flags & AF_LOCALVARS)
+			arg->arg_flags |= AF_LOCALVARS;
 		    arg[1].arg_flags |= AF_ARYOK;
 		    arg[2].arg_flags |= AF_ARYOK;
 		}
@@ -1055,7 +1055,7 @@
 localize(arg)
 ARG *arg;
 {
-    arg->arg_flags |= AF_LOCAL;
+    arg->arg_flags |= AF_LOCALVARS;
     return arg;
 }
 
--- perl4.036/doarg.c	Wed Jun 19 17:06:30 1996
+++ perl4.036_FreeBSD/doarg.c	Mon Oct  4 18:48:23 1999
@@ -1198,7 +1198,7 @@
     HASH *hash;
     int i;
 
-    makelocal = (arg->arg_flags & AF_LOCAL) != 0;
+    makelocal = (arg->arg_flags & AF_LOCALVARS) != 0;
     localizing = makelocal;
     delaymagic = DM_DELAY;		/* catch simultaneous items */
 
--- perl4.036/doio.c	Wed Jun 19 17:08:52 1996
+++ perl4.036_FreeBSD/doio.c	Mon Oct  4 18:57:21 1999
@@ -291,8 +291,8 @@
 #endif
 	) {
 	    int buflen = sizeof tokenbuf;
-	    if (getsockname(fileno(fp), tokenbuf, &buflen) >= 0
-		|| errno != ENOTSOCK)
+	    if (getsockname(fileno(fp), (struct sockaddr *)tokenbuf, &buflen)
+			>= 0 || errno != ENOTSOCK)
 		stio->type = 's'; /* some OS's return 0 on fstat()ed socket */
 				/* but some return 0 for streams too, sigh */
 	}
@@ -1448,7 +1448,8 @@
 #ifdef TAINT
     taintproper("Insecure dependency in bind");
 #endif
-    return bind(fileno(stio->ifp), addr, st[sp]->str_cur) >= 0;
+    return bind(fileno(stio->ifp), (struct sockaddr *)addr,
+				st[sp]->str_cur) >= 0;
 
 nuts:
     if (dowarn)
@@ -1479,7 +1480,8 @@
 #ifdef TAINT
     taintproper("Insecure dependency in connect");
 #endif
-    return connect(fileno(stio->ifp), addr, st[sp]->str_cur) >= 0;
+    return connect(fileno(stio->ifp), (struct sockaddr *)addr,
+				st[sp]->str_cur) >= 0;
 
 nuts:
     if (dowarn)
@@ -1670,11 +1672,13 @@
     fd = fileno(stio->ifp);
     switch (optype) {
     case O_GETSOCKNAME:
-	if (getsockname(fd, st[sp]->str_ptr, (int*)&st[sp]->str_cur) < 0)
+	if (getsockname(fd, (struct sockaddr *)st[sp]->str_ptr,
+			(int*)&st[sp]->str_cur) < 0)
 	    goto nuts2;
 	break;
     case O_GETPEERNAME:
-	if (getpeername(fd, st[sp]->str_ptr, (int*)&st[sp]->str_cur) < 0)
+	if (getpeername(fd, (struct sockaddr *)st[sp]->str_ptr,
+			(int*)&st[sp]->str_cur) < 0)
 	    goto nuts2;
 	break;
     }
--- perl4.036/dump.c	Wed Jun 19 17:07:49 1996
+++ perl4.036_FreeBSD/dump.c	Mon Oct  4 18:49:55 1999
@@ -260,7 +260,7 @@
 	(void)strcat(b,"DEPR,");
     if (flags & AF_LISTISH)
 	(void)strcat(b,"LISTISH,");
-    if (flags & AF_LOCAL)
+    if (flags & AF_LOCALVARS)
 	(void)strcat(b,"LOCAL,");
     if (*b)
 	b[strlen(b)-1] = '\0';
--- perl4.036/t/comp/cpp.t	Wed Jun 19 17:08:28 1996
+++ perl4.036_FreeBSD/t/comp/cpp.t	Mon Oct  4 18:27:31 1999
@@ -7,7 +7,7 @@
     if (/^cppstdin/) {
 	if (/^cppstdin='(.*cppstdin)'/ && ! -e $1) {
 	    print "1..0\n";
-	    exit; 		# Can't test till after install, alas.
+	    exit; 		# Cannot test till after install, alas.
 	}
 	last;
     }
--- perl4.036/t/op/dbm.t	Wed Jun 19 17:08:11 1996
+++ perl4.036_FreeBSD/t/op/dbm.t	Mon Oct  4 18:14:11 1999
@@ -14,7 +14,7 @@
 umask(0);
 print (dbmopen(h,'Op.dbmx',0640) ? "ok 1\n" : "not ok 1\n");
 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
-   $blksize,$blocks) = stat('Op.dbmx.pag');
+   $blksize,$blocks) = stat('Op.dbmx.db');
 print (($mode & 0777) == 0640 ? "ok 2\n" : "not ok 2\n");
 while (($key,$value) = each(h)) {
     $i++;
@@ -93,7 +93,7 @@
 print ($ok ? "ok 8\n" : "not ok 8\n");
 
 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
-   $blksize,$blocks) = stat('Op.dbmx.pag');
+   $blksize,$blocks) = stat('Op.dbmx.db');
 print ($size > 0 ? "ok 9\n" : "not ok 9\n");
 
 @h{0..200} = 200..400;
@@ -103,4 +103,4 @@
 print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n");
 print ($h{''} eq 'bar' ? "ok 12\n" : "not ok 12\n");
 
-unlink 'Op.dbmx.dir', 'Op.dbmx.pag';
+unlink 'Op.dbmx.db';
--- perl4.036/x2p/util.h	Wed Jun 19 17:08:26 1996
+++ perl4.036_FreeBSD/x2p/util.h	Mon Oct  4 18:07:50 1999
@@ -42,7 +42,6 @@
 char	*get_a_line();
 char	*savestr();
 int	makedir();
-void	setenv();
 int	envix();
 void	notincl();
 char	*getval();
--- perl4.036/installperl	Wed Jun 19 17:07:56 1996
+++ perl4.036_FreeBSD/installperl	Mon Oct  4 20:03:01 1999
@@ -81,26 +81,6 @@
     &link("$installbin/perl$ver", "$installbin/perl");
     &link("$installbin/tperl$ver", "$installbin/taintperl");
     &link("$installbin/sperl$ver", "$installbin/suidperl") if $d_dosuid;
-}
-
-($bdev,$bino) = stat($installbin);
-($ddev,$dino) = stat('x2p');
-
-if ($bdev != $ddev || $bino != $dino) {
-    &unlink("$installbin/a2p");
-    &cmd("cp x2p/a2p $installbin/a2p");
-    &chmod(0755, "$installbin/a2p");
-}
-
-# Make some enemies in the name of standardization.   :-)
-
-($udev,$uino) = stat($mainperldir);
-
-if (-w _ && ($udev != $bdev || $uino != $bino) && !$nonono) {
-    &unlink("$mainperldir/perl");
-    eval 'link("$installbin/perl", "$mainperldir/perl")' ||
-    eval 'symlink("$installbin/perl", "$mainperldir/perl")' ||
-    &cmd("cp $installbin/perl $mainperldir");
 }
 
 # Install scripts.
--- perl4.036/perl.c	Wed Jun 19 17:06:37 1996
+++ perl4.036_FreeBSD/perl.c	Tue Oct  5 01:52:38 1999
@@ -244,6 +244,8 @@
 	    break;
 	case '-':
 	    argc--,argv++;
+	    if (!strcmp(argv[0], "-*-perl-*-"))
+		argc--,argv++;
 	    goto switch_end;
 	case 0:
 	    break;

