[gnu.emacs.bug] function-key-sequence, support for NS Sys V.2.2 etc

ian@UUNET.UU.NET (11/24/88)

In GNU Emacs 18.52.12 of Sun Nov 20 1988 on sibyl (usg-unix-v)

All bug fixes and enhancements are included as a shar file at the end of
this message.

function-key-sequence bug:

	This lisp function (keypad.el) stopped working between 18.47 and
	18.52. A fix has been applied to Fwhere-is-internal.

Better USG support:

       HIGHPRI does nothing on USG systems. Setpriority has been modified to
       better emulate the BSD version. Sys_suspend has also been modified so
       that the shell started on vanilla USG systems runs at the
       default priority and not HIGHPRI.

       Use TCSETAW ioctl instead of TCSETA when exiting emacs or doing a fake
       suspend. Otherwise the screen can get garbled. I assume this would be
       true of all USG systems but I have only tested it on National
       Semiconductors version.

       Emacsclient didn't parse its command arguments properly when compiled
       with HAVE_SYSV_IPC. I have changed it so it much more closely mimics
       the BSD version (which should also be a win for maintainability).

Support for National Semiconductors System V.2.2 for the ICM 3216:

	I have written a s-ns5-2-2.h. Slight modifications were required to
	crt0.c and alloca.s. A change was needed to malloc.c in order to
	work around a bug in the NS version of ulimit(2). For emacs to work
	on this system fixes to the terminal driver and to the libc routine
	signal(2), are also required. I am happy to provide patches for these
	to anyone who wants them but since they would contain some NS code
	I'm not sure if you would want to distribute them.

	The NS compiler puts static variables in the .data section as do many
	compilers on usg systems. I have provided an alternative fix for this
	problem which is to pipe the compilers assembler output through an
	awk script.

The following shar file consists of two new files

s-ns5-2-2.h   System dependendent file for National Semiconductor Sys V.2.2 on
	      an ICM 3216 (probably also on other 32000 machines).

move_to_bss   An awk script to filter the assembler output of the compiler.

diff-ns5.2.2.h
	      Context differences to the files in emacs/src and to
	      emacs/src/emacsclient.c. All changes to the emacs src are
	      conditionally compiled dependent on the definition of
	      NS5, ULIMIT_BREAK_VALUE, NS_STATIC_LOSSAGE or IWD_FIX.
	      The changes to emacsclient.c have not been conditionalised.

This is part 1 of two. This is a shell archive of new files for emacs.
The second part will contain context differences for the existing files.

------------------Cut Here----------------------------------------
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by ian on Thu Nov 24 02:12:43 CST 1988
# Contents:  s-ns5-2-2.h move_to_bss
 
echo x - s-ns5-2-2.h
sed 's/^@//' > "s-ns5-2-2.h" <<'@//E*O*F s-ns5-2-2.h//'
/* Definitions file for GNU Emacs running on National Semiconductor System V
   Release 2.2 for the ICM-3216. You may also need to fix bugs in the terminal
   driver and in the libc routine "signal" for GNU emacs to work. Fixes for
   those bugs are available from  ian@sibyl.eleceng.ua.oz.

   Copyright (C) 1988 Ian Dall

This file is not part of GNU Emacs (yet) but may be distributed under the
same terms as GNU Emacs

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.  No author or distributor
accepts responsibility to anyone for the consequences of using it
or for whether it serves any particular purpose or works at all,
unless he says so in writing.  Refer to the GNU Emacs General Public
License for full details.

Everyone is granted permission to copy, modify and redistribute
GNU Emacs, but only under the conditions described in the
GNU Emacs General Public License.   A copy of this license is
supposed to have been given to you along with GNU Emacs so you
can know your rights and responsibilities.  It should be in a
file named COPYING.  Among other things, the copyright notice
and this notice must be preserved on all copies.  */

/*
 *	Define symbols to identify the version of Unix this is.
 *	Define all the symbols that apply correctly.
 */

