From: Jeff Lee <talcott!seismo!gatech!jeff>
Subject: Georgia Tech 'se' screen editor (Part 1 of 8)
Keywords: Software Tools, Yet Another Screen Editor, Both BSD and USG
Newsgroups: mod.sources
Approved: jpn@panda.UUCP

Mod.sources:  Volume 4, Issue 82
Submitted by: Jeff Lee <seismo!gatech!jeff>

#! /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:
#	README
#	ascii.h
#	constdefs.h
#	debug.h
#	extern.h
#	se.h
#	m4munge
#	where
#	makefile
# This archive created: Tue Apr 29 10:45:25 1986
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'README'" '(5755 characters)'
if test -f 'README'
then
	echo shar: "will not over-write existing file 'README'"
else
cat << \SHAR_EOF > 'README'
README:

This directory contains the source files for the Vax version of the Georgia
Tech Screen Editor "Se".  It has three subdirectories which contain things
that se needs. Here is a rundown of the various files.

Files containing documentation are:

README		-- this file.
se.m4		-- nroff manual page for se (has to be munged to create se.1).
scriptse.1	-- nroff manual page for scriptse.

The header files are:

ascii.h		-- definition of ASCII mnemonics and control characters.
extern.h	-- external data definitions for the screen editor.
se.h		-- global #define's for the screen editor.
constdefs.h	-- global constants, also used by files in subdirectories.

The C source files are:

main.c		-- main program and declaration of globals, initialization.
edit.c		-- main command loop to get and execute commands, file handling.
docmd1.c	-- command decoder and functions for most commands.
docmd2.c	-- functions for the rest of the commands.
misc.c		-- miscellanious functions.
scratch.c	-- scratch file manipulating functions.
screen.c	-- routines to keep track of the screen contents.
term.c		-- routines for changing the terminal.

The subdirectories are:

libchangetty	-- routines to change the terminal driver back and forth.
pat		-- pattern matching routines.
se_h		-- contains help scripts for all commands in se.

Miscellanious files:

where		-- shell file to determine System V (R 1 or 2), 4.1, or 4.2 BSD.
m4munge		-- manipulate output of where for m4 for se man page
makefile	-- the makefile for make(1).
print2		-- inode used by make for printing only changed stuff.

scriptse.c	-- quick and dirty C program to make scripts for se.
scriptse.1	-- manual page for same.

Executable files:

se		-- executable version of the screen editor.
scriptse	-- the executable version of the script maker.


Conditional Compilation flags:

	The flag HARD_TERMS, if added to the CFLAGS macro in the makefile,
will remove the terminal-independant code which uses termlib, and put back
the original, terminal-types-hardwired-into-the-program code.  The only
reason to do this is if se has to run on a system without the termlib pacakage.
Using termlib, se is considerably smaller, as well as more flexible.

	The flag OLD_SCRATCH, if added to the CFLAGS macro in the makefile,
will cause se to use the original, linked-list method for keeping track of
lines in the buffer.  This method is faster for rearranging lines, but
considerably slower for simply looking up lines.  Currently, se uses the
method given is Software Tools in Pascal, which keeps the lines in order in
an array.  It is slower at rearranging, but as fast as possible for finding
lines in the buffer.  This version also takes less data and code space.

	The flag OLD_GLOB, if added to the CFLAGS macro in the makefile,
will keep se from special casing commands whose effect is to reverse the
order of the lines in the buffer.  The special casing code can save an
*incredible* amount of time for this pathological case, so it is best to leave
things alone.  This only applies to the Software Tools in Pascal style
line handling.

	The flag LOG_USAGE, if added to the CFLAGS macro in the makefile,
will cause se to write usage "statistics" to a log file, consisting of the
login name and time and date when an individual used se.  This is only done
at Georgia Tech, and the logfile path name in the log() routine in edit.c
should be changed to use a system accounting file somewhere.  It currently
creates a file in /usr/tmp.

	The 'where' command creates a file called 'flags', which the makefile
cats inside ``s.  These define and/or undefine the flags USG for System V,
S5R2 if for Release 2, BSD for 4.1 and 4.2, and BSD4_2 for 4.2 specific code.

