allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (06/22/89)
Posting-number: Volume 7, Issue 52 Submitted-by: fox@marlow.UUCP (Paul Fox) Archive-name: crisp1.9/part32 #!/bin/sh # this is part 11 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file ./undo.c continued # CurArch=11 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 echo "x - Continuing file ./undo.c" sed 's/^X//' << 'SHAR_EOF' >> ./undo.c X curbp->b_nummod--; X re_goto(undop); X pos = ftell(ufp); X while (undop->u_length > 0) { X fseek(ufp, pos, 0); X n = undop->u_length; X if (n > sizeof buf) X n = sizeof buf; X fread(buf, n, 1, ufp); X linsert(buf, n); X pos += n; X undop->u_length -= n; X } X if (undo_state == UNDO) X re_goto(undop); X break; X case GOTO: X re_goto(undop); X break; X X case DELETE: X curbp->b_nummod--; X re_goto(undop); X ldelete(undop->u_length); X break; X X case RAISE: X raise_anchor(); X break; X X case DROP: X drop_anchor(); X *curbp->b_anchor = undop->u_anchor; X break; X case SCRAP: X undoing_scrap = TRUE; X k_undo(); X undoing_scrap = FALSE; X break; X default: X ewprintf("undo: opcode error"); X } X /*if (hooked) X curwp->w_flag |= WFHARD;*/ X u_atend = FALSE; X/* fseek(ufp, 0l, 2);*/ X return 0; X} Xstatic void Xre_goto(undop) Xstruct undo *undop; X{ X win_modify(WFMOVE); X *cur_line = undop->u_line; X *cur_col = (u_int16) undop->u_col; X win_modify(WFMOVE); X} Xstatic Xread_last_undo(undop, up) Xstruct undo *undop; Xundo_info *up; X{ X fseek(ufp, up->u_last, 0); X if (fread((char *) undop, sizeof *undop, 1, ufp) != 1) { X fseek(ufp, 0l, 2); X u_atend = TRUE; X ewprintf("undo: I/O error"); X return -1; X } X u_atend = FALSE; X return 0; X} SHAR_EOF echo "File ./undo.c is complete" chmod 0444 ./undo.c || echo "restore of ./undo.c fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./unix.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ./unix.c && X/************************************************************** X * X * CRISP - Custom Reduced Instruction Set Programmers Editor X * X * (C) Paul Fox, 1989 X * 43, Jerome Close Tel: +44 6284 4222 X * Marlow X * Bucks. X * England SL7 1TX X * X * X * Please See COPYRIGHT notice. X * X **************************************************************/ X X# include "list.h" X# if defined(SYSV) X# include <termio.h> X static struct termio ot; /* entry state of the terminal */ X static struct termio nt; /* editor's terminal state */ X# else X# include <sys/time.h> X# include <sgtty.h> X struct sgttyb ot; X struct sgttyb nt; X# define TCGETA TIOCGETP X# define TCSETA TIOCSETN X# endif X XSCCSID("@(#) unix.c 1.6, (C) 1989, P. Fox"); X X/*--------------------------------------- X/* Directory entries for CRISP under VMS. X/*---------------------------------------*/ Xchar *termcap_dir = "/etc/termcap"; Xchar *bhelp = "/usr/local/crisp/help"; Xchar *bpath = "/usr/local/crisp/macros;.;/usr/local/crisp/src"; X X X X# define CENTISECONDS 5 /* x0.1 seconds */ Xvoid ttflush(); Xextern int ega43_flag; Xint console_mode = -1; /* Only used on EGA screen. */ X Xextern unsigned char kbdq; Xint kbdflgs = 0; /* saved keyboard fd flags */ X Xstatic int ttyactivep = FALSE; X/* X * This function gets called once, to set up X * the terminal channel. This version turns off flow X * control. This may be wrong for your system, but no X * good solution has really been found (daveb). X */ Xvoid Xsys_open() X{ X if (ttyactivep) X return; X# if defined(CONS_GET) X /*---------------------------------------- X /* We want to handle the peculiarities of X /* EGA 43 line mode on those systems that X /* support it. We need to handle things X /* like ALT-Z being used to change screen X /* modes. Setting old_ega_flag to -1 X /* ensures that when the sub-shells exit X /* we make sure the screen is in the right X /* mode. X /*----------------------------------------*/ X { X int val; X extern int old_ega_flag; X static int old_mode = -1; X if (old_mode == -1) X old_mode = console_mode = ioctl(0, CONS_GET, &val); X else X old_ega_flag = -1; X } X# endif X X ioctl(0, TCGETA, &ot); X nt = ot; /* save entry state */ X# if defined(SYSV) X nt.c_cc[VINTR] = 'Y' & 0x1f; /* Default interrupt key. */ X nt.c_cc[VQUIT] = 0xff; X nt.c_cc[VMIN] = 1; /* one character read is OK */ X nt.c_cc[VTIME] = 0; /* Never time out. */ X nt.c_iflag |= IGNBRK; X nt.c_iflag &= ~( ICRNL | INLCR | ISTRIP | IXON | IXOFF ); X nt.c_oflag &= ~OPOST; X nt.c_cflag |= CS8; /* allow 8th bit on input */ X nt.c_cflag &= ~PARENB; /* Don't check parity */ X nt.c_lflag &= ~( ECHO | ICANON/* | ISIG*/ ); X X kbdflgs = fcntl( 0, F_GETFL, 0 ); X# else /* BSD */ X nt.sg_flags |= RAW; X nt.sg_flags &= ~(ECHO|CRMOD); X# endif X X ioctl(0, TCSETA, &nt); X X ttyactivep = TRUE; X} Xsys_timeout(yes) X{ X# if defined(SYSV) X if (yes) { X nt.c_cc[VTIME] = CENTISECONDS; X nt.c_cc[VMIN] = 0; X } X else { X nt.c_cc[VTIME] = 0; X nt.c_cc[VMIN] = 1; X } X ioctl(0, TCSETA, &nt); X# endif X} X/* X * This function gets called just X * before we go back home to the shell. Put all of X * the terminal parameters back. X */ Xvoid Xsys_close() X{ X if (!ttyactivep) X return; X ioctl(0, TCSETA, &ot); X fcntl( 0, F_SETFL, kbdflgs); X ttyactivep = FALSE; X# if defined(SW_ENHC80x25) X switch (console_mode) { X case M_ENH_C80x43: X ioctl(1, SW_ENHC80x43, 0); X break; X case M_ENH_C80x25: X ioctl(1, SW_ENHC80x25, 0); X break; X } X# endif X} Xsys_checkc() X{ char kbdq = 0; X X fcntl(0, F_SETFL, kbdflgs | O_NDELAY); X read(0, &kbdq, 1); X fcntl(0, F_SETFL, kbdflgs); X return kbdq; X} Xsys_getchar(fd, buf, cnt) Xchar *buf; X{ X return read(fd, buf, cnt); X} Xchar * Xsys_delim() X{ X return "/"; X} SHAR_EOF chmod 0444 ./unix.c || echo "restore of ./unix.c fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./version.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ./version.c && X# include "def.h" X Xint version_number = (1*100) + 9; X Xchar *version = "CRISP v1.9, (C) by P. Fox"; SHAR_EOF chmod 0444 ./version.c || echo "restore of ./version.c fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./vms.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ./vms.c && X/************************************************************** X * X * CRISP - Custom Reduced Instruction Set Programmers Editor X * X * (C) Paul Fox, 1989 X * 43, Jerome Close Tel: +44 6284 4222 X * Marlow X * Bucks. X * England SL7 1TX X * X * X * Please See COPYRIGHT notice. X * X **************************************************************/ X X# include <stdio.h> X# include <ssdef.h> X# include <stsdef.h> X# include <ttdef.h> X# include <tt2def.h> X# include <iodef.h> X# include <descrip.h> X/* XNotes on VMS implementation: X X1. Backups not supported since X (a) VMS does not support link() and unlink() X (b) and VMS supports version numbers anyway. X2. Filenames can be in the normal VMS format or the X Unix style can be used: /dev/dir1/dir2/file X (same as dev:[dir1.dir2]file ). X3. Node-names are not supported. X4. If the user uses the DEC-shell, then CRISP may hang trying to X parse unexpected path names. X5. Changing directory and editing relative files will fail. X*/ X# define CENTISECONDS 5 /* x0.1 Read ahead timeout*/ X X/*--------------------------------------- X/* Directory entries for CRISP under VMS. X/*---------------------------------------*/ Xchar *termcap_dir = "crisp_library:[etc]termcap.dat"; Xchar *bhelp = "crisp_library:[help]"; Xchar *bpath = "crisp_library:[macros];crisp_library:[src]"; X Xstatic struct iosb { X short status; X short offset; X short term; X short termlen; X } input_iosb; X Xstatic struct sensemode { X short status; X unsigned char xmit_baud; X unsigned char rcv_baud; X unsigned char crfill; X unsigned char lffill; X unsigned char parity; X unsigned char unused; X char class; X char type; X short scr_wid; X unsigned long tt_char : 24, X scr_len : 8; X unsigned long tt2_char; X }; X Xstatic int input_ef = 0; Xstatic int input_chan = 0; Xstatic int timeout_flag = FALSE; Xstatic $DESCRIPTOR (input_dsc, "TT"); Xstatic struct sensemode old_gtty; X Xstatic int sys_first_time = 0; X# ifdef FRED_BLOGGS Xmain() X{ X int ch; X do { X ch = sys_getchar(); X printf("ch='%c' %d %02x\n", ch, ch, ch); X } X while (ch != 'X'); X sys_close(); X} X# endif Xsys_open() X{ struct sensemode sg; X X if (sys_first_time) X return; X sys_first_time = 1; X X if (input_chan == 0) { X int status = SYS$ASSIGN(&input_dsc, &input_chan, 0, 0); X if (!(status & 1)) X LIB$STOP(status); X } X if (input_ef == 0) { X LIB$GET_EF(&input_ef); X SYS$CLREF(input_ef); X } X X SYS$QIOW(0, input_chan, IO$_SENSEMODE, &old_gtty, 0, 0, X &old_gtty.class, 12, 0, 0, 0, 0); X X sg = old_gtty; X sg.tt_char |= TT$M_PASSALL | TT$M_NOECHO | TT$M_EIGHTBIT; X sg.tt_char &= ~TT$M_TTSYNC; X sg.tt2_char |= TT2$M_PASTHRU | TT2$M_XON; X X SYS$QIOW(0, input_chan, IO$_SETMODE, &input_iosb, 0, 0, X &sg.class, 12, 0, 0, 0, 0); X X} Xsys_close() X{ X if (!sys_first_time) X return; X X SYS$QIOW(0, input_chan, IO$_SETMODE, &input_iosb, 0, 0, X &old_gtty.class, 12, 0, 0, 0, 0); X} Xsys_timeout(yes) X{ X timeout_flag = yes; X} X# define MAX_INPUT 128 Xstatic unsigned char input_buffer[MAX_INPUT]; Xstatic int iptr = MAX_INPUT + 1; Xstatic int icnt = 0; Xsys_cancel_io() X{ X SYS$CANCEL(input_chan); X} Xsys_checkc() X{ X return iptr < icnt; X} X Xsys_getchar(fd, buf, cnt) Xunsigned char *buf; X{ X if (iptr >= icnt) { X SYS$QIOW(0, input_chan, X IO$_READVBLK | (timeout_flag ? IO$M_TIMED : 0), X &input_iosb, 0, 0, X &input_buffer, 1, 2, 0, 0, 0); X if (input_iosb.status != SS$_NORMAL) X return 0; X iptr = 0; X icnt = 1; X } X *buf = input_buffer[iptr++]; X return 1; X} Xsys_write(fd, buf, cnt) Xunsigned char *buf; X{ X SYS$QIOW(0, input_chan, IO$_WRITEVBLK, X &input_iosb, 0, 0, X buf, cnt, 0, 0, 0, 0); X} X/* X/* We need to put in VMS style wild card expansions. X/**/ Xchar ** Xshell_expand(filename) Xchar *filename; X{ char **buf = chk_alloc(sizeof (char *) * 2); X X buf[0] = strdup(filename); X buf[1] = 0; X return buf; X} Xchar * Xsys_delim() X{ X return ""; X} Xchar * Xsys_fname_unix_to_vms(src, dst, size) Xchar *src; Xchar *dst; X{ int slash_count = 0; X char *orig_src = src; X char *orig_dst = dst; X char *strchr(); X X size--; X if (*src != '/' && strchr(src, '/') != NULL) { X *dst++ = '['; X *dst++ = '.'; X size -= 2; X slash_count = 2; X } X while (*src) { X if (*src != '/') { X if (size-- <= 0) X break; X *dst++ = *src++; X continue; X } X src++; X switch (slash_count++) { X case 0: break; X case 1: *dst++ = ':'; X size--; X if (strchr(src, '/')) { X *dst++ = '['; X size--; X } X break; X default: X if (strchr(src, '/') == 0) X *dst++ = ']'; X else X *dst++ = '.'; X size--; X break; X } X } X *dst = 0; X return orig_dst; X} Xchar * Xvms_filename_canon(buf) Xchar *buf; X{ register char *cp; X register char *cp1; X X for (cp = buf; *cp; cp++) { X /*---------------------------------------- X /* Map fred:[dir1.dir2.][dir3]... to X /* fred:[dir1.dir2.dir3]... X /*----------------------------------------*/ X if (*cp == '.' && cp[1] == ']' && cp[2] == '[') { X strcpy(cp+1, cp+3); X continue; X } X /*---------------------------------------- X /* Map fred:[dir1.dir2][.dir3]... to X /* fred:[dir1.dir2.dir3]... X /*----------------------------------------*/ X if (*cp == ']' && cp[1] == '[' && cp[2] == '.') { X strcpy(cp, cp+2); X cp--; X continue; X } X /*---------------------------------------- X /* Map fred:[dir1.dir2][dir3]... to X /* fred:[dir3]... X /*----------------------------------------*/ X if (*cp == '[') { X extern char *strchr(); X cp1 = strchr(buf, '['); X if (cp1 != cp) X strcpy(cp1, cp); X } X } X X /*---------------------------------------- X /* Map fred:[dir1.dir2.-.dir3]... to X /* fred:[dir1.dir3]... X /* X /* we do this after the others so that X /* we can ensure theres only one PPN left. X /*----------------------------------------*/ X for (cp = buf; *cp && *cp != '['; ) X cp++; X while (*cp && *cp != ']') { X if (*cp == '.' && cp[1] == '-') { X for (cp1 = cp-1; *cp1 != '['; cp1--) X if (*cp1 == '.') X break; X strcpy(cp1, cp+2); X cp = cp1; X } X else X cp++; X } X return buf; X} X X/* X * Run a command. The "cmd" is a pointer to a command string, or NULL if you X * want to run a copy of DCL in the subjob (this is how the standard routine X * LIB$SPAWN works. You have to do wierd stuff with the terminal on the way in X * and the way out, because DCL does not want the channel to be in raw mode. X */ Xsystem(cmd) Xregister char *cmd; X{ X struct dsc$descriptor cdsc; X struct dsc$descriptor *cdscp; X long status; X long substatus; X long iosb[2]; X X sys_close(); X sys_first_time = 0; X cdscp = NULL; /* Assume DCL. */ X if (cmd && (strcmp(cmd, "/bin/sh") == 0 || strcmp(cmd, "/bin/csh") == 0)) X cmd = NULL; X if (cmd != NULL) { /* Build descriptor. */ X cdsc.dsc$a_pointer = cmd; X cdsc.dsc$w_length = strlen(cmd); X cdsc.dsc$b_dtype = DSC$K_DTYPE_T; X cdsc.dsc$b_class = DSC$K_CLASS_S; X cdscp = &cdsc; X } X status = LIB$SPAWN(cdscp, 0, 0, 0, 0, 0, &substatus, 0, 0, 0); X if (status != SS$_NORMAL) X substatus = status; X sys_open(); X if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) X return (FALSE); X if ((substatus&STS$M_SUCCESS) == 0) /* Command failed. */ X return (FALSE); X return (TRUE); X} SHAR_EOF chmod 0444 ./vms.c || echo "restore of ./vms.c fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./wild.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ./wild.c && X/************************************************************** X * X * CRISP - Custom Reduced Instruction Set Programmers Editor X * X * (C) Paul Fox, 1989 X * 43, Jerome Close Tel: +44 6284 4222 X * Marlow X * Bucks. X * England SL7 1TX X * X * X * Please See COPYRIGHT notice. X * X **************************************************************/ X# include <stdio.h> X# include <sys/types.h> X# include <sys/stat.h> X# include "m-machine.h" X# include "gdir.h" X X# if !defined(lint) Xstatic char sccsid[] = "@(#) wild.c 1.11, (C) 1988, P. Fox"; X# endif X X# define SHE_TOO_MANY_NAMES -1 X# define TRUE 1 X# define FALSE 0 X X# define MAX_NAMES 1024 X# define NAME_SIZE 128 X X# ifdef TESTING_WILD Xmain(argc, argv) Xchar **argv; X{ X char lbuf[256]; X char **files; X int i; X extern char **shell_expand(); X while (1) { X printf("Filename: "); X gets(lbuf); X if (lbuf[strlen(lbuf) - 1] == '\n') X lbuf[strlen(lbuf) - 1] = NULL; X files = shell_expand(lbuf); X if (files == (char **) NULL) { X printf("Expansion error.\n"); X continue; X } X for (i = 0; files[i]; i++) { X if (files[i][0]) X printf("%s ", files[i]); X chk_free(files[i]); X } X chk_free(files); X putchar('\n'); X } X} X# endif X/*---------------------------*/ Xwild_match(file, str) Xregister char *file; Xregister char *str; X{ register char *cp; X char *start_str = str; X int low, hi; X X while (*str) { X switch (*str) { X case '*': X if (start_str == str && file[0] == '.') X return FALSE; X str++; X if (*str == NULL) X return TRUE; X for (cp = file + strlen(file) - 1; X cp >= file; cp--) X if (wild_match(cp, str)) X return TRUE; X return FALSE; X case '?': X if (*file == NULL) X return FALSE; X str++; X break; X case '[': X if (*file == NULL) X return FALSE; X str++; X while (1) { X if (*str == ']' || *str == NULL) X return FALSE; X hi = low = *str++; X if (*str == '-') { X hi = str[1]; X str += 2; X } X if (*file >= low && *file <= hi) { X file++; X break; X } X } X while (*str) X if (*str++ == ']') X break; X break; X default: X if (*file == NULL || *file++ != *str++) X return FALSE; X break; X } X } X return *str == NULL; X} X/*--------------------------*/ X# if !defined(VMS) X# include <pwd.h> Xint shell_error; Xextern char *chk_alloc(); Xchar ** Xshell_expand(file) Xchar *file; X{ char name[128]; X struct passwd *pwd; X struct passwd *getpwuid(); X struct passwd *getpwnam(); X unsigned short getuid(); X char **shell_wild(); X char **shell_delete(); X char *cp; X X if (file[0] != '~') X return shell_wild(file); X if (*++file == '/') { X file++; X pwd = getpwuid(getuid()); X } X else { X for (cp = name; *file && *file != '/'; ) X *cp++ = *file++; X if (*file == '/') X file++; X *cp = NULL; X pwd = getpwnam(name); X } X X sprintf(name, "%s/%s", pwd->pw_dir, file); X endpwent(); X return shell_wild(name); X} Xchar ** Xshell_delete(files, wild) Xchar **files; X{ int i; X if (files == NULL || !wild) X return files; X for (i = 0; files[i]; i++) { X struct stat stat_buf; X if (files[i][0] == NULL) X continue; X if (stat(files[i], &stat_buf) < 0) X files[i][0] = NULL; X } X return files; X X} Xchar ** Xshell_wild(file) Xchar *file; X{ int i, j, k; X int ecnt; X char *cp; X char suffix[64]; X char **names; X int name_cnt = 0; X char *wild_expand(); X char *get_sname(); Xstatic int compare(); X int found_wild = FALSE; X X shell_error = 0; X names = (char **) chk_alloc(MAX_NAMES * sizeof(char*)); X X if (file[0] == '/') { X names[0] = chk_alloc(NAME_SIZE); X strcpy(names[0], "/"); X file++; X name_cnt = 1; X } X X do { X extern char *strpbrk(); X char *prefix; X suffix[0] = NULL; X file = get_sname(file, suffix); X if (suffix[0] && strpbrk(suffix, "*?[")) { X found_wild = TRUE; X j = name_cnt; X for (i = 0; i <= j; i++) { X if (i == j) { X if (j == 0) X prefix = NULL; X else X break; X } X else { X prefix = names[i]; X if (prefix[0] == NULL) X continue; X } X for (ecnt = 0; ; ecnt++) { X if ((cp = wild_expand(prefix, suffix, ecnt)) == NULL) { X if (j) X names[i][0] = NULL; X break; X } X names[name_cnt] = chk_alloc(NAME_SIZE); X if (prefix) { X if (prefix[strlen(prefix)-1] == '/') X sprintf(names[name_cnt], X "%s%s", prefix, cp); X else X sprintf(names[name_cnt], X "%s/%s", prefix, cp); X } X else X strcpy(names[name_cnt], cp); X if (++name_cnt >= MAX_NAMES-1) { X she_error(name_cnt, names, name_cnt); X return NULL; X } X } X } X } X else { X if (name_cnt == 0) { X names[0] = chk_alloc(NAME_SIZE); X strcpy(names[0], suffix); X name_cnt = 1; X } X else X for (k = 0; k < name_cnt; k++) { X strcat(names[k], "/"); X strcat(names[k], suffix); X } X } X } X while (file); X names[name_cnt] = NULL; X qsort(names, name_cnt, sizeof(char *), compare); X return shell_delete(names, found_wild); X} Xstatic Xcompare(p1, p2) Xchar **p1, **p2; X{ X return strcmp(*p1, *p2); X} Xshe_error(err, names, name_cnt) Xchar **names; X{ int i; X shell_error = err; X for (i = 0; i < name_cnt; i++) X chk_free(names[i]); X chk_free(names); X} Xchar * Xwild_expand(prefix, suffix, cnt) Xchar *prefix; Xchar *suffix; X{ static DIR *dirp = NULL; X struct dirent *de; X static char name[DIRSIZ+1]; X X if (dirp == NULL) { X if ((dirp = opendir(prefix ? prefix : ".")) == NULL) { X return (char *) NULL; X } X } X while ((de = readdir(dirp)) != (struct dirent *) NULL) { X strncpy(name, de->d_name, DIRSIZ); X name[DIRSIZ] = NULL; X if (wild_match(name, suffix)) X return name; X } X closedir(dirp); X dirp = NULL; X return (char *) NULL; X X} Xchar * Xget_sname(file, buf) Xregister char *file; Xregister char *buf; X{ X if (*file == NULL) X return (char *) NULL; X while (*file && *file != '/') X *buf++ = *file++; X if (*file == '/') X file++; X *buf = NULL; X return *file ? file : NULL; X} X# endif SHAR_EOF chmod 0444 ./wild.c || echo "restore of ./wild.c fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./window.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ./window.c && X/************************************************************** X * X * CRISP - Custom Reduced Instruction Set Programmers Editor X * X * (C) Paul Fox, 1989 X * 43, Jerome Close Tel: +44 6284 4222 X * Marlow X * Bucks. X * England SL7 1TX X * X * X * Please See COPYRIGHT notice. X * X **************************************************************/ X#include "list.h" X XSCCSID("@(#) window.c 1.9, (C) 1988, P. Fox"); X Xvoid w_title(); Xextern char *bname(); XWINDOW *new_window(); Xu_int16 win_num = 0; Xint border_flag = TRUE; Xint w_layer = 0; Xborders() X{ register WINDOW *wp; X extern int sgarbf; X int oflag = border_flag; X X accumulator = border_flag; X if (argv[1].l_flags != F_NULL) X border_flag = argv[1].l_int != 0; X else X border_flag = !border_flag; X X if (border_flag == oflag) X return; X for (wp = wheadp; wp; wp = wp->w_wndp) X if (wp->w_tiled != W_POPUP) { X if (border_flag) { X wp->w_tiled = W_ROOT; X/* wp->w_h--;*/ X } X else { X wp->w_tiled = 0; X/* wp->w_h++;*/ X } X } X sgarbf = TRUE; X} X/* X * Split the current window. A window X * smaller than 3 lines cannot be split. X * The only other error that is possible is X * a "malloc" failure allocating the structure X * for the new window. X */ XWINDOW * Xsplitwind() X{ X register WINDOW *wp; X X if (curwp->w_h <= 3) { X ewprintf("Window would be too small."); X return NULL; X } X wp = new_window(); X curwp->w_flag |= WFHARD; X *wp = *curwp; X X wp->w_ttitle = wp->w_btitle = NULL; X wp->w_popup = FALSE; X ++curbp->b_nwnd; /* Displayed twice. */ X wp->w_num = win_num++; X wp->w_bufp = curbp; X wp->w_force = 0; X wp->w_h = curwp->w_h / 2 - 1; X curwp->w_h -= wp->w_h; X wp->w_y = curwp->w_y + curwp->w_h; X curwp->w_h--; X wp->w_old_line = wp->w_line = wp->w_top_line = 1; X if (curwp->w_top_line + curwp->w_h < curwp->w_line) { X curwp->w_top_line = curwp->w_line - (curwp->w_h / 2); X if (curwp->w_top_line < 1) X curwp->w_top_line = 1; X } X curwp->w_old_line = curwp->w_line; X wp->w_tiled = W_ROOT; X win_append(wp); X X w_title(wp, bname(curbp->b_fname), ""); X X return wp; X} Xwin_append(win) XWINDOW *win; X{ register WINDOW *wp; X X for (wp = wheadp; wp->w_wndp; ) X wp = wp->w_wndp; X wp->w_wndp = win; X win->w_wndp = NULL; X} Xcreate_window() X{ register WINDOW *wp = new_window(); X X if (wp == NULL) X return 0; X X win_append(wp); X X wp->w_old_line = wp->w_top_line = wp->w_line = 1; X wp->w_num = win_num++; X X wp->w_x = (u_char) (argv[1].l_int + 1); X wp->w_y = (u_char) (argv[4].l_int + 1); X wp->w_h = (u_char) (argv[2].l_int - argv[4].l_int - 1); X wp->w_w = (u_char) (argv[3].l_int - argv[1].l_int - 1); X if (wp->w_y >= nrow) X wp->w_y = nrow -1; X if (wp->w_y + wp->w_h >= nrow - 2) X wp->w_h = nrow - wp->w_y - 3; X X wp->w_tiled = W_POPUP; X wp->w_force = TRUE; X wp->w_popup = TRUE; X wp->w_flag = WFHARD; X wp->w_prev = curwp; X w_title(wp, "", get_str(5)); X X curwp = wp; X X return 0; X} Xvoid Xw_title(wp, top, bottom) XWINDOW *wp; Xchar *top; Xchar *bottom; X{ X if (wp->w_ttitle && top) X chk_free(wp->w_ttitle); X if (wp->w_btitle && bottom) X chk_free(wp->w_btitle); X if (top) X wp->w_ttitle = strdup(top); X if (bottom) X wp->w_btitle = strdup(bottom); X} X Xattach_buffer() X{ extern BUFFER *numberb(); X BUFFER *bp = numberb((u_int16) argv[1].l_int); X char buf[128]; X X if (bp == NULL) { X ewprintf("attach_buffer: no such buffer"); X return -1; X } X detach_buffer(curwp); X curwp->w_bufp = bp; X bp->b_nwnd++; X curwp->w_old_line = 1; X curwp->w_top_line = bp->b_top;/*1; /*bp->b_line;*/ X curwp->w_line = bp->b_line; X curwp->w_col = bp->b_col; X curwp->w_flag |= WFHARD; X curbp = bp; X X strcpy(buf, curbp->b_title ? curbp->b_title : curbp->b_fname); X w_title(curwp, bname(buf), (char *) NULL); X return 0; X} Xdel_window() X{ WINDOW *wp = curwp->w_prev; X WINDOW *wp1; X X if (wheadp == curwp) X wheadp = curwp->w_wndp; X else { X for (wp1 = wheadp; wp1; wp1 = wp1->w_wndp) X if (wp1->w_wndp == curwp) { X wp1->w_wndp = curwp->w_wndp; X break; X } X if (wp1 == NULL) X panic("del_window: window not found."); X } X if (curwp->w_bufp == curbp && curbp) { X curbp->b_line = curwp->w_line; X curbp->b_col = curwp->w_col; X curbp->b_top = curwp->w_top_line; X curbp->b_nwnd--; X } X if (curwp->w_btitle) X chk_free(curwp->w_btitle); X if (curwp->w_ttitle) X chk_free(curwp->w_ttitle); X chk_free((char *) curwp); X curwp = wp; X/* curbp = wp->w_bufp;*/ X for (wp = wheadp; wp; wp = wp->w_wndp) X wp->w_flag |= WFHARD; X return 0; X} X Xinq_screen_size() X{ X if (argv[1].l_flags != F_NULL) X argv[1].l_sym->s_int = nrow; X if (argv[2].l_flags != F_NULL) X argv[2].l_sym->s_int = ncol; X return 0; X} Xinq_window_size() X{ X accumulator = curwp->w_h; X X if (argv[1].l_flags != F_NULL) X argv[1].l_sym->s_int = curwp->w_h; X if (argv[2].l_flags != F_NULL) X argv[2].l_sym->s_int = curwp->w_w - 2; X if (argv[3].l_flags != F_NULL) X argv[3].l_sym->s_int = curwp->w_indent; X X return 0; X} X Xinq_w() X{ X accumulator = curwp->w_num; X return 0; X} Xset_window() X{ register WINDOW *wp; X X for (wp = wheadp; wp; wp = wp->w_wndp) X if (wp->w_num == (u_int16) argv[1].l_int) { X curwp = wp; X/* curbp = wp->w_bufp;*/ X break; X } X return 0; X} XWINDOW * Xvsplitwind() X{ X register WINDOW *wp; X int w; X X if (curwp->w_w < 16) { X ewprintf("Window would be too small."); X return 0; X } X wp = new_window(); X *wp = *curwp; X wp->w_indent = curwp->w_indent = 0; X wp->w_btitle = wp->w_ttitle = NULL; X wp->w_tiled = W_ROOT; X ++curbp->b_nwnd; /* Displayed twice. */ X X w = wp->w_w; X wp->w_w /= 2; X curwp->w_w = (u_char) (w - wp->w_w - 1); X wp->w_x = curwp->w_x + curwp->w_w + 1; X X wp->w_num = win_num++; X wp->w_force = 0; X wp->w_wndp = wheadp; X X win_append(wp); X X curwp->w_flag |= WFHARD; X wp->w_flag |= WFHARD; X X w_title(wp, bname(curbp->b_fname), ""); X return wp; X} X Xwindow_color() X{ X return 0; X} Xwin_modify(flag) X{ X wwin_modify(curwp, flag); X} Xwwin_modify(wp, flag) Xregister WINDOW *wp; X{ register int line = *cur_line; X X if (wp->w_bufp != curbp) X return; X X if (flag & WFDELL & wp->w_flag) /* That really is '&' and '&' */ X flag |= WFHARD; X if (flag == WFMOVE && curbp->b_anchor) X flag = WFEDIT; X wp->w_flag |= flag; X if ((wp->w_flag & WFEDIT) == 0) X return; X if (wp->w_mined == 0 || wp->w_mined > line) X wp->w_mined = line; X if (wp->w_maxed < line) X wp->w_maxed = line; X} Xset_buffer_bottom(wp) XWINDOW *wp; X{ int new_top_line = wp->w_line - wp->w_h + 1; X X if (new_top_line < 1) X new_top_line = 1; X if (new_top_line != wp->w_top_line) { X wp->w_top_line = new_top_line; X wwin_modify(wp, WFHARD); X } X} XWINDOW * Xnew_window() X{ static WINDOW null_window = {0}; X WINDOW *wp = (WINDOW *) chk_alloc(sizeof (WINDOW)); X X *wp = null_window; X wp->w_layer = w_layer++; X return wp; X} SHAR_EOF chmod 0444 ./window.c || echo "restore of ./window.c fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./word.c (Text)" sed 's/^X//' << 'SHAR_EOF' > ./word.c && X/************************************************************************ X * Code to implement portable mappings to and from internal word * X * and byte order. Note we dont use the standard htons() and * X * htonl() because these are only available on systems with the * X * socket library. This code is so that we can generate machine * X * independent .cm files. This currently works for 68020s and * X * 80386's, and Vaxes, but will probably need changing for other * X * machines. * X ************************************************************************/ X# include "list.h" X Xstatic short one = 1; Xstatic char *onep = (char *) &one; X Xstatic char one234[4] = {1,2,3,4}; X XWGET16(n) X{ short s = (short) n; X X if (*onep == 0) X return s; X return ((s >> 8) & 0xff) | ((s & 0xff) << 8); X} Xlong XWGET32(n) Xlong n; X{ long l = *(long *) one234; X unsigned char buf[4]; X X *(long *) buf = n; X if (l == 0x01020304) X return n; X if (l == 0x04030201) X return ((long) buf[0] << 24) | ((long) buf[1] << 16) | X (buf[2] << 8) | buf[3]; X printf("l=%08lx, What?\n", l); X abort(); X /* NOTREACHED */ X} Xvoid XLPUT16(lp, n) XLIST *lp; Xregister int n; X{ X register u_char *cp = (u_char *) lp; X X *++cp = (u_char) (n >> 8); X *++cp = (u_char) n; X} Xvoid XLPUT32(lp, n) XLIST *lp; Xregister long n; X{ X register u_char *cp = (u_char *) lp; X X *++cp = (u_char) (n >> 24); X *++cp = (u_char) (n >> 16); X *++cp = (u_char) (n >> 8); X *++cp = (u_char) n; X} Xlong XLGET32(lp) Xregister LIST *lp; X{ X return ((long) lp[1] << 24) | (long) lp[2] << 16 | X (long) lp[3] << 8 | (long) lp[4]; X} Xu_int16 XLGET16(lp) Xregister LIST *lp; X{ X return (u_int16) (lp[1] << 8) | lp[2]; X} Xswap_words(warray, size) Xregister u_int32 *warray; X{ register int i; X X for (i = 0; i < size; i++, warray++) X *warray = WGET32(*warray); X} X X/**************************************************************/ X/* X/* If porting to a new system, the following: X/* X/* a.out 01020304 X/* X/* should generate: X/* X/* 03 04 01 02 03 04 X/* X/* as output in order for the .cm files to be portable X/* across to other CPU types. X/**************************************************************/ X# if 0 Xmain(argc, argv) Xchar **argv; X{ long l; X int i; X char buf[6]; X X sscanf(argv[1], "%lx", &l); X i = l & 0xffff; X *(short *) buf = WGET16(i); X *(long *) (buf+2) = WGET32(l); X for (i = 0; i < 6; i++) X printf("%c", buf[i]); X} X# endif SHAR_EOF chmod 0444 ./word.c || echo "restore of ./word.c fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./m-sun3os3.h (Text)" sed 's/^X//' << 'SHAR_EOF' > ./m-sun3os3.h && X/************************************************************************ X * * X * CRISP - Custom Reduced Instruction Set Programmers Editor * X * * X * (C) Paul Fox, 1989 * X * 43, Jerome Close Tel: +44 6284 4222 * X * Marlow * X * Bucks. * X * England SL7 1TX * X * * X * * X * Please See COPYRIGHT notice. * X * * X * This file contains various conditional compilation flags * X * which are needed to support different operating systems. * X * Different versions of this file are supplied for various * X * operating systems. You should set up a link between the * X * m-machine.h file and the m- file describing your system. If * X * your system isn't supported then simply modify the * X * definitions below as appropriate. You may need to change the * X * code as well depending on your system. * X ************************************************************************/ X X/************************************************************************ X * One of the following should be set to indicate machine type. * X * Some of the definitions may apply to more than one machine * X * type, eg SUN may be more indicative of BSD, but I dont have a * X * generic BSD to try this out on. * X ************************************************************************/ X# define SUN X/*# define SYSV*/ X/*#define VMS*/ X/************************************************************************ X * Some combination of the following may need to be set for * X * operating system dependent features which dont fit under the * X * general category of operating system features. * X ************************************************************************/ X# define BSD X/*# define XENIX*/ X X/************************************************************************ X * DIRSIZ_DEFINED should be define'd if the POSIX directory * X * access include files are wrong. (Are they wrong or right ?) * X ************************************************************************/ X# define DIRSIZ_DEFINED X/*#undef DIRSIZ_DEFINED*/ X X/************************************************************************ X * The following # define is used to control the use of the enum * X * OPCODE typedef in the list.h. It doesn't matter if you set * X * this to 'int' as below, but if it is undefined then it is * X * easier to debug the CRISP lisp-code. Older Unix C compilers * X * do not treat enum's and int's as the same type and will * X * complain during compilation. * X ************************************************************************/ X# define OPCODE int X/*#undef OPCODE */ X X X/************************************************************************ X * If you have support for pty's in your kernel, then define * X * HAVE_PTY. If not #undef it, and normal unnamed pipes will be * X * used instead. * X ************************************************************************/ X# undef HAVE_PTY X/*# define HAVE_PTY*/ X X/************************************************************************ X * SELECT should be defined if we can do a select() on the * X * keyboard and on the process pty's/pipes. This will tend to be * X * true on BSD systems, and Sys V.4. Alas, poll() isn't * X * generally applicable on V.3 because the standard pipe and tty * X * drivers are streams modules. * X ************************************************************************/ X/*# undef SELECT*/ X# define SELECT X X/************************************************************************ X * CRISP defines a typedef called u_char. Some Unix systems also * X * define this type in one of the system header files * X * (/usr/include/sys/types.h) which causes a compilation error. * X * If you have this typedef in your system header file, then * X * #define U_CHAR. Otherwise undefine it. * X ************************************************************************/ X/*#undef U_CHAR*/ X# define U_CHAR X X X SHAR_EOF chmod 0644 ./m-sun3os3.h || echo "restore of ./m-sun3os3.h fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./m-sun3os4.h (Text)" sed 's/^X//' << 'SHAR_EOF' > ./m-sun3os4.h && X/************************************************************************ X * * X * CRISP - Custom Reduced Instruction Set Programmers Editor * X * * X * (C) Paul Fox, 1989 * X * 43, Jerome Close Tel: +44 6284 4222 * X * Marlow * X * Bucks. * X * England SL7 1TX * X * * X * * X * Please See COPYRIGHT notice. * X * * X * This file contains various conditional compilation flags * X * which are needed to support different operating systems. * X * Different versions of this file are supplied for various * X * operating systems. You should set up a link between the * X * m-machine.h file and the m- file describing your system. If * X * your system isn't supported then simply modify the * X * definitions below as appropriate. You may need to change the * X * code as well depending on your system. * X ************************************************************************/ X X X/************************************************************************ X * One of the following should be set to indicate machine type. * X * Some of the definitions may apply to more than one machine * X * type, eg SUN may be more indicative of BSD, but I dont have a * X * generic BSD to try this out on. * X ************************************************************************/ X# define SUN X/*# define SYSV*/ X/*#define VMS*/ X/************************************************************************ X * Some combination of the following may need to be set for * X * operating system dependent features which dont fit under the * X * general category of operating system features. * X ************************************************************************/ X# define BSD X/*# define XENIX*/ X X/************************************************************************ X * DIRSIZ_DEFINED should be define'd if the POSIX directory * X * access include files are wrong. (Are they wrong or right ?) * X ************************************************************************/ X# define DIRSIZ_DEFINED X/*#undef DIRSIZ_DEFINED*/ X X/************************************************************************ X * The following # define is used to control the use of the enum * X * OPCODE typedef in the list.h. It doesn't matter if you set * X * this to 'int' as below, but if it is undefined then it is * X * easier to debug the CRISP lisp-code. Older Unix C compilers * X * do not treat enum's and int's as the same type and will * X * complain during compilation. * X ************************************************************************/ X/*# define OPCODE int*/ X#undef OPCODE X X X/************************************************************************ X * If you have support for pty's in your kernel, then define * X * HAVE_PTY. If not #undef it, and normal unnamed pipes will be * X * used instead. * X ************************************************************************/ X# define HAVE_PTY X X/************************************************************************ X * SELECT should be defined if we can do a select() on the * X * keyboard and on the process pty's/pipes. This will tend to be * X * true on BSD systems, and Sys V.4. Alas, poll() isn't * X * generally applicable on V.3 because the standard pipe and tty * X * drivers are streams modules. * X ************************************************************************/ X# define SELECT X X/************************************************************************ X * CRISP defines a typedef called u_char. Some Unix systems also * X * define this type in one of the system header files * X * (/usr/include/sys/types.h) which causes a compilation error. * X * If you have this typedef in your system header file, then * X * #define U_CHAR. Otherwise undefine it. * X ************************************************************************/ X/*#undef U_CHAR*/ X# define U_CHAR X X X SHAR_EOF chmod 0644 ./m-sun3os4.h || echo "restore of ./m-sun3os4.h fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./m-sysv.h (Text)" sed 's/^X//' << 'SHAR_EOF' > ./m-sysv.h && X/************************************************************************ X * * X * CRISP - Custom Reduced Instruction Set Programmers Editor * X * * X * (C) Paul Fox, 1989 * X * 43, Jerome Close Tel: +44 6284 4222 * X * Marlow * X * Bucks. * X * England SL7 1TX * X * * X * * X * Please See COPYRIGHT notice. * X * * X * This file is suitable for the following operating systems: * X * * X * Microport V.3/386 * X * Interactive V.3/386 * X * * X ************************************************************************/ X X/************************************************************************ X * One of the following should be set to indicate machine type. * X * Some of the definitions may apply to more than one machine * X * type, eg SUN may be more indicative of BSD, but I dont have a * X * generic BSD to try this out on. * X ************************************************************************/ X/*# define SUN*/ X# define SYSV X/*#define VMS*/ X/************************************************************************ X * Some combination of the following may need to be set for * X * operating system dependent features which dont fit under the * X * general category of operating system features. * X ************************************************************************/ X/*# define BSD*/ X/*# define XENIX*/ X X/************************************************************************ X * DIRSIZ_DEFINED should be define'd if the POSIX directory * X * access include files are wrong. (Are they wrong or right ?) * X ************************************************************************/ X/*# define DIRSIZ_DEFINED*/ X#undef DIRSIZ_DEFINED X X/************************************************************************ X * The following # define is used to control the use of the enum * X * OPCODES typedef in the list.h. It doesn't matter if you set * X * this to 'int' as below, but if it is undefined then it is * X * easier to debug the CRISP lisp-code. Older Unix C compilers * X * do not treat enum's and int's as the same type and will * X * complain during compilation. * X ************************************************************************/ X/*# define OPCODE int*/ X#undef OPCODE X X X/************************************************************************ X * If you have support for pty's in your kernel, then define * X * HAVE_PTY. If not #undef it, and normal unnamed pipes will be * X * used instead. * X ************************************************************************/ X# undef HAVE_PTY X/*# define HAVE_PTY*/ X X X/************************************************************************ X * SELECT should be defined if we can do a select() on the * X * keyboard and on the process pty's/pipes. This will tend to be * X * true on BSD systems, and Sys V.4. Alas, poll() isn't * X * generally applicable on V.3 because the standard pipe and tty * X * drivers are streams modules. * X ************************************************************************/ X# undef SELECT X/*# define SELECT*/ X X/************************************************************************ X * CRISP defines a typedef called u_char. Some Unix systems also * X * define this type in one of the system header files * X * (/usr/include/sys/types.h) which causes a compilation error. * X * If you have this typedef in your system header file, then * X * #define U_CHAR. Otherwise undefine it. * X ************************************************************************/ X#undef U_CHAR X/*# define U_CHAR*/ X X X SHAR_EOF chmod 0644 ./m-sysv.h || echo "restore of ./m-sysv.h fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./m-sysv3.2.h (Text)" sed 's/^X//' << 'SHAR_EOF' > ./m-sysv3.2.h && X/************************************************************************ X * * X * CRISP - Custom Reduced Instruction Set Programmers Editor * X * * X * (C) Paul Fox, 1989 * X * 43, Jerome Close Tel: +44 6284 4222 * X * Marlow * X * Bucks. * X * England SL7 1TX * X * * X * * X * Please See COPYRIGHT notice. * X * * X * This file is suitable for the following operating systems: * X * * X * Interactive V.3.2/386 * X * * X ************************************************************************/ X X/************************************************************************ X * One of the following should be set to indicate machine type. * X * Some of the definitions may apply to more than one machine * X * type, eg SUN may be more indicative of BSD, but I dont have a * X * generic BSD to try this out on. * X ************************************************************************/ X/*# define SUN*/ X# define SYSV X/*#define VMS*/ X/************************************************************************ X * Some combination of the following may need to be set for * X * operating system dependent features which dont fit under the * X * general category of operating system features. * X ************************************************************************/ X/*# define BSD*/ X/*# define XENIX*/ X X/************************************************************************ X * DIRSIZ_DEFINED should be define'd if the POSIX directory * X * access include files are wrong. (Are they wrong or right ?) * X ************************************************************************/ X/*# define DIRSIZ_DEFINED*/ X#undef DIRSIZ_DEFINED X X/************************************************************************ X * The following # define is used to control the use of the enum * X * OPCODE typedef in the list.h. It doesn't matter if you set * X * this to 'int' as below, but if it is undefined then it is * X * easier to debug the CRISP lisp-code. Older Unix C compilers * X * do not treat enum's and int's as the same type and will * X * complain during compilation. * X ************************************************************************/ X/*# define OPCODE int*/ X#undef OPCODE X X X/************************************************************************ X * If you have support for pty's in your kernel, then define * X * HAVE_PTY. If not #undef it, and normal unnamed pipes will be * X * used instead. * X ************************************************************************/ X# undef HAVE_PTY X/*# define HAVE_PTY*/ X X X/************************************************************************ X * SELECT should be defined if we can do a select() on the * X * keyboard and on the process pty's/pipes. This will tend to be * X * true on BSD systems, and Sys V.4. Alas, poll() isn't * X * generally applicable on V.3 because the standard pipe and tty * X * drivers are streams modules. * X ************************************************************************/ X# undef SELECT X/*# define SELECT*/ X X/************************************************************************ X * CRISP defines a typedef called u_char. Some Unix systems also * X * define this type in one of the system header files * X * (/usr/include/sys/types.h) which causes a compilation error. * X * If you have this typedef in your system header file, then * X * #define U_CHAR. Otherwise undefine it. * X ************************************************************************/ X#undef U_CHAR X/*# define U_CHAR*/ X X/************************************************************************ X * If EGA43 is defined, then the Unix V.3.2 ioctl() for putting * X * PC display into 43 line mode is available. * X ************************************************************************/ X# define EGA43 X/* #undef EGA43*/ X X SHAR_EOF chmod 0644 ./m-sysv3.2.h || echo "restore of ./m-sysv3.2.h fails" mkdir . >/dev/null 2>&1 echo "x - extracting ./m-vms.h (Text)" sed 's/^X//' << 'SHAR_EOF' > ./m-vms.h && X/************************************************************************ SHAR_EOF echo "End of part 11" echo "File ./m-vms.h is continued in part 12" echo "12" > s2_seq_.tmp exit 0 -- ===================== Reuters Ltd PLC, Tel: +44 628 891313 x. 212 Westthorpe House, UUCP: fox%marlow.uucp@idec.stc.co.uk Little Marlow, Bucks, England SL7 3RQ