#include "s-usg5-2-2.h"

#define NS5

/* On early NS systems ulimit was buggy. If set emacs uses this value
 * for the maximum sbrk value instead of getting it from ulimit.
 */
#define ULIMIT_BREAK_VALUE 0x7E0000

/* Two alternative methods of preventing the compiler from putting
 * uninitialised static variables in .bss. If you are using the NS
 * compiler, you must define one or other of these.
 */
#undef static
#define NS_STATIC_LOSSAGE


/* Early NS compilers have this bug. I believe it has been fixed in later
 * releases.
 */
#define SHORT_CAST_BUG

#define SEGMENT_MASK (NBPS - 1)

/* Variables to get crt0.c to come out correctly */
#define CRT0_DUMMIES bogus_fp,
#define DOT_GLOBAL_START

#define IWD_FIX	  /* Non NS specific bug fixes and enhancemants by Ian Dall */

#undef LOAD_AVE_TYPE	   /* Loadst does not support USG style load data */
#define HAVE_SYSVIPC

/* Set this to /bin/mail unless you have a better mail posting program */
#define MAIL_PROGRAM_NAME "/usr/local/bin/remail"

/* Macro definitions to emulate BSD functions with SysV ones */
#ifndef BSTRING
#define BSTRING
#endif

#ifdef BSTRING
#undef bcopy
#undef bzero
#undef bcmp

#define bcopy(a,b,s)	memcpy(b,a,s)
#define bzero(a,s)	memset(a,0,s)
#define bcmp		memcmp
#endif
@//E*O*F s-ns5-2-2.h//
chmod u=rw,g=r,o=r s-ns5-2-2.h
 
echo x - move_to_bss
sed 's/^@//' > "move_to_bss" <<'@//E*O*F move_to_bss//'
# AWK script to hack the assembler output from the compiler so that it puts
# uninitialised data in .bss ( instead of .data). This script can not deal
# with all possible assembler input and there is no guarantee that the C
# compiler won't put out some form which this script can't handle. It works
# for all C compiler output tested so far. The -g option must be used.
BEGIN {}

/^	\.def.*\.scl	3;.*\.endef/ {
  if (bss) #This .def must be a new allocation -- must print out old one
    {
      out_bss = 1;
      out_size = size;
      out_val = val;
      out_type = type;
      out_align = align;
      out_dsize = dsize;
    }
  else
    {
      line_processed = 1;
      print $0;
    }
  align = 0;
  size = 0;
  for (i = 0; i < NF; i++)
    {
      if ($i == ".val") val = substr($(i+1), 1, length($(i+1)) - 1);
      if ($i == ".size") size = substr($(i+1), 1, length($(i+1)) - 1) + 0;
      if ($i == ".type") type = substr($(i+1), 1, length($(i+1)) - 1) + 0;
    }
# Weird comparison to see if this is a function. Type is actually interpreted
# as an octal number.
  if ( type"" ~ /.*[45].$/ || (type"" ~ /.*[2367].$/ && size == 0))
    bss = 0;
  else
    bss = 1;
}

/^	?\.align/ {
  
  if (align && bss) #This .align must be a new allocation -- must print out old one
    {
      out_bss = 1;
      out_size = size;
      out_val = val;
      out_type = type;
      out_align = align;
      out_dsize = dsize;
      line_no = 0;
      bss = 0;
    }
  line_processed = 1;
  align = $2;
  print $0;
}

/^	?\.data/ { print $0; line_processed = 1;}

bss == 1 && /^	?\.double	/ {
  if ($2 == "0" || $2 == "0x0")
    {
      dsize += 4;
      line_processed = 1;
    }
  else
    bss = 0;
}

bss == 1 && (/^	?.ascii/ || /^	?.byte/ || /^	?.word/ || /^	?.int/ || /^	?.float/ || /^	?.long/) { bss = 0; }