Miscellanious:

	Code which is dependant on the Berkeley job control stuff is also
conditionally compiled in, so that on systems without it, it won't get in
the way.

	Code has been added which should allow se to come up under USG Unix
5.0 (System V).  If S5R2 is defined, se will use the terminfo package.
Otherwise, it assumes Release 1, and that the BSD termlib package has
been ported and is available.

	The where program will also define or undefine GITVAX.  This is
is used 1) to allow control-s and control-q as control characters, and
2) to come up in SWT mode.

Comments:

	It is a big piece of software. But, if you 1) read both Software Tools
and Software Tools in Pascal (the chapters on editing and pattern matching, if
you don't want to read all of the books), and 2) take your time, you should be
able to understand, and eventually make changes to it, as necessary.

Authors:

	Se started out as the version of 'ed' that came with the book 'Sofware
Tools', by Kernighan and Plauger, which was written in Ratfor. On the Pr1me
computers at the School of Information and Computer Science at Georgia Tech,
Dan Forsyth, Perry Flinn, and Alan Akin added all the enhancements suggested
in the exercises in the book, and some more of their own. Jack Waugh made
extensive modifications to turn it into a screen editor; further work was done
by Dan Forsyth. All of this was in an improved Georgia Tech version of Ratfor.

	Later, Dan Forsyth, then (and now) at Medical Systems Develepment
Corporation, converted the Ratfor version into C, for Berkeley Unix (4.1 BSD).
At Georgia Tech, Arnold Robbins took the C version and added many new features
and improvements, the most important of which was termcap support and System V
support. The existing help screens were edited and completed at that time, as
well. This was completed in early 1985.

	Arnold Robbins is now at ...!gatech!emory!arnold, and will make every
reasonable attempt to answer any questions anyone may have about it, but in
no way promises to support or enhance 'se'.
SHAR_EOF
fi
echo shar: "extracting 'ascii.h'" '(1225 characters)'
if test -f 'ascii.h'
then
	echo shar: "will not over-write existing file 'ascii.h'"
else
cat << \SHAR_EOF > 'ascii.h'
/*
** ascii.h
**
** definitions of ASCII mnemonics and synonyms.
*/

#ifndef	_ASCII_H
#define	_ASCII_H
#define	NUL	'\0'
#define	SOH	'\001'
#define	STX	'\002'
#define	ETX	'\003'
#define	EOT	'\004'
#define	ENQ	'\005'
#define	ACK	'\006'
#define	BEL	'\007'
#define	BS	'\010'
#define	HT	'\011'
#define	LF	'\012'
#define	VT	'\013'
#define	FF	'\014'
#define	CR	'\015'
#define	SO	'\016'
#define	SI	'\017'
#define	DLE	'\020'
#define	DC1	'\021'
#define	DC2	'\022'
#define	DC3	'\023'
#define	DC4	'\024'
#define	NAK	'\025'
#define	SYN	'\026'
#define	ETB	'\027'
#define	CAN	'\030'
#define	EM	'\031'
#define	SUB	'\032'
#define	ESC	'\033'
#define	FS	'\034'
#define	GS	'\035'
#define	RS	'\036'
#define	US	'\037'
#define	SP	'\040'
#define	DEL	'\177'
#define	CTRL_A	SOH
#define	CTRL_B	STX
#define	CTRL_C	ETX
#define	CTRL_D	EOT
#define	CTRL_E	ENQ
#define	CTRL_F	ACK
#define	CTRL_G	BEL
#define	CTRL_H	BS
#define	CTRL_I	HT
#define	CTRL_J	LF
#define	CTRL_K	VT
#define	CTRL_L	FF
#define	CTRL_M	CR
#define	CTRL_N	SO
#define	CTRL_O	SI
#define	CTRL_P	DLE
#define	CTRL_Q	DC1
#define	CTRL_R	DC2
#define	CTRL_S	DC3
#define	CTRL_T	DC4
#define	CTRL_U	NAK
#define	CTRL_V	SYN
#define	CTRL_W	ETB
#define	CTRL_X	CAN
#define	CTRL_Y	EM
#define	CTRL_Z	SUB
#endif
SHAR_EOF
fi
echo shar: "extracting 'constdefs.h'" '(153 characters)'
if test -f 'constdefs.h'
then
	echo shar: "will not over-write existing file 'constdefs.h'"
else
cat << \SHAR_EOF > 'constdefs.h'
/*
** constdefs.h
**
** Standard macro definitions for se screen editor
*/

#define	EOS '\0'
#define	ERR (-3)
#define	OK (-2)
#define	NO 0
#define	YES 1
SHAR_EOF
fi
echo shar: "extracting 'debug.h'" '(119 characters)'
if test -f 'debug.h'
then
	echo shar: "will not over-write existing file 'debug.h'"
else
cat << \SHAR_EOF > 'debug.h'
/*
** debug.h
**
** put debugging code into programs
*/

#ifdef DEBUG
#define debug(x)	x
#else
#define debug(x)
#endif
SHAR_EOF
fi
echo shar: "extracting 'extern.h'" '(4918 characters)'
if test -f 'extern.h'
then
	echo shar: "will not over-write existing file 'extern.h'"
else
cat << \SHAR_EOF > 'extern.h'
/*
** extern.h
**
** external data definitions
** for the screen editor
*/

/* Concerning line numbers: */
extern int Line1;		/* first line number on command */
extern int Line2;		/* second line number on command */
extern int Nlines;		/* number of line numbers specified */
extern int Curln;		/* current line; value of dot */
extern int Lastln;		/* last line; value of dollar */


/* Concerning patterns: */
extern char Pat[MAXPAT];	/* saved pattern */


/* Concerning the text of lines: */
extern char Txt[MAXLINE];	/* text of current line */


/* Concerning file names: */
extern char Savfil[MAXLINE];	/* remembered file name */


/* Concerning line descriptors: */
extern LINEDESC Buf[MAXBUF];
#ifdef OLD_SCRATCH
extern LINEDESC *Lastbf;	/* last pointer used in Buf */
extern LINEDESC *Free;		/* head of free list */
#endif
extern LINEDESC *Line0;		/* head of list of line descriptors */


/* Concerning the 'undo' command: */
extern LINEDESC *Limbo;		/* head of limbo list for undo */
extern int Limcnt;		/* number of lines in limbo list */


/* Concerning the scratch file: */
extern filedes Scr;		/* scratch file descriptor */
extern unsigned Scrend;		/* end of info on scratch file */
extern char Scrname[MAXLINE];	/* name of scratch file */
extern int Lost_lines;		/* number of garbage lines in scratch file */


/* Concerning miscellaneous variables */
extern int Buffer_changed;	/* YES if buffer changed since last write */
extern int Errcode;		/* cause of most recent error */
extern int Saverrcode;		/* cause of previous error */
extern int Probation;		/* YES if unsaved buffer can be destroyed */
extern int Argno;		/* command line argument pointer */
extern char Last_char_scanned;	/* last char scanned with ctl-s or -l */
#ifdef HARD_TERMS
extern int Tspeed;		/* terminal speed in characters/second */
#endif
extern char Peekc;		/* push a SKIP_RIGHT if adding delimiters */
#ifdef BSD4_2
extern int Reading;		/* are we doing terminal input? */
#endif


/* Concerning options: */
extern int Tabstops[MAXLINE];	/* array of tab stops */
extern char Unprintable;	/* char to print for unprintable chars */
extern int Absnos;		/* use absolute numbers in margin */
extern int Nchoise;		/* choice of line number for cont. display */
extern int Overlay_col;		/* initial cursor column for 'v' command */
extern int Warncol;		/* where to turn on column warning */
extern int Firstcol;		/* leftmost column to display */
extern int Indent;		/* indent col; 0=same as previous line */
extern int Notify;		/* notify user if he has mail in mail file */
extern int Globals;		/* substitutes in a global don't fail */
extern int No_hardware;		/* never use hardware insert/delete */


#ifdef HARD_TERMS
/* Concerning the terminal type */
extern int Term_type;          /* terminal type */
#endif


/* Concerning the screen format: */
extern char Screen_image[MAXROWS][MAXCOLS];
extern char Msgalloc[MAXCOLS];	/* column allocation of status line */
extern int Nrows;		/* number of rows on screen */
extern int Ncols;		/* number of columns on screen */
extern int Currow;		/* vertical cursor coordinate */
extern int Curcol;		/* horizontal cursor coordinate */
extern int Toprow;		/* top row of window field on screen */
extern int Botrow;		/* bottom row of window field on screen */
extern int Cmdrow;		/* row number of command line */
extern int Topln;		/* line number of first line on screen */
extern int Insert_mode;		/* flag to specify character insertion */
extern int Invert_case;		/* flag to specify case mapping on input */
extern int First_affected;	/* number of first line affected by cmd */
extern int Rel_a;		/* char to use for first alpha line number */
extern int Rel_z;		/* char to use for last alpha line number */
extern int Scline[MAXROWS];	/* lines currently on screen (rel to Sctop) */
extern int Sctop;		/* first line currently on screen */
extern int Sclen;		/* number of lines currently on screen */
extern char Blanks[MAXCOLS];	/* all blanks for filling in lines on screen */
extern char Tobuf[MAXTOBUF];	/* buffer for collecting terminal output */
extern char *Tobp;		/* pointer to last used part of Tobuf */


/* Concerning interrupts: */
extern int Int_caught;		/* caught a SIGINT from user */
extern int Hup_caught;		/* caught a SIGHUP when phone line dropped */
#ifdef SIGTSTP
extern int Catching_stops;	/* catching or ignoring SIGTSTP's? */
#endif

/* Concerning Unix and SWT compatiblity: */
extern int Unix_mode;		/* behaving like Unix editors? */
extern char BACKSCAN;		/* back scan character */
extern char NOTINCCL;		/* class negation character */
extern char XMARK;		/* global exclude on mark name */
extern char ESCAPE;		/* escape character */

/* Concerning Georgia Tech I.C.S. specific code: */
extern int At_gtics;		/* are we at Georgia Tech ICS? */

/* Concerning file encryption: */
extern int Crypting;		/* doing file encryption? */
extern char Key[KEYSIZE];	/* encryption key */
SHAR_EOF
fi
echo shar: "extracting 'se.h'" '(7529 characters)'
if test -f 'se.h'
then
	echo shar: "will not over-write existing file 'se.h'"
else
cat << \SHAR_EOF > 'se.h'
/* se.h	--- definitions	for the	screen editor */

#include <stdio.h>
#include <ctype.h>
#include <signal.h>

/* some standard definitions used throughout the screen editor */
#include "constdefs.h"
#include "ascii.h"	/* definitions of ascii characters */

/* new data types */
typedef	int filedes;		/* Unix	file descriptor	*/

typedef	struct ldesc {		/* line	descriptor */
#ifdef OLD_SCRATCH
	struct	ldesc *Prevline; /* link to previous line */
	struct	ldesc *Nextline; /* link to next line */
#endif
	unsigned Seekaddr;	/* scratch file seek address / 8 */
	unsigned Lineleng : 16;	/* line length	including NL  EOS */
	unsigned Globmark : 1;	/* mark for global commands */
	unsigned Markname : 7;	/* mark name associated with line */
} LINEDESC;

/* Language extensions */
#define min(a,b)	((a)<(b)?(a):(b))
#define max(a,b)	((a)>(b)?(a):(b))
#define SKIPBL(l,i)	while (l[i] == ' ') (i)++

/* save a little procedure call overhead... */
#define remark(text)	mesg(text, REMARK_MSG)

/* Arbitrary definitions */
#define BACKWARD	-1
#define FORWARD		0
#define NOSTATUS	1
#define NOMORE		0
#define NEWLINE		'\n'
#define TAB		'\t'
#define RETERR	1
#define RETOK	0

/* Array dimensions and	other limit values */
#define MAXBUF		8192
#define MAXTOBUF	512
#define MAXCHARS	10
#define MAXROWS		200
#define MINROWS		16
#define MAXCOLS		200
#define MAXLINE		512
#define MAXPAT		512
#define GARB_FACTOR	2
#define GARB_THRESHOLD	1000
#define BUFENT		1
#define KEYSIZE		11

/* Message classes for status line at bottom of	screen */
#define NOMSG		0
#define REMARK_MSG	1
#define CHAR_MSG	2
#define CASE_MSG	3
#define INS_MSG		4
#define TIME_MSG	5
#define FILE_MSG	6
#define COL_MSG		7
#define LINE_MSG	8
#define COMPRESS_MSG	9
#define HELP_MSG	10
#define MODE_MSG	11
#define CRYPT_MSG	12

/* Characters typed by the user	*/
#define ANYWAY		'!'
#define APPENDCOM	'a'
#define UCAPPENDCOM	'A'
#define BACKSEARCH	'<'
#define CHANGE		'c'
#define UCCHANGE	'C'
#define COPYCOM		't'
#define UCCOPYCOM	'T'
#define CURLINE		'.'
#define DEFAULTNAME	' '
#define DELCOM		'd'
#define UCDELCOM	'D'
#define ENTER		'e'
#define UCENTER		'E'
#define EXCLUDE		'x'
#define UCEXCLUDE	'X'
#define GLOBAL		'g'
#define UCGLOBAL	'G'
#define GMARK		'\''
#define HELP		'h'
#define UCHELP		'H'
#define INSERT		'i'
#define UCINSERT	'I'
#define JOINCOM		'j'
#define UCJOINCOM	'J'
#define LASTLINE	'$'
#define LOCATECMD	'l'
#define UCLOCATECMD	'L'
#define MARKCOM		'k'
#define UCMARKCOM	'K'
#define MOVECOM		'm'
#define UCMOVECOM	'M'
#define NAMECOM		'n'
#define UCNAMECOM	'N'
#define OPTCOM		'o'
#define UCOPTCOM	'O'
#define PAGECOM		':'
#define OVERLAYCOM	'v'
#define UCOVERLAYCOM	'V'
#define PREVLINE	'^'
#define PREVLINE2	'-'
#define PRINT		'p'
#define UCPRINT		'P'
#define PRINTCUR	'='
#define PRINTFIL	'f'
#define UCPRINTFIL	'F'
#define QUIT		'q'
#define UCQUIT		'Q'
#define READCOM		'r'
#define UCREADCOM	'R'
#define SCAN		'/'
#define SEARCH		'>'
#define SUBSTITUTE	's'
#define UCSUBSTITUTE	'S'
#define TLITCOM		'y'
#define UCTLITCOM	'Y'
#define TOPLINE		'#'
#define UNDOCOM		'u'
#define UCUNDOCOM	'U'
#define WRITECOM	'w'
#define UCWRITECOM	'W'
#define MISCCOM		'z'
#define UCMISCCOM	'Z'
#define SHELLCOM	'!'

/* Error message numbers.  Arbitrary so	long as	they are different. */
#define EBACKWARD	1
#define ENOPAT		2
#define EBADPAT		3
#define EBADSTR		4
#define EBADSUB		5
#define ECANTREAD	6
#define EEGARB		7
#define EFILEN		8
#define EBADTABS	9
#define EINSIDEOUT	10
#define EKNOTFND	11
#define ELINE1		12
#define E2LONG		13
#define ENOERR		14
#define ENOLIMBO	15
#define EODLSSGTR	16
#define EORANGE		17
#define EOWHAT		18
#define EPNOTFND	19
#define ESTUPID		20
#define EWHATZAT	21
#define EBREAK		22
#define ELINE2		23
#define ECANTWRITE	24
#define ECANTINJECT	25
#define ENOMATCH	26
#define ENOFN		27
#define EBADLIST	28
#define ENOLIST		29
#define ENONSENSE	30
#define ENOHELP		31
#define EBADLNR		32
#define EFEXISTS	33
#define EBADCOL		34
#define ENOLANG		35
#define ETRUNC		36
#define ENOSHELL	37
#define ECANTFORK	38
#define EHANGUP		39
#define ENOSUB		40
#define ENOCMD		41

#ifdef HARD_TERMS
/* Terminal types */
#define NOTERM		0	/* type	not known yet */
#define ADDS980		1	/* ADDS	Consul 980 */
#define ADDS100		2	/* ADDS	Regent 100, 20,	40, etc	*/
#define FOX		3	/* Perkin-Elmer	1100 */
#define TVT		4	/* Allen's SWTPC T. V. Typewriter II */
#define GT40		5	/* DEC GT40 with Waugh terminal	program	*/
#define BEE150		6	/* Beehive 150 */
#define BEE200		7	/* Beehive 200 */
#define SBEE		8	/* Beehive Super-Bee */
#define SOL		9	/* Sol emulating Beehive 200 */
#define HAZ1510		10	/* Hazeltine 1500 series */
#define CG		11	/* Chromatics CG */
#define ISC8001		12	/* ISC 8001 color terminal */
#define ADM3A		13	/* Lear-Siegler	ADM 3A */
#define IBM		14	/* IBM 3101 */
#define ANP		15	/* Allen & Paul	model 1	*/
#define NETRON		16	/* Netronics */
#define H19		17	/* Heath H19/Zenith Z19	*/
#define TRS80		18	/* Radio Shaft TRS80 */
#define HP21		19	/* Hewlett-Packard 2621A/P */
#define ADM31		20	/* Lear-Siegler	ADM 31 */
#define VI200		21	/* VIsual 200 terminal */
#define VC4404		22	/* Volker-Craig	4404 */
#define ESPRIT		23	/* Hazeltine Esprit (Hazeltine mode) */
#define TS1		24	/* Falco TS-1 */
#define TVI950		25	/* Televideo 950 */
#define VI50		26	/* Visual 50 */
#define VI300		27	/* Visual 300	*/
#endif

/* Screen design positions */
#define NAMECOL		5	/* column to put mark name in */
#define BARCOL		6	/* column for "|" divider */
#define POOPCOL		7	/* column for text to start in */

/* Control characters */

/* Leftward cursor motion */
#define CURSOR_LEFT		CTRL_H	/* left	one column */
#define TAB_LEFT		CTRL_E	/* left	one tab	stop */
#define SKIP_LEFT		CTRL_W	/* go to column	1 */
#define SCAN_LEFT		CTRL_L	/* scan	left for a char	*/
#define G_LEFT			CTRL_U	/* erase char to left */
#define G_TAB_LEFT		FS	/* erase to prev tab stop */
#define KILL_LEFT		CTRL_Y	/* erase to column 1 */
#define G_SCAN_LEFT		CTRL_N	/* scan	left and erase */

/* Rightward cursor motion */
#define CURSOR_RIGHT		CTRL_G	/* right one column */
#define TAB_RIGHT		CTRL_I	/* right one tab stop */
#define SKIP_RIGHT		CTRL_O	/* go to end of	line */
#ifdef GITVAX
#define SCAN_RIGHT		CTRL_S	/* scan	right for char */
#else
#define SCAN_RIGHT		CTRL_J	/* scan	right for char */
#endif
#define G_RIGHT			CTRL_R	/* erase over cursor */
#define G_TAB_RIGHT		RS	/* erase to next tab */
#define KILL_RIGHT		CTRL_T	/* erase to end	of line	*/
#define G_SCAN_RIGHT		CTRL_B	/* scan	right and erase	*/

/* Line	termination */
#define T_SKIP_RIGHT		CTRL_V	/* skip	to end and terminate */
#define T_KILL_RIGHT		CR	/* KILL_RIGHT,	SKIP_RIGHT_AND_TERM */
#define FUNNY			CTRL_F	/* take	funny return */
#define CURSOR_UP		CTRL_D	/* move	up one line */
#define CURSOR_DOWN		CTRL_K	/* move	down one line */
#define CURSOR_SAME		CTRL_J	/* leave cursor	on same	line */

/* Insertion */
#define INSERT_BLANK		CTRL_C	/* insert one blank */
#define INSERT_TAB		CTRL_X	/* insert blanks to next tab */
#define INSERT_NEWLINE		US	/* insert a newline */

/* Miscellany */
#define TOGGLE_INSERT_MODE	CTRL_A	/* toggle insert mode flag */
#define SHIFT_CASE		CTRL_Z	/* toggle case mapping flag */
#define KILL_ALL		DEL	/* erase entire	line */
#ifdef GITVAX
#define FIX_SCREEN		CTRL_Q	/* clear and restore screen */
#else
#define FIX_SCREEN		GS	/* clear and restore screen */
#endif

/* Function for moving around the buffer, either style line handling: */
#ifdef OLD_SCRATCH
#define NEXTLINE(k)	((k) -> Nextline)
#else
#define NEXTLINE(k)	(((k) < &Buf[Lastln]) ? (k) + 1 : Line0)
#endif
SHAR_EOF
fi
echo shar: "extracting 'm4munge'" '(548 characters)'
if test -f 'm4munge'
then
	echo shar: "will not over-write existing file 'm4munge'"
else
cat << \SHAR_EOF > 'm4munge'
#! /bin/sh
# m4munge --- take what the 'where' command produces, and change it for m4

for i in $*
do
	case $i in
	-DUSG)		echo 'define(USG,YES)'		;;
	-UUSG)		echo 'define(USG,NO)'		;;
	-DBSD)		echo 'define(BSD,YES)'		;;
	-UBSD)		echo 'define(BSD,NO)'		;;
	-DBSD4_2)	echo 'define(BSD4_2,YES)'	;;
	-UBSD4_2)	echo 'define(BSD4_2,NO)'	;;
	-DGITVAX)	echo 'define(GITVAX,YES)'	;;
	-UGITVAX)	echo 'define(GITVAX,NO)'	;;
	-DS5R2)		echo 'define(S5R2,YES)'		;;
	-US5R2)		echo 'define(S5R2,NO)'		;;
	-DHARD_TERMS)	echo 'define(HARD_TERMS,YES)'	;;
	esac
