[comp.unix.microport] results of porting Jove

hedrick@athos.rutgers.edu (Charles Hedrick) (03/13/88)

Here's another in my series of reports on porting to Microport System V/AT.
This one is Jove.  Jove is yet another dialect of Emacs.  It seems to be the
most complete of the "small" Emacses, with good builtin documentation, and
filename and command completion.  Its disadvantages compared to MicroEmacs
are (1) it is somewhat larger, and thus takes slightly longer to start up,
(2) it can't handle files with lines longer than 256 (actually, you can
choose the constant), nor lines will nulls in them, and (3) the way it
handles echoing, very fast typists will find that characters do not echo as
they type.  (There's a delay in the update code so that if characters are
still coming in, the screen update doesn't happen.)

Jove is available from comp.sources.unix archive sites.  (I used
j.cc.purdue.edu.)  An older version is v08i020 through v08i032.  An update
was posted as v11i045 through v11i048 and v11i081.  The v08 version came up
with little or no trouble.  The revised version has a couple of obvious
minor problems with System V, which are fixed by the diffs shown here.  In
addition, I make a few changes because of my taste (which directory various
files go in, which is in Makefile, and backup files being called foo.BAK
instead of #foo) and because of a bug in the Microport kernel that causes
updating the time in the mode line to interfere with typein.  I still have
not fixed the fact that the time update causes the program to swap a lot.
This seems to depend upon exactly what is running on the system, so you may
not see it.  If it bothers you, you should remove the time from the mode
line.  I am including an example .joverc, which is designed to make it as
close as possible to Gnu Emacs, and also defines functions for the keypad.

Note by the way that the 2.3.0-L optimizer blows up when compiling disp, io,
misc, and wind.  You must compile them without -O.

Here is a detailed list of the changes:

Makefile - put files in my preferred directories, change SHELL to
XSHELL since setting SHELL to csh causes make to use csh to execute
commands.  This makes the build process bomb.  This makefile causes
jove to be loaded with -lxmalloc.  I posted that previously. It's an
improved malloc.  Note that for some reason curses is unable to use my
modified version of sbrk.  So malloc.c and sbrk.c from my previous
posting should be edited so that sbrk is called something else, e.g. xsbrk.

fp - used an undefined symbol

io - change the name of the backup files.  You may prefer not to install
this.  Without the patch the old version of foo is saved as #foo.  With
the patch it is saved as foo.BAK.  It's all a matter of taste.

jove - fix to getch to avoid dropping characters due to bug in kernel

re1 - included a non-existent include file.  Turns out not to be needed.

screen - The Uport ANSI terminal driver puts the cursor in a different
place than a VT100 after a set scrolling region command.  There's no
reason to expect other terminals to behave exactly like a VT100, so
fix the code to make no assumptions as to where the cursor is after
this command.

tune.h - set options apropriate for this operating system.  (You might
want to look at the options to see if they make sense.  The .DIFF
file looks a bit odd to me.)

.joverc - example startup file.  A few Gnu-based options, plus definitions
for the keypad keys.  WARNING: I had to turn control-S, control-R, and
escape into ^[ ^S and ^R (i.e. two-character sequences) in order to
get this posting past our news system.  You may want to turn them back
into the control characters.

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	Makefile.DIFF
#	fp.c.DIFF
#	io.c.DIFF
#	jove.c.DIFF
#	re1.c.DIFF
#	screen.c.DIFF
#	tune.h.DIFF
#	.joverc
# This archive created: Sun Mar 13 00:50:46 1988
export PATH; PATH=/bin:$PATH
if test -f 'Makefile.DIFF'
then
	echo shar: will not over-write existing file "'Makefile.DIFF'"
else
cat << \SHAR_EOF > 'Makefile.DIFF'
*** Makefile.ORIG	Sun Feb 21 23:07:55 1988
--- Makefile	Sat Mar 12 23:38:48 1988
***************
*** 18,25
  # e.g., jove.1 or jove.l or jove.m.
  
  DESTDIR =
! TMPDIR = /tmp
! LIBDIR = /usr/lib/jovelib
  BINDIR = /usr/local/bin
  MANDIR = /usr/man/man1
  MANEXT = 1

--- 18,25 -----
  # e.g., jove.1 or jove.l or jove.m.
  
  DESTDIR =
! TMPDIR = /usr/local/tmp/jove
! LIBDIR = /usr/local/lib/jovelib
  BINDIR = /usr/local/bin
  MANDIR = /usr/man/man1
  MANEXT = 1
***************
*** 23,29
  BINDIR = /usr/local/bin
  MANDIR = /usr/man/man1
  MANEXT = 1
! SHELL = /bin/csh
  
  # These should all just be right if the above ones are.
  JOVE = $(DESTDIR)$(BINDIR)/jove

--- 23,29 -----
  BINDIR = /usr/local/bin
  MANDIR = /usr/man/man1
  MANEXT = 1
! XSHELL = /bin/csh
  
  # These should all just be right if the above ones are.
  JOVE = $(DESTDIR)$(BINDIR)/jove
***************
*** 63,69
  LDFLAGS = -Ml
  SEPFLAGS =
  
! CFLAGS = -Ml
  
  BASESEG = funcdefs.o keymaps.o argcount.o ask.o buf.o ctype.o delete.o \
  	  disp.o fmt.o insert.o io.o jove.o malloc.o marks.o misc.o re.o \

--- 63,69 -----
  LDFLAGS = -Ml
  SEPFLAGS =
  
! CFLAGS = -Ml -O
  
  BASESEG = funcdefs.o keymaps.o argcount.o ask.o buf.o ctype.o delete.o \
  	  disp.o fmt.o insert.o io.o jove.o malloc.o marks.o misc.o re.o \
***************
*** 130,136
  	@sed -e 's;TMPDIR;$(TMPDIR);' \
  	     -e 's;LIBDIR;$(LIBDIR);' \
  	     -e 's;BINDIR;$(BINDIR);' \
! 	     -e 's;SHELL;$(SHELL);' tune.template >> tune.c
  
  install: $(DESTDIR)$(LIBDIR) $(TEACH-JOVE) $(CMDS.DOC) $(JOVERC) \
  	 $(PORTSRV) $(RECOVER) $(JOVE) $(TEACHJOVE) $(JOVEM) \

--- 130,136 -----
  	@sed -e 's;TMPDIR;$(TMPDIR);' \
  	     -e 's;LIBDIR;$(LIBDIR);' \
  	     -e 's;BINDIR;$(BINDIR);' \
! 	     -e 's;SHELL;$(XSHELL);' tune.template >> tune.c
  
  install: $(DESTDIR)$(LIBDIR) $(TEACH-JOVE) $(CMDS.DOC) $(JOVERC) \
  	 $(PORTSRV) $(RECOVER) $(JOVE) $(TEACHJOVE) $(JOVEM) \
SHAR_EOF
fi # end of overwriting check
if test -f 'fp.c.DIFF'
then
	echo shar: will not over-write existing file "'fp.c.DIFF'"
else
cat << \SHAR_EOF > 'fp.c.DIFF'
*** fp.c.ORIG	Sun Feb 21 15:18:04 1988
--- fp.c	Sun Feb 21 16:14:43 1988
***************
*** 158,164
  		flush(fp);
  	fp->f_cnt = 0;		/* next read will filbuf(), next write
  				   will flush() with no bad effects */
! 	lseek(fp->f_fd, (long) offset, L_SET);
  }
  
  _flush(c, fp)

--- 158,164 -----
  		flush(fp);
  	fp->f_cnt = 0;		/* next read will filbuf(), next write
  				   will flush() with no bad effects */
! 	lseek(fp->f_fd, (long) offset, 0);
  }
  
  _flush(c, fp)
SHAR_EOF
fi # end of overwriting check
if test -f 'io.c.DIFF'
then
	echo shar: will not over-write existing file "'io.c.DIFF'"
else
cat << \SHAR_EOF > 'io.c.DIFF'
*** io.c.ORIG	Sat Mar 12 20:59:38 1988
--- io.c	Sat Mar 12 19:46:15 1988
***************
*** 1079,1086
  	
  	strcpy(tmp1, fname);
  	
! 	if ((s = rindex(tmp1, '/')) == NULL)
! 		sprintf(tmp2, "#%s", fname);
  	else {
  		*s++ = '\0';
  		sprintf(tmp2, "%s/#%s", tmp1, s);

--- 1079,1093 -----
  	
  	strcpy(tmp1, fname);
  	
! 	if ((s = rindex(tmp1, '/')) == NULL) {
! #ifdef SYSV
! /* maxbase is max name length - length of .BAK */
! #define MAXBASE 10
! 		if (strlen(tmp1) > MAXBASE)
! 			tmp1[MAXBASE] = 0;
! #endif
! 		sprintf(tmp2, "%s.BAK", tmp1);
! 	}
  	else {
  		*s++ = '\0';
  #ifdef SYSV
***************
*** 1083,1089
  		sprintf(tmp2, "#%s", fname);
  	else {
  		*s++ = '\0';
! 		sprintf(tmp2, "%s/#%s", tmp1, s);
  	}
  
  	if ((fd1 = open(fname, 0)) < 0)

--- 1090,1100 -----
  	}
  	else {
  		*s++ = '\0';
! #ifdef SYSV
! 		if (strlen(s) > MAXBASE)
! 			s[MAXBASE] = 0;
! #endif
! 		sprintf(tmp2, "%s/%s.BAK", tmp1, s);
  	}
  
  	if ((fd1 = open(fname, 0)) < 0)
SHAR_EOF
fi # end of overwriting check
if test -f 'jove.c.DIFF'
then
	echo shar: will not over-write existing file "'jove.c.DIFF'"
else
cat << \SHAR_EOF > 'jove.c.DIFF'
*** jove.c.ORIG	Sun Feb 21 23:01:29 1988
--- jove.c	Sat Mar 12 18:57:12 1988
***************
*** 255,261
  	register int	c;
  
  	if (nchars <= 0) {
! 		do
  			nchars = read(0, smbuf, sizeof smbuf);
  		while (nchars < 0 && errno == EINTR);
  

--- 255,269 -----
  	register int	c;
  
  	if (nchars <= 0) {
! 		do {
! /* Microport has a bug where read will return -1 even though it has
!  * given us useful data.  SIGALRM will trigger it.
!  */
! #ifdef UPORT
! 			register char *cp;
! 			for (cp = smbuf, c = 0; c < sizeof smbuf; cp++, c++)
! 				*cp = 0xff;
! #endif
  			nchars = read(0, smbuf, sizeof smbuf);
  #ifdef UPORT
  			if (nchars < 0) {
***************
*** 257,262
  	if (nchars <= 0) {
  		do
  			nchars = read(0, smbuf, sizeof smbuf);
  		while (nchars < 0 && errno == EINTR);
  
  		if (nchars <= 0)

--- 265,282 -----
  				*cp = 0xff;
  #endif
  			nchars = read(0, smbuf, sizeof smbuf);
+ #ifdef UPORT
+ 			if (nchars < 0) {
+ 				for (cp = smbuf, c = 0;
+ 				     c < sizeof smbuf && *cp != 0xff;
+ 				     cp++, c++)
+ 				  ;
+ 				if (c > 0) {
+ 				     nchars = c;
+ 				}
+ 			}
+ #endif
+ 		}
  		while (nchars < 0 && errno == EINTR);
  
  		if (nchars <= 0)
SHAR_EOF
fi # end of overwriting check
if test -f 're1.c.DIFF'
then
	echo shar: will not over-write existing file "'re1.c.DIFF'"
else
cat << \SHAR_EOF > 're1.c.DIFF'
*** re1.c.ORIG	Sun Feb 21 15:20:17 1988
--- re1.c	Sun Feb 21 16:24:42 1988
***************
*** 8,14
  #include "jove.h"
  #include "io.h"
  #include "re.h"
- #include <sys/types.h>
  #include <sys/stat.h>
  
  private

--- 8,13 -----
  #include "jove.h"
  #include "io.h"
  #include "re.h"
  #include <sys/stat.h>
  
  private
SHAR_EOF
fi # end of overwriting check
if test -f 'screen.c.DIFF'
then
	echo shar: will not over-write existing file "'screen.c.DIFF'"
else
cat << \SHAR_EOF > 'screen.c.DIFF'
*** screen.c.ORIG	Sun Feb 21 15:20:52 1988
--- screen.c	Tue Feb 23 03:41:16 1988
***************
*** 717,723
  
  	if (CS) {
  		putpad(tgoto(CS, bottom, top), 1);
! 		CapCol = CapLine = 0;
  		Placur(top, 0);
  		for (i = 0; i < num; i++)
  			putpad(SR, bottom - top);

--- 717,724 -----
  
  	if (CS) {
  		putpad(tgoto(CS, bottom, top), 1);
! 		CapCol = 10000;
! 		CapLine = 10000;
  		Placur(top, 0);
  		for (i = 0; i < num; i++)
  			putpad(SR, bottom - top);
***************
*** 722,728
  		for (i = 0; i < num; i++)
  			putpad(SR, bottom - top);
  		putpad(tgoto(CS, ILI, 0), 1);
! 		CapCol = CapLine = 0;
  	} else {
  		Placur(bottom - num + 1, 0);
  		if (M_DL && (num > 1)) {

--- 723,730 -----
  		for (i = 0; i < num; i++)
  			putpad(SR, bottom - top);
  		putpad(tgoto(CS, ILI, 0), 1);
! 		CapCol = 10000;
! 		CapLine = 10000;
  	} else {
  		Placur(bottom - num + 1, 0);
  		if (M_DL && (num > 1)) {
***************
*** 786,792
  
  	if (CS) {
  		putpad(tgoto(CS, bottom, top), 1);
! 		CapCol = CapLine = 0;
  		Placur(bottom, 0);
  		for (i = 0; i < num; i++)
  			putpad(SF, bottom - top);

--- 788,795 -----
  
  	if (CS) {
  		putpad(tgoto(CS, bottom, top), 1);
! 		CapCol = 10000;
! 		CapLine = 10000;
  		Placur(bottom, 0);
  		for (i = 0; i < num; i++)
  			putpad(SF, bottom - top);
***************
*** 791,797
  		for (i = 0; i < num; i++)
  			putpad(SF, bottom - top);
  		putpad(tgoto(CS, ILI, 0), 1);
! 		CapCol = CapLine = 0;
  	} else {
  		Placur(top, 0);
  		if (M_DL && (num > 1)) {

--- 794,801 -----
  		for (i = 0; i < num; i++)
  			putpad(SF, bottom - top);
  		putpad(tgoto(CS, ILI, 0), 1);
! 		CapCol = 10000;
! 		CapLine = 10000;
  	} else {
  		Placur(top, 0);
  		if (M_DL && (num > 1)) {
SHAR_EOF
fi # end of overwriting check
if test -f 'tune.h.DIFF'
then
	echo shar: will not over-write existing file "'tune.h.DIFF'"
else
cat << \SHAR_EOF > 'tune.h.DIFF'
*** tune.h.ORIG	Sun Feb 21 03:06:48 1988
--- tune.h	Sat Mar 12 22:56:06 1988
***************
*** 7,13
  
  #define TUNED		/* don't touch this */
  
- /*#define LSRHS		/* if this is Lincoln-Sudbury Regional High School */
  /*#define MSDOS		/* if this is MSDOS */
  #define BSD4_2		/* Berkeley 4.2 BSD */
  /*#define BSD4_3	/* Berkeley 4.3 BSD */

--- 7,12 -----
  
  #define TUNED		/* don't touch this */
  
  /*#define MSDOS		/* if this is MSDOS */
  /*#define BSD4_2		/* Berkeley 4.2 BSD */
  /*#define BSD4_3	/* Berkeley 4.3 BSD */
***************
*** 9,15
  
  /*#define LSRHS		/* if this is Lincoln-Sudbury Regional High School */
  /*#define MSDOS		/* if this is MSDOS */
! #define BSD4_2		/* Berkeley 4.2 BSD */
  /*#define BSD4_3	/* Berkeley 4.3 BSD */
  /*#define SYSV		/* for (System III/System V) UNIX systems */
  #ifdef BSD4_3

--- 8,14 -----
  #define TUNED		/* don't touch this */
  
  /*#define MSDOS		/* if this is MSDOS */
! /*#define BSD4_2		/* Berkeley 4.2 BSD */
  /*#define BSD4_3	/* Berkeley 4.3 BSD */
  #define SYSV		/* for (System III/System V) UNIX systems */
  #define SYSVR2		/* system 5, rel. 2 */
***************
*** 11,17
  /*#define MSDOS		/* if this is MSDOS */
  #define BSD4_2		/* Berkeley 4.2 BSD */
  /*#define BSD4_3	/* Berkeley 4.3 BSD */
! /*#define SYSV		/* for (System III/System V) UNIX systems */
  #ifdef BSD4_3
  #   ifndef BSD4_2
  #	define BSD4_2	/* 4.3 is 4.2 only different. */

--- 10,23 -----
  /*#define MSDOS		/* if this is MSDOS */
  /*#define BSD4_2		/* Berkeley 4.2 BSD */
  /*#define BSD4_3	/* Berkeley 4.3 BSD */
! #define SYSV		/* for (System III/System V) UNIX systems */
! #define SYSVR2		/* system 5, rel. 2 */
! #define UPORT		/* Microport-specific stuff */
! #ifdef SYSVR2
! #   ifndef SYSV
! #	define SYSV	/* SYSV is a subset of SYSVR2 */
! #   endif
! #endif
  #ifdef BSD4_3
  #   ifndef BSD4_2
  #	define BSD4_2	/* 4.3 is 4.2 only different. */
***************
*** 18,24
  #   endif
  #endif
  
- 
  #ifdef MSDOS
  #   define SMALL
  #else			/* assume we're UNIX or something */

--- 24,29 -----
  #   endif
  #endif
  
  #ifdef MSDOS
  #   define SMALL
  #else			/* assume we're UNIX or something */
***************
*** 40,46
  #			   Do not define this if you lack a load average
  #			   system call and kmem is read protected. */
  #
! #   define JOB_CONTROL	/* if you have job stopping */
  #
  #   ifdef JOB_CONTROL
  #       define MENLO_JCL

--- 45,51 -----
  #			   Do not define this if you lack a load average
  #			   system call and kmem is read protected. */
  #
! /* #   define JOB_CONTROL	/* if you have job stopping */
  #
  #   ifdef JOB_CONTROL
  #       define MENLO_JCL
***************
*** 64,70
  #   define ABBREV		/* word abbreviation mode */
  #   define BACKUPFILES		/* enable the backup files code */
  #   ifndef MSDOS
! #       define BIFF		/* if you have biff (or the equivalent) */
  #       define F_COMPLETION	/* filename completion */
  #       define CHDIR		/* cd command and absolute pathnames */
  #       define	KILL0	/* kill(pid, 0) returns 0 if proc exists */

--- 69,75 -----
  #   define ABBREV		/* word abbreviation mode */
  #   define BACKUPFILES		/* enable the backup files code */
  #   ifndef MSDOS
! /* #       define BIFF		/* if you have biff (or the equivalent) */
  #       define F_COMPLETION	/* filename completion */
  #       define CHDIR		/* cd command and absolute pathnames */
  #       define	KILL0		/* kill(pid, 0) returns 0 if proc exists */
***************
*** 67,73
  #       define BIFF		/* if you have biff (or the equivalent) */
  #       define F_COMPLETION	/* filename completion */
  #       define CHDIR		/* cd command and absolute pathnames */
! #       define	KILL0	/* kill(pid, 0) returns 0 if proc exists */
  #       define SPELL		/* spell words and buffer commands */
  #       define ID_CHAR		/* include code to IDchar */
  #       define WIRED_TERMS	/* include code for wired terminals */

--- 72,78 -----
  /* #       define BIFF		/* if you have biff (or the equivalent) */
  #       define F_COMPLETION	/* filename completion */
  #       define CHDIR		/* cd command and absolute pathnames */
! #       define	KILL0		/* kill(pid, 0) returns 0 if proc exists */
  #       define SPELL		/* spell words and buffer commands */
  /* #       define ID_CHAR		/* include code to IDchar */
  /* #       define WIRED_TERMS	/* include code for wired terminals */
***************
*** 69,76
  #       define CHDIR		/* cd command and absolute pathnames */
  #       define	KILL0	/* kill(pid, 0) returns 0 if proc exists */
  #       define SPELL		/* spell words and buffer commands */
! #       define ID_CHAR		/* include code to IDchar */
! #       define WIRED_TERMS	/* include code for wired terminals */
  #       define ANSICODES	/* extra commands that process ANSI codes */
  #   endif
  #   define LISP			/* include the code for Lisp Mode */

--- 74,81 -----
  #       define CHDIR		/* cd command and absolute pathnames */
  #       define	KILL0		/* kill(pid, 0) returns 0 if proc exists */
  #       define SPELL		/* spell words and buffer commands */
! /* #       define ID_CHAR		/* include code to IDchar */
! /* #       define WIRED_TERMS	/* include code for wired terminals */
  #       define ANSICODES	/* extra commands that process ANSI codes */
  #   endif
  #   define LISP			/* include the code for Lisp Mode */
SHAR_EOF
fi # end of overwriting check
if test -f '.joverc'
then
	echo shar: will not over-write existing file "'.joverc'"
else
cat << \SHAR_EOF > '.joverc'
set make-backup-files on
set allow-^S-and-^Q on
set case-ignore-search on
set mail-check-frequency 0
set update-time-frequency 0
set paren-flash-delay 15
set mode-line --%m*-%m*--Jove: %b     %[%f%] (%M)------------------------------------------------------------%e
auto-execute-command c-mode .*\.[ch]$
auto-execute-command show-match-mode .*$
bind-to-key backward-character 
bind-to-key i-search-forward ^S
bind-to-key i-search-reverse ^R
bind-to-key fill-paragraph ^[q
bind-to-key fill-paragraph ^[Q
bind-to-key prefix-3 ^[[
bind-to-key previous-line ^[[A
bind-to-key previous-page ^[[H
bind-to-key next-page ^[[V
bind-to-key backward-character ^[[D
bind-to-key i-search-forward ^[[G
bind-to-key forward-character ^[[C
bind-to-key backward-word ^[[Y
bind-to-key next-line ^[[B
bind-to-key forward-word ^[[U
bind-to-key set-mark ^[[@
bind-to-key prefix-1 ^[N
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0