/^	?\.space/ {
  if (bss)
    dsize += $2;
  else
    print $0;
  line_processed = 1;
}


/^[A-Za-z._][A-Za-z0-9._]*:/ {
  if ($1 != val":")
    {
      if (bss) #This label must be a new allocation -- must print out old one
	{
	  out_bss = 1;
	  out_size = size;
	  out_val = val;
	  out_type = type;
	  out_align = align;
	  out_dsize = dsize;
	}

      if ($2 == ".space")
	{
	  if(!align) align = 1
	  x_bss = sprintf ("	.bss	%s, %s, %d", substr($1, 1, length($1) - 1), $3, align);
	}
      else
	{
	  print $0;
	  line_processed = 1;
	}
    }
  else
    if (!bss)
      {
	print $0;
      }
  line_processed = 1;
}

out_bss == 0 && bss == 0 && x_bss == "" && line_processed == 0 && line_no == 0{
  print $0; line_processed = 1; align = 0;}

# On reading a line which isn't part of a static data allocation, print out
# the .bss directive if we are at the end of a static allocation, otherwise
# print out any buffered lines

out_bss == 1 || line_processed == 0 || x_bss != "" {
  if ( !out_bss )
     {
          out_bss = bss;
	  out_size = size;
	  out_val = val;
	  out_type = type;
	  out_align = align;
	  out_dsize = dsize;
	  bss = 0;
	  size = 0;
	  align = 0;
	  dsize = 0;
	  val = "";
	  type = 0;
	}
      if (out_bss)
	{
	  # The type is actually octal in the assembly file. Awk doesn't
	  # handle octal but we can do comparisons as if it did. ie awk reads
	  # octal 14 as decimal 14.

	  if (out_type == 2 || out_type == 14)
	    {
	      if (!out_align) out_align = 1;
	      if (!out_size) out_size = 1;
	    }
	  if (out_type == 3 || out_type == 15)
	    {
	      if (!out_align) out_align = 2;
	      if (!out_size) out_size = 2;
	    }
	  if (out_type == 4 || out_type == 5 || out_type == 16 || out_type == 17)
	    {
	      if (!out_align) out_align = 4;
	      if (!out_size) out_size = 4;
	    }
	  if (!out_align) out_align = 1;
	  if (!out_size) out_size = out_dsize;
	  printf ("	.bss	%s, %d, %d\n", out_val, out_size, out_align);
	}
      
      if ( x_bss != "")
	{
	  print x_bss;
	  x_bss = "";
	}
      else
	{
#	  if (!out_bss)
#	    {
#	      for (i = 0; i < line_no; i++) print line[i];
#	    }
	  if ( !line_processed) print $0;
	}
      out_bss = 0;
      line_no = 0;
}

{line_processed = 0;}

# END {for (i = 0; i < line_no; i++) print line[i];}
@//E*O*F move_to_bss//
chmod u=rw,g=r,o=r move_to_bss
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
     80    415   2561 s-ns5-2-2.h
    180    735   4102 move_to_bss
    260   1150   6663 total
!!!
wc  s-ns5-2-2.h move_to_bss | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0

ian@UUNET.UU.NET (11/24/88)

In GNU Emacs 18.52.12 of Sun Nov 20 1988 on sibyl (usg-unix-v)


This is part two of two. Part one was a shell archive of new files for emacs.
The this part contains context differences for the existing files.

------------------Cut Here----------------------------------------
*** ../etc/emacsclient.c.orig	Fri Nov  4 01:55:48 1988
--- ../etc/emacsclient.c	Fri Nov  4 11:36:23 1988
***************
*** 134,139
  #include <sys/ipc.h>
  #include <sys/msg.h>
  #include <stdio.h>
  
  main (argc, argv)
       int argc;

--- 134,140 -----
  #include <sys/ipc.h>
  #include <sys/msg.h>
  #include <stdio.h>