done
SHAR_EOF
chmod +x 'm4munge'
fi
echo shar: "extracting 'where'" '(1263 characters)'
if test -f 'where'
then
	echo shar: "will not over-write existing file 'where'"
else
cat << \SHAR_EOF > 'where'
#! /bin/sh

# where --- shell file to determine what kind of environment we are in

if test -r /bin/universe	# on a pyramid
then
	OPATH=$PATH
	PATH=/bin
	case `universe` in	# universe is dumb, looking only at argv[0]
	att)	echo "-DUSG -UBSD -UBSD4_2"
		if grep LOBLK /usr/include/sys/termio.h > /dev/null
		then
			echo -DS5R2
		else
			echo -US5R2
		fi
		;;

	ucb)	echo "-UUSG -DBSD -DBSD4_2 -US5R2"
		;;

	*)	echo unknown operating system! 1>&2
		echo "-UUSG -UBSD -UBSD4_2"	# undefine them all
		echo "-US5R2"
		;;
	esac
	PATH=$OPATH
	echo -UGITVAX	# pyramid is never GITVAX
else		# on something that is not a pyrmaid
	if grep SIGTSTP /usr/include/signal.h > /dev/null
	then		# berkeley unix
		if test -r /usr/include/whoami.h	# 4.1
		then
			echo "-UUSG -DBSD -UBSD4_2"
			host="`sed 's/[^\"]*\"\([^\"]*\)\"/\1/' < /usr/include/whoami.h`"
		else					# 4.2
			echo "-UUSG -DBSD -DBSD4_2"
			host=`hostname`
		fi
		case $host in
		gatech | \
		gt-nimbus | nimbus | \
		gt-cirrus | cirrus | \
		gt-stratus | stratus)	echo -DGITVAX
				;;
		
		*)	echo -UGITVAX
			;;
		esac
		echo -US5R2
	else			# ATT unix
		echo "-DUSG -UBSD -UBSD4_2"
		if grep LOBLK /usr/include/sys/termio.h > /dev/null
		then
			echo -DS5R2
		else
			echo -US5R2
		fi
		echo -UGITVAX
	fi
