*** ../pine-2.4.old/.bld.hlp	Fri Feb 28 16:13:13 1992
--- ./.bld.hlp	Mon Apr 27 08:43:43 1992
***************
*** 6,11
      sun   Works on SPARCs running SunOS 4.1
      dyn   Works on Sequent Symmetry running Dynix 3.0
      aix   Works on IBM 3090 running AIX/370 1.2.1
      ...   Others are available, see doc/pine-ports
    clean   Clean up object files and such to reduce disk space after building
            Pine/Pico. Also, a good way to rebuild Pine/Pico from scratch.

--- 6,12 -----
      sun   Works on SPARCs running SunOS 4.1
      dyn   Works on Sequent Symmetry running Dynix 3.0
      aix   Works on IBM 3090 running AIX/370 1.2.1
+     s53   Works on System V Release 3.2
      ...   Others are available, see doc/pine-ports
    clean   Clean up object files and such to reduce disk space after building
            Pine/Pico. Also, a good way to rebuild Pine/Pico from scratch.
*** ../pine-2.4.old/build	Thu Feb 20 17:54:05 1992
--- ./build	Fri Apr 24 16:16:20 1992
***************
*** 59,64
      sun   Works on SPARCs running SunOS 4.1
      dyn   Works on Sequent Symmetry running Dynix 3.0
      aix   Works on IBM 3090 running AIX/370 1.2.1
      ...   Others are available, see doc/pine-ports
    clean   Clean up object files and such to reduce disk space after building
            Pine/Pico. Also, a good way to rebuild Pine/Pico from scratch.

--- 59,65 -----
      sun   Works on SPARCs running SunOS 4.1
      dyn   Works on Sequent Symmetry running Dynix 3.0
      aix   Works on IBM 3090 running AIX/370 1.2.1
+     s53   Works on System V Release 3.2
      ...   Others are available, see doc/pine-ports
    clean   Clean up object files and such to reduce disk space after building
            Pine/Pico. Also, a good way to rebuild Pine/Pico from scratch.
***************
*** 145,150

     ???)
          echo ''
          echo "Making c-client library and mtest"
          cd c-client
          make $makeargs -f makefile.$maketarget

--- 146,156 -----

     ???)
          echo ''
+ 	if [ $maketarget = s53 ] ; then
+ 		echo "Making libregexp"
+ 		(cd regexp ; make)
+ 		echo ''
+ 	fi
          echo "Making c-client library and mtest"
          cd c-client
          make $makeargs -f makefile.$maketarget
***************
*** 177,182


      clean) # This only sort of works
          echo "Cleaning c-client"
          cd c-client
          make -f makefile.nxt $makeargs clean

--- 183,192 -----


      clean) # This only sort of works
+ 	if [ -f regexp/libregexp.a ] ; then
+ 		echo "Cleaning libregexp"
+ 		(cd regexp ; make clean)
+ 	fi
          echo "Cleaning c-client"
          cd c-client
          make -f makefile.nxt $makeargs clean
*** ../pine-2.4.old/c-client/bezerk.c	Wed Jan  8 18:15:33 1992
--- ./c-client/bezerk.c	Sun Apr 26 15:35:21 1992
***************
*** 55,60
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
  #include "osdep.h"
  #include "mail.h"
  #include "bezerk.h"

--- 55,64 -----
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
+ #ifdef	_SYSV3
+ #include <unistd.h>
+ #include <sys/fcntl.h>
+ #endif
  #include "osdep.h"
  #include "mail.h"
  #include "bezerk.h"