+ #include <string.h>
  
  main (argc, argv)
       int argc;
***************
*** 139,147
       int argc;
       char **argv;
  {
!   int s;
!   key_t key;
!   struct msgbuf * msgp =
        (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
    struct msqid_ds * msg_st;
    char *homedir, *getenv (), buf[BUFSIZ];

--- 140,149 -----
       int argc;
       char **argv;
  {
!   int s, i;
!   key_t key, ftok();
!   char *malloc();
!   struct msgbuf *msgp =
        (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
    char *homedir, *getenv (), buf[BUFSIZ];
    char *getwd (), *getcwd (), gwdirb[BUFSIZ], *cwd, *val;
***************
*** 143,149
    key_t key;
    struct msgbuf * msgp =
        (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
-   struct msqid_ds * msg_st;
    char *homedir, *getenv (), buf[BUFSIZ];
    char *getwd (), *getcwd (), gwdirb[BUFSIZ], *cwd;
    if (argc < 2)

--- 145,150 -----
    char *malloc();
    struct msgbuf *msgp =
        (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
    char *homedir, *getenv (), buf[BUFSIZ];
    char *getwd (), *getcwd (), gwdirb[BUFSIZ], *cwd, *val;
    if (argc < 2)
***************
*** 145,151
        (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
    struct msqid_ds * msg_st;
    char *homedir, *getenv (), buf[BUFSIZ];
!   char *getwd (), *getcwd (), gwdirb[BUFSIZ], *cwd;
    if (argc < 2)
      {
        printf ("Usage: %s [filename]\n", argv[0]);

--- 146,152 -----
    struct msgbuf *msgp =
        (struct msgbuf *) malloc (sizeof *msgp + BUFSIZ);
    char *homedir, *getenv (), buf[BUFSIZ];
!   char *getwd (), *getcwd (), gwdirb[BUFSIZ], *cwd, *val;
    if (argc < 2)
      {
        printf ("Usage: %s [filename]\n", argv[0]);
***************
*** 171,184
        exit (1);
      }
  
!   msgp->mtext[0] = 0;
!   argc--; argv++;
!   while (argc)
!     {
!       if (*argv[0] != '/')
! 	{
! 	  char *val;
! 	  cwd = gwdirb; *cwd = '\0';
  #ifdef BSD
  	  val = getwd (gwdirb);
  #else

--- 172,178 -----
        exit (1);
      }
  
!   cwd = gwdirb; *cwd = '\0';
  #ifdef BSD
    val = getwd (gwdirb);
  #else
***************
*** 180,186
  	  char *val;
  	  cwd = gwdirb; *cwd = '\0';
  #ifdef BSD
! 	  val = getwd (gwdirb);
  #else
  	  val = getcwd (gwdirb, sizeof gwdirb);
  #endif

--- 174,180 -----
  
    cwd = gwdirb; *cwd = '\0';
  #ifdef BSD
!   val = getwd (gwdirb);
  #else
    val = getcwd (gwdirb, sizeof gwdirb);
  #endif
***************
*** 182,188
  #ifdef BSD
  	  val = getwd (gwdirb);
  #else
! 	  val = getcwd (gwdirb, sizeof gwdirb);
  #endif
  	  if (val != 0)
  	    {

--- 176,182 -----
  #ifdef BSD
    val = getwd (gwdirb);
  #else
!   val = getcwd (gwdirb, sizeof gwdirb);
  #endif
    if (val = NULL)
      {
***************
*** 184,190
  #else
  	  val = getcwd (gwdirb, sizeof gwdirb);
  #endif
! 	  if (val != 0)
  	    {
  	      strcat (cwd, "/");
  	    }

--- 178,197 -----
  #else
    val = getcwd (gwdirb, sizeof gwdirb);
  #endif
!   if (val = NULL)
!     {
!       perror ("Getpwd");
!       exit(1);
!     }
! 
!   msgp->mtext[0] = '\0';
!   for (i = 1; i < argc; i++)
!     {
!       if (*argv[i] == '+')
! 	{
! 	  char *p = argv[i] + 1;
! 	  while (*p >= '0' && *p <= '9') p++;
! 	  if (*p != 0)
  	    {
  	      strcat (msgp->mtext, cwd);
  	      strcat (msgp->mtext, "/");
***************
*** 186,192
  #endif
  	  if (val != 0)
  	    {
! 	      strcat (cwd, "/");
  	    }
  	  else
  	    {

--- 193,200 -----
  	  while (*p >= '0' && *p <= '9') p++;
  	  if (*p != 0)
  	    {
! 	      strcat (msgp->mtext, cwd);
! 	      strcat (msgp->mtext, "/");
  	    }
  	}
        else if (*argv[i] != '/')
***************
*** 188,194
  	    {
  	      strcat (cwd, "/");
  	    }
! 	  else
  	    {
  	      fprintf (stderr, cwd);
  	      *cwd = '\0';

--- 196,203 -----
  	      strcat (msgp->mtext, cwd);
  	      strcat (msgp->mtext, "/");
  	    }
! 	}
!       else if (*argv[i] != '/')
  	    {
  	      strcat (msgp->mtext, cwd);
  	      strcat (msgp->mtext, "/");
***************
*** 190,197
  	    }
  	  else
  	    {
! 	      fprintf (stderr, cwd);
! 	      *cwd = '\0';
  	    }
  	}
  	

--- 199,206 -----
  	}
        else if (*argv[i] != '/')
  	    {
! 	      strcat (msgp->mtext, cwd);
! 	      strcat (msgp->mtext, "/");
  	    }
        strcat (msgp->mtext, argv[i]);
        strcat (msgp->mtext, " ");
***************
*** 193,202
  	      fprintf (stderr, cwd);
  	      *cwd = '\0';
  	    }
! 	}
! 	
!       strcat (msgp->mtext, cwd);
!       strcat (msgp->mtext, argv[0]);
        strcat (msgp->mtext, " ");
        argv++; argc--;
      }

--- 202,208 -----
  	      strcat (msgp->mtext, cwd);
  	      strcat (msgp->mtext, "/");
  	    }
!       strcat (msgp->mtext, argv[i]);
        strcat (msgp->mtext, " ");
      }
  
***************
*** 198,204
        strcat (msgp->mtext, cwd);
        strcat (msgp->mtext, argv[0]);
        strcat (msgp->mtext, " ");
-       argv++; argc--;
      }
    strcat (msgp->mtext, "\n");
    msgp->mtype = 1;

--- 204,209 -----
  	    }
        strcat (msgp->mtext, argv[i]);
        strcat (msgp->mtext, " ");
      }
  
    strcat (msgp->mtext, "\n");
***************
*** 200,205
        strcat (msgp->mtext, " ");
        argv++; argc--;
      }
    strcat (msgp->mtext, "\n");
    msgp->mtype = 1;
    if (msgsnd (s, msgp, strlen (msgp->mtext)+1, 1, 0) < 0)

--- 205,211 -----
        strcat (msgp->mtext, argv[i]);
        strcat (msgp->mtext, " ");
      }
+ 
    strcat (msgp->mtext, "\n");
    msgp->mtype = 1;
    if (msgsnd (s, msgp, strlen (msgp->mtext)+1, 1) < 0)
***************
*** 202,208
      }
    strcat (msgp->mtext, "\n");
    msgp->mtype = 1;