fi
SHAR_EOF
chmod +x 'where'
fi
echo shar: "extracting 'makefile'" '(3113 characters)'
if test -f 'makefile'
then
	echo shar: "will not over-write existing file 'makefile'"
else
cat << \SHAR_EOF > 'makefile'
# makefile for the Georgia Tech Screen Editor, 'se'

HEADERS= ascii.h constdefs.h extern.h se.h

SRCS= docmd1.c docmd2.c edit.c main.c misc.c scratch.c screen.c term.c
OBJS= docmd1.o docmd2.o edit.o main.o misc.o scratch.o screen.o term.o

LIBRARIES= libchangetty/libchangetty.a pat/libpat.a

LIBS=`echo $(LIBRARIES); if egrep 'DBSD|US5R2' flags > /dev/null; then echo -ltermlib; else echo -lcurses; fi`

DOCS= makefile README changes.made
MANS= scriptse.1 se.1

CFLAGS= -O `cat flags`
LDFLAGS=

# On BSD systems, force make to use the right shell for commands
SHELL=/bin/sh

###########################################################################
# Begin system dependant macro definitions

# PR is to print the files nicely.  Use pr -n if available, or else just pr
# I use a private utility called 'prt'
PR=prt

# NROFF is for nroffing.  we use the System V nroff. 
NROFF=/usr/5bin/nroff