***************
*** 228,233
    if ((i = open (LOCAL->lname,O_RDWR|O_CREAT,0666)) < 0)
      mm_log ("Can't open mailbox lock, access is readonly",WARN);
  				/* try lock it */
    else if (flock (i,LOCK_EX|LOCK_NB)) {
      close (i);			/* couldn't lock, give up on it then */
      mm_log ("Mailbox is open by another user or process, access is readonly",

--- 232,240 -----
    if ((i = open (LOCAL->lname,O_RDWR|O_CREAT,0666)) < 0)
      mm_log ("Can't open mailbox lock, access is readonly",WARN);
  				/* try lock it */
+ #ifdef	_SYSV3
+   else if (lockf (i,F_TLOCK,0)) {
+ #else
    else if (flock (i,LOCK_EX|LOCK_NB)) {
  #endif
      close (i);			/* couldn't lock, give up on it then */
***************
*** 229,234
      mm_log ("Can't open mailbox lock, access is readonly",WARN);
  				/* try lock it */
    else if (flock (i,LOCK_EX|LOCK_NB)) {
      close (i);			/* couldn't lock, give up on it then */
      mm_log ("Mailbox is open by another user or process, access is readonly",
  	    WARN);

--- 236,242 -----
    else if (lockf (i,F_TLOCK,0)) {
  #else
    else if (flock (i,LOCK_EX|LOCK_NB)) {
+ #endif
      close (i);			/* couldn't lock, give up on it then */
      mm_log ("Mailbox is open by another user or process, access is readonly",
  	    WARN);
***************
*** 233,240
      mm_log ("Mailbox is open by another user or process, access is readonly",
  	    WARN);
    }
! 				/* got the lock, nobody else can alter state */
!   else fchmod ((LOCAL->ld = i),0666);
  				/* parse mailbox */
    stream->nmsgs = stream->recent = 0;
  				/* will we be able to get write access? */

--- 241,252 -----
      mm_log ("Mailbox is open by another user or process, access is readonly",
  	    WARN);
    }
!   else {			/* got the lock, nobody else can alter state */
!     LOCAL->ld = i;
! #ifndef	_SYSV3
!     fchmod (LOCAL->ld,0666);
! #endif
!   }
  				/* parse mailbox */
    stream->nmsgs = stream->recent = 0;
  				/* will we be able to get write access? */
***************
*** 240,245
  				/* will we be able to get write access? */
    if (LOCAL->ld && access (LOCAL->fname,W_OK) && (errno == EACCES)) {
      mm_log ("Can't get write access to mailbox, access is readonly",WARN);
      flock (LOCAL->ld,LOCK_UN);	/* release the lock */
      close (LOCAL->ld);		/* close the lock file */
      LOCAL->ld = NIL;		/* no more lock fd */

--- 252,260 -----
  				/* will we be able to get write access? */
    if (LOCAL->ld && access (LOCAL->fname,W_OK) && (errno == EACCES)) {
      mm_log ("Can't get write access to mailbox, access is readonly",WARN);
+ #ifdef	_SYSV3
+     lockf (LOCAL->ld,F_ULOCK,0);	/* release the lock */
+ #else
      flock (LOCAL->ld,LOCK_UN);	/* release the lock */
  #endif
      close (LOCAL->ld);		/* close the lock file */
***************
*** 241,246
    if (LOCAL->ld && access (LOCAL->fname,W_OK) && (errno == EACCES)) {
      mm_log ("Can't get write access to mailbox, access is readonly",WARN);
      flock (LOCAL->ld,LOCK_UN);	/* release the lock */
      close (LOCAL->ld);		/* close the lock file */
      LOCAL->ld = NIL;		/* no more lock fd */
      unlink (LOCAL->lname);	/* delete it */

--- 256,262 -----
      lockf (LOCAL->ld,F_ULOCK,0);	/* release the lock */
  #else
      flock (LOCAL->ld,LOCK_UN);	/* release the lock */
+ #endif
      close (LOCAL->ld);		/* close the lock file */
      LOCAL->ld = NIL;		/* no more lock fd */
      unlink (LOCAL->lname);	/* delete it */
***************
*** 272,277
      stream->silent = T;		/* note this stream is dying */
  				/* lock mailbox and parse new messages */
      if (LOCAL->dirty && (fd = bezerk_parse (stream,lock)) >= 0) {
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  				/* dump any changes not saved yet */
        if (bezerk_extend	(stream,fd,"Close failed to update mailbox"))

--- 288,294 -----
      stream->silent = T;		/* note this stream is dying */
  				/* lock mailbox and parse new messages */
      if (LOCAL->dirty && (fd = bezerk_parse (stream,lock)) >= 0) {
+ #ifndef	_SYSV3
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  #endif
  				/* dump any changes not saved yet */
***************
*** 273,278
  				/* lock mailbox and parse new messages */
      if (LOCAL->dirty && (fd = bezerk_parse (stream,lock)) >= 0) {
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  				/* dump any changes not saved yet */
        if (bezerk_extend	(stream,fd,"Close failed to update mailbox"))
  	bezerk_save (stream,fd);

--- 290,296 -----
      if (LOCAL->dirty && (fd = bezerk_parse (stream,lock)) >= 0) {
  #ifndef	_SYSV3
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
+ #endif
  				/* dump any changes not saved yet */
        if (bezerk_extend	(stream,fd,"Close failed to update mailbox"))
  	bezerk_save (stream,fd);
***************
*** 660,665
  				/* parse and lock mailbox */
    if (LOCAL && LOCAL->ld && ((fd = bezerk_parse (stream,lock)) >= 0)) {
      if (LOCAL->dirty) {		/* only if checkpoint needed */
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  				/* dump a checkpoint */
        if (bezerk_extend (stream,fd,"Unable to update mailbox"))

--- 678,684 -----
  				/* parse and lock mailbox */
    if (LOCAL && LOCAL->ld && ((fd = bezerk_parse (stream,lock)) >= 0)) {
      if (LOCAL->dirty) {		/* only if checkpoint needed */
+ #ifndef	_SYSV3
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  #endif
  				/* dump a checkpoint */
***************
*** 661,666
    if (LOCAL && LOCAL->ld && ((fd = bezerk_parse (stream,lock)) >= 0)) {
      if (LOCAL->dirty) {		/* only if checkpoint needed */
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  				/* dump a checkpoint */
        if (bezerk_extend (stream,fd,"Unable to update mailbox"))
  	bezerk_save (stream,fd);

--- 680,686 -----
      if (LOCAL->dirty) {		/* only if checkpoint needed */
  #ifndef	_SYSV3
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
+ #endif
  				/* dump a checkpoint */
        if (bezerk_extend (stream,fd,"Unable to update mailbox"))
  	bezerk_save (stream,fd);
***************
*** 692,697
        while ((j = (i<=stream->nmsgs)) && !(elt = mail_elt (stream,i))->deleted)
  	i++;			/* find first deleted message */
        if (j) {			/* found one? */
  	flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  				/* make sure we can do the worst case thing */
  	if (bezerk_extend (stream,fd,"Unable to expunge mailbox")) {

--- 712,718 -----
        while ((j = (i<=stream->nmsgs)) && !(elt = mail_elt (stream,i))->deleted)
  	i++;			/* find first deleted message */
        if (j) {			/* found one? */
+ #ifndef	_SYSV3
  	flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  #endif
  				/* make sure we can do the worst case thing */
***************
*** 693,698
  	i++;			/* find first deleted message */
        if (j) {			/* found one? */
  	flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
  				/* make sure we can do the worst case thing */
  	if (bezerk_extend (stream,fd,"Unable to expunge mailbox")) {
  	  do {			/* flush deleted messages */

--- 714,720 -----
        if (j) {			/* found one? */
  #ifndef	_SYSV3
  	flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
+ #endif
  				/* make sure we can do the worst case thing */
  	if (bezerk_extend (stream,fd,"Unable to expunge mailbox")) {
  	  do {			/* flush deleted messages */
***************
*** 790,795
    if (LOCAL) {			/* only if a file is open */
      if (LOCAL->host) fs_give ((void **) &LOCAL->host);
      if (LOCAL->ld) {		/* have a mailbox lock? */
        flock (LOCAL->ld,LOCK_UN);/* yes, release the lock */
        close (LOCAL->ld);	/* close the lock file */
        unlink (LOCAL->lname);	/* and delete it */

--- 812,820 -----
    if (LOCAL) {			/* only if a file is open */
      if (LOCAL->host) fs_give ((void **) &LOCAL->host);
      if (LOCAL->ld) {		/* have a mailbox lock? */
+ #ifdef	_SYSV3
+       lockf (LOCAL->ld,F_ULOCK,0);	/* yes, release the lock */
+ #else
        flock (LOCAL->ld,LOCK_UN);/* yes, release the lock */
  #endif
        close (LOCAL->ld);	/* close the lock file */
***************
*** 791,796
      if (LOCAL->host) fs_give ((void **) &LOCAL->host);
      if (LOCAL->ld) {		/* have a mailbox lock? */
        flock (LOCAL->ld,LOCK_UN);/* yes, release the lock */
        close (LOCAL->ld);	/* close the lock file */
        unlink (LOCAL->lname);	/* and delete it */
      }

--- 816,822 -----
        lockf (LOCAL->ld,F_ULOCK,0);	/* yes, release the lock */
  #else
        flock (LOCAL->ld,LOCK_UN);/* yes, release the lock */
+ #endif
        close (LOCAL->ld);	/* close the lock file */
        unlink (LOCAL->lname);	/* and delete it */
      }
***************
*** 828,834
      uid = (pwd = getpwuid (geteuid ()))->pw_name;
      if (strcmp (ucase (dst),"INBOX")) sprintf (dst,"%s/%s",pwd->pw_dir,name);
  				/* INBOX becomes /usr/spool/mail/USER file */
!     else sprintf (dst,"/usr/spool/mail/%s",uid);
    }
    return dst;
  }

--- 854,865 -----
      uid = (pwd = getpwuid (geteuid ()))->pw_name;
      if (strcmp (ucase (dst),"INBOX")) sprintf (dst,"%s/%s",pwd->pw_dir,name);
  				/* INBOX becomes /usr/spool/mail/USER file */
!     else
! #ifdef	_SYSV3
!       sprintf (dst,"/usr/mail/%s",uid);
! #else
!       sprintf (dst,"/usr/spool/mail/%s",uid);
! #endif
    }
    return dst;
  }
***************
*** 876,881
        }
      }
      else {			/* got a hitching-post */
        fchmod (ld,0666);		/* make sure others can break the lock */
        close (ld);		/* close the hitching-post */
        link (tmp,lock);		/* tie hitching-post to lock, ignore failure */

--- 907,913 -----
        }
      }
      else {			/* got a hitching-post */
+ #ifndef	_SYSV3
        fchmod (ld,0666);		/* make sure others can break the lock */
  #endif
        close (ld);		/* close the hitching-post */
***************
*** 877,882
      }
      else {			/* got a hitching-post */
        fchmod (ld,0666);		/* make sure others can break the lock */
        close (ld);		/* close the hitching-post */
        link (tmp,lock);		/* tie hitching-post to lock, ignore failure */
        stat (tmp,&sb);		/* get its data */

--- 909,915 -----
      else {			/* got a hitching-post */
  #ifndef	_SYSV3
        fchmod (ld,0666);		/* make sure others can break the lock */
+ #endif
        close (ld);		/* close the hitching-post */
        link (tmp,lock);		/* tie hitching-post to lock, ignore failure */
        stat (tmp,&sb);		/* get its data */
***************
*** 910,915
        break;
      }
      if (ld >= 0) {		/* if made a lock file */
        fchmod (ld,0666);		/* make sure others can break the lock */
        close (ld);		/* close the lock file */
      }

--- 943,949 -----
        break;
      }
      if (ld >= 0) {		/* if made a lock file */
+ #ifndef	_SYSV3
        fchmod (ld,0666);		/* make sure others can break the lock */
  #endif
        close (ld);		/* close the lock file */
***************
*** 911,916
      }
      if (ld >= 0) {		/* if made a lock file */
        fchmod (ld,0666);		/* make sure others can break the lock */
        close (ld);		/* close the lock file */
      }
  #endif

--- 945,951 -----
      if (ld >= 0) {		/* if made a lock file */
  #ifndef	_SYSV3
        fchmod (ld,0666);		/* make sure others can break the lock */
+ #endif
        close (ld);		/* close the lock file */
      }
  #endif
***************
*** 924,930
      }
    } while (i-- && ld < 0 && *lock);
  				/* open file */
!   if ((fd = open (file,flags,mode)) >= 0) flock (fd,op);
    else {			/* open failed */
      j = errno;			/* preserve error code */
      if (*lock) unlink (lock);	/* flush the lock file if any */

--- 959,970 -----
      }
    } while (i-- && ld < 0 && *lock);
  				/* open file */
!   if ((fd = open (file,flags,mode)) >= 0)
! #ifdef	_SYSV3
!     lockf (fd,op,0);
! #else
!     flock (fd,op);
! #endif
    else {			/* open failed */
      j = errno;			/* preserve error code */
      if (*lock) unlink (lock);	/* flush the lock file if any */
***************
*** 955,961
        tp[0].tv_sec - 1;
      tp[1].tv_usec = 0;		/* oh well */
  				/* set the times, note change */
!     if (!utimes (stream->mailbox,tp)) LOCAL->filetime = tp[1].tv_sec;
    }
    flock (fd,LOCK_UN);		/* release flock'ers */
    close (fd);			/* close the file */

--- 995,1006 -----
        tp[0].tv_sec - 1;
      tp[1].tv_usec = 0;		/* oh well */
  				/* set the times, note change */
! #ifdef	_SYSV3
!     if (!utime (stream->mailbox,tp))
! #else
!     if (!utimes (stream->mailbox,tp))
! #endif
!       LOCAL->filetime = tp[1].tv_sec;
    }
  #ifdef	_SYSV3
    lockf (fd,F_ULOCK,0);		/* release flock'ers */
***************
*** 957,962
  				/* set the times, note change */
      if (!utimes (stream->mailbox,tp)) LOCAL->filetime = tp[1].tv_sec;
    }
    flock (fd,LOCK_UN);		/* release flock'ers */
    close (fd);			/* close the file */
  				/* flush the lock file if any */

--- 1002,1010 -----
  #endif
        LOCAL->filetime = tp[1].tv_sec;
    }
+ #ifdef	_SYSV3
+   lockf (fd,F_ULOCK,0);		/* release flock'ers */
+ #else
    flock (fd,LOCK_UN);		/* release flock'ers */
  #endif
    close (fd);			/* close the file */
***************
*** 958,963
      if (!utimes (stream->mailbox,tp)) LOCAL->filetime = tp[1].tv_sec;
    }
    flock (fd,LOCK_UN);		/* release flock'ers */
    close (fd);			/* close the file */
  				/* flush the lock file if any */
    if (lock && *lock) unlink (lock);

--- 1006,1012 -----
    lockf (fd,F_ULOCK,0);		/* release flock'ers */
  #else
    flock (fd,LOCK_UN);		/* release flock'ers */
+ #endif
    close (fd);			/* close the file */
  				/* flush the lock file if any */
    if (lock && *lock) unlink (lock);
***************
*** 989,996
    int recent = stream->recent;
    mail_lock (stream);		/* guard against recursion or pingers */
  				/* open and lock mailbox (shared OK) */
!   if ((fd = bezerk_lock (LOCAL->fname,LOCAL->ld ? O_RDWR : O_RDONLY,NIL,
! 			 lock,LOCK_SH)) < 0) {
  				/* failed, OK for non-ex file? */
      if ((errno != ENOENT) || LOCAL->filesize) {
        sprintf (LOCAL->buf,"Mailbox open failed, aborted: %s",strerror (errno));

--- 1038,1051 -----
    int recent = stream->recent;
    mail_lock (stream);		/* guard against recursion or pingers */
  				/* open and lock mailbox (shared OK) */
!   if ((fd = bezerk_lock (LOCAL->fname,LOCAL->ld ? O_RDWR : O_RDONLY,
! 			NIL, lock,
! #ifdef	_SYSV3
! 			F_LOCK
! #else
! 			LOCK_SH
! #endif
! 			)) < 0) {
  				/* failed, OK for non-ex file? */
      if ((errno != ENOENT) || LOCAL->filesize) {
        sprintf (LOCAL->buf,"Mailbox open failed, aborted: %s",strerror (errno));
***************
*** 1370,1376
    int ivc = 0;
    int i = 0;
    int fd = bezerk_lock (bezerk_file (file,mailbox),O_WRONLY|O_APPEND|O_CREAT,
! 			S_IREAD|S_IWRITE,lock,LOCK_EX);
    if (fd < 0) {			/* got file? */
      sprintf (LOCAL->buf,"Can't open destination mailbox: %s",strerror (errno));
      mm_log (LOCAL->buf,ERROR);

--- 1425,1437 -----
    int ivc = 0;
    int i = 0;
    int fd = bezerk_lock (bezerk_file (file,mailbox),O_WRONLY|O_APPEND|O_CREAT,
! 			S_IREAD|S_IWRITE,lock,
! #ifdef	_SYSV3
! 			F_LOCK
! #else
! 			LOCK_SH
! #endif
! 			);
    if (fd < 0) {			/* got file? */
      sprintf (LOCAL->buf,"Can't open destination mailbox: %s",strerror (errno));
      mm_log (LOCAL->buf,ERROR);
*** ../pine-2.4.old/c-client/dummy.c	Sun Dec 15 22:44:06 1991
--- ./c-client/dummy.c	Sat Apr 11 17:25:01 1992
***************
*** 42,47
  #include <sys/types.h>
  #include <sys/file.h>
  #include <sys/uio.h>
  #include "osdep.h"
  #include "mail.h"
  #include "dummy.h"

--- 42,50 -----
  #include <sys/types.h>
  #include <sys/file.h>
  #include <sys/uio.h>
+ #ifdef	_SYSV3
+ #include <sys/fcntl.h>
+ #endif
  #include "osdep.h"
  #include "mail.h"
  #include "dummy.h"
*** ../pine-2.4.old/c-client/imap2.c	Mon Dec 30 18:31:37 1991
--- ./c-client/imap2.c	Sat Apr 11 17:23:37 1992
***************
*** 47,52
  #include <pwd.h>
  #include <sys/file.h>
  #include <sys/stat.h>
  #endif
  #include "osdep.h"
  #include "mail.h"

--- 47,55 -----
  #include <pwd.h>
  #include <sys/file.h>
  #include <sys/stat.h>
+ #ifdef	_SYSV3
+ #include <sys/fcntl.h>
+ #endif
  #endif
  #include "osdep.h"
  #include "mail.h"
*** ../pine-2.4.old/c-client/misc.c	Sun Dec 15 20:57:27 1991
--- ./c-client/misc.c	Fri Apr 24 15:51:36 1992
***************
*** 44,49

  #include <ctype.h>
  #include <sys/types.h>
  #include "osdep.h"
  #include "mail.h"
  #include "misc.h"

--- 44,53 -----

  #include <ctype.h>
  #include <sys/types.h>
+ #ifdef	_SYSV3
+ #include "regexp.h"
+ #include "regmagic.h"
+ #endif
  #include "osdep.h"
  #include "mail.h"
  #include "misc.h"
***************
*** 244,249
  	char *s;
  	char *pat;
  {
    char tmp[MAILTMPLEN];
    char c;
    char *t = tmp;

--- 248,256 -----
  	char *s;
  	char *pat;
  {
+ #ifdef	_SYSV3
+   regexp *rp;
+ #endif
    char tmp[MAILTMPLEN];
    char c;
    char *t = tmp;
***************
*** 267,271
    *t++ = '$';			/* constrained at both ends */
    *t = '\0';			/* tie off regular expression */
  				/* do the match -- some systems lack recmp */
    return (!re_comp (tmp)) && (re_exec (s) > 0);
  }

--- 274,282 -----
    *t++ = '$';			/* constrained at both ends */
    *t = '\0';			/* tie off regular expression */
  				/* do the match -- some systems lack recmp */
+ #ifdef	_SYSV3
+   return((rp = regcomp(tmp)) && regexec(rp, s));
+ #else
    return (!re_comp (tmp)) && (re_exec (s) > 0);
  #endif
  }
***************
*** 268,271
    *t = '\0';			/* tie off regular expression */
  				/* do the match -- some systems lack recmp */
    return (!re_comp (tmp)) && (re_exec (s) > 0);
  }

--- 278,282 -----
    return((rp = regcomp(tmp)) && regexec(rp, s));
  #else
    return (!re_comp (tmp)) && (re_exec (s) > 0);
+ #endif
  }
*** ../pine-2.4.old/c-client/news.c	Fri Dec 27 20:03:21 1991
--- ./c-client/news.c	Sun Apr 26 14:28:29 1992
***************
*** 45,50
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
  #include "osdep.h"
  #include "mail.h"
  #include "news.h"

--- 45,54 -----
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
+ #ifdef	_SYSV3
+ #include <unistd.h>
+ #include <sys/fcntl.h>
+ #endif
  #include "osdep.h"
  #include "mail.h"
  #include "news.h"
***************
*** 698,703
      mm_log ("Can't update .newsrc",ERROR);
      return;
    }
    flock (fd,LOCK_EX);		/* wait for exclusive access */
    fstat (fd,&sbuf);		/* get size of data */
  				/* ensure enough room */

--- 702,710 -----
      mm_log ("Can't update .newsrc",ERROR);
      return;
    }
+ #ifdef	_SYSV3
+   lockf (fd,F_LOCK,0);		/* wait for exclusive access */
+ #else
    flock (fd,LOCK_EX);		/* wait for exclusive access */
  #endif
    fstat (fd,&sbuf);		/* get size of data */
***************
*** 699,704
      return;
    }
    flock (fd,LOCK_EX);		/* wait for exclusive access */
    fstat (fd,&sbuf);		/* get size of data */
  				/* ensure enough room */
    if (sbuf.st_size >= (LOCAL->buflen + 1))

--- 706,712 -----
    lockf (fd,F_LOCK,0);		/* wait for exclusive access */
  #else
    flock (fd,LOCK_EX);		/* wait for exclusive access */
+ #endif
    fstat (fd,&sbuf);		/* get size of data */
  				/* ensure enough room */
    if (sbuf.st_size >= (LOCAL->buflen + 1))
***************
*** 763,768
    lseek (fd,0,L_SET);		/* go to beginning of file */
    ftruncate (fd,iov[0].iov_len + iov[1].iov_len + iov[2].iov_len);
    writev (fd,iov,3);		/* write the new contents */
    flock (fd,LOCK_UN);		/* unlock the file */
    close (fd);			/* flush .newsrc file */
  }

--- 771,779 -----
    lseek (fd,0,L_SET);		/* go to beginning of file */
    ftruncate (fd,iov[0].iov_len + iov[1].iov_len + iov[2].iov_len);
    writev (fd,iov,3);		/* write the new contents */
+ #ifdef	_SYSV3
+   lockf (fd,F_ULOCK,0);		/* unlock the file */
+ #else
    flock (fd,LOCK_UN);		/* unlock the file */
  #endif
    close (fd);			/* flush .newsrc file */
***************
*** 764,769
    ftruncate (fd,iov[0].iov_len + iov[1].iov_len + iov[2].iov_len);
    writev (fd,iov,3);		/* write the new contents */
    flock (fd,LOCK_UN);		/* unlock the file */
    close (fd);			/* flush .newsrc file */
  }


--- 775,781 -----
    lockf (fd,F_ULOCK,0);		/* unlock the file */
  #else
    flock (fd,LOCK_UN);		/* unlock the file */
+ #endif
    close (fd);			/* flush .newsrc file */
  }

***************
*** 804,810
    if (!news_getsequence (stream,s,sequence)) return NIL;
  				/* get destination mailbox */
    if ((dfd = bezerk_lock (bezerk_file (tmp,mailbox),O_WRONLY|O_APPEND|O_CREAT,
! 			  S_IREAD|S_IWRITE,lock,LOCK_EX)) < 0) {
      sprintf (LOCAL->buf,"Can't open destination mailbox: %s",strerror (errno));
      mm_log (LOCAL->buf,ERROR);
      return NIL;

--- 816,828 -----
    if (!news_getsequence (stream,s,sequence)) return NIL;
  				/* get destination mailbox */
    if ((dfd = bezerk_lock (bezerk_file (tmp,mailbox),O_WRONLY|O_APPEND|O_CREAT,
! 			S_IREAD|S_IWRITE,lock,
! #ifdef	_SYSV3
! 			F_LOCK
! #else
! 			LOCK_EX
! #endif
! 			)) < 0) {
      sprintf (LOCAL->buf,"Can't open destination mailbox: %s",strerror (errno));
      mm_log (LOCAL->buf,ERROR);
      return NIL;
*** ../pine-2.4.old/c-client/tenex.c	Sun Dec 15 22:37:58 1991
--- ./c-client/tenex.c	Sun Apr 26 14:31:46 1992
***************
*** 45,50
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
  #include "osdep.h"
  #include "mail.h"
  #include "tenex.h"

--- 45,54 -----
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
+ #ifdef	_SYSV3
+ #include <unistd.h>
+ #include <sys/fcntl.h>
+ #endif
  #include "osdep.h"
  #include "mail.h"
  #include "tenex.h"
***************
*** 235,240
    LOCAL->host = cpystr ((host_name = gethostbyname (tmp)) ?
  			host_name->h_name : tmp);
  				/* bind and lock the file */
    flock (LOCAL->fd = fd,LOCK_SH);
    LOCAL->filesize = 0;		/* initialize parsed file size */
    for (i = 0; i < MAXMESSAGES; ++i) LOCAL->msgs[i] = NIL;

--- 239,247 -----
    LOCAL->host = cpystr ((host_name = gethostbyname (tmp)) ?
  			host_name->h_name : tmp);
  				/* bind and lock the file */
+ #ifdef	_SYSV3
+   lockf (LOCAL->fd = fd,F_LOCK,0);
+ #else
    flock (LOCAL->fd = fd,LOCK_SH);
  #endif
    LOCAL->filesize = 0;		/* initialize parsed file size */
***************
*** 236,241
  			host_name->h_name : tmp);
  				/* bind and lock the file */
    flock (LOCAL->fd = fd,LOCK_SH);
    LOCAL->filesize = 0;		/* initialize parsed file size */
    for (i = 0; i < MAXMESSAGES; ++i) LOCAL->msgs[i] = NIL;
    LOCAL->text = NIL;		/* no text yet */

--- 243,249 -----
    lockf (LOCAL->fd = fd,F_LOCK,0);
  #else
    flock (LOCAL->fd = fd,LOCK_SH);
+ #endif
    LOCAL->filesize = 0;		/* initialize parsed file size */
    for (i = 0; i < MAXMESSAGES; ++i) LOCAL->msgs[i] = NIL;
    LOCAL->text = NIL;		/* no text yet */
***************
*** 259,264
    int i;
    if (stream && LOCAL) {	/* only if a file is open */
      if (LOCAL->host) fs_give ((void **) &LOCAL->host);
      flock (LOCAL->fd,LOCK_UN);	/* unlock local file */
      close (LOCAL->fd);		/* close the local file */
  				/* free local cache */

--- 267,275 -----
    int i;
    if (stream && LOCAL) {	/* only if a file is open */
      if (LOCAL->host) fs_give ((void **) &LOCAL->host);
+ #ifdef	_SYSV3
+     lockf (LOCAL->fd,F_ULOCK,0);	/* unlock local file */
+ #else
      flock (LOCAL->fd,LOCK_UN);	/* unlock local file */
  #endif
      close (LOCAL->fd);		/* close the local file */
***************
*** 260,265
    if (stream && LOCAL) {	/* only if a file is open */
      if (LOCAL->host) fs_give ((void **) &LOCAL->host);
      flock (LOCAL->fd,LOCK_UN);	/* unlock local file */
      close (LOCAL->fd);		/* close the local file */
  				/* free local cache */
      for (i = 0; i < MAXMESSAGES; ++i)

--- 271,277 -----
      lockf (LOCAL->fd,F_ULOCK,0);	/* unlock local file */
  #else
      flock (LOCAL->fd,LOCK_UN);	/* unlock local file */
+ #endif
      close (LOCAL->fd);		/* close the local file */
  				/* free local cache */
      for (i = 0; i < MAXMESSAGES; ++i)
***************
*** 611,616
  
      mm_critical (stream);	/* go critical */
  				/* calculate name of bezerk file */
      sprintf (LOCAL->buf,"/usr/spool/mail/%s",getpwuid (geteuid ())->pw_name);
      stat (LOCAL->buf,&sbuf);	/* see if anything there */
  				/* non-empty and we can lock our file? */

--- 623,631 -----
  
      mm_critical (stream);	/* go critical */
  				/* calculate name of bezerk file */
+ #ifdef	_SYSV3
+     sprintf (LOCAL->buf,"/usr/mail/%s",getpwuid (geteuid ())->pw_name);
+ #else
      sprintf (LOCAL->buf,"/usr/spool/mail/%s",getpwuid (geteuid ())->pw_name);
  #endif
      stat (LOCAL->buf,&sbuf);	/* see if anything there */
***************
*** 612,617
      mm_critical (stream);	/* go critical */
  				/* calculate name of bezerk file */
      sprintf (LOCAL->buf,"/usr/spool/mail/%s",getpwuid (geteuid ())->pw_name);
      stat (LOCAL->buf,&sbuf);	/* see if anything there */
  				/* non-empty and we can lock our file? */
      if (sbuf.st_size && !flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {

--- 627,633 -----
      sprintf (LOCAL->buf,"/usr/mail/%s",getpwuid (geteuid ())->pw_name);
  #else
      sprintf (LOCAL->buf,"/usr/spool/mail/%s",getpwuid (geteuid ())->pw_name);
+ #endif
      stat (LOCAL->buf,&sbuf);	/* see if anything there */
  				/* non-empty and we can lock our file? */
      if (sbuf.st_size &&
***************
*** 614,620
      sprintf (LOCAL->buf,"/usr/spool/mail/%s",getpwuid (geteuid ())->pw_name);
      stat (LOCAL->buf,&sbuf);	/* see if anything there */
  				/* non-empty and we can lock our file? */
!     if (sbuf.st_size && !flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {
        fstat (LOCAL->fd,&sbuf);	/* yes, get current file size */
  				/* sizes match and can get bezerk mailbox? */
        if ((sbuf.st_size == LOCAL->filesize) &&

--- 630,641 -----
  #endif
      stat (LOCAL->buf,&sbuf);	/* see if anything there */
  				/* non-empty and we can lock our file? */
!     if (sbuf.st_size &&
! #ifdef	_SYSV3
!      !lockf (LOCAL->fd,F_TLOCK,0)) {
! #else
!      !flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {
! #endif
        fstat (LOCAL->fd,&sbuf);	/* yes, get current file size */
  				/* sizes match and can get bezerk mailbox? */
        if ((sbuf.st_size == LOCAL->filesize) &&
***************
*** 645,650
        }
        if (bezerk) mail_close (bezerk);
      }
      flock (LOCAL->fd,LOCK_SH);	/* back to shared access */
      mm_nocritical (stream);	/* release critical */
    }

--- 666,674 -----
        }
        if (bezerk) mail_close (bezerk);
      }
+ #ifdef	_SYSV3
+     lockf (LOCAL->fd,F_ULOCK,0);	/* back to shared access */
+ #else
      flock (LOCAL->fd,LOCK_SH);	/* back to shared access */
  #endif
      mm_nocritical (stream);	/* release critical */
***************
*** 646,651
        if (bezerk) mail_close (bezerk);
      }
      flock (LOCAL->fd,LOCK_SH);	/* back to shared access */
      mm_nocritical (stream);	/* release critical */
    }
  #endif

--- 670,676 -----
      lockf (LOCAL->fd,F_ULOCK,0);	/* back to shared access */
  #else
      flock (LOCAL->fd,LOCK_SH);	/* back to shared access */
+ #endif
      mm_nocritical (stream);	/* release critical */
    }
  #endif
***************
*** 691,696
      return;
    }
  				/* get exclusive access */
    if (flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {
      flock (LOCAL->fd,LOCK_SH);	/* recover previous lock */
      mm_log ("Expunge rejected: mailbox locked",ERROR);

--- 716,724 -----
      return;
    }
  				/* get exclusive access */
+ #ifdef	_SYSV3
+   if (lockf (LOCAL->fd,F_TLOCK,0)) {
+ #else
    if (flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {
      flock (LOCAL->fd,LOCK_SH);	/* recover previous lock */
  #endif
***************
*** 693,698
  				/* get exclusive access */
    if (flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {
      flock (LOCAL->fd,LOCK_SH);	/* recover previous lock */
      mm_log ("Expunge rejected: mailbox locked",ERROR);
      return;
    }

--- 721,727 -----
  #else
    if (flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {
      flock (LOCAL->fd,LOCK_SH);	/* recover previous lock */
+ #endif
      mm_log ("Expunge rejected: mailbox locked",ERROR);
      return;
    }
***************
*** 740,745
  				/* notify upper level of new mailbox size */
    mail_exists (stream,stream->nmsgs);
    mail_recent (stream,recent);
    flock (LOCAL->fd,LOCK_SH);	/* allow sharers again */
  }
  

--- 769,777 -----
  				/* notify upper level of new mailbox size */
    mail_exists (stream,stream->nmsgs);
    mail_recent (stream,recent);
+ #ifdef	_SYSV3
+   lockf (LOCAL->fd,F_ULOCK,0);	/* allow sharers again */
+ #else
    flock (LOCAL->fd,LOCK_SH);	/* allow sharers again */
  #endif
  }
***************
*** 741,746
    mail_exists (stream,stream->nmsgs);
    mail_recent (stream,recent);
    flock (LOCAL->fd,LOCK_SH);	/* allow sharers again */
  }
  
  /* Tenex mail copy message(s)

--- 773,779 -----
    lockf (LOCAL->fd,F_ULOCK,0);	/* allow sharers again */
  #else
    flock (LOCAL->fd,LOCK_SH);	/* allow sharers again */
+ #endif
  }
  
  /* Tenex mail copy message(s)
***************
*** 1035,1040
      return NIL;
    }
    mm_critical (stream);		/* go critical */
    flock (fd,LOCK_EX);
    fstat (fd,&sbuf);		/* get current file size */
  				/* for each requested message */

--- 1068,1076 -----
      return NIL;
    }
    mm_critical (stream);		/* go critical */
+ #ifdef	_SYSV3
+   lockf (fd,F_LOCK,0);
+ #else
    flock (fd,LOCK_EX);
  #endif
    fstat (fd,&sbuf);		/* get current file size */
***************
*** 1036,1041
    }
    mm_critical (stream);		/* go critical */
    flock (fd,LOCK_EX);
    fstat (fd,&sbuf);		/* get current file size */
  				/* for each requested message */
    while (i < stream->nmsgs) if (s[i++]) {

--- 1072,1078 -----
    lockf (fd,F_LOCK,0);
  #else
    flock (fd,LOCK_EX);
+ #endif
    fstat (fd,&sbuf);		/* get current file size */
  				/* for each requested message */
    while (i < stream->nmsgs) if (s[i++]) {
***************
*** 1056,1061
      }
    }
    fsync (fd);			/* force out the update */
    flock (fd,LOCK_UN);		/* unlock mailbox */
    close (fd);			/* close the file */
    mm_nocritical (stream);	/* release critical */

--- 1093,1101 -----
      }
    }
    fsync (fd);			/* force out the update */
+ #ifdef	_SYSV3
+   lockf (fd,F_ULOCK,0);		/* unlock mailbox */
+ #else
    flock (fd,LOCK_UN);		/* unlock mailbox */
  #endif
    close (fd);			/* close the file */
***************
*** 1057,1062
    }
    fsync (fd);			/* force out the update */
    flock (fd,LOCK_UN);		/* unlock mailbox */
    close (fd);			/* close the file */
    mm_nocritical (stream);	/* release critical */
    return !j;

--- 1097,1103 -----
    lockf (fd,F_ULOCK,0);		/* unlock mailbox */
  #else
    flock (fd,LOCK_UN);		/* unlock mailbox */
+ #endif
    close (fd);			/* close the file */
    mm_nocritical (stream);	/* release critical */
    return !j;
*** ../pine-2.4.old/pico/os_unix.c	Fri Feb 21 18:12:25 1992
--- ./pico/os_unix.c	Fri Apr 24 10:42:47 1992
***************
*** 44,50
  #include        "edef.h"
  #include        "pico.h"

! #include        <sgtty.h>        /* for stty/gtty functions */

  struct  sgttyb  ostate;          /* saved tty state */
  struct  sgttyb  nstate;          /* values for editor mode */

--- 44,51 -----
  #include        "edef.h"
  #include        "pico.h"

! #ifdef	_SYSV3
! #include <termio.h>

  struct termio	ostate;		/* saved tty state */
  struct termio	nstate;		/* values for editor mode */
***************
*** 46,53

  #include        <sgtty.h>        /* for stty/gtty functions */

! struct  sgttyb  ostate;          /* saved tty state */
! struct  sgttyb  nstate;          /* values for editor mode */
  struct tchars	otchars;	/* Saved terminal special character set */
  struct tchars	ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  				/* A lot of nothing */

--- 47,66 -----
  #ifdef	_SYSV3
  #include <termio.h>

! struct termio	ostate;		/* saved tty state */
! struct termio	nstate;		/* values for editor mode */
!
! #ifdef	TIOCGWINSZ
! #include <sys/types.h>		/* for stream.h */
! #include <sys/stream.h>		/* for ptem.h */
! #include <sys/ptem.h>		/* for struct winsize */
! #endif
!
! #else	/* !_SYSV3 */
! #include <sgtty.h>
!
! struct  sgttyb  ostate;		/* saved tty state */
! struct  sgttyb  nstate;		/* values for editor mode */
  struct tchars	otchars;	/* Saved terminal special character set */
  struct tchars	ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  				/* A lot of nothing */
***************
*** 51,56
  struct tchars	otchars;	/* Saved terminal special character set */
  struct tchars	ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  				/* A lot of nothing */

  extern	int rtfrmshell();	/* return from suspended shell */


--- 64,70 -----
  struct tchars	otchars;	/* Saved terminal special character set */
  struct tchars	ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  				/* A lot of nothing */
+ #endif	/* _SYSV3 */

  extern	int rtfrmshell();	/* return from suspended shell */

***************
*** 75,80
   */
  ttopen()
  {
  	if(!for_pine){
  	    ioctl(0, TIOCGETP, &ostate);	/* save old state */
  	    ioctl(0, TIOCGETP, &nstate);	/* get base of new state */

--- 89,95 -----
   */
  ttopen()
  {
+
  	if(!for_pine){
  #ifdef	_SYSV3
  	    ioctl(0, TCGETA, &ostate);
***************
*** 76,81
  ttopen()
  {
  	if(!for_pine){
  	    ioctl(0, TIOCGETP, &ostate);	/* save old state */
  	    ioctl(0, TIOCGETP, &nstate);	/* get base of new state */
  	    nstate.sg_flags |= RAW;

--- 91,108 -----
  {

  	if(!for_pine){
+ #ifdef	_SYSV3
+ 	    ioctl(0, TCGETA, &ostate);
+
+ 	    nstate = ostate;
+ 	    nstate.c_oflag &= ~ONLCR;
+ 	    nstate.c_lflag &= ~(ICANON | ECHO);
+
+ 	    nstate.c_cc[VMIN] = 1;
+ 	    nstate.c_cc[VTIME] = 0;
+
+ 	    ioctl(0, TCSETAW, &nstate);
+ #else
  	    ioctl(0, TIOCGETP, &ostate);	/* save old state */
  	    ioctl(0, TIOCGETP, &nstate);	/* get base of new state */
  	    nstate.sg_flags |= RAW;
***************
*** 84,89

  	    ioctl(0, TIOCGETC, &otchars); 	/* Save old characters */
  	    ioctl(0, TIOCSETC, &ntchars); 	/* put new character into K */
  	}

  	signal(SIGHUP, (SIGTYPE *)do_hup_signal); /* deal with SIGHUP */

--- 111,117 -----

  	    ioctl(0, TIOCGETC, &otchars); 	/* Save old characters */
  	    ioctl(0, TIOCSETC, &ntchars); 	/* put new character into K */
+ #endif
  	}

  	signal(SIGHUP, (SIGTYPE *)do_hup_signal); /* deal with SIGHUP */
***************
*** 110,115
  	signal(SIGWINCH, SIG_DFL);
      }
      else{
  	ioctl(0, TIOCSETP, &ostate);
  	ioctl(0, TIOCSETC, &otchars);
      }

--- 138,146 -----
  	signal(SIGWINCH, SIG_DFL);
      }
      else{
+ #ifdef	_SYSV3
+ 	ioctl(0, TCSETAW, &ostate);
+ #else
  	ioctl(0, TIOCSETP, &ostate);
  	ioctl(0, TIOCSETC, &otchars);
  #endif
***************
*** 112,117
      else{
  	ioctl(0, TIOCSETP, &ostate);
  	ioctl(0, TIOCSETC, &otchars);
      }
  }


--- 143,149 -----
  #else
  	ioctl(0, TIOCSETP, &ostate);
  	ioctl(0, TIOCSETC, &otchars);
+ #endif
      }
  }

*** ../pine-2.4.old/pico/tcap.c	Fri Feb 21 18:01:55 1992
--- ./pico/tcap.c	Fri Apr 24 15:54:21 1992
***************
*** 44,50
  #include	"osdep.h"

  #if TERMCAP
- #include <sys/ioctl.h>
  #include        "pico.h"
  #include        <signal.h>
  #include        <sgtty.h>

--- 44,49 -----
  #include	"osdep.h"

  #if TERMCAP
  #include        "pico.h"
  #include        <signal.h>
  #ifdef	_SYSV3
***************
*** 47,52
  #include <sys/ioctl.h>
  #include        "pico.h"
  #include        <signal.h>
  #include        <sgtty.h>
  #include        <sys/ttydev.h>


--- 46,56 -----
  #if TERMCAP
  #include        "pico.h"
  #include        <signal.h>
+ #ifdef	_SYSV3
+ #include        <termio.h>	/* for stty/gtty functions */
+ #include	<sys/stream.h>	/* for ptem.h */
+ #include	<sys/ptem.h>	/* for struct winsize */
+ #else
  #include        <sgtty.h>
  #include	<sys/ioctl.h>
  #include        <sys/ttydev.h>
***************
*** 48,53
  #include        "pico.h"
  #include        <signal.h>
  #include        <sgtty.h>
  #include        <sys/ttydev.h>

  #define NROW    24

--- 52,58 -----
  #include	<sys/ptem.h>	/* for struct winsize */
  #else
  #include        <sgtty.h>
+ #include	<sys/ioctl.h>
  #include        <sys/ttydev.h>
  #endif

***************
*** 49,54
  #include        <signal.h>
  #include        <sgtty.h>
  #include        <sys/ttydev.h>

  #define NROW    24
  #define NCOL    80

--- 54,60 -----
  #include        <sgtty.h>
  #include	<sys/ioctl.h>
  #include        <sys/ttydev.h>
+ #endif

  #define NROW    24
  #define NCOL    80
***************
*** 120,125
          char *tv_stype;
          char *initstrng = "";
          char err_str[72];
          struct  sgttyb tty;

  #ifdef TIOCGWINSZ

--- 126,134 -----
          char *tv_stype;
          char *initstrng = "";
          char err_str[72];
+ #ifdef	_SYSV3
+ 	struct	termio tty;
+ #else
          struct  sgttyb tty;
  #endif

***************
*** 121,126
          char *initstrng = "";
          char err_str[72];
          struct  sgttyb tty;

  #ifdef TIOCGWINSZ
          struct winsize win;

--- 130,136 -----
  	struct	termio tty;
  #else
          struct  sgttyb tty;
+ #endif

  #ifdef TIOCGWINSZ
          struct winsize win;
***************
*** 137,142
           * determine the terminal's communication speed and decide
           * if we need to do optimization ...
           */
          if(ioctl(1, TIOCGETP, &tty) == 0){
              if(tty.sg_ospeed < B9600)
                  optimize = TRUE;

--- 147,158 -----
           * determine the terminal's communication speed and decide
           * if we need to do optimization ...
           */
+ #ifdef	_SYSV3
+         if(ioctl(1, TCGETA, &tty) == 0){
+             if(tty.c_cflag & CBAUD < B9600)
+                 optimize = TRUE;
+         }
+ #else
          if(ioctl(1, TIOCGETP, &tty) == 0){
              if(tty.sg_ospeed < B9600)
                  optimize = TRUE;
***************
*** 141,146
              if(tty.sg_ospeed < B9600)
                  optimize = TRUE;
          }

          if ((tv_stype = getenv("TERM")) == NULL){
  	    if(for_pine){

--- 157,163 -----
              if(tty.sg_ospeed < B9600)
                  optimize = TRUE;
          }
+ #endif

          if ((tv_stype = getenv("TERM")) == NULL){
  	    if(for_pine){
***************
*** 570,573
  {
  }

! #endif TERMCAP

--- 587,590 -----
  {
  }

! #endif	/* TERMCAP */
*** ../pine-2.4.old/pine/addrbook.c	Mon Jan 27 20:08:18 1992
--- ./pine/addrbook.c	Fri Apr 24 15:57:40 1992
***************
*** 115,121
  static int   init_addr_disp(AdrBk_Entry  *, char *);
  static void  paint_line(int, AddrScrn_Disp *, int, int);

! #else ANSI

  static int   addr_book_delete();
  static int   add_add();

--- 115,121 -----
  static int   init_addr_disp(AdrBk_Entry  *, char *);
  static void  paint_line(int, AddrScrn_Disp *, int, int);

! #else	/* ANSI */

  static int   addr_book_delete();
  static int   add_add();
***************
*** 132,138
  static int   init_addr_disp();
  static void  paint_line();

! #endif ANSI


  /*

--- 132,138 -----
  static int   init_addr_disp();
  static void  paint_line();

! #endif	/* ANSI */


  /*
***************
*** 139,146
    HEADER_LINES is the number of lines in the header
    FOOTER_LINES is the number of lines in the footer
   */
! #define ADDR_BOOK_HEADER_LINES   1
! #define ADDR_BOOK_FOOTER_LINES   3




--- 139,146 -----
    HEADER_LINES is the number of lines in the header
    FOOTER_LINES is the number of lines in the footer
   */
! #define	ADDR_BOOK_HEADER_LINES   1
! #define	ADDR_BOOK_FOOTER_LINES   3



***************
*** 556,562
      ps_global = pine_state;
      addr_book(pine_state->prev_screen == compose_screen);
      pine_state->prev_screen = addr_book_screen;
! #ifdef ANSI
      pine_state->next_screen = (void (*)(struct pine *))NULL;
  #else
      pine_state->next_screen = (void (*)())NULL;

--- 556,562 -----
      ps_global = pine_state;
      addr_book(pine_state->prev_screen == compose_screen);
      pine_state->prev_screen = addr_book_screen;
! #ifdef	ANSI
      pine_state->next_screen = (void (*)(struct pine *))NULL;
  #else
      pine_state->next_screen = (void (*)())NULL;
*** ../pine-2.4.old/pine/compile.c	Fri Feb 28 16:22:52 1992
--- ./pine/compile.c	Sun Apr 26 15:48:51 1992
***************
*** 1,1
! int COMPILE= 53 ;

--- 1,1 -----
! int COMPILE= 1 ;
*** ../pine-2.4.old/pine/folder.c	Mon Feb 24 17:44:01 1992
--- ./pine/folder.c	Fri Apr 24 15:59:30 1992
***************
*** 107,113
  static struct  folder_display
                *create_folder_display(char **, int, unsigned char *);

! #else ANSI
  static char   *add_new_folder();
  static char   *rename_folder();
  static         delete_folder();

--- 107,113 -----
  static struct  folder_display
                *create_folder_display(char **, int, unsigned char *);

! #else	/* ANSI */
  static char   *add_new_folder();
  static char   *rename_folder();
  static         delete_folder();
***************
*** 126,132
  static struct  folder_display
                *create_folder_display();

! #endif ANSI


  static struct key_menu folder_keymenu0 =

--- 126,132 -----
  static struct  folder_display
                *create_folder_display();

! #endif	/* ANSI */


  static struct key_menu folder_keymenu0 =
*** ../pine-2.4.old/pine/other.c	Mon Jan 27 20:07:09 1992
--- ./pine/other.c	Fri Apr 24 16:02:14 1992
***************
*** 60,66

  char *crypt(), *byte_string();

! #ifdef ANSI
  static void draw_other_body(int, int, int, int, int);
  static void draw_klocked_body(char *, char *);
  #else  ANSI

--- 60,66 -----

  char *crypt(), *byte_string();

! #ifdef	ANSI
  static void draw_other_body(int, int, int, int, int);
  static void draw_klocked_body(char *, char *);
  #else	/* ANSI */
***************
*** 63,69
  #ifdef ANSI
  static void draw_other_body(int, int, int, int, int);
  static void draw_klocked_body(char *, char *);
! #else  ANSI
  static void draw_other_body();
  static void draw_klocked_body();
  #endif ANSI

--- 63,69 -----
  #ifdef	ANSI
  static void draw_other_body(int, int, int, int, int);
  static void draw_klocked_body(char *, char *);
! #else	/* ANSI */
  static void draw_other_body();
  static void draw_klocked_body();
  #endif	/* ANSI */
***************
*** 66,72
  #else  ANSI
  static void draw_other_body();
  static void draw_klocked_body();
! #endif ANSI

  static void redraw_kl_body();
  static void redraw_klocked_body();

--- 66,72 -----
  #else	/* ANSI */
  static void draw_other_body();
  static void draw_klocked_body();
! #endif	/* ANSI */

  static void redraw_kl_body();
  static void redraw_klocked_body();
***************
*** 259,265
              dump_memlog(0);
              q_status_message(3,4, "Memory stats dumped");
              break;
! #endif MEMLOG


              /*--------- SUSPEND PINE ----------*/

--- 259,265 -----
              dump_memlog(0);
              q_status_message(3,4, "Memory stats dumped");
              break;
! #endif	/* MEMLOG */


              /*--------- SUSPEND PINE ----------*/
*** ../pine-2.4.old/pine/pine-use.c	Mon Mar  2 00:25:37 1992
--- ./pine/pine-use.c	Thu Apr 23 10:50:02 1992
***************
*** 139,144
      FILE *f;
      char buf[20480];

      sprintf(buf, "/usr/spool/mail/%s",user);

      f = fopen(buf, "r");

--- 139,147 -----
      FILE *f;
      char buf[20480];

+ #ifdef	_SYSV3
+     sprintf(buf, "/usr/mail/%s",user);
+ #else
      sprintf(buf, "/usr/spool/mail/%s",user);
  #endif

***************
*** 140,145
      char buf[20480];

      sprintf(buf, "/usr/spool/mail/%s",user);

      f = fopen(buf, "r");
      if(f  == NULL)

--- 143,149 -----
      sprintf(buf, "/usr/mail/%s",user);
  #else
      sprintf(buf, "/usr/spool/mail/%s",user);
+ #endif

      f = fopen(buf, "r");
      if(f  == NULL)
*** ../pine-2.4.old/pine/pine.h	Thu Feb 20 09:39:38 1992
--- ./pine/pine.h	Fri Apr 24 11:00:46 1992
***************
*** 954,960
   are in osdep.c as part of the imap client. They call fatal() with a string
   if malloc fails.
    -------*/
! #ifdef DYN
  char *fs_get();
  #else
  void *fs_get();

--- 954,960 -----
   are in osdep.c as part of the imap client. They call fatal() with a string
   if malloc fails.
    -------*/
! #if	(defined DYN) || (defined _SYSV3)
  char *fs_get();
  #else
  void *fs_get();
*** ../pine-2.4.old/pine/send.c	Tue Feb 25 13:54:07 1992
--- ./pine/send.c	Thu Apr 16 17:44:20 1992
***************
*** 509,515
              /* Back out append */
              strcpy(filename, malloced_fcc);
              expand_foldername(filename);
!             truncate(filename, start_of_append);
              /*---- go back to composer ----*/
  	} else {
              /*--- Mail sent OK, get out of here ---*/

--- 509,515 -----
              /* Back out append */
              strcpy(filename, malloced_fcc);
              expand_foldername(filename);
! 	    truncate(filename, start_of_append);
              /*---- go back to composer ----*/
  	} else {
              /*--- Mail sent OK, get out of here ---*/
***************
*** 721,726

      dprint(9, (debugfile, "Command: \"%s\"\n", command));

      if((pid = vfork()) == 0){
          execl("/bin/sh", "sh", "-c", command, 0);
          _exit(-1);

--- 721,729 -----

      dprint(9, (debugfile, "Command: \"%s\"\n", command));

+ #ifdef	_SYSV3
+     if((pid = fork()) == 0){
+ #else
      if((pid = vfork()) == 0){
  #endif
          execl("/bin/sh", "sh", "-c", command, 0);
***************
*** 722,727
      dprint(9, (debugfile, "Command: \"%s\"\n", command));

      if((pid = vfork()) == 0){
          execl("/bin/sh", "sh", "-c", command, 0);
          _exit(-1);
      }

--- 725,731 -----
      if((pid = fork()) == 0){
  #else
      if((pid = vfork()) == 0){
+ #endif
          execl("/bin/sh", "sh", "-c", command, 0);
          _exit(-1);
      }
*** ../pine-2.4.old/pine/ttyin.c	Mon Jan 27 20:05:57 1992
--- ./pine/ttyin.c	Fri Apr 24 16:06:26 1992
***************
*** 59,65

  #ifndef DOS  /* Beginning of giant switch between UNIX and DOS input driver */

! #ifdef HAVE_TERMIO
  #include <termio.h>

  struct termio _raw_tty,

--- 59,65 -----

  #ifndef DOS  /* Beginning of giant switch between UNIX and DOS input driver */

! #ifdef	_SYSV3
  #include <termio.h>

  #ifdef	TIOCGWINSZ
***************
*** 62,70
  #ifdef HAVE_TERMIO
  #include <termio.h>

! struct termio _raw_tty,
!               _original_tty;
! #else

  #include <sgtty.h>


--- 62,72 -----
  #ifdef	_SYSV3
  #include <termio.h>

! #ifdef	TIOCGWINSZ
! #include <sys/types.h>	/* for stream.h */
! #include <sys/stream.h>	/* for ptem.h */
! #include <sys/ptem.h>	/* for struct winsize */
! #endif

  #include <sys/time.h>	/* for struct timeval */

***************
*** 66,71
                _original_tty;
  #else

  #include <sgtty.h>

  static struct sgttyb  _raw_tty,     _original_tty;

--- 68,78 -----
  #include <sys/ptem.h>	/* for struct winsize */
  #endif

+ #include <sys/time.h>	/* for struct timeval */
+
+ static struct	termio _raw_tty, _original_tty;
+
+ #else	/* !_SYSV3 */
  #include <sgtty.h>

  static struct sgttyb  _raw_tty,     _original_tty;
***************
*** 71,77
  static struct sgttyb  _raw_tty,     _original_tty;
  static struct ltchars _raw_ltchars, _original_ltchars;
  static struct tchars  _raw_tchars,  _original_tchars;
- #endif

  #define STDIN_FD 0


--- 78,83 -----
  static struct sgttyb  _raw_tty,     _original_tty;
  static struct ltchars _raw_ltchars, _original_ltchars;
  static struct tchars  _raw_tchars,  _original_tchars;

  #endif	/* !_SYSV3 */

***************
*** 73,78
  static struct tchars  _raw_tchars,  _original_tchars;
  #endif

  #define STDIN_FD 0

  /*----------------------------------------------------------------------

--- 79,86 -----
  static struct ltchars _raw_ltchars, _original_ltchars;
  static struct tchars  _raw_tchars,  _original_tchars;

+ #endif	/* !_SYSV3 */
+
  #define STDIN_FD 0

  /*----------------------------------------------------------------------
***************
*** 135,142

      if (state == 0 && _inraw) {
          /*----- restore state to original -----*/
! #ifdef HAVE_TERMIO
!         if(ioctl(STDIN_FD, TCSETAW, &_original_tty) < 0)
            return(-1);
  #else
  	if(ioctl(STDIN_FD, TIOCSETP, &_original_tty) < 0)

--- 143,150 -----

      if (state == 0 && _inraw) {
          /*----- restore state to original -----*/
! #ifdef	_SYSV3
! 	if(ioctl(STDIN_FD, TCSETAW, &_original_tty) < 0)
            return(-1);
  #else
  	if(ioctl(STDIN_FD, TIOCSETP, &_original_tty) < 0)
***************
*** 148,155
      } else if (state == 1 && ! _inraw) {
          /*----- Go into raw mode (cbreak actually) ----*/

! #ifdef HAVE_TERMIO
!         if(ioctl(STDIN_FD, TCGETA, &_original_tty) < 0)
            return(-1);
  	(void) ioctl(STDIN_FD, TCGETA, &_raw_tty);    /** again! **/


--- 156,163 -----
      } else if (state == 1 && ! _inraw) {
          /*----- Go into raw mode (cbreak actually) ----*/

! #ifdef	_SYSV3
! 	if(ioctl(STDIN_FD, TCGETA, &_original_tty) < 0)
            return(-1);

  	_raw_tty = _original_tty;
***************
*** 151,157
  #ifdef HAVE_TERMIO
          if(ioctl(STDIN_FD, TCGETA, &_original_tty) < 0)
            return(-1);
- 	(void) ioctl(STDIN_FD, TCGETA, &_raw_tty);    /** again! **/

  	_raw_tty.c_lflag &= ~(ICANON | ECHO);	/* noecho raw mode  */


--- 159,164 -----
  #ifdef	_SYSV3
  	if(ioctl(STDIN_FD, TCGETA, &_original_tty) < 0)
            return(-1);

  	_raw_tty = _original_tty;
  	_raw_tty.c_oflag &= ~ONLCR;
***************
*** 153,159
            return(-1);
  	(void) ioctl(STDIN_FD, TCGETA, &_raw_tty);    /** again! **/

! 	_raw_tty.c_lflag &= ~(ICANON | ECHO);	/* noecho raw mode  */

  	_raw_tty.c_cc[VMIN] = '\01';  /* minimum # of chars to queue  */
  	_raw_tty.c_cc[VTIME] = '\0'; /* minimum time to wait for input */

--- 160,168 -----
  	if(ioctl(STDIN_FD, TCGETA, &_original_tty) < 0)
            return(-1);

! 	_raw_tty = _original_tty;
! 	_raw_tty.c_oflag &= ~ONLCR;
! 	_raw_tty.c_lflag &= ~(ICANON | ECHO);

  	_raw_tty.c_cc[VMIN] = 1;	/* minimum # of chars to queue  */
  	_raw_tty.c_cc[VTIME] = 0;	/* minimum time to wait for input */
***************
*** 155,163

  	_raw_tty.c_lflag &= ~(ICANON | ECHO);	/* noecho raw mode  */

! 	_raw_tty.c_cc[VMIN] = '\01';  /* minimum # of chars to queue  */
! 	_raw_tty.c_cc[VTIME] = '\0'; /* minimum time to wait for input */
! 	(void) ioctl(STDIN_FD, TCSETAW, &_raw_tty);

  #else/* HAVE_TERMIO */
          if(ioctl(STDIN_FD, TIOCGETP, &_original_tty) < 0)

--- 164,171 -----
  	_raw_tty.c_oflag &= ~ONLCR;
  	_raw_tty.c_lflag &= ~(ICANON | ECHO);

! 	_raw_tty.c_cc[VMIN] = 1;	/* minimum # of chars to queue  */
! 	_raw_tty.c_cc[VTIME] = 0;	/* minimum time to wait for input */

  	(void) ioctl(STDIN_FD, TCSETAW, &_raw_tty);
  #else
***************
*** 159,165
  	_raw_tty.c_cc[VTIME] = '\0'; /* minimum time to wait for input */
  	(void) ioctl(STDIN_FD, TCSETAW, &_raw_tty);

! #else/* HAVE_TERMIO */
          if(ioctl(STDIN_FD, TIOCGETP, &_original_tty) < 0)
            return(-1);
  	(void) ioctl(STDIN_FD, TIOCGETP, &_raw_tty);

--- 167,174 -----
  	_raw_tty.c_cc[VMIN] = 1;	/* minimum # of chars to queue  */
  	_raw_tty.c_cc[VTIME] = 0;	/* minimum time to wait for input */

! 	(void) ioctl(STDIN_FD, TCSETAW, &_raw_tty);
! #else
          if(ioctl(STDIN_FD, TIOCGETP, &_original_tty) < 0)
            return(-1);
  	(void) ioctl(STDIN_FD, TIOCGETP, &_raw_tty);
***************
*** 570,576
  }


! #else DOS /* Middle of giant siwtch UNX and DOS input drivers */




--- 579,585 -----
  }


! #else	/* DOS */	/* Middle of giant siwtch UNX and DOS input drivers */



***************
*** 862,868
      return(ch);
  }

! #endif DOS /* End of giant switch between UNX and DOS input drivers */




--- 871,877 -----
      return(ch);
  }

! #endif	/* DOS */	/* End of giant switch between UNX and DOS input drivers */



*** ../pine-2.4.old/pine/ttyout.c	Mon Jan 27 20:05:52 1992
--- ./pine/ttyout.c	Fri Apr 24 16:05:23 1992
***************
*** 83,89

  #ifndef DOS /* Beginning of giant ifdef to switch between UNIX and DOS */

! #ifdef HAVE_TERMIO
  #include <termio.h>
  #else
  #include <sgtty.h>

--- 83,89 -----

  #ifndef DOS /* Beginning of giant ifdef to switch between UNIX and DOS */

! #ifdef	_SYSV3
  #include <termio.h>
  #ifdef	TIOCGWINSZ
  #include <sys/types.h>	/* for stream.h */
***************
*** 85,90

  #ifdef HAVE_TERMIO
  #include <termio.h>
  #else
  #include <sgtty.h>
  #endif

--- 85,95 -----

  #ifdef	_SYSV3
  #include <termio.h>
+ #ifdef	TIOCGWINSZ
+ #include <sys/types.h>	/* for stream.h */
+ #include <sys/stream.h>	/* for ptem.h */
+ #include <sys/ptem.h>	/* for struct winsize */
+ #endif
  #else
  #include <sgtty.h>
  #endif
***************
*** 90,96
  #endif


! #ifdef ANSI
  static void moveabsolute(int, int);
  static void CursorUp(int);
  static void CursorDown(int);

--- 95,101 -----
  #endif


! #ifdef	ANSI
  static void moveabsolute(int, int);
  static void CursorUp(int);
  static void CursorDown(int);
***************
*** 281,287
  {
      struct winsize win;

! #ifdef RESIZING
      /*---- Get the window size from the tty driver ---*/
      if ( ioctl(1, TIOCGWINSZ, &win) >= 0) { /* 1 is stdout */
          _lines    = min(win.ws_row, MAX_SCREEN_ROWS);

--- 286,292 -----
  {
      struct winsize win;

! #ifdef	RESIZING
      /*---- Get the window size from the tty driver ---*/
      if ( ioctl(0, TIOCGWINSZ, &win) >= 0) { /* 1 is stdout */
          _lines    = min(win.ws_row, MAX_SCREEN_ROWS);
***************
*** 283,289

  #ifdef RESIZING
      /*---- Get the window size from the tty driver ---*/
!     if ( ioctl(1, TIOCGWINSZ, &win) >= 0) { /* 1 is stdout */
          _lines    = min(win.ws_row, MAX_SCREEN_ROWS);
  	_columns  = min(win.ws_col, MAX_SCREEN_COLS);
          if(_lines == 0 && _columns == 0) {

--- 288,294 -----

  #ifdef	RESIZING
      /*---- Get the window size from the tty driver ---*/
!     if ( ioctl(0, TIOCGWINSZ, &win) >= 0) { /* 1 is stdout */
          _lines    = min(win.ws_row, MAX_SCREEN_ROWS);
  	_columns  = min(win.ws_col, MAX_SCREEN_COLS);
          dprint(2, (debugfile, "new win size -----<%d %d>------\n",
***************
*** 286,297
      if ( ioctl(1, TIOCGWINSZ, &win) >= 0) { /* 1 is stdout */
          _lines    = min(win.ws_row, MAX_SCREEN_ROWS);
  	_columns  = min(win.ws_col, MAX_SCREEN_COLS);
-         if(_lines == 0 && _columns == 0) {
-             _lines   = DEFAULT_LINES_ON_TERMINAL;
-             _columns = DEFAULT_COLUMNS_ON_TERMINAL;
-         }
-         ttyo->screen_cols = _columns;
-         ttyo->screen_rows = _lines ;
          dprint(2, (debugfile, "new win size -----<%d %d>------\n",
                     _lines, _columns));
      } else{

--- 291,296 -----
      if ( ioctl(0, TIOCGWINSZ, &win) >= 0) { /* 1 is stdout */
          _lines    = min(win.ws_row, MAX_SCREEN_ROWS);
  	_columns  = min(win.ws_col, MAX_SCREEN_COLS);
          dprint(2, (debugfile, "new win size -----<%d %d>------\n",
                     _lines, _columns));
      } else{
***************
*** 301,306
  #else
      /* Termcap takes care of it above */
  #endif
  }



--- 300,312 -----
  #else
      /* Termcap takes care of it above */
  #endif
+
+     if(_lines == 0 && _columns == 0) {
+         _lines   = DEFAULT_LINES_ON_TERMINAL;
+         _columns = DEFAULT_COLUMNS_ON_TERMINAL;
+     }
+     ttyo->screen_cols = _columns;
+     ttyo->screen_rows = _lines ;
  }


***************
*** 1204,1210



! #else DOS  /* Middle of giant ifdef for dos driver */


  /*  This DOS code compiled at one time, though it was never run.

--- 1210,1216 -----



! #else	/* DOS */	/* Middle of giant ifdef for dos driver */


  /*  This DOS code compiled at one time, though it was never run.
***************
*** 1215,1222
  #include "headers.h"


! #ifdef TO_UP_LOW_MACRO
! #undef tolower
  #endif



--- 1221,1228 -----
  #include "headers.h"


! #ifdef	TO_UP_LOW_MACRO
! #undef	tolower
  #endif


***************
*** 1837,1842
      }
  }

! #endif DOS /* End of giant ifdef for DOS drivers */



--- 1843,1848 -----
      }
  }

! #endif	/* DOS */	/* End of giant ifdef for DOS drivers */