!   if (msgsnd (s, msgp, strlen (msgp->mtext)+1, 1, 0) < 0)
      {
        perror ("msgsnd");
        exit (1);

--- 208,214 -----
  
    strcat (msgp->mtext, "\n");
    msgp->mtype = 1;
!   if (msgsnd (s, msgp, strlen (msgp->mtext)+1, 1) < 0)
      {
        perror ("msgsnd");
        exit (1);
*** alloca.s.orig	Wed Nov  2 13:02:12 1988
--- alloca.s	Wed Nov  2 13:04:36 1988
***************
*** 201,206
  #define IM
  #define REGISTER(x) x
  #else
  #define IM $
  #define REGISTER(x) 0(x)
  #endif

--- 201,210 -----
  #define IM
  #define REGISTER(x) x
  #else
+ #ifdef NS5   /* ns SysV assembler */
+ #define IM $
+ #define REGISTER(x) x
+ #else
  #define IM $
  #define REGISTER(x) 0(x)
  #endif
*** crt0.c.orig	Wed Nov  2 12:25:31 1988
--- crt0.c	Wed Nov  2 23:55:42 1988
***************
*** 188,194
  
  #endif /* orion or pyramid or celerity or alliant or clipper */
  
! #if defined (ns16000) && !defined (sequent) && !defined (UMAX)
  
  _start ()
  {

--- 188,194 -----
  
  #endif /* orion or pyramid or celerity or alliant or clipper */
  
! #if defined (ns16000) && !defined (sequent) && !defined (UMAX) && !defined (CRT0_DUMMIES)
  
  _start ()
  {
***************
*** 210,215
    exit (main (argc, argv, environ));
  }
  #endif /* ns16000, not sequent and not UMAX */
  
  #ifdef UMAX
  _start()

--- 210,216 -----
    exit (main (argc, argv, environ));
  }
  #endif /* ns16000, not sequent and not UMAX */
+ 
  
  #ifdef UMAX
  _start()
*** keymap.c.orig	Sun Nov  6 02:01:45 1988
--- keymap.c	Sun Nov 20 14:38:36 1988
***************
*** 806,811
  	      i++;
  	    }
  
  	  elt = get_keyelt (elt);
  
  	  /* End this iteration if this element does not match

--- 806,817 -----
  	      i++;
  	    }
  
+ #ifndef IWD_FIX		/* The following line breaks the case where
+ 			 * definition is a cons as used by
+ 			 * function-key-sequence in keypad.el.
+ 			 * So move this code so it only gets done if
+ 			 * definition is not a cons
+ 			 */
  	  elt = get_keyelt (elt);
  #endif
  
***************
*** 807,812
  	    }
  
  	  elt = get_keyelt (elt);
  
  	  /* End this iteration if this element does not match
  	     the target.  */