# MANSEC is where to put the manual pages. Use 'l' for local, otherwise '1'.
MANSEC=l

# DESTBIN is where se and scriptse will go
DESTBIN= /usr/local/bin

# OWNER and GROUP are the owner and group respectively
OWNER= root
GROUP= admin

# INSTALL is the program to do the installation, use cp for real work
INSTALL= cp

# CHOWN changes the owner.
CHOWN= /etc/chown

# CHGRP changes the group.
CHGRP= chgrp

# CHMOD will change permissions.
CHMOD= chmod

########
# other things to change:
#
# on non-BSD systems, change the 'lpr' below to 'lp'
########

# Begin list of dependencies

all: se scriptse se.1
	@echo all done

se: $(OBJS) $(LIBRARIES)
	$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@

$(OBJS): $(HEADERS) flags

flags: where
	where > flags

libchangetty/libchangetty.a: libchangetty/changetty.c
	cd libchangetty; make

pat/libpat.a: pat/pat.c
	cd pat; make

scriptse: scriptse.c
	$(CC) -O scriptse.c -o scriptse

se.1: se.m4 flags
	(m4munge $(CFLAGS) ; cat se.m4) | m4 | sed '/^$$/d' > se.1

install: all $(MANS)
	$(INSTALL) se $(DESTBIN)
	$(CHOWN) $(OWNER) $(DESTBIN)/se
	$(CHGRP) $(GROUP) $(DESTBIN)/se
	$(CHMOD) 711 $(DESTBIN)/se 
	$(INSTALL) scriptse $(DESTBIN)
	$(CHOWN) $(OWNER) $(DESTBIN)/scriptse
	$(CHGRP) $(GROUP) $(DESTBIN)/scriptse
	$(CHMOD) 711 $(DESTBIN)/scriptse 
	$(INSTALL) se.1 /usr/man/man$(MANSEC)/se.$(MANSEC)
	$(CHOWN) $(OWNER) /usr/man/man$(MANSEC)/se.$(MANSEC)
	$(CHGRP) $(GROUP) /usr/man/man$(MANSEC)/se.$(MANSEC)
	$(CHMOD) 644 /usr/man/man$(MANSEC)/se.$(MANSEC)
	$(INSTALL) scriptse.1 /usr/man/man$(MANSEC)/scriptse.$(MANSEC)
	$(CHOWN) $(OWNER) /usr/man/man$(MANSEC)/scriptse.$(MANSEC)
	$(CHGRP) $(GROUP) /usr/man/man$(MANSEC)/scriptse.$(MANSEC)
	$(CHMOD) 644 /usr/man/man$(MANSEC)/scriptse.$(MANSEC)
	cd se_h; make install
	
print:
	$(PR) $(HEADERS) $(SRCS) $(DOCS) $(MANS) | lpr

printman: $(MANS)
	$(NROFF) -man $(MANS) | col | lpr

print2:	$(HEADERS) $(SRCS) $(DOCS) $(MANS)
	$(PR) $? | lpr

printall: printman print
	cd pat; make print
	cd libchangetty; make print
	cd se_h; make print

clean:
	rm -f *.o print2
	cd pat; make clean
	cd libchangetty; make clean

clobber: clean
	rm -f se scriptse flags se.1
	cd pat; make clobber
	cd libchangetty; make clobber
	cd se_h; make clobber
SHAR_EOF
fi
exit 0
#	End of shell archive