--- 813,819 -----
  			 * definition is not a cons
  			 */
  	  elt = get_keyelt (elt);
+ #endif
  
  	  /* End this iteration if this element does not match
  	     the target.  */
***************
*** 819,824
  		continue;
  	    }
  	  else
  	    if (!EQ (elt, definition))
  	      continue;
  

--- 826,838 -----
  		continue;
  	    }
  	  else
+ #ifdef IWD_FIX
+ 	    {
+ 	      elt = get_keyelt (elt);
+ 	      if (!EQ (elt, definition))
+ 		continue;
+ 	    }
+ #else
  	    if (!EQ (elt, definition))
  	      continue;
  #endif
***************
*** 821,826
  	  else
  	    if (!EQ (elt, definition))
  	      continue;
  
  	  /* We have found a match.
  	     Construct the key sequence where we found it.  */

--- 835,841 -----
  #else
  	    if (!EQ (elt, definition))
  	      continue;
+ #endif
  
  	  /* We have found a match.
  	     Construct the key sequence where we found it.  */
*** m-ns16000.h.orig	Sun Mar 15 00:28:11 1987
--- m-ns16000.h	Thu Nov  3 01:49:50 1988
***************
*** 46,52
  #define NO_UNION_TYPE
  
  /* Data type of load average, as read out of kmem.  */
! 
  #define LOAD_AVE_TYPE double
  
  /* Convert that into an integer that is 100 for a load average of 1.0  */

--- 46,52 -----
  #define NO_UNION_TYPE
  
  /* Data type of load average, as read out of kmem.  */
! #ifndef NS5  /* Really depends on operating system rather than on machine */
  #define LOAD_AVE_TYPE double
  
  /* Convert that into an integer that is 100 for a load average of 1.0  */
***************
*** 52,54
  /* Convert that into an integer that is 100 for a load average of 1.0  */
  
  #define LOAD_AVE_CVT(x) ((int) ((x) * 100.0))

--- 52,55 -----
  /* Convert that into an integer that is 100 for a load average of 1.0  */
  
  #define LOAD_AVE_CVT(x) ((int) ((x) * 100.0))
+ #endif
*** malloc.c.orig	Wed Nov  2 20:08:33 1988
--- malloc.c	Sun Nov 20 14:49:37 1988
***************
*** 714,719
  {
    extern long ulimit ();
      
    lim_data = ulimit (3, 0);
    lim_data -= (long) data_space_start;
  }

--- 714,722 -----
  {
    extern long ulimit ();
      
+ #ifdef ULIMIT_BREAK_VALUE
+   lim_data = ULIMIT_BREAK_VALUE;
+ #else
    lim_data = ulimit (3, 0);
  #endif
    lim_data -= (long) data_space_start;
***************
*** 715,720
    extern long ulimit ();
      
    lim_data = ulimit (3, 0);
    lim_data -= (long) data_space_start;
  }
  

--- 718,724 -----
    lim_data = ULIMIT_BREAK_VALUE;
  #else
    lim_data = ulimit (3, 0);
+ #endif
    lim_data -= (long) data_space_start;
  }
  
*** sysdep.c.orig	Wed Nov  2 16:49:08 1988
--- sysdep.c	Sun Nov 20 14:38:30 1988
***************
*** 111,116
  #undef TIOCGETP
  #define TIOCGETP TCGETA
  #undef TIOCSETN
  #define TIOCSETN TCSETA
  #undef TIOCSETP
  #define TIOCSETP TCSETAF

--- 111,124 -----
  #undef TIOCGETP
  #define TIOCGETP TCGETA
  #undef TIOCSETN
+ #ifdef IWD_FIX			/* Make the driver wait till the output queue
+ 				 * is empty before changing modes. Otherwise
+ 				 * the screen can get mangled. This code only
+ 				 * applies when doing fake-suspends or when
+ 				 * exiting emacs
+ 				 */
+ #define TIOCSETN TCSETAW
+ #else
  #define TIOCSETN TCSETA
  #endif
  #undef TIOCSETP
***************
*** 112,117
  #define TIOCGETP TCGETA
  #undef TIOCSETN
  #define TIOCSETN TCSETA
  #undef TIOCSETP
  #define TIOCSETP TCSETAF
  #define TERMINAL struct termio

--- 120,126 -----
  #define TIOCSETN TCSETAW
  #else
  #define TIOCSETN TCSETA
+ #endif
  #undef TIOCSETP
  #define TIOCSETP TCSETAF
  #define TERMINAL struct termio
***************
*** 555,560
  #ifdef subprocesses
        close_process_descs ();	/* Close Emacs's pipes/ptys */
  #endif
        execlp (sh, sh, 0);
        write (1, "Can't execute subshell", 22);
        _exit (1);

--- 564,572 -----
  #ifdef subprocesses
        close_process_descs ();	/* Close Emacs's pipes/ptys */
  #endif
+ #ifdef IWD_FIX			/* Emacs might be running at HIGHPRI */
+       nice(-nice(0));		/* Give the new shell the default piority */ 
+ #endif
        execlp (sh, sh, 0);
        write (1, "Can't execute subshell", 22);
        _exit (1);
***************
*** 964,969
    clear_end_of_line (screen_width);
    /* clear_end_of_line may move the cursor */
    topos (screen_height - 1, 0);
    /* Output raw CR so kernel can track the cursor hpos.  */
    cmputc ('\r');
    reset_terminal_modes ();

--- 976,982 -----
    clear_end_of_line (screen_width);
    /* clear_end_of_line may move the cursor */
    topos (screen_height - 1, 0);
+ 
    /* Output raw CR so kernel can track the cursor hpos.  */
  #ifndef IWD_FIX			/* This behaviour is objectionable on magic
  				 * cookie terminals. The cursor is positioned
***************
*** 965,970
    /* clear_end_of_line may move the cursor */
    topos (screen_height - 1, 0);
    /* Output raw CR so kernel can track the cursor hpos.  */
    cmputc ('\r');
    reset_terminal_modes ();
    fflush (stdout);

--- 978,990 -----
    topos (screen_height - 1, 0);
  
    /* Output raw CR so kernel can track the cursor hpos.  */
+ #ifndef IWD_FIX			/* This behaviour is objectionable on magic
+ 				 * cookie terminals. The cursor is positioned
+ 				 * so that the first character the system
+ 				 * sends erases the "return to normal" magic
+ 				 * cookie. The effect is that the terminal is
+ 				 * left in standout mode.
+ 				 */
    cmputc ('\r');
  #endif
    reset_terminal_modes ();
***************
*** 966,971
    topos (screen_height - 1, 0);
    /* Output raw CR so kernel can track the cursor hpos.  */
    cmputc ('\r');
    reset_terminal_modes ();
    fflush (stdout);
  #ifdef BSD

--- 986,992 -----
  				 * left in standout mode.
  				 */
    cmputc ('\r');
+ #endif
    reset_terminal_modes ();
  
    fflush (stdout);
***************
*** 967,972
    /* Output raw CR so kernel can track the cursor hpos.  */
    cmputc ('\r');
    reset_terminal_modes ();
    fflush (stdout);
  #ifdef BSD
  #ifndef BSD4_1

--- 988,994 -----
    cmputc ('\r');
  #endif
    reset_terminal_modes ();
+ 
    fflush (stdout);
  #ifdef BSD
  #ifndef BSD4_1
***************
*** 2055,2060
    return (-1);
  }
  
  /* VARARGS */
  setpriority ()
  {

--- 2077,2094 -----
    return (-1);
  }
  
+ #ifdef IWD_FIX			/* Improved emulation of this function on USG
+ 				 * systems
+ 				 */
+ setpriority (which, who, prio)
+ int which, who, prio;
+ {
+   int nice();
+ 
+   nice(prio - nice(0));
+   return (0);
+ }
+ #else
  /* VARARGS */
  setpriority ()
  {
***************
*** 2060,2066
  {
    return (0);
  }
! 
  #ifndef HAVE_VFORK
  
  /*

--- 2094,2100 -----
  {
    return (0);
  }
! #endif
  #ifndef HAVE_VFORK
  
  /*
*** ymakefile.orig	Wed Nov  2 11:49:10 1988
--- ymakefile	Wed Nov  2 11:48:11 1988
***************
*** 33,38
     don't let it interfere with this file.  */
  #undef register
  
  /* Some machines don't find the standard C libraries in the usual place.  */
  #ifndef LIB_STANDARD
  #define LIB_STANDARD -lc

--- 33,49 -----
     don't let it interfere with this file.  */
  #undef register
  
+ /* The NS sysV compiler puts static variables in .data even if they are not
+    initialised. This is a losage because the dumped emacs moves everthing
+    in .data to .text.  --- IWD
+  */
+ #ifdef NS_STATIC_LOSSAGE
+ .c.o:	move_to_bss
+ 	$(CC) -S -g $(CFLAGS) $<
+ 	awk -f move_to_bss < $*.s | as -o $*.o
+ 	@-rm $*.s
+ #endif
+ 
  /* Some machines don't find the standard C libraries in the usual place.  */
  #ifndef LIB_STANDARD
  #define LIB_STANDARD -lc