1
0
mirror of https://github.com/rfivet/uemacs.git synced 2025-07-26 11:24:26 -04:00

Run "indent -kr -i8" on the sources

Let's see how nasty it is to clean things up. For real.
This commit is contained in:
Linus Torvalds 2005-09-30 15:26:09 -07:00
parent 1f6239bfeb
commit 435dd32ae2
34 changed files with 6805 additions and 6655 deletions

37
ansi.c
View File

@ -91,8 +91,8 @@ TERM term = {
}; };
#if COLOR #if COLOR
ansifcol(color) /* set the current output color */ ansifcol(color)
/* set the current output color */
int color; /* color to set */ int color; /* color to set */
{ {
@ -105,8 +105,8 @@ int color; /* color to set */
cfcolor = color; cfcolor = color;
} }
ansibcol(color) /* set the current background color */ ansibcol(color)
/* set the current background color */
int color; /* color to set */ int color; /* color to set */
{ {
@ -148,8 +148,8 @@ ansieeop()
ttputc('J'); ttputc('J');
} }
ansirev(state) /* change reverse video state */ ansirev(state)
/* change reverse video state */
int state; /* TRUE = reverse, FALSE = normal */ int state; /* TRUE = reverse, FALSE = normal */
{ {
@ -173,15 +173,13 @@ int state; /* TRUE = reverse, FALSE = normal */
#endif #endif
} }
ansicres() /* change screen resolution */ ansicres()
{ /* change screen resolution */
{
return (TRUE); return (TRUE);
} }
spal(dummy) /* change pallette settings */ spal(dummy)
{ /* change pallette settings */
{
/* none for now */ /* none for now */
} }
@ -228,7 +226,6 @@ ansiopen()
} }
ansiclose() ansiclose()
{ {
#if COLOR #if COLOR
ansifcol(7); ansifcol(7);
@ -237,19 +234,17 @@ ansiclose()
ttclose(); ttclose();
} }
ansikopen() /* open the keyboard (a noop here) */ ansikopen()
{ /* open the keyboard (a noop here) */
{
} }
ansikclose() /* close the keyboard (a noop here) */ ansikclose()
{ /* close the keyboard (a noop here) */
{
} }
#if FNLABEL #if FNLABEL
fnclabel(f, n) /* label a function key */ fnclabel(f, n)
/* label a function key */
int f, n; /* default flag, numeric argument [unused] */ int f, n; /* default flag, numeric argument [unused] */
{ {

16
basic.c
View File

@ -83,17 +83,17 @@ register int n;
return (TRUE); return (TRUE);
} }
gotoline(f, n) /* move to a particular line. gotoline(f, n)
{ /* move to a particular line.
argument (n) must be a positive integer for argument (n) must be a positive integer for
this to actually do anything */ this to actually do anything */
{
register int status; /* status return */ register int status; /* status return */
char arg[NSTRING]; /* buffer to hold argument */ char arg[NSTRING]; /* buffer to hold argument */
/* get an argument if one doesnt exist */ /* get an argument if one doesnt exist */
if (f == FALSE) { if (f == FALSE) {
if ((status = mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) { if ((status =
mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) {
mlwrite("(Aborted)"); mlwrite("(Aborted)");
return (status); return (status);
} }
@ -211,10 +211,10 @@ backline(f, n)
} }
#if WORDPRO #if WORDPRO
gotobop(f, n) /* go back to the beginning of the current paragraph gotobop(f, n)
/* go back to the beginning of the current paragraph
here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE> here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
combination to delimit the beginning of a paragraph */ combination to delimit the beginning of a paragraph */
int f, n; /* default Flag & Numeric argument */ int f, n; /* default Flag & Numeric argument */
{ {
@ -256,10 +256,10 @@ int f, n; /* default Flag & Numeric argument */
return (TRUE); return (TRUE);
} }
gotoeop(f, n) /* go forword to the end of the current paragraph gotoeop(f, n)
/* go forword to the end of the current paragraph
here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE> here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
combination to delimit the beginning of a paragraph */ combination to delimit the beginning of a paragraph */
int f, n; /* default Flag & Numeric argument */ int f, n; /* default Flag & Numeric argument */
{ {

39
bind.c
View File

@ -14,10 +14,10 @@
extern int meta(), cex(), unarg(), ctrlg(); /* dummy prefix binding functions */ extern int meta(), cex(), unarg(), ctrlg(); /* dummy prefix binding functions */
help(f, n) /* give me some help!!!! help(f, n)
{ /* give me some help!!!!
bring up a fake buffer and read the help file bring up a fake buffer and read the help file
into it with view mode */ into it with view mode */
{
register WINDOW *wp; /* scaning pointer to windows */ register WINDOW *wp; /* scaning pointer to windows */
register BUFFER *bp; /* buffer pointer to help */ register BUFFER *bp; /* buffer pointer to help */
char *fname; /* ptr to file returned by flook() */ char *fname; /* ptr to file returned by flook() */
@ -55,9 +55,8 @@ help(f, n) /* give me some help!!!!
return (TRUE); return (TRUE);
} }
deskey(f, n) /* describe the command for a certain key */ deskey(f, n)
{ /* describe the command for a certain key */
{
register int c; /* key to describe */ register int c; /* key to describe */
register char *ptr; /* string pointer to scan output strings */ register char *ptr; /* string pointer to scan output strings */
char outseq[NSTRING]; /* output buffer for command sequence */ char outseq[NSTRING]; /* output buffer for command sequence */
@ -240,18 +239,17 @@ int c; /* command key to unbind */
return (TRUE); return (TRUE);
} }
desbind(f, n) /* describe bindings desbind(f, n)
/* describe bindings
bring up a fake buffer and list the key bindings bring up a fake buffer and list the key bindings
into it with view mode */ into it with view mode */
#if APROP #if APROP
{ {
buildlist(TRUE, ""); buildlist(TRUE, "");
} }
apro(f, n) /* Apropos (List functions that match a substring) */ apro(f, n)
{ /* Apropos (List functions that match a substring) */
{
char mstring[NSTRING]; /* string to match cmd names to */ char mstring[NSTRING]; /* string to match cmd names to */
int status; /* status return */ int status; /* status return */
@ -262,8 +260,8 @@ apro(f, n) /* Apropos (List functions that match a substring) */
return (buildlist(FALSE, mstring)); return (buildlist(FALSE, mstring));
} }
buildlist(type, mstring) /* build a binding list (limited or full) */ buildlist(type, mstring)
/* build a binding list (limited or full) */
int type; /* true = full list, false = partial list */ int type; /* true = full list, false = partial list */
char *mstring; /* match string if a partial list */ char *mstring; /* match string if a partial list */
@ -374,8 +372,8 @@ fail: /* and on to the next name */
} }
#if APROP #if APROP
strinc(source, sub) /* does source include sub? */ strinc(source, sub)
/* does source include sub? */
char *source; /* string to search in */ char *source; /* string to search in */
char *sub; /* substring to look for */ char *sub; /* substring to look for */
@ -498,7 +496,6 @@ int hflag; /* Look in the HOME environment variable first? */
ffclose(); ffclose();
return (fname); return (fname);
} }
#if ENVFUNC #if ENVFUNC
/* get the PATH variable */ /* get the PATH variable */
path = getenv("PATH"); path = getenv("PATH");
@ -542,8 +539,8 @@ int hflag; /* Look in the HOME environment variable first? */
return (NULL); /* no such luck */ return (NULL); /* no such luck */
} }
cmdstr(c, seq) /* change a key command to a string we can print out */ cmdstr(c, seq)
/* change a key command to a string we can print out */
int c; /* sequence to translate */ int c; /* sequence to translate */
char *seq; /* destination string for sequence */ char *seq; /* destination string for sequence */
@ -623,9 +620,9 @@ int (*func)(); /* ptr to the requested function to bind to */
return (NULL); return (NULL);
} }
int (*fncmatch(fname))() /* match fname to a function in the names table int (*fncmatch(fname)) ()
/* match fname to a function in the names table
and return any match or NULL if none */ and return any match or NULL if none */
char *fname; /* name to attempt to match */ char *fname; /* name to attempt to match */
{ {
@ -691,8 +688,8 @@ char *keyname; /* name of key to translate to Command key form */
return (c); return (c);
} }
char *transbind(skey) /* string key name to binding name.... */ char *transbind(skey)
/* string key name to binding name.... */
char *skey; /* name of keey to get binding for */ char *skey; /* name of keey to get binding for */
{ {

View File

@ -32,8 +32,8 @@ usebuffer(f, n)
return (swbuffer(bp)); return (swbuffer(bp));
} }
nextbuffer(f, n) /* switch to the next buffer in the buffer list */ nextbuffer(f, n)
/* switch to the next buffer in the buffer list */
int f, n; /* default flag, numeric argument */ int f, n; /* default flag, numeric argument */
{ {
register BUFFER *bp; /* eligable buffer to switch to */ register BUFFER *bp; /* eligable buffer to switch to */
@ -69,8 +69,8 @@ int f, n; /* default flag, numeric argument */
return (swbuffer(bp)); return (swbuffer(bp));
} }
swbuffer(bp) /* make buffer BP current */ swbuffer(bp)
/* make buffer BP current */
BUFFER *bp; BUFFER *bp;
{ {
@ -126,7 +126,6 @@ BUFFER *bp;
* line and the buffer header. Bound to "C-X K". * line and the buffer header. Bound to "C-X K".
*/ */
killbuffer(f, n) killbuffer(f, n)
{ {
register BUFFER *bp; register BUFFER *bp;
register int s; register int s;
@ -141,8 +140,8 @@ killbuffer(f, n)
return (zotbuf(bp)); return (zotbuf(bp));
} }
zotbuf(bp) /* kill the buffer pointed to by bp */ zotbuf(bp)
/* kill the buffer pointed to by bp */
register BUFFER *bp; register BUFFER *bp;
{ {
@ -172,8 +171,8 @@ register BUFFER *bp;
return (TRUE); return (TRUE);
} }
namebuffer(f,n) /* Rename the current buffer */ namebuffer(f, n)
/* Rename the current buffer */
int f, n; /* default Flag & Numeric arg */ int f, n; /* default Flag & Numeric arg */
{ {
@ -181,7 +180,8 @@ int f, n; /* default Flag & Numeric arg */
char bufn[NBUFN]; /* buffer to hold buffer name */ char bufn[NBUFN]; /* buffer to hold buffer name */
/* prompt for and get the new buffer name */ /* prompt for and get the new buffer name */
ask: if (mlreply("Change buffer name to: ", bufn, NBUFN) != TRUE) ask:if (mlreply("Change buffer name to: ", bufn, NBUFN) !=
TRUE)
return (FALSE); return (FALSE);
/* and check for duplicates */ /* and check for duplicates */
@ -278,7 +278,8 @@ int iflag; /* list hidden buffer flag */
return (s); return (s);
strcpy(blistp->b_fname, ""); strcpy(blistp->b_fname, "");
if (addline("ACT MODES Size Buffer File") == FALSE if (addline("ACT MODES Size Buffer File") == FALSE
|| addline("--- ----- ---- ------ ----") == FALSE) || addline("--- ----- ---- ------ ----") ==
FALSE)
return (FALSE); return (FALSE);
bp = bheadp; /* For all buffers */ bp = bheadp; /* For all buffers */
@ -428,7 +429,8 @@ anycb()
bp = bheadp; bp = bheadp;
while (bp != NULL) { while (bp != NULL) {
if ((bp->b_flag&BFINVS)==0 && (bp->b_flag&BFCHG)!=0) if ((bp->b_flag & BFINVS) == 0
&& (bp->b_flag & BFCHG) != 0)
return (TRUE); return (TRUE);
bp = bp->b_bufp; bp = bp->b_bufp;
} }
@ -442,8 +444,7 @@ anycb()
* and the "cflag" is TRUE, create it. The "bflag" is * and the "cflag" is TRUE, create it. The "bflag" is
* the settings for the flags in in buffer. * the settings for the flags in in buffer.
*/ */
BUFFER * BUFFER *bfind(bname, cflag, bflag)
bfind(bname, cflag, bflag)
register char *bname; register char *bname;
{ {
register BUFFER *bp; register BUFFER *bp;
@ -533,8 +534,8 @@ register BUFFER *bp;
return (TRUE); return (TRUE);
} }
unmark(f, n) /* unmark the current buffers change flag */ unmark(f, n)
/* unmark the current buffers change flag */
int f, n; /* unused command arguments */ int f, n; /* unused command arguments */
{ {

View File

@ -13,8 +13,8 @@
static int mod95(); static int mod95();
setkey(f, n) /* reset encryption key of current buffer */ setkey(f, n)
/* reset encryption key of current buffer */
int f; /* default flag */ int f; /* default flag */
int n; /* numeric argument */ int n; /* numeric argument */

View File

@ -73,8 +73,7 @@ vtinit()
exit(1); exit(1);
#endif #endif
for (i = 0; i < term.t_mrow; ++i) for (i = 0; i < term.t_mrow; ++i) {
{
vp = (VIDEO *) malloc(sizeof(VIDEO) + term.t_mcol); vp = (VIDEO *) malloc(sizeof(VIDEO) + term.t_mcol);
if (vp == NULL) if (vp == NULL)
@ -200,7 +199,6 @@ vteeol()
always finishes complete update */ always finishes complete update */
upscreen(f, n) upscreen(f, n)
{ {
update(TRUE); update(TRUE);
return (TRUE); return (TRUE);
@ -266,7 +264,8 @@ int force; /* force update past type ahead? */
reframe(wp); /* check the framing */ reframe(wp); /* check the framing */
#if SCROLLCODE #if SCROLLCODE
if (wp->w_flag & (WFKILLS | WFINS)) { if (wp->w_flag & (WFKILLS | WFINS)) {
scrflags |= (wp->w_flag & (WFINS|WFKILLS)); scrflags |=
(wp->w_flag & (WFINS | WFKILLS));
wp->w_flag &= ~(WFKILLS | WFINS); wp->w_flag &= ~(WFKILLS | WFINS);
} }
#endif #endif
@ -368,7 +367,6 @@ WINDOW *wp;
lp = lforw(lp); lp = lforw(lp);
} }
} }
#if SCROLLCODE #if SCROLLCODE
if (i == -1) { /* we're just above the window */ if (i == -1) { /* we're just above the window */
i = scrollcount; /* put dot at first line */ i = scrollcount; /* put dot at first line */
@ -481,7 +479,6 @@ WINDOW *wp; /* window to update lines in */
lines. This is the only update for simple moves. */ lines. This is the only update for simple moves. */
updpos() updpos()
{ {
register LINE *lp; register LINE *lp;
register int c; register int c;
@ -502,8 +499,7 @@ updpos()
c = lgetc(lp, i++); c = lgetc(lp, i++);
if (c == '\t') if (c == '\t')
curcol |= tabmask; curcol |= tabmask;
else else if (c < 0x20 || c == 0x7f)
if (c < 0x20 || c == 0x7f)
++curcol; ++curcol;
++curcol; ++curcol;
@ -520,7 +516,6 @@ updpos()
/* upddex: de-extend any line that derserves it */ /* upddex: de-extend any line that derserves it */
upddex() upddex()
{ {
register WINDOW *wp; register WINDOW *wp;
register LINE *lp; register LINE *lp;
@ -558,7 +553,6 @@ upddex()
the virtual screen and force a full update */ the virtual screen and force a full update */
updgar() updgar()
{ {
register char *txt; register char *txt;
register int i, j; register int i, j;
@ -629,9 +623,8 @@ int force; /* forced update flag */
/* optimize out scrolls (line breaks, and newlines) */ /* optimize out scrolls (line breaks, and newlines) */
/* arg. chooses between looking for inserts or deletes */ /* arg. chooses between looking for inserts or deletes */
int int scrolls(inserts)
scrolls(inserts) /* returns true if it does something */ { /* returns true if it does something */
{
struct VIDEO *vpv; /* virtual screen image */ struct VIDEO *vpv; /* virtual screen image */
struct VIDEO *vpp; /* physical screen image */ struct VIDEO *vpp; /* physical screen image */
int i, j, k; int i, j, k;
@ -682,8 +675,10 @@ scrolls(inserts) /* returns true if it does something */
if (inserts ? texttest(i, from) : texttest(from, i)) { if (inserts ? texttest(i, from) : texttest(from, i)) {
match = i; match = i;
count = 1; count = 1;
for (j=match+1, k=from+1; j<rows && k<rows; j++, k++) { for (j = match + 1, k = from + 1;
if (inserts ? texttest(j,k) : texttest(k,j)) j < rows && k < rows; j++, k++) {
if (inserts ? texttest(j, k) :
texttest(k, j))
count++; count++;
else else
break; break;
@ -721,7 +716,8 @@ scrolls(inserts) /* returns true if it does something */
char line[NLINE]; char line[NLINE];
sprintf(line, sprintf(line,
"scrolls: move the %d lines starting at %d to %d, first %d, scrolls %d", "scrolls: move the %d lines starting at %d to %d, first %d, scrolls %d",
count,from,to,first, 2*count >= abs(from-to)); count, from, to, first,
2 * count >= abs(from - to));
mlwrite(line); mlwrite(line);
} }
#endif #endif
@ -779,13 +775,13 @@ struct VIDEO *vpp = pscreen[prow] ; /* physical screen image */
} }
/* return the index of the first blank of trailing whitespace */ /* return the index of the first blank of trailing whitespace */
int int endofline(s, n)
endofline(s,n)
char *s; char *s;
{ {
int i; int i;
for (i = n - 1; i >= 0; i--) for (i = n - 1; i >= 0; i--)
if (s[i] != ' ') return(i+1) ; if (s[i] != ' ')
return (i + 1);
return (0); return (0);
} }
@ -798,7 +794,6 @@ int i ;
*/ */
updext() updext()
{ {
register int rcursor; /* real cursor location */ register int rcursor; /* real cursor location */
register LINE *lp; /* pointer to current line */ register LINE *lp; /* pointer to current line */
@ -853,8 +848,7 @@ struct VIDEO *vp2;
cp1 = &vp1->v_text[0]; cp1 = &vp1->v_text[0];
cp2 = &vp2->v_text[0]; cp2 = &vp2->v_text[0];
nch = term.t_ncol; nch = term.t_ncol;
do do {
{
*cp2 = *cp1; *cp2 = *cp1;
++cp2; ++cp2;
++cp1; ++cp1;
@ -899,8 +893,7 @@ struct VIDEO *vp2; /* physical screen image */
putline(row + 1, 1, cp1); putline(row + 1, 1, cp1);
nch = term.t_ncol; nch = term.t_ncol;
do do {
{
*cp2 = *cp1; *cp2 = *cp1;
++cp2; ++cp2;
++cp1; ++cp1;
@ -936,7 +929,8 @@ struct VIDEO *vp2; /* physical screen image */
req = (vp1->v_flag & VFREQ) == VFREQ; req = (vp1->v_flag & VFREQ) == VFREQ;
if ((rev != req) if ((rev != req)
#if COLOR #if COLOR
|| (vp1->v_fcolor != vp1->v_rfcolor) || (vp1->v_bcolor != vp1->v_rbcolor) || (vp1->v_fcolor != vp1->v_rfcolor)
|| (vp1->v_bcolor != vp1->v_rbcolor)
#endif #endif
) { ) {
movecursor(row, 0); /* Go to start of line. */ movecursor(row, 0); /* Go to start of line. */
@ -1096,15 +1090,13 @@ modeline(wp)
strcat(tline, VERSION); strcat(tline, VERSION);
strcat(tline, ": "); strcat(tline, ": ");
cp = &tline[0]; cp = &tline[0];
while ((c = *cp++) != 0) while ((c = *cp++) != 0) {
{
vtputc(c); vtputc(c);
++n; ++n;
} }
cp = &bp->b_bname[0]; cp = &bp->b_bname[0];
while ((c = *cp++) != 0) while ((c = *cp++) != 0) {
{
vtputc(c); vtputc(c);
++n; ++n;
} }
@ -1114,8 +1106,7 @@ modeline(wp)
/* display the modes */ /* display the modes */
firstm = TRUE; firstm = TRUE;
if ((bp->b_flag&BFTRUNC) != 0) if ((bp->b_flag & BFTRUNC) != 0) {
{
firstm = FALSE; firstm = FALSE;
strcat(tline, "Truncated"); strcat(tline, "Truncated");
} }
@ -1129,8 +1120,7 @@ modeline(wp)
strcat(tline, ") "); strcat(tline, ") ");
cp = &tline[0]; cp = &tline[0];
while ((c = *cp++) != 0) while ((c = *cp++) != 0) {
{
vtputc(c); vtputc(c);
++n; ++n;
} }
@ -1148,8 +1138,7 @@ modeline(wp)
#endif #endif
#if PKCODE #if PKCODE
if (bp->b_fname[0] != 0 && if (bp->b_fname[0] != 0 && strcmp(bp->b_bname, bp->b_fname) != 0)
strcmp(bp->b_bname, bp->b_fname) != 0)
#else #else
if (bp->b_fname[0] != 0) /* File name. */ if (bp->b_fname[0] != 0) /* File name. */
#endif #endif
@ -1157,8 +1146,7 @@ modeline(wp)
#if PKCODE == 0 #if PKCODE == 0
cp = "File: "; cp = "File: ";
while ((c = *cp++) != 0) while ((c = *cp++) != 0) {
{
vtputc(c); vtputc(c);
++n; ++n;
} }
@ -1166,8 +1154,7 @@ modeline(wp)
cp = &bp->b_fname[0]; cp = &bp->b_fname[0];
while ((c = *cp++) != 0) while ((c = *cp++) != 0) {
{
vtputc(c); vtputc(c);
++n; ++n;
} }
@ -1176,8 +1163,7 @@ modeline(wp)
++n; ++n;
} }
while (n < term.t_ncol) /* Pad to full width. */ while (n < term.t_ncol) { /* Pad to full width. */
{
vtputc(lchar); vtputc(lchar);
++n; ++n;
} }
@ -1205,8 +1191,7 @@ modeline(wp)
msg = " Top "; msg = " Top ";
} }
} }
if (!msg) if (!msg) {
{
LINE *lp; LINE *lp;
int numlines, predlines, ratio; int numlines, predlines, ratio;
@ -1224,7 +1209,8 @@ modeline(wp)
} else { } else {
ratio = 0; ratio = 0;
if (numlines != 0) if (numlines != 0)
ratio = (100L*predlines) / numlines; ratio =
(100L * predlines) / numlines;
if (ratio > 99) if (ratio > 99)
ratio = 99; ratio = 99;
sprintf(tline, " %2d%% ", ratio); sprintf(tline, " %2d%% ", ratio);
@ -1233,17 +1219,15 @@ modeline(wp)
} }
cp = msg; cp = msg;
while ((c = *cp++) != 0) while ((c = *cp++) != 0) {
{
vtputc(c); vtputc(c);
++n; ++n;
} }
} }
} }
upmode() /* update all the mode lines */ upmode()
{ /* update all the mode lines */
{
register WINDOW *wp; register WINDOW *wp;
wp = wheadp; wp = wheadp;
@ -1260,8 +1244,7 @@ upmode() /* update all the mode lines */
*/ */
movecursor(row, col) movecursor(row, col)
{ {
if (row!=ttrow || col!=ttcol) if (row != ttrow || col != ttcol) {
{
ttrow = row; ttrow = row;
ttcol = col; ttcol = col;
TTmove(row, col); TTmove(row, col);
@ -1318,7 +1301,6 @@ char *arg; /* pointer to first argument to print */
movecursor(term.t_nrow, 0); movecursor(term.t_nrow, 0);
return; return;
} }
#if COLOR #if COLOR
/* set up the proper colors for the command line */ /* set up the proper colors for the command line */
TTforg(7); TTforg(7);
@ -1417,8 +1399,7 @@ mlputs(s)
{ {
register int c; register int c;
while ((c = *s++) != 0) while ((c = *s++) != 0) {
{
TTputc(c); TTputc(c);
++ttcol; ++ttcol;
} }
@ -1433,8 +1414,7 @@ mlputi(i, r)
register int q; register int q;
static char hexdigits[] = "0123456789ABCDEF"; static char hexdigits[] = "0123456789ABCDEF";
if (i < 0) if (i < 0) {
{
i = -i; i = -i;
TTputc('-'); TTputc('-');
} }
@ -1456,8 +1436,7 @@ mlputli(l, r)
{ {
register long q; register long q;
if (l < 0) if (l < 0) {
{
l = -l; l = -l;
TTputc('-'); TTputc('-');
} }
@ -1568,4 +1547,3 @@ int h, w;
} }
#endif #endif

515
ebind.h
View File

@ -12,230 +12,401 @@
* control-X commands. * control-X commands.
*/ */
KEYTAB keytab[NBINDS] = { KEYTAB keytab[NBINDS] = {
{CONTROL|'A', gotobol}, {CONTROL | 'A', gotobol}
{CONTROL|'B', backchar}, ,
{CONTROL|'C', insspace}, {CONTROL | 'B', backchar}
{CONTROL|'D', forwdel}, ,
{CONTROL|'E', gotoeol}, {CONTROL | 'C', insspace}
{CONTROL|'F', forwchar}, ,
{CONTROL|'G', ctrlg}, {CONTROL | 'D', forwdel}
{CONTROL|'H', backdel}, ,
{CONTROL|'I', tab}, {CONTROL | 'E', gotoeol}
{CONTROL|'J', indent}, ,
{CONTROL|'K', killtext}, {CONTROL | 'F', forwchar}
{CONTROL|'L', refresh}, ,
{CONTROL|'M', newline}, {CONTROL | 'G', ctrlg}
{CONTROL|'N', forwline}, ,
{CONTROL|'O', openline}, {CONTROL | 'H', backdel}
{CONTROL|'P', backline}, ,
{CONTROL|'Q', quote}, {CONTROL | 'I', tab}
{CONTROL|'R', backsearch}, ,
{CONTROL|'S', forwsearch}, {CONTROL | 'J', indent}
{CONTROL|'T', twiddle}, ,
{CONTROL|'U', unarg}, {CONTROL | 'K', killtext}
{CONTROL|'V', forwpage}, ,
{CONTROL|'W', killregion}, {CONTROL | 'L', refresh}
{CONTROL|'X', cex}, ,
{CONTROL|'Y', yank}, {CONTROL | 'M', newline}
{CONTROL|'Z', backpage}, ,
{CONTROL|']', meta}, {CONTROL | 'N', forwline}
{CTLX|CONTROL|'B', listbuffers}, ,
{CTLX|CONTROL|'C', quit}, /* Hard quit. */ {CONTROL | 'O', openline}
,
{CONTROL | 'P', backline}
,
{CONTROL | 'Q', quote}
,
{CONTROL | 'R', backsearch}
,
{CONTROL | 'S', forwsearch}
,
{CONTROL | 'T', twiddle}
,
{CONTROL | 'U', unarg}
,
{CONTROL | 'V', forwpage}
,
{CONTROL | 'W', killregion}
,
{CONTROL | 'X', cex}
,
{CONTROL | 'Y', yank}
,
{CONTROL | 'Z', backpage}
,
{CONTROL | ']', meta}
,
{CTLX | CONTROL | 'B', listbuffers}
,
{CTLX | CONTROL | 'C', quit}
, /* Hard quit. */
#if PKCODE & AEDIT #if PKCODE & AEDIT
{CTLX|CONTROL|'A', detab}, {CTLX | CONTROL | 'A', detab}
,
#endif #endif
#if PKCODE #if PKCODE
{CTLX|CONTROL|'D', filesave}, /* alternative */ {CTLX | CONTROL | 'D', filesave}
, /* alternative */
#else #else
#if AEDIT #if AEDIT
{CTLX|CONTROL|'D', detab}, {CTLX | CONTROL | 'D', detab}
,
#endif #endif
#endif #endif
#if AEDIT #if AEDIT
{CTLX|CONTROL|'E', entab}, {CTLX | CONTROL | 'E', entab}
,
#endif #endif
{CTLX|CONTROL|'F', filefind}, {CTLX | CONTROL | 'F', filefind}
{CTLX|CONTROL|'I', insfile}, ,
{CTLX|CONTROL|'L', lowerregion}, {CTLX | CONTROL | 'I', insfile}
{CTLX|CONTROL|'M', delmode}, ,
{CTLX|CONTROL|'N', mvdnwind}, {CTLX | CONTROL | 'L', lowerregion}
{CTLX|CONTROL|'O', deblank}, ,
{CTLX|CONTROL|'P', mvupwind}, {CTLX | CONTROL | 'M', delmode}
{CTLX|CONTROL|'R', fileread}, ,
{CTLX|CONTROL|'S', filesave}, {CTLX | CONTROL | 'N', mvdnwind}
,
{CTLX | CONTROL | 'O', deblank}
,
{CTLX | CONTROL | 'P', mvupwind}
,
{CTLX | CONTROL | 'R', fileread}
,
{CTLX | CONTROL | 'S', filesave}
,
#if AEDIT #if AEDIT
{CTLX|CONTROL|'T', trim}, {CTLX | CONTROL | 'T', trim}
,
#endif #endif
{CTLX|CONTROL|'U', upperregion}, {CTLX | CONTROL | 'U', upperregion}
{CTLX|CONTROL|'V', viewfile}, ,
{CTLX|CONTROL|'W', filewrite}, {CTLX | CONTROL | 'V', viewfile}
{CTLX|CONTROL|'X', swapmark}, ,
{CTLX|CONTROL|'Z', shrinkwind}, {CTLX | CONTROL | 'W', filewrite}
{CTLX|'?', deskey}, ,
{CTLX|'!', spawn}, {CTLX | CONTROL | 'X', swapmark}
{CTLX|'@', pipecmd}, ,
{CTLX|'#', filter}, {CTLX | CONTROL | 'Z', shrinkwind}
{CTLX|'$', execprg}, ,
{CTLX|'=', showcpos}, {CTLX | '?', deskey}
{CTLX|'(', ctlxlp}, ,
{CTLX|')', ctlxrp}, {CTLX | '!', spawn}
{CTLX|'^', enlargewind}, ,
{CTLX|'0', delwind}, {CTLX | '@', pipecmd}
{CTLX|'1', onlywind}, ,
{CTLX|'2', splitwind}, {CTLX | '#', filter}
{CTLX|'A', setvar}, ,
{CTLX|'B', usebuffer}, {CTLX | '$', execprg}
{CTLX|'C', spawncli}, ,
{CTLX | '=', showcpos}
,
{CTLX | '(', ctlxlp}
,
{CTLX | ')', ctlxrp}
,
{CTLX | '^', enlargewind}
,
{CTLX | '0', delwind}
,
{CTLX | '1', onlywind}
,
{CTLX | '2', splitwind}
,
{CTLX | 'A', setvar}
,
{CTLX | 'B', usebuffer}
,
{CTLX | 'C', spawncli}
,
#if BSD | __hpux | SVR4 #if BSD | __hpux | SVR4
{CTLX|'D', bktoshell}, {CTLX | 'D', bktoshell}
,
#endif #endif
{CTLX|'E', ctlxe}, {CTLX | 'E', ctlxe}
{CTLX|'F', setfillcol}, ,
{CTLX|'K', killbuffer}, {CTLX | 'F', setfillcol}
{CTLX|'M', setmode}, ,
{CTLX|'N', filename}, {CTLX | 'K', killbuffer}
{CTLX|'O', nextwind}, ,
{CTLX|'P', prevwind}, {CTLX | 'M', setmode}
,
{CTLX | 'N', filename}
,
{CTLX | 'O', nextwind}
,
{CTLX | 'P', prevwind}
,
#if PKCODE #if PKCODE
{CTLX|'Q', quote}, /* alternative */ {CTLX | 'Q', quote}
, /* alternative */
#endif #endif
#if ISRCH #if ISRCH
{CTLX|'R', risearch}, {CTLX | 'R', risearch}
{CTLX|'S', fisearch}, ,
{CTLX | 'S', fisearch}
,
#endif #endif
{CTLX|'W', resize}, {CTLX | 'W', resize}
{CTLX|'X', nextbuffer}, ,
{CTLX|'Z', enlargewind}, {CTLX | 'X', nextbuffer}
,
{CTLX | 'Z', enlargewind}
,
#if WORDPRO #if WORDPRO
{META|CONTROL|'C', wordcount}, {META | CONTROL | 'C', wordcount}
,
#endif #endif
#if PKCODE #if PKCODE
{META|CONTROL|'D', newsize}, {META | CONTROL | 'D', newsize}
,
#endif #endif
#if PROC #if PROC
{META|CONTROL|'E', execproc}, {META | CONTROL | 'E', execproc}
,
#endif #endif
#if CFENCE #if CFENCE
{META|CONTROL|'F', getfence}, {META | CONTROL | 'F', getfence}
,
#endif #endif
{META|CONTROL|'H', delbword}, {META | CONTROL | 'H', delbword}
{META|CONTROL|'K', unbindkey}, ,
{META|CONTROL|'L', reposition}, {META | CONTROL | 'K', unbindkey}
{META|CONTROL|'M', delgmode}, ,
{META|CONTROL|'N', namebuffer}, {META | CONTROL | 'L', reposition}
{META|CONTROL|'R', qreplace}, ,
{META|CONTROL|'S', newsize}, {META | CONTROL | 'M', delgmode}
{META|CONTROL|'T', newwidth}, ,
{META|CONTROL|'V', scrnextdw}, {META | CONTROL | 'N', namebuffer}
,
{META | CONTROL | 'R', qreplace}
,
{META | CONTROL | 'S', newsize}
,
{META | CONTROL | 'T', newwidth}
,
{META | CONTROL | 'V', scrnextdw}
,
#if WORDPRO #if WORDPRO
{META|CONTROL|'W', killpara}, {META | CONTROL | 'W', killpara}
,
#endif #endif
{META|CONTROL|'Z', scrnextup}, {META | CONTROL | 'Z', scrnextup}
{META|' ', setmark}, ,
{META|'?', help}, {META | ' ', setmark}
{META|'!', reposition}, ,
{META|'.', setmark}, {META | '?', help}
{META|'>', gotoeob}, ,
{META|'<', gotobob}, {META | '!', reposition}
{META|'~', unmark}, ,
{META | '.', setmark}
,
{META | '>', gotoeob}
,
{META | '<', gotobob}
,
{META | '~', unmark}
,
#if APROP #if APROP
{META|'A', apro}, {META | 'A', apro}
,
#endif #endif
{META|'B', backword}, {META | 'B', backword}
{META|'C', capword}, ,
{META|'D', delfword}, {META | 'C', capword}
,
{META | 'D', delfword}
,
#if CRYPT #if CRYPT
{META|'E', setkey}, {META | 'E', setkey}
,
#endif #endif
{META|'F', forwword}, {META | 'F', forwword}
{META|'G', gotoline}, ,
{META | 'G', gotoline}
,
#if PKCODE #if PKCODE
#if WORDPRO #if WORDPRO
{META|'J', justpara}, {META | 'J', justpara}
,
#endif #endif
#endif #endif
{META|'K', bindtokey}, {META | 'K', bindtokey}
{META|'L', lowerword}, ,
{META|'M', setgmode}, {META | 'L', lowerword}
,
{META | 'M', setgmode}
,
#if WORDPRO #if WORDPRO
{META|'N', gotoeop}, {META | 'N', gotoeop}
{META|'P', gotobop}, ,
{META|'Q', fillpara}, {META | 'P', gotobop}
,
{META | 'Q', fillpara}
,
#endif #endif
{META|'R', sreplace}, {META | 'R', sreplace}
,
#if PKCODE #if PKCODE
{META|'S', forwsearch}, /* alternative P.K. */ {META | 'S', forwsearch}
, /* alternative P.K. */
#else #else
#if BSD #if BSD
{META|'S', bktoshell}, {META | 'S', bktoshell}
,
#endif #endif
#endif #endif
{META|'U', upperword}, {META | 'U', upperword}
{META|'V', backpage}, ,
{META|'W', copyregion}, {META | 'V', backpage}
{META|'X', namedcmd}, ,
{META|'Z', quickexit}, {META | 'W', copyregion}
{META|0x7F, delbword}, ,
{META | 'X', namedcmd}
,
{META | 'Z', quickexit}
,
{META | 0x7F, delbword}
,
#if MSDOS #if MSDOS
{SPEC|CONTROL|'_', forwhunt}, {SPEC | CONTROL | '_', forwhunt}
{SPEC|CONTROL|'S', backhunt}, ,
{SPEC|71, gotobol}, {SPEC | CONTROL | 'S', backhunt}
{SPEC|72, backline}, ,
{SPEC|73, backpage}, {SPEC | 71, gotobol}
{SPEC|75, backchar}, ,
{SPEC|77, forwchar}, {SPEC | 72, backline}
{SPEC|79, gotoeol}, ,
{SPEC|80, forwline}, {SPEC | 73, backpage}
{SPEC|81, forwpage}, ,
{SPEC|82, insspace}, {SPEC | 75, backchar}
{SPEC|83, forwdel}, ,
{SPEC|115, backword}, {SPEC | 77, forwchar}
{SPEC|116, forwword}, ,
{SPEC | 79, gotoeol}
,
{SPEC | 80, forwline}
,
{SPEC | 81, forwpage}
,
{SPEC | 82, insspace}
,
{SPEC | 83, forwdel}
,
{SPEC | 115, backword}
,
{SPEC | 116, forwword}
,
#if WORDPRO #if WORDPRO
{SPEC|132, gotobop}, {SPEC | 132, gotobop}
{SPEC|118, gotoeop}, ,
{SPEC | 118, gotoeop}
,
#endif #endif
{SPEC|84, cbuf1}, {SPEC | 84, cbuf1}
{SPEC|85, cbuf2}, ,
{SPEC|86, cbuf3}, {SPEC | 85, cbuf2}
{SPEC|87, cbuf4}, ,
{SPEC|88, cbuf5}, {SPEC | 86, cbuf3}
{SPEC|89, cbuf6}, ,
{SPEC|90, cbuf7}, {SPEC | 87, cbuf4}
{SPEC|91, cbuf8}, ,
{SPEC|92, cbuf9}, {SPEC | 88, cbuf5}
{SPEC|93, cbuf10}, ,
{SPEC | 89, cbuf6}
,
{SPEC | 90, cbuf7}
,
{SPEC | 91, cbuf8}
,
{SPEC | 92, cbuf9}
,
{SPEC | 93, cbuf10}
,
#if PKCODE #if PKCODE
{SPEC|117, gotoeob}, {SPEC | 117, gotoeob}
{SPEC|119, gotobob}, ,
{SPEC|141, gotobop}, {SPEC | 119, gotobob}
{SPEC|145, gotoeop}, ,
{SPEC|146, yank}, {SPEC | 141, gotobop}
{SPEC|147, killregion}, ,
{SPEC | 145, gotoeop}
,
{SPEC | 146, yank}
,
{SPEC | 147, killregion}
,
#endif #endif
#endif #endif
#if VT220 #if VT220
{SPEC|'1', fisearch}, /* VT220 keys */ {SPEC | '1', fisearch}
{SPEC|'2', yank}, , /* VT220 keys */
{SPEC|'3', killregion}, {SPEC | '2', yank}
{SPEC|'4', setmark}, ,
{SPEC|'5', backpage}, {SPEC | '3', killregion}
{SPEC|'6', forwpage}, ,
{SPEC|'A', backline}, {SPEC | '4', setmark}
{SPEC|'B', forwline}, ,
{SPEC|'C', forwchar}, {SPEC | '5', backpage}
{SPEC|'D', backchar}, ,
{SPEC|'c', meta}, {SPEC | '6', forwpage}
{SPEC|'d', backchar}, ,
{SPEC|'e', forwline}, {SPEC | 'A', backline}
{SPEC|'f', gotobob}, ,
{SPEC|'h', help}, {SPEC | 'B', forwline}
{SPEC|'i', cex}, ,
{SPEC | 'C', forwchar}
,
{SPEC | 'D', backchar}
,
{SPEC | 'c', meta}
,
{SPEC | 'd', backchar}
,
{SPEC | 'e', forwline}
,
{SPEC | 'f', gotobob}
,
{SPEC | 'h', help}
,
{SPEC | 'i', cex}
,
#endif #endif
{0x7F, backdel}, {0x7F, backdel}
,
/* special internal bindings */ /* special internal bindings */
SPEC | META | 'W', wrapword, /* called on word wrap */ SPEC | META | 'W', wrapword, /* called on word wrap */
@ -245,5 +416,3 @@ KEYTAB keytab[NBINDS] = {
{0, NULL} {0, NULL}
}; };

8
edef.h
View File

@ -46,10 +46,12 @@ int revexist = FALSE; /* does reverse video exist? */
int flickcode = FALSE; /* do flicker supression? */ int flickcode = FALSE; /* do flicker supression? */
char *modename[] = { /* name of modes */ char *modename[] = { /* name of modes */
"WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER",
"MAGIC", "CRYPT", "ASAVE"}; "MAGIC", "CRYPT", "ASAVE"
};
char *mode2name[] = { /* name of modes */ char *mode2name[] = { /* name of modes */
"Wrap", "Cmode", "Spell", "Exact", "View", "Over", "Wrap", "Cmode", "Spell", "Exact", "View", "Over",
"Magic", "Crypt", "Asave"}; "Magic", "Crypt", "Asave"
};
char modecode[] = "WCSEVOMYA"; /* letters to represent modes */ char modecode[] = "WCSEVOMYA"; /* letters to represent modes */
int gmode = 0; /* global editor mode */ int gmode = 0; /* global editor mode */
int gflags = GFREAD; /* global control flag */ int gflags = GFREAD; /* global control flag */
@ -319,5 +321,3 @@ extern char outline[]; /* global string to hold debug line text */
#ifndef termdef #ifndef termdef
extern TERM term; /* Terminal information. */ extern TERM term; /* Terminal information. */
#endif #endif

23
epath.h
View File

@ -9,7 +9,6 @@
/* possible names and paths of help files under different OSs */ /* possible names and paths of help files under different OSs */
char *pathname[] = char *pathname[] =
#if MSDOS #if MSDOS
{ {
"emacs.rc", "emacs.rc",
@ -24,30 +23,20 @@ char *pathname[] =
#if V7 | BSD | USG #if V7 | BSD | USG
{ {
".emacsrc", ".emacsrc", "emacs.hlp",
"emacs.hlp",
#if PKCODE #if PKCODE
"/usr/global/lib/", "/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/",
"/usr/local/bin/",
"/usr/local/lib/",
#endif #endif
"/usr/local/", "/usr/local/", "/usr/lib/", ""};
"/usr/lib/",
""
};
#endif #endif
#if VMS #if VMS
{ {
"emacs.rc", "emacs.rc", "emacs.hlp", "",
"emacs.hlp",
"",
#if PKCODE #if PKCODE
"sys$login:", "sys$login:", "emacs_dir:",
"emacs_dir:",
#endif #endif
"sys$sysdevice:[vmstools]" "sys$sysdevice:[vmstools]"};
};
#endif #endif
#define NPNAMES (sizeof(pathname)/sizeof(char *)) #define NPNAMES (sizeof(pathname)/sizeof(char *))

View File

@ -728,4 +728,3 @@ typedef struct {
char *rstr; char *rstr;
} RMC; } RMC;
#endif #endif

476
eval.c
View File

@ -11,17 +11,16 @@
#include "edef.h" #include "edef.h"
#include "evar.h" #include "evar.h"
varinit() /* initialize the user variable list */ varinit()
{ /* initialize the user variable list */
{
register int i; register int i;
for (i = 0; i < MAXVARS; i++) for (i = 0; i < MAXVARS; i++)
uv[i].u_name[0] = 0; uv[i].u_name[0] = 0;
} }
char *gtfun(fname) /* evaluate a function */ char *gtfun(fname)
/* evaluate a function */
char *fname; /* name of function to evaluate */ char *fname; /* name of function to evaluate */
{ {
@ -69,43 +68,73 @@ char *fname; /* name of function to evaluate */
/* and now evaluate it! */ /* and now evaluate it! */
switch (fnum) { switch (fnum) {
case UFADD: return(itoa(atoi(arg1) + atoi(arg2))); case UFADD:
case UFSUB: return(itoa(atoi(arg1) - atoi(arg2))); return (itoa(atoi(arg1) + atoi(arg2)));
case UFTIMES: return(itoa(atoi(arg1) * atoi(arg2))); case UFSUB:
case UFDIV: return(itoa(atoi(arg1) / atoi(arg2))); return (itoa(atoi(arg1) - atoi(arg2)));
case UFMOD: return(itoa(atoi(arg1) % atoi(arg2))); case UFTIMES:
case UFNEG: return(itoa(-atoi(arg1))); return (itoa(atoi(arg1) * atoi(arg2)));
case UFCAT: strcpy(result, arg1); case UFDIV:
return (itoa(atoi(arg1) / atoi(arg2)));
case UFMOD:
return (itoa(atoi(arg1) % atoi(arg2)));
case UFNEG:
return (itoa(-atoi(arg1)));
case UFCAT:
strcpy(result, arg1);
return (strcat(result, arg2)); return (strcat(result, arg2));
case UFLEFT: return(strncpy(result, arg1, atoi(arg2))); case UFLEFT:
case UFRIGHT: return(strcpy(result, return (strncpy(result, arg1, atoi(arg2)));
case UFRIGHT:
return (strcpy(result,
&arg1[(strlen(arg1) - atoi(arg2))])); &arg1[(strlen(arg1) - atoi(arg2))]));
case UFMID: return(strncpy(result, &arg1[atoi(arg2)-1], case UFMID:
return (strncpy(result, &arg1[atoi(arg2) - 1],
atoi(arg3))); atoi(arg3)));
case UFNOT: return(ltos(stol(arg1) == FALSE)); case UFNOT:
case UFEQUAL: return(ltos(atoi(arg1) == atoi(arg2))); return (ltos(stol(arg1) == FALSE));
case UFLESS: return(ltos(atoi(arg1) < atoi(arg2))); case UFEQUAL:
case UFGREATER: return(ltos(atoi(arg1) > atoi(arg2))); return (ltos(atoi(arg1) == atoi(arg2)));
case UFSEQUAL: return(ltos(strcmp(arg1, arg2) == 0)); case UFLESS:
case UFSLESS: return(ltos(strcmp(arg1, arg2) < 0)); return (ltos(atoi(arg1) < atoi(arg2)));
case UFSGREAT: return(ltos(strcmp(arg1, arg2) > 0)); case UFGREATER:
case UFIND: return(strcpy(result, getval(arg1))); return (ltos(atoi(arg1) > atoi(arg2)));
case UFAND: return(ltos(stol(arg1) && stol(arg2))); case UFSEQUAL:
case UFOR: return(ltos(stol(arg1) || stol(arg2))); return (ltos(strcmp(arg1, arg2) == 0));
case UFLENGTH: return(itoa(strlen(arg1))); case UFSLESS:
case UFUPPER: return(mkupper(arg1)); return (ltos(strcmp(arg1, arg2) < 0));
case UFLOWER: return(mklower(arg1)); case UFSGREAT:
case UFTRUTH: return(ltos(atoi(arg1) == 42)); return (ltos(strcmp(arg1, arg2) > 0));
case UFASCII: return(itoa((int)arg1[0])); case UFIND:
case UFCHR: result[0] = atoi(arg1); return (strcpy(result, getval(arg1)));
case UFAND:
return (ltos(stol(arg1) && stol(arg2)));
case UFOR:
return (ltos(stol(arg1) || stol(arg2)));
case UFLENGTH:
return (itoa(strlen(arg1)));
case UFUPPER:
return (mkupper(arg1));
case UFLOWER:
return (mklower(arg1));
case UFTRUTH:
return (ltos(atoi(arg1) == 42));
case UFASCII:
return (itoa((int) arg1[0]));
case UFCHR:
result[0] = atoi(arg1);
result[1] = 0; result[1] = 0;
return (result); return (result);
case UFGTKEY: result[0] = tgetc(); case UFGTKEY:
result[0] = tgetc();
result[1] = 0; result[1] = 0;
return (result); return (result);
case UFRND: return(itoa((ernd() % abs(atoi(arg1))) + 1)); case UFRND:
case UFABS: return(itoa(abs(atoi(arg1)))); return (itoa((ernd() % abs(atoi(arg1))) + 1));
case UFSINDEX: return(itoa(sindex(arg1, arg2))); case UFABS:
return (itoa(abs(atoi(arg1))));
case UFSINDEX:
return (itoa(sindex(arg1, arg2)));
case UFENV: case UFENV:
#if ENVFUNC #if ENVFUNC
tsp = getenv(arg1); tsp = getenv(arg1);
@ -113,23 +142,30 @@ char *fname; /* name of function to evaluate */
#else #else
return (""); return ("");
#endif #endif
case UFBIND: return(transbind(arg1)); case UFBIND:
case UFEXIST: return(ltos(fexist(arg1))); return (transbind(arg1));
case UFEXIST:
return (ltos(fexist(arg1)));
case UFFIND: case UFFIND:
tsp = flook(arg1, TRUE); tsp = flook(arg1, TRUE);
return (tsp == NULL ? "" : tsp); return (tsp == NULL ? "" : tsp);
case UFBAND: return(itoa(atoi(arg1) & atoi(arg2))); case UFBAND:
case UFBOR: return(itoa(atoi(arg1) | atoi(arg2))); return (itoa(atoi(arg1) & atoi(arg2)));
case UFBXOR: return(itoa(atoi(arg1) ^ atoi(arg2))); case UFBOR:
case UFBNOT: return(itoa(~atoi(arg1))); return (itoa(atoi(arg1) | atoi(arg2)));
case UFXLATE: return(xlat(arg1, arg2, arg3)); case UFBXOR:
return (itoa(atoi(arg1) ^ atoi(arg2)));
case UFBNOT:
return (itoa(~atoi(arg1)));
case UFXLATE:
return (xlat(arg1, arg2, arg3));
} }
exit(-11); /* never should get here */ exit(-11); /* never should get here */
} }
char *gtusr(vname) /* look up a user var's value */ char *gtusr(vname)
/* look up a user var's value */
char *vname; /* name of user variable to fetch */ char *vname; /* name of user variable to fetch */
{ {
@ -179,68 +215,106 @@ char *vname; /* name of environment variable to retrieve */
/* otherwise, fetch the appropriate value */ /* otherwise, fetch the appropriate value */
switch (vnum) { switch (vnum) {
case EVFILLCOL: return(itoa(fillcol)); case EVFILLCOL:
case EVPAGELEN: return(itoa(term.t_nrow + 1)); return (itoa(fillcol));
case EVCURCOL: return(itoa(getccol(FALSE))); case EVPAGELEN:
case EVCURLINE: return(itoa(getcline())); return (itoa(term.t_nrow + 1));
case EVRAM: return(itoa((int)(envram / 1024l))); case EVCURCOL:
case EVFLICKER: return(ltos(flickcode)); return (itoa(getccol(FALSE)));
case EVCURWIDTH:return(itoa(term.t_ncol)); case EVCURLINE:
case EVCBUFNAME:return(curbp->b_bname); return (itoa(getcline()));
case EVCFNAME: return(curbp->b_fname); case EVRAM:
case EVSRES: return(sres); return (itoa((int) (envram / 1024l)));
case EVDEBUG: return(ltos(macbug)); case EVFLICKER:
case EVSTATUS: return(ltos(cmdstatus)); return (ltos(flickcode));
case EVPALETTE: return(palstr); case EVCURWIDTH:
case EVASAVE: return(itoa(gasave)); return (itoa(term.t_ncol));
case EVACOUNT: return(itoa(gacount)); case EVCBUFNAME:
case EVLASTKEY: return(itoa(lastkey)); return (curbp->b_bname);
case EVCFNAME:
return (curbp->b_fname);
case EVSRES:
return (sres);
case EVDEBUG:
return (ltos(macbug));
case EVSTATUS:
return (ltos(cmdstatus));
case EVPALETTE:
return (palstr);
case EVASAVE:
return (itoa(gasave));
case EVACOUNT:
return (itoa(gacount));
case EVLASTKEY:
return (itoa(lastkey));
case EVCURCHAR: case EVCURCHAR:
return (curwp->w_dotp->l_used == return (curwp->w_dotp->l_used ==
curwp->w_doto ? itoa('\n') : curwp->w_doto ? itoa('\n') :
itoa(lgetc(curwp->w_dotp, curwp->w_doto))); itoa(lgetc(curwp->w_dotp, curwp->w_doto)));
case EVDISCMD: return(ltos(discmd)); case EVDISCMD:
case EVVERSION: return(VERSION); return (ltos(discmd));
case EVPROGNAME:return(PROGNAME); case EVVERSION:
case EVSEED: return(itoa(seed)); return (VERSION);
case EVDISINP: return(ltos(disinp)); case EVPROGNAME:
case EVWLINE: return(itoa(curwp->w_ntrows)); return (PROGNAME);
case EVCWLINE: return(itoa(getwpos())); case EVSEED:
case EVTARGET: saveflag = lastflag; return (itoa(seed));
case EVDISINP:
return (ltos(disinp));
case EVWLINE:
return (itoa(curwp->w_ntrows));
case EVCWLINE:
return (itoa(getwpos()));
case EVTARGET:
saveflag = lastflag;
return (itoa(curgoal)); return (itoa(curgoal));
case EVSEARCH: return(pat); case EVSEARCH:
case EVREPLACE: return(rpat); return (pat);
case EVMATCH: return((patmatch == NULL)? "": patmatch); case EVREPLACE:
case EVKILL: return(getkill()); return (rpat);
case EVCMODE: return(itoa(curbp->b_mode)); case EVMATCH:
case EVGMODE: return(itoa(gmode)); return ((patmatch == NULL) ? "" : patmatch);
case EVTPAUSE: return(itoa(term.t_pause)); case EVKILL:
return (getkill());
case EVCMODE:
return (itoa(curbp->b_mode));
case EVGMODE:
return (itoa(gmode));
case EVTPAUSE:
return (itoa(term.t_pause));
case EVPENDING: case EVPENDING:
#if TYPEAH #if TYPEAH
return (ltos(typahead())); return (ltos(typahead()));
#else #else
return (falsem); return (falsem);
#endif #endif
case EVLWIDTH: return(itoa(llength(curwp->w_dotp))); case EVLWIDTH:
case EVLINE: return(getctext()); return (itoa(llength(curwp->w_dotp)));
case EVGFLAGS: return(itoa(gflags)); case EVLINE:
case EVRVAL: return(itoa(rval)); return (getctext());
case EVTAB: return(itoa(tabmask+1)); case EVGFLAGS:
case EVOVERLAP: return(itoa(overlap)); return (itoa(gflags));
case EVRVAL:
return (itoa(rval));
case EVTAB:
return (itoa(tabmask + 1));
case EVOVERLAP:
return (itoa(overlap));
case EVSCROLLCOUNT: case EVSCROLLCOUNT:
return (itoa(scrollcount)); return (itoa(scrollcount));
#if SCROLLCODE #if SCROLLCODE
case EVSCROLL: return(ltos(term.t_scroll != NULL)); case EVSCROLL:
return (ltos(term.t_scroll != NULL));
#else #else
case EVSCROLL: return(ltos(0)); case EVSCROLL:
return (ltos(0));
#endif #endif
} }
exit(-12); /* again, we should never get here */ exit(-12); /* again, we should never get here */
} }
char *getkill() /* return some of the contents of the kill buffer */ char *getkill()
{ /* return some of the contents of the kill buffer */
{
register int size; /* max number of chars to return */ register int size; /* max number of chars to return */
static char value[NSTRING]; /* temp buffer for value */ static char value[NSTRING]; /* temp buffer for value */
@ -260,8 +334,8 @@ char *getkill() /* return some of the contents of the kill buffer */
return (value); return (value);
} }
int setvar(f, n) /* set a variable */ int setvar(f, n)
/* set a variable */
int f; /* default flag */ int f; /* default flag */
int n; /* numeric arg (can overide prompted value) */ int n; /* numeric arg (can overide prompted value) */
@ -331,8 +405,7 @@ int n; /* numeric arg (can overide prompted value) */
if (*sp++ == '%') { if (*sp++ == '%') {
/* advance to the end */ /* advance to the end */
ep = --sp; ep = --sp;
while (*ep++) while (*ep++);
;
/* null terminate the string one out */ /* null terminate the string one out */
*(ep + 1) = 0; *(ep + 1) = 0;
/* copy backwards */ /* copy backwards */
@ -359,8 +432,8 @@ int n; /* numeric arg (can overide prompted value) */
return (status); return (status);
} }
findvar(var, vd, size) /* find a variables type and name */ findvar(var, vd, size)
/* find a variables type and name */
char *var; /* name of var to get */ char *var; /* name of var to get */
VDESC *vd; /* structure to hold type and ptr */ VDESC *vd; /* structure to hold type and ptr */
int size; /* size of var array */ int size; /* size of var array */
@ -414,8 +487,8 @@ fvar: vtype = -1;
return; return;
} }
int svar(var, value) /* set a variable */ int svar(var, value)
/* set a variable */
VDESC *var; /* variable to set */ VDESC *var; /* variable to set */
char *value; /* value to set to */ char *value; /* value to set to */
@ -446,41 +519,58 @@ char *value; /* value to set to */
case TKENV: /* set an environment variable */ case TKENV: /* set an environment variable */
status = TRUE; /* by default */ status = TRUE; /* by default */
switch (vnum) { switch (vnum) {
case EVFILLCOL: fillcol = atoi(value); case EVFILLCOL:
fillcol = atoi(value);
break; break;
case EVPAGELEN: status = newsize(TRUE, atoi(value)); case EVPAGELEN:
status = newsize(TRUE, atoi(value));
break; break;
case EVCURCOL: status = setccol(atoi(value)); case EVCURCOL:
status = setccol(atoi(value));
break; break;
case EVCURLINE: status = gotoline(TRUE, atoi(value)); case EVCURLINE:
status = gotoline(TRUE, atoi(value));
break; break;
case EVRAM: break; case EVRAM:
case EVFLICKER: flickcode = stol(value);
break; break;
case EVCURWIDTH:status = newwidth(TRUE, atoi(value)); case EVFLICKER:
flickcode = stol(value);
break; break;
case EVCBUFNAME:strcpy(curbp->b_bname, value); case EVCURWIDTH:
status = newwidth(TRUE, atoi(value));
break;
case EVCBUFNAME:
strcpy(curbp->b_bname, value);
curwp->w_flag |= WFMODE; curwp->w_flag |= WFMODE;
break; break;
case EVCFNAME: strcpy(curbp->b_fname, value); case EVCFNAME:
strcpy(curbp->b_fname, value);
curwp->w_flag |= WFMODE; curwp->w_flag |= WFMODE;
break; break;
case EVSRES: status = TTrez(value); case EVSRES:
status = TTrez(value);
break; break;
case EVDEBUG: macbug = stol(value); case EVDEBUG:
macbug = stol(value);
break; break;
case EVSTATUS: cmdstatus = stol(value); case EVSTATUS:
cmdstatus = stol(value);
break; break;
case EVPALETTE: strncpy(palstr, value, 48); case EVPALETTE:
strncpy(palstr, value, 48);
spal(palstr); spal(palstr);
break; break;
case EVASAVE: gasave = atoi(value); case EVASAVE:
gasave = atoi(value);
break; break;
case EVACOUNT: gacount = atoi(value); case EVACOUNT:
gacount = atoi(value);
break; break;
case EVLASTKEY: lastkey = atoi(value); case EVLASTKEY:
lastkey = atoi(value);
break; break;
case EVCURCHAR: ldelete(1L, FALSE); /* delete 1 char */ case EVCURCHAR:
ldelete(1L, FALSE); /* delete 1 char */
c = atoi(value); c = atoi(value);
if (c == '\n') if (c == '\n')
lnewline(FALSE, 1); lnewline(FALSE, 1);
@ -488,51 +578,72 @@ char *value; /* value to set to */
linsert(1, c); linsert(1, c);
backchar(FALSE, 1); backchar(FALSE, 1);
break; break;
case EVDISCMD: discmd = stol(value); case EVDISCMD:
discmd = stol(value);
break; break;
case EVVERSION: break; case EVVERSION:
case EVPROGNAME:break;
case EVSEED: seed = atoi(value);
break; break;
case EVDISINP: disinp = stol(value); case EVPROGNAME:
break; break;
case EVWLINE: status = resize(TRUE, atoi(value)); case EVSEED:
seed = atoi(value);
break; break;
case EVCWLINE: status = forwline(TRUE, case EVDISINP:
atoi(value) - getwpos()); disinp = stol(value);
break; break;
case EVTARGET: curgoal = atoi(value); case EVWLINE:
status = resize(TRUE, atoi(value));
break;
case EVCWLINE:
status = forwline(TRUE, atoi(value) - getwpos());
break;
case EVTARGET:
curgoal = atoi(value);
thisflag = saveflag; thisflag = saveflag;
break; break;
case EVSEARCH: strcpy(pat, value); case EVSEARCH:
strcpy(pat, value);
rvstrcpy(tap, pat); rvstrcpy(tap, pat);
#if MAGIC #if MAGIC
mcclear(); mcclear();
#endif #endif
break; break;
case EVREPLACE: strcpy(rpat, value); case EVREPLACE:
strcpy(rpat, value);
break; break;
case EVMATCH: break; case EVMATCH:
case EVKILL: break; break;
case EVCMODE: curbp->b_mode = atoi(value); case EVKILL:
break;
case EVCMODE:
curbp->b_mode = atoi(value);
curwp->w_flag |= WFMODE; curwp->w_flag |= WFMODE;
break; break;
case EVGMODE: gmode = atoi(value); case EVGMODE:
gmode = atoi(value);
break; break;
case EVTPAUSE: term.t_pause = atoi(value); case EVTPAUSE:
term.t_pause = atoi(value);
break; break;
case EVPENDING: break; case EVPENDING:
case EVLWIDTH: break;
case EVLINE: putctext(value);
case EVGFLAGS: gflags = atoi(value);
break; break;
case EVRVAL: break; case EVLWIDTH:
case EVTAB: tabmask = atoi(value)-1; break;
case EVLINE:
putctext(value);
case EVGFLAGS:
gflags = atoi(value);
break;
case EVRVAL:
break;
case EVTAB:
tabmask = atoi(value) - 1;
if (tabmask != 0x07 && tabmask != 0x03) if (tabmask != 0x07 && tabmask != 0x03)
tabmask = 0x07; tabmask = 0x07;
curwp->w_flag |= WFHARD; curwp->w_flag |= WFHARD;
break; break;
case EVOVERLAP: overlap = atoi(value); case EVOVERLAP:
overlap = atoi(value);
break; break;
case EVSCROLLCOUNT: case EVSCROLLCOUNT:
scrollcount = atoi(value); scrollcount = atoi(value);
@ -623,8 +734,8 @@ int i; /* integer to translate to a string */
return (sp); return (sp);
} }
int gettyp(token) /* find the type of a passed token */ int gettyp(token)
/* find the type of a passed token */
char *token; /* token to analyze */ char *token; /* token to analyze */
{ {
@ -642,22 +753,31 @@ char *token; /* token to analyze */
return (TKLIT); return (TKLIT);
switch (c) { switch (c) {
case '"': return(TKSTR); case '"':
return (TKSTR);
case '!': return(TKDIR); case '!':
case '@': return(TKARG); return (TKDIR);
case '#': return(TKBUF); case '@':
case '$': return(TKENV); return (TKARG);
case '%': return(TKVAR); case '#':
case '&': return(TKFUN); return (TKBUF);
case '*': return(TKLBL); case '$':
return (TKENV);
case '%':
return (TKVAR);
case '&':
return (TKFUN);
case '*':
return (TKLBL);
default: return(TKCMD); default:
return (TKCMD);
} }
} }
char *getval(token) /* find the value of a token */ char *getval(token)
/* find the value of a token */
char *token; /* token to evaluate */ char *token; /* token to evaluate */
{ {
@ -668,14 +788,14 @@ char *token; /* token to evaluate */
static char buf[NSTRING]; /* string buffer for some returns */ static char buf[NSTRING]; /* string buffer for some returns */
switch (gettyp(token)) { switch (gettyp(token)) {
case TKNUL: return(""); case TKNUL:
return ("");
case TKARG: /* interactive argument */ case TKARG: /* interactive argument */
strcpy(token, getval(&token[1])); strcpy(token, getval(&token[1]));
distmp = discmd; /* echo it always! */ distmp = discmd; /* echo it always! */
discmd = TRUE; discmd = TRUE;
status = getstring(token, status = getstring(token, buf, NSTRING, ctoec('\n'));
buf, NSTRING, ctoec('\n'));
discmd = distmp; discmd = distmp;
if (status == ABORT) if (status == ABORT)
return (errorm); return (errorm);
@ -704,8 +824,7 @@ char *token; /* token to evaluate */
blen = bp->b_dotp->l_used - bp->b_doto; blen = bp->b_dotp->l_used - bp->b_doto;
if (blen > NSTRING) if (blen > NSTRING)
blen = NSTRING; blen = NSTRING;
strncpy(buf, bp->b_dotp->l_text + bp->b_doto, strncpy(buf, bp->b_dotp->l_text + bp->b_doto, blen);
blen);
buf[blen] = 0; buf[blen] = 0;
/* and step the buffer's line ptr ahead a line */ /* and step the buffer's line ptr ahead a line */
@ -722,19 +841,27 @@ char *token; /* token to evaluate */
/* and return the spoils */ /* and return the spoils */
return (buf); return (buf);
case TKVAR: return(gtusr(token+1)); case TKVAR:
case TKENV: return(gtenv(token+1)); return (gtusr(token + 1));
case TKFUN: return(gtfun(token+1)); case TKENV:
case TKDIR: return(errorm); return (gtenv(token + 1));
case TKLBL: return(errorm); case TKFUN:
case TKLIT: return(token); return (gtfun(token + 1));
case TKSTR: return(token+1); case TKDIR:
case TKCMD: return(token); return (errorm);
case TKLBL:
return (errorm);
case TKLIT:
return (token);
case TKSTR:
return (token + 1);
case TKCMD:
return (token);
} }
} }
int stol(val) /* convert a string to a numeric logical */ int stol(val)
/* convert a string to a numeric logical */
char *val; /* value to check for stol */ char *val; /* value to check for stol */
{ {
@ -748,8 +875,8 @@ char *val; /* value to check for stol */
return ((atoi(val) != 0)); return ((atoi(val) != 0));
} }
char *ltos(val) /* numeric logical to string logical */ char *ltos(val)
/* numeric logical to string logical */
int val; /* value to translate */ int val; /* value to translate */
{ {
@ -759,8 +886,8 @@ int val; /* value to translate */
return (falsem); return (falsem);
} }
char *mkupper(str) /* make a string upper case */ char *mkupper(str)
/* make a string upper case */
char *str; /* string to upper case */ char *str; /* string to upper case */
{ {
@ -775,8 +902,8 @@ char *str; /* string to upper case */
return (str); return (str);
} }
char *mklower(str) /* make a string lower case */ char *mklower(str)
/* make a string lower case */
char *str; /* string to lower case */ char *str; /* string to lower case */
{ {
@ -791,23 +918,22 @@ char *str; /* string to lower case */
return (str); return (str);
} }
int abs(x) /* take the absolute value of an integer */ int abs(x)
/* take the absolute value of an integer */
int x; int x;
{ {
return (x < 0 ? -x : x); return (x < 0 ? -x : x);
} }
int ernd() /* returns a random integer */ int ernd()
{ /* returns a random integer */
{
seed = abs(seed * 1721 + 10007); seed = abs(seed * 1721 + 10007);
return (seed); return (seed);
} }
int sindex(source, pattern) /* find pattern within source */ int sindex(source, pattern)
/* find pattern within source */
char *source; /* source string to search */ char *source; /* source string to search */
char *pattern; /* string to look for */ char *pattern; /* string to look for */

120
exec.c
View File

@ -153,12 +153,23 @@ int size; /* maximum size of token */
if (*src == 0) if (*src == 0)
break; break;
switch (*src++) { switch (*src++) {
case 'r': c = 13; break; case 'r':
case 'n': c = 10; break; c = 13;
case 't': c = 9; break; break;
case 'b': c = 8; break; case 'n':
case 'f': c = 12; break; c = 10;
default: c = *(src-1); break;
case 't':
c = 9;
break;
case 'b':
c = 8;
break;
case 'f':
c = 12;
break;
default:
c = *(src - 1);
} }
if (--size > 0) { if (--size > 0) {
*tok++ = c; *tok++ = c;
@ -191,8 +202,8 @@ int size; /* maximum size of token */
return (src); return (src);
} }
macarg(tok) /* get a macro line argument */ macarg(tok)
/* get a macro line argument */
char *tok; /* buffer to place argument */ char *tok; /* buffer to place argument */
{ {
@ -291,7 +302,8 @@ int n; /* macro number to use */
return (storemac(f, n)); return (storemac(f, n));
/* get the name of the procedure */ /* get the name of the procedure */
if ((status = mlreply("Procedure name: ", &bname[1], NBUFN-2)) != TRUE) if ((status =
mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE)
return (status); return (status);
/* construct the macro buffer name */ /* construct the macro buffer name */
@ -325,7 +337,8 @@ int f, n; /* default flag and numeric arg */
char bufn[NBUFN + 2]; /* name of buffer to execute */ char bufn[NBUFN + 2]; /* name of buffer to execute */
/* find out what buffer the user wants to execute */ /* find out what buffer the user wants to execute */
if ((status = mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE) if ((status =
mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE)
return (status); return (status);
/* construct the buffer name */ /* construct the buffer name */
@ -447,8 +460,10 @@ BUFFER *bp; /* buffer to execute */
if (eline[0] == '!' && eline[1] == 'w' && eline[2] == 'h') { if (eline[0] == '!' && eline[1] == 'w' && eline[2] == 'h') {
whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK)); whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK));
if (whtemp == NULL) { if (whtemp == NULL) {
noram: mlwrite("%%Out of memory during while scan"); noram:mlwrite
failexit: freewhile(scanner); ("%%Out of memory during while scan");
failexit:freewhile
(scanner);
freewhile(whlist); freewhile(whlist);
return (FALSE); return (FALSE);
} }
@ -461,7 +476,8 @@ failexit: freewhile(scanner);
/* if is a BREAK directive, make a block... */ /* if is a BREAK directive, make a block... */
if (eline[0] == '!' && eline[1] == 'b' && eline[2] == 'r') { if (eline[0] == '!' && eline[1] == 'b' && eline[2] == 'r') {
if (scanner == NULL) { if (scanner == NULL) {
mlwrite("%%!BREAK outside of any !WHILE loop"); mlwrite
("%%!BREAK outside of any !WHILE loop");
goto failexit; goto failexit;
} }
whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK)); whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK));
@ -476,7 +492,8 @@ failexit: freewhile(scanner);
/* if it is an endwhile directive, record the spot... */ /* if it is an endwhile directive, record the spot... */
if (eline[0] == '!' && strncmp(&eline[1], "endw", 4) == 0) { if (eline[0] == '!' && strncmp(&eline[1], "endw", 4) == 0) {
if (scanner == NULL) { if (scanner == NULL) {
mlwrite("%%!ENDWHILE with no preceding !WHILE in '%s'", mlwrite
("%%!ENDWHILE with no preceding !WHILE in '%s'",
bp->b_bname); bp->b_bname);
goto failexit; goto failexit;
} }
@ -554,8 +571,7 @@ nxtscan: /* on to the next line */
if (*sp++ == '%') { if (*sp++ == '%') {
/* advance to the end */ /* advance to the end */
ep = --sp; ep = --sp;
while (*ep++) while (*ep++);
;
/* null terminate the string one out */ /* null terminate the string one out */
*(ep + 1) = 0; *(ep + 1) = 0;
/* copy backwards */ /* copy backwards */
@ -615,7 +631,8 @@ nxtscan: /* on to the next line */
/* allocate the space for the line */ /* allocate the space for the line */
linlen = strlen(eline); linlen = strlen(eline);
if ((mp = lalloc(linlen)) == NULL) { if ((mp = lalloc(linlen)) == NULL) {
mlwrite("Out of memory while storing macro"); mlwrite
("Out of memory while storing macro");
return (FALSE); return (FALSE);
} }
@ -681,7 +698,8 @@ nxtscan: /* on to the next line */
} }
if (whtemp == NULL) { if (whtemp == NULL) {
mlwrite("%%Internal While loop error"); mlwrite
("%%Internal While loop error");
freewhile(whlist); freewhile(whlist);
return (FALSE); return (FALSE);
} }
@ -707,12 +725,15 @@ nxtscan: /* on to the next line */
if (execlevel == 0) { if (execlevel == 0) {
/* grab label to jump to */ /* grab label to jump to */
eline = token(eline, golabel, NPAT); eline =
token(eline, golabel, NPAT);
linlen = strlen(golabel); linlen = strlen(golabel);
glp = hlp->l_fp; glp = hlp->l_fp;
while (glp != hlp) { while (glp != hlp) {
if (*glp->l_text == '*' && if (*glp->l_text == '*' &&
(strncmp(&glp->l_text[1], golabel, (strncmp
(&glp->l_text[1],
golabel,
linlen) == 0)) { linlen) == 0)) {
lp = glp; lp = glp;
goto onward; goto onward;
@ -738,14 +759,16 @@ nxtscan: /* on to the next line */
/* find the right while loop */ /* find the right while loop */
whtemp = whlist; whtemp = whlist;
while (whtemp) { while (whtemp) {
if (whtemp->w_type == BTWHILE && if (whtemp->w_type ==
whtemp->w_end == lp) BTWHILE
&& whtemp->w_end == lp)
break; break;
whtemp = whtemp->w_next; whtemp = whtemp->w_next;
} }
if (whtemp == NULL) { if (whtemp == NULL) {
mlwrite("%%Internal While loop error"); mlwrite
("%%Internal While loop error");
freewhile(whlist); freewhile(whlist);
return (FALSE); return (FALSE);
} }
@ -799,8 +822,8 @@ eexec: /* exit the current function */
return (TRUE); return (TRUE);
} }
freewhile(wp) /* free a list of while block pointers */ freewhile(wp)
/* free a list of while block pointers */
WHBLOCK *wp; /* head of structure to free */ WHBLOCK *wp; /* head of structure to free */
{ {
@ -811,8 +834,8 @@ WHBLOCK *wp; /* head of structure to free */
free(wp); free(wp);
} }
execfile(f, n) /* execute a series of commands in a file */ execfile(f, n)
/* execute a series of commands in a file */
int f, n; /* default flag and numeric arg to pass on to file */ int f, n; /* default flag and numeric arg to pass on to file */
{ {
@ -820,7 +843,8 @@ int f, n; /* default flag and numeric arg to pass on to file */
char fname[NSTRING]; /* name of file to execute */ char fname[NSTRING]; /* name of file to execute */
char *fspec; /* full file spec */ char *fspec; /* full file spec */
if ((status = mlreply("File to execute: ", fname, NSTRING -1)) != TRUE) if ((status =
mlreply("File to execute: ", fname, NSTRING - 1)) != TRUE)
return (status); return (status);
#if 1 #if 1
@ -908,241 +932,201 @@ int bufnum; /* number of buffer to execute */
} }
cbuf1(f, n) cbuf1(f, n)
{ {
return cbuf(f, n, 1); return cbuf(f, n, 1);
} }
cbuf2(f, n) cbuf2(f, n)
{ {
return cbuf(f, n, 2); return cbuf(f, n, 2);
} }
cbuf3(f, n) cbuf3(f, n)
{ {
return cbuf(f, n, 3); return cbuf(f, n, 3);
} }
cbuf4(f, n) cbuf4(f, n)
{ {
return cbuf(f, n, 4); return cbuf(f, n, 4);
} }
cbuf5(f, n) cbuf5(f, n)
{ {
return cbuf(f, n, 5); return cbuf(f, n, 5);
} }
cbuf6(f, n) cbuf6(f, n)
{ {
return cbuf(f, n, 6); return cbuf(f, n, 6);
} }
cbuf7(f, n) cbuf7(f, n)
{ {
return cbuf(f, n, 7); return cbuf(f, n, 7);
} }
cbuf8(f, n) cbuf8(f, n)
{ {
return cbuf(f, n, 8); return cbuf(f, n, 8);
} }
cbuf9(f, n) cbuf9(f, n)
{ {
return cbuf(f, n, 9); return cbuf(f, n, 9);
} }
cbuf10(f, n) cbuf10(f, n)
{ {
return cbuf(f, n, 10); return cbuf(f, n, 10);
} }
cbuf11(f, n) cbuf11(f, n)
{ {
return cbuf(f, n, 11); return cbuf(f, n, 11);
} }
cbuf12(f, n) cbuf12(f, n)
{ {
return cbuf(f, n, 12); return cbuf(f, n, 12);
} }
cbuf13(f, n) cbuf13(f, n)
{ {
return cbuf(f, n, 13); return cbuf(f, n, 13);
} }
cbuf14(f, n) cbuf14(f, n)
{ {
return cbuf(f, n, 14); return cbuf(f, n, 14);
} }
cbuf15(f, n) cbuf15(f, n)
{ {
return cbuf(f, n, 15); return cbuf(f, n, 15);
} }
cbuf16(f, n) cbuf16(f, n)
{ {
return cbuf(f, n, 16); return cbuf(f, n, 16);
} }
cbuf17(f, n) cbuf17(f, n)
{ {
return cbuf(f, n, 17); return cbuf(f, n, 17);
} }
cbuf18(f, n) cbuf18(f, n)
{ {
return cbuf(f, n, 18); return cbuf(f, n, 18);
} }
cbuf19(f, n) cbuf19(f, n)
{ {
return cbuf(f, n, 19); return cbuf(f, n, 19);
} }
cbuf20(f, n) cbuf20(f, n)
{ {
return cbuf(f, n, 20); return cbuf(f, n, 20);
} }
cbuf21(f, n) cbuf21(f, n)
{ {
return cbuf(f, n, 21); return cbuf(f, n, 21);
} }
cbuf22(f, n) cbuf22(f, n)
{ {
return cbuf(f, n, 22); return cbuf(f, n, 22);
} }
cbuf23(f, n) cbuf23(f, n)
{ {
return cbuf(f, n, 23); return cbuf(f, n, 23);
} }
cbuf24(f, n) cbuf24(f, n)
{ {
return cbuf(f, n, 24); return cbuf(f, n, 24);
} }
cbuf25(f, n) cbuf25(f, n)
{ {
return cbuf(f, n, 25); return cbuf(f, n, 25);
} }
cbuf26(f, n) cbuf26(f, n)
{ {
return cbuf(f, n, 26); return cbuf(f, n, 26);
} }
cbuf27(f, n) cbuf27(f, n)
{ {
return cbuf(f, n, 27); return cbuf(f, n, 27);
} }
cbuf28(f, n) cbuf28(f, n)
{ {
return cbuf(f, n, 28); return cbuf(f, n, 28);
} }
cbuf29(f, n) cbuf29(f, n)
{ {
return cbuf(f, n, 29); return cbuf(f, n, 29);
} }
cbuf30(f, n) cbuf30(f, n)
{ {
return cbuf(f, n, 30); return cbuf(f, n, 30);
} }
cbuf31(f, n) cbuf31(f, n)
{ {
return cbuf(f, n, 31); return cbuf(f, n, 31);
} }
cbuf32(f, n) cbuf32(f, n)
{ {
return cbuf(f, n, 32); return cbuf(f, n, 32);
} }
cbuf33(f, n) cbuf33(f, n)
{ {
return cbuf(f, n, 33); return cbuf(f, n, 33);
} }
cbuf34(f, n) cbuf34(f, n)
{ {
return cbuf(f, n, 34); return cbuf(f, n, 34);
} }
cbuf35(f, n) cbuf35(f, n)
{ {
return cbuf(f, n, 35); return cbuf(f, n, 35);
} }
cbuf36(f, n) cbuf36(f, n)
{ {
return cbuf(f, n, 36); return cbuf(f, n, 36);
} }
cbuf37(f, n) cbuf37(f, n)
{ {
return cbuf(f, n, 37); return cbuf(f, n, 37);
} }
cbuf38(f, n) cbuf38(f, n)
{ {
return cbuf(f, n, 38); return cbuf(f, n, 38);
} }
cbuf39(f, n) cbuf39(f, n)
{ {
return cbuf(f, n, 39); return cbuf(f, n, 39);
} }
cbuf40(f, n) cbuf40(f, n)
{ {
return cbuf(f, n, 40); return cbuf(f, n, 40);
} }

22
file.c
View File

@ -74,8 +74,8 @@ filefind(f, n)
return (getfile(fname, TRUE)); return (getfile(fname, TRUE));
} }
viewfile(f, n) /* visit a file in VIEW mode */ viewfile(f, n)
{ { /* visit a file in VIEW mode */
char fname[NFILEN]; /* file user wishes to find */ char fname[NFILEN]; /* file user wishes to find */
register int s; /* status return */ register int s; /* status return */
register WINDOW *wp; /* scan for windows that need updating */ register WINDOW *wp; /* scan for windows that need updating */
@ -99,9 +99,8 @@ viewfile(f, n) /* visit a file in VIEW mode */
} }
#if CRYPT #if CRYPT
resetkey() /* reset the encryption key if needed */ resetkey()
{ /* reset the encryption key if needed */
{
register int s; /* return status */ register int s; /* return status */
/* turn off the encryption flag */ /* turn off the encryption flag */
@ -148,7 +147,8 @@ int lockfl; /* check the file for locks? */
mklower(fname); /* msdos isn't case sensitive */ mklower(fname); /* msdos isn't case sensitive */
#endif #endif
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
if ((bp->b_flag&BFINVS)==0 && strcmp(bp->b_fname, fname)==0) { if ((bp->b_flag & BFINVS) == 0
&& strcmp(bp->b_fname, fname) == 0) {
swbuffer(bp); swbuffer(bp);
lp = curwp->w_dotp; lp = curwp->w_dotp;
i = curwp->w_ntrows / 2; i = curwp->w_ntrows / 2;
@ -336,14 +336,16 @@ char fname[];
#if VMS #if VMS
#if PKCODE #if PKCODE
while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!=']' && cp1[-1]!='>') while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']'
&& cp1[-1] != '>')
#else #else
while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']') while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']')
#endif #endif
--cp1; --cp1;
#endif #endif
#if MSDOS #if MSDOS
while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!='\\'&&cp1[-1]!='/') while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != '\\'
&& cp1[-1] != '/')
--cp1; --cp1;
#endif #endif
#if V7 | USG | BSD #if V7 | USG | BSD
@ -356,8 +358,8 @@ char fname[];
*cp2 = 0; *cp2 = 0;
} }
unqname(name) /* make sure a buffer name is unique */ unqname(name)
/* make sure a buffer name is unique */
char *name; /* name to check on */ char *name; /* name to check on */
{ {

View File

@ -121,7 +121,6 @@ char buf[];
* errors too. Return status. * errors too. Return status.
*/ */
ffgetline() ffgetline()
{ {
register int c; /* current character read */ register int c; /* current character read */
register int i; /* current index into fline */ register int i; /* current index into fline */
@ -148,8 +147,7 @@ ffgetline()
if (fgets(fline, NSTRING, ffp) == (char *) NULL) { /* EOF ? */ if (fgets(fline, NSTRING, ffp) == (char *) NULL) { /* EOF ? */
i = 0; i = 0;
c = EOF; c = EOF;
} } else {
else {
i = strlen(fline); i = strlen(fline);
c = 0; c = 0;
if (i > 0) { if (i > 0) {
@ -157,8 +155,7 @@ ffgetline()
i--; i--;
} }
} }
} } else {
else {
i = 0; i = 0;
c = fgetc(ffp); c = fgetc(ffp);
} }
@ -173,7 +170,8 @@ ffgetline()
fline[i++] = c; fline[i++] = c;
/* if it's longer, get more room */ /* if it's longer, get more room */
if (i >= flen) { if (i >= flen) {
if ((tmpline = malloc(flen+NSTRING)) == NULL) if ((tmpline =
malloc(flen + NSTRING)) == NULL)
return (FIOMEM); return (FIOMEM);
strncpy(tmpline, fline, flen); strncpy(tmpline, fline, flen);
flen += NSTRING; flen += NSTRING;
@ -208,8 +206,8 @@ ffgetline()
return (FIOSUC); return (FIOSUC);
} }
int fexist(fname) /* does <fname> exist on disk? */ int fexist(fname)
/* does <fname> exist on disk? */
char *fname; /* file to check for existance */ char *fname; /* file to check for existance */
{ {

89
ibmpc.c
View File

@ -130,16 +130,16 @@ TERM term = {
}; };
#if COLOR #if COLOR
ibmfcol(color) /* set the current output color */ ibmfcol(color)
/* set the current output color */
int color; /* color to set */ int color; /* color to set */
{ {
cfcolor = ctrans[color]; cfcolor = ctrans[color];
} }
ibmbcol(color) /* set the current background color */ ibmbcol(color)
/* set the current background color */
int color; /* color to set */ int color; /* color to set */
{ {
@ -156,9 +156,8 @@ ibmmove(row, col)
int86(0x10, &rg, &rg); int86(0x10, &rg, &rg);
} }
ibmeeol() /* erase to the end of the line */ ibmeeol()
{ /* erase to the end of the line */
{
unsigned int attr; /* attribute byte mask to place in RAM */ unsigned int attr; /* attribute byte mask to place in RAM */
unsigned int *lnptr; /* pointer to the destination line */ unsigned int *lnptr; /* pointer to the destination line */
int i; int i;
@ -187,12 +186,10 @@ ibmeeol() /* erase to the end of the line */
if (flickcode && (dtype == CDCGA)) { if (flickcode && (dtype == CDCGA)) {
/* wait for vertical retrace to be off */ /* wait for vertical retrace to be off */
while ((inp(0x3da) & 8)) while ((inp(0x3da) & 8));
;
/* and to be back on */ /* and to be back on */
while ((inp(0x3da) & 8) == 0) while ((inp(0x3da) & 8) == 0);
;
} }
/* and send the string out */ /* and send the string out */
@ -200,9 +197,9 @@ ibmeeol() /* erase to the end of the line */
} }
ibmputc(ch) /* put a character at the current position in the ibmputc(ch)
/* put a character at the current position in the
current colors */ current colors */
int ch; int ch;
{ {
@ -230,7 +227,8 @@ ibmeeop()
/* lower right corner of scroll */ /* lower right corner of scroll */
#if COLOR #if COLOR
if (dtype != CDMONO) if (dtype != CDMONO)
attr = ((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15); attr =
((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
else else
attr = 0; attr = 0;
#else #else
@ -240,16 +238,16 @@ ibmeeop()
int86(0x10, &rg, &rg); int86(0x10, &rg, &rg);
} }
ibmrev(state) /* change reverse video state */ ibmrev(state)
/* change reverse video state */
int state; /* TRUE = reverse, FALSE = normal */ int state; /* TRUE = reverse, FALSE = normal */
{ {
/* This never gets used under the IBM-PC driver */ /* This never gets used under the IBM-PC driver */
} }
ibmcres(res) /* change screen resolution */ ibmcres(res)
/* change screen resolution */
char *res; /* resolution to change to */ char *res; /* resolution to change to */
{ {
@ -272,19 +270,19 @@ ibmscroll_reg(from, to, howmany)
if (to < from) if (to < from)
for (i = 0; i < howmany; i++) for (i = 0; i < howmany; i++)
movmem(scptr[from+i], scptr[to+i], term.t_ncol*2); movmem(scptr[from + i], scptr[to + i],
else term.t_ncol * 2);
if (to > from) else if (to > from)
for (i = howmany - 1; i >= 0; i--) for (i = howmany - 1; i >= 0; i--)
movmem(scptr[from+i], scptr[to+i], term.t_ncol*2); movmem(scptr[from + i], scptr[to + i],
term.t_ncol * 2);
return; return;
} }
#endif #endif
spal() /* reset the pallette registers */ spal()
{ /* reset the pallette registers */
{
/* nothin here now..... */ /* nothin here now..... */
} }
@ -301,7 +299,6 @@ ibmopen()
} }
ibmclose() ibmclose()
{ {
#if COLOR #if COLOR
ibmfcol(7); ibmfcol(7);
@ -318,18 +315,16 @@ ibmclose()
ttclose(); ttclose();
} }
ibmkopen() /* open the keyboard */ ibmkopen()
{ /* open the keyboard */
{
} }
ibmkclose() /* close the keyboard */ ibmkclose()
{ /* close the keyboard */
{
} }
scinit(type) /* initialize the screen head pointers */ scinit(type)
/* initialize the screen head pointers */
int type; /* type of adapter to init for */ int type; /* type of adapter to init for */
{ {
@ -410,7 +405,6 @@ int type; /* type of adapter to init for */
*/ */
int getboard() int getboard()
{ {
int type; /* board type to return */ int type; /* board type to return */
@ -427,9 +421,8 @@ int getboard()
return (type); return (type);
} }
egaopen() /* init the computer to work with the EGA */ egaopen()
{ /* init the computer to work with the EGA */
{
/* put the beast into EGA 43 row mode */ /* put the beast into EGA 43 row mode */
rg.x.ax = 3; rg.x.ax = 3;
int86(16, &rg, &rg); int86(16, &rg, &rg);
@ -453,15 +446,14 @@ egaopen() /* init the computer to work with the EGA */
} }
egaclose() egaclose()
{ {
/* put the beast into 80 column mode */ /* put the beast into 80 column mode */
rg.x.ax = 3; rg.x.ax = 3;
int86(16, &rg, &rg); int86(16, &rg, &rg);
} }
scwrite(row, outstr, forg, bacg) /* write a line out*/ scwrite(row, outstr, forg, bacg)
/* write a line out */
int row; /* row of screen to place outstr on */ int row; /* row of screen to place outstr on */
char *outstr; /* string to write out (must be term.t_ncol long) */ char *outstr; /* string to write out (must be term.t_ncol long) */
int forg; /* forground color of string to write */ int forg; /* forground color of string to write */
@ -475,7 +467,9 @@ int bacg; /* background color */
/* build the attribute byte and setup the screen pointer */ /* build the attribute byte and setup the screen pointer */
#if COLOR #if COLOR
if (dtype != CDMONO) if (dtype != CDMONO)
attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8; attr =
(((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) <<
8;
else else
attr = (((bacg & 15) << 4) | (forg & 15)) << 8; attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
#else #else
@ -487,12 +481,10 @@ int bacg; /* background color */
if (flickcode && (dtype == CDCGA)) { if (flickcode && (dtype == CDCGA)) {
/* wait for vertical retrace to be off */ /* wait for vertical retrace to be off */
while ((inp(0x3da) & 8)) while ((inp(0x3da) & 8));
;
/* and to be back on */ /* and to be back on */
while ((inp(0x3da) & 8) == 0) while ((inp(0x3da) & 8) == 0);
;
} }
/* and send the string out */ /* and send the string out */
@ -500,8 +492,8 @@ int bacg; /* background color */
} }
#if FNLABEL #if FNLABEL
fnclabel(f, n) /* label a function key */ fnclabel(f, n)
/* label a function key */
int f, n; /* default flag, numeric argument [unused] */ int f, n; /* default flag, numeric argument [unused] */
{ {
@ -514,4 +506,3 @@ ibmhello()
{ {
} }
#endif #endif

104
input.c
View File

@ -115,7 +115,6 @@ int c;
*/ */
int (*getname()) () int (*getname()) ()
{ {
register int cpos; /* current column on screen output */ register int cpos; /* current column on screen output */
register int c; register int c;
@ -179,10 +178,13 @@ int (*getname())()
buf[cpos] = 0; /* terminate it for us */ buf[cpos] = 0; /* terminate it for us */
ffp = &names[0]; /* scan for matches */ ffp = &names[0]; /* scan for matches */
while (ffp->n_func != NULL) { while (ffp->n_func != NULL) {
if (strncmp(buf, ffp->n_name, strlen(buf)) == 0) { if (strncmp(buf, ffp->n_name, strlen(buf))
== 0) {
/* a possible match! More than one? */ /* a possible match! More than one? */
if ((ffp + 1)->n_func == NULL || if ((ffp + 1)->n_func == NULL ||
(strncmp(buf, (ffp+1)->n_name, strlen(buf)) != 0)) { (strncmp
(buf, (ffp + 1)->n_name,
strlen(buf)) != 0)) {
/* no...we match, print it */ /* no...we match, print it */
sp = ffp->n_name + cpos; sp = ffp->n_name + cpos;
while (*sp) while (*sp)
@ -195,8 +197,15 @@ int (*getname())()
/* first scan down until we no longer match the current input */ /* first scan down until we no longer match the current input */
lffp = (ffp + 1); lffp = (ffp + 1);
while ((lffp+1)->n_func != NULL) { while ((lffp +
if (strncmp(buf, (lffp+1)->n_name, strlen(buf)) != 0) 1)->n_func !=
NULL) {
if (strncmp
(buf,
(lffp +
1)->n_name,
strlen(buf))
!= 0)
break; break;
++lffp; ++lffp;
} }
@ -204,18 +213,27 @@ int (*getname())()
/* and now, attempt to partial complete the string, char at a time */ /* and now, attempt to partial complete the string, char at a time */
while (TRUE) { while (TRUE) {
/* add the next char in */ /* add the next char in */
buf[cpos] = ffp->n_name[cpos]; buf[cpos] =
ffp->
n_name[cpos];
/* scan through the candidates */ /* scan through the candidates */
cffp = ffp + 1; cffp = ffp + 1;
while (cffp <= lffp) { while (cffp <=
if (cffp->n_name[cpos] != buf[cpos]) lffp) {
if (cffp->
n_name
[cpos]
!=
buf
[cpos])
goto onward; goto onward;
++cffp; ++cffp;
} }
/* add the character */ /* add the character */
TTputc(buf[cpos++]); TTputc(buf
[cpos++]);
} }
/* << << << << << << << << << << << << << << << << << */ /* << << << << << << << << << << << << << << << << << */
} }
@ -244,7 +262,6 @@ onward:;
macro action */ macro action */
int tgetc() int tgetc()
{ {
int c; /* fetched character */ int c; /* fetched character */
@ -297,7 +314,6 @@ int tgetc()
*/ */
get1key() get1key()
{ {
int c; int c;
@ -322,7 +338,6 @@ get1key()
prefix keys prefix keys
*/ */
getcmd() getcmd()
{ {
int c; /* fetched keystroke */ int c; /* fetched keystroke */
#if VT220 #if VT220
@ -349,13 +364,17 @@ proc_metac:
if (d == '~') /* ESC [ n ~ P.K. */ if (d == '~') /* ESC [ n ~ P.K. */
return (SPEC | c | cmask); return (SPEC | c | cmask);
switch (c) { /* ESC [ n n ~ P.K. */ switch (c) { /* ESC [ n n ~ P.K. */
case '1': c = d + 32; case '1':
c = d + 32;
break; break;
case '2': c = d + 48; case '2':
c = d + 48;
break; break;
case '3': c = d + 64; case '3':
c = d + 64;
break; break;
default: c = '?'; default:
c = '?';
break; break;
} }
if (d != '~') /* eat tilde P.K. */ if (d != '~') /* eat tilde P.K. */
@ -363,8 +382,7 @@ proc_metac:
if (c == 'i') { /* DO key P.K. */ if (c == 'i') { /* DO key P.K. */
c = ctlxc; c = ctlxc;
goto proc_ctlxc; goto proc_ctlxc;
} } else if (c == 'c') /* ESC key P.K. */
else if (c == 'c') /* ESC key P.K. */
c = get1key(); c = get1key();
else else
return (SPEC | c | cmask); return (SPEC | c | cmask);
@ -383,8 +401,7 @@ proc_metac:
return (META | c); return (META | c);
} }
#if PKCODE #if PKCODE
else else if (c == metac) {
if (c == metac) {
c = get1key(); c = get1key();
#if VT220 #if VT220
if (c == (CONTROL | '[')) { if (c == (CONTROL | '[')) {
@ -430,7 +447,9 @@ proc_ctlxc:
*/ */
getstring(prompt, buf, nbuf, eolchar) getstring(prompt, buf, nbuf, eolchar)
char *prompt; char *buf; int eolchar; char *prompt;
char *buf;
int eolchar;
{ {
register int cpos; /* current character position in string */ register int cpos; /* current character position in string */
@ -536,7 +555,8 @@ char *prompt; char *buf; int eolchar;
TTflush(); TTflush();
#if COMPLC #if COMPLC
} else if ((c == 0x09 || c == ' ') && quotef == FALSE && ffile) { } else if ((c == 0x09 || c == ' ') && quotef == FALSE
&& ffile) {
/* TAB, complete file name */ /* TAB, complete file name */
char ffbuf[255]; char ffbuf[255];
#if MSDOS #if MSDOS
@ -564,13 +584,13 @@ char *prompt; char *buf; int eolchar;
#if MSDOS #if MSDOS
if (lsav < 0 && (buf[cpos] == '\\' || if (lsav < 0 && (buf[cpos] == '\\' ||
buf[cpos] == '/' || buf[cpos] == '/' ||
buf[cpos] == ':' && cpos == 1)) buf[cpos] == ':'
&& cpos == 1))
lsav = cpos; lsav = cpos;
#endif #endif
} }
TTflush(); TTflush();
if (nskip < 0) if (nskip < 0) {
{
buf[ocpos] = 0; buf[ocpos] = 0;
#if UNIX #if UNIX
if (tmpf != NULL) if (tmpf != NULL)
@ -597,33 +617,31 @@ char *prompt; char *buf; int eolchar;
#if UNIX #if UNIX
c = ' '; c = ' ';
for (n = nskip; n > 0; n--) for (n = nskip; n > 0; n--)
while ((c = getc(tmpf)) != EOF && c != ' '); while ((c = getc(tmpf)) != EOF
&& c != ' ');
#endif #endif
#if MSDOS #if MSDOS
if (nskip == 0) if (nskip == 0) {
{
strcpy(ffbuf, sffbuf); strcpy(ffbuf, sffbuf);
c = findfirst(ffbuf, &ffblk, FA_DIREC) ? '*' : ' '; c = findfirst(ffbuf, &ffblk,
} FA_DIREC) ? '*' : ' ';
else if (nskip > 0) } else if (nskip > 0)
c = findnext(&ffblk) ? 0 : ' '; c = findnext(&ffblk) ? 0 : ' ';
#endif #endif
nskip++; nskip++;
if (c != ' ') if (c != ' ') {
{
TTbeep(); TTbeep();
nskip = 0; nskip = 0;
} }
#if UNIX #if UNIX
while ((c = getc(tmpf)) != EOF && c != '\n' && c != ' ' && c != '*') while ((c = getc(tmpf)) != EOF && c != '\n'
&& c != ' ' && c != '*')
#endif #endif
#if MSDOS #if MSDOS
if (c == '*') if (c == '*')
fcp = sffbuf; fcp = sffbuf;
else else {
{
strncpy(buf, sffbuf, lsav + 1); strncpy(buf, sffbuf, lsav + 1);
cpos = lsav + 1; cpos = lsav + 1;
fcp = ffblk.ff_name; fcp = ffblk.ff_name;
@ -639,8 +657,7 @@ char *prompt; char *buf; int eolchar;
TTbeep(); TTbeep();
#endif #endif
for (n = 0; n < cpos; n++) for (n = 0; n < cpos; n++) {
{
c = buf[n]; c = buf[n];
if ((c < ' ') && (c != '\n')) { if ((c < ' ') && (c != '\n')) {
outstring("^"); outstring("^");
@ -691,8 +708,8 @@ char *prompt; char *buf; int eolchar;
} }
} }
outstring(s) /* output a string of characters */ outstring(s)
/* output a string of characters */
char *s; /* string to output */ char *s; /* string to output */
{ {
@ -701,8 +718,8 @@ char *s; /* string to output */
TTputc(*s++); TTputc(*s++);
} }
ostring(s) /* output a string of output characters */ ostring(s)
/* output a string of output characters */
char *s; /* string to output */ char *s; /* string to output */
{ {
@ -710,4 +727,3 @@ char *s; /* string to output */
while (*s) while (*s)
TTputc(*s++); TTputc(*s++);
} }

View File

@ -62,8 +62,7 @@ int risearch(f, n)
backchar(TRUE, 1); /* Back up a character */ backchar(TRUE, 1); /* Back up a character */
if (!(isearch(f, -n))) /* Call ISearch backwards */ if (!(isearch(f, -n))) { /* Call ISearch backwards *//* If error in search: */
{ /* If error in search: */
curwp->w_dotp = curline; /* Reset the line pointer */ curwp->w_dotp = curline; /* Reset the line pointer */
curwp->w_doto = curoff; /* and the offset to original value */ curwp->w_doto = curoff; /* and the offset to original value */
curwp->w_flag |= WFMOVE; /* Say we've moved */ curwp->w_flag |= WFMOVE; /* Say we've moved */
@ -72,7 +71,8 @@ int risearch(f, n)
#if PKCODE #if PKCODE
matchlen = strlen(pat); matchlen = strlen(pat);
#endif #endif
} else mlerase (); /* If happy, just erase the cmd line */ } else
mlerase(); /* If happy, just erase the cmd line */
#if PKCODE #if PKCODE
matchlen = strlen(pat); matchlen = strlen(pat);
#endif #endif
@ -92,8 +92,7 @@ int fisearch(f, n)
/* do the search */ /* do the search */
if (!(isearch(f, n))) /* Call ISearch forwards */ if (!(isearch(f, n))) { /* Call ISearch forwards *//* If error in search: */
{ /* If error in search: */
curwp->w_dotp = curline; /* Reset the line pointer */ curwp->w_dotp = curline; /* Reset the line pointer */
curwp->w_doto = curoff; /* and the offset to original value */ curwp->w_doto = curoff; /* and the offset to original value */
curwp->w_flag |= WFMOVE; /* Say we've moved */ curwp->w_flag |= WFMOVE; /* Say we've moved */
@ -102,7 +101,8 @@ int fisearch(f, n)
#if PKCODE #if PKCODE
matchlen = strlen(pat); matchlen = strlen(pat);
#endif #endif
} else mlerase (); /* If happy, just erase the cmd line */ } else
mlerase(); /* If happy, just erase the cmd line */
#if PKCODE #if PKCODE
matchlen = strlen(pat); matchlen = strlen(pat);
#endif #endif
@ -172,10 +172,7 @@ start_over:
*/ */
c = ectoc(expc = get_char()); /* Get the first character */ c = ectoc(expc = get_char()); /* Get the first character */
if ((c == IS_FORWARD) || if ((c == IS_FORWARD) || (c == IS_REVERSE) || (c == IS_VMSFORW)) { /* Reuse old search string? */
(c == IS_REVERSE) ||
(c == IS_VMSFORW)) /* Reuse old search string? */
{
for (cpos = 0; pat[cpos] != 0; cpos++) /* Yup, find the length */ for (cpos = 0; pat[cpos] != 0; cpos++) /* Yup, find the length */
col = echochar(pat[cpos], col); /* and re-echo the string */ col = echochar(pat[cpos], col); /* and re-echo the string */
if (c == IS_REVERSE) { /* forward search? */ if (c == IS_REVERSE) { /* forward search? */
@ -189,16 +186,14 @@ start_over:
/* Top of the per character loop */ /* Top of the per character loop */
for (;;) /* ISearch per character loop */ for (;;) { /* ISearch per character loop */
{
/* Check for special characters first: */ /* Check for special characters first: */
/* Most cases here change the search */ /* Most cases here change the search */
if (expc == metac) /* Want to quit searching? */ if (expc == metac) /* Want to quit searching? */
return (TRUE); /* Quit searching now */ return (TRUE); /* Quit searching now */
switch (c) /* dispatch on the input char */ switch (c) { /* dispatch on the input char */
{
case IS_ABORT: /* If abort search request */ case IS_ABORT: /* If abort search request */
return (FALSE); /* Quit searching again */ return (FALSE); /* Quit searching again */
@ -241,8 +236,7 @@ start_over:
/* Presumably a quasi-normal character comes here */ /* Presumably a quasi-normal character comes here */
default: /* All other chars */ default: /* All other chars */
if (c < ' ') /* Is it printable? */ if (c < ' ') { /* Is it printable? *//* Nope. */
{ /* Nope. */
reeat(c); /* Re-eat the char */ reeat(c); /* Re-eat the char */
return (TRUE); /* And return the last status */ return (TRUE); /* And return the last status */
} }
@ -251,8 +245,7 @@ start_over:
/* I guess we got something to search for, so search for it */ /* I guess we got something to search for, so search for it */
pat[cpos++] = c; /* put the char in the buffer */ pat[cpos++] = c; /* put the char in the buffer */
if (cpos >= NPAT) /* too many chars in string? */ if (cpos >= NPAT) { /* too many chars in string? *//* Yup. Complain about it */
{ /* Yup. Complain about it */
mlwrite("? Search string too long"); mlwrite("? Search string too long");
return (TRUE); /* Return an error */ return (TRUE); /* Return an error */
} }
@ -261,8 +254,7 @@ start_over:
if (!status) { /* If we lost last time */ if (!status) { /* If we lost last time */
TTputc(BELL); /* Feep again */ TTputc(BELL); /* Feep again */
TTflush(); /* see that the feep feeps */ TTflush(); /* see that the feep feeps */
} else /* Otherwise, we must have won*/ } else /* Otherwise, we must have won */ if (!(status = checknext(c, pat, n))) /* See if match */
if (!(status = checknext(c, pat, n))) /* See if match */
status = scanmore(pat, n); /* or find the next match */ status = scanmore(pat, n); /* or find the next match */
c = ectoc(expc = get_char()); /* Get the next char */ c = ectoc(expc = get_char()); /* Get the next char */
} /* for {;;} */ } /* for {;;} */
@ -295,10 +287,8 @@ int dir; /* Search direction */
curline = curwp->w_dotp; /* Get the current line structure */ curline = curwp->w_dotp; /* Get the current line structure */
curoff = curwp->w_doto; /* Get the offset within that line */ curoff = curwp->w_doto; /* Get the offset within that line */
if (dir > 0) /* If searching forward */ if (dir > 0) { /* If searching forward */
{ if (curoff == llength(curline)) { /* If at end of line */
if (curoff == llength(curline)) /* If at end of line */
{
curline = lforw(curline); /* Skip to the next line */ curline = lforw(curline); /* Skip to the next line */
if (curline == curbp->b_linep) if (curline == curbp->b_linep)
return (FALSE); /* Abort if at end of buffer */ return (FALSE); /* Abort if at end of buffer */
@ -306,8 +296,7 @@ int dir; /* Search direction */
buffchar = '\n'; /* And say the next char is NL */ buffchar = '\n'; /* And say the next char is NL */
} else } else
buffchar = lgetc(curline, curoff++); /* Get the next char */ buffchar = lgetc(curline, curoff++); /* Get the next char */
if (status = eq(buffchar, chr)) /* Is it what we're looking for? */ if (status = eq(buffchar, chr)) { /* Is it what we're looking for? */
{
curwp->w_dotp = curline; /* Yes, set the buffer's point */ curwp->w_dotp = curline; /* Yes, set the buffer's point */
curwp->w_doto = curoff; /* to the matched character */ curwp->w_doto = curoff; /* to the matched character */
curwp->w_flag |= WFMOVE; /* Say that we've moved */ curwp->w_flag |= WFMOVE; /* Say that we've moved */
@ -333,16 +322,13 @@ int dir; /* direction to search */
{ {
int sts; /* search status */ int sts; /* search status */
if (dir < 0) /* reverse search? */ if (dir < 0) { /* reverse search? */
{
rvstrcpy(tap, patrn); /* Put reversed string in tap */ rvstrcpy(tap, patrn); /* Put reversed string in tap */
sts = scanner(tap, REVERSE, PTBEG); sts = scanner(tap, REVERSE, PTBEG);
} } else
else
sts = scanner(patrn, FORWARD, PTEND); /* Nope. Go forward */ sts = scanner(patrn, FORWARD, PTEND); /* Nope. Go forward */
if (!sts) if (!sts) {
{
TTputc(BELL); /* Feep if search fails */ TTputc(BELL); /* Feep if search fails */
TTflush(); /* see that the feep feeps */ TTflush(); /* see that the feep feeps */
} }
@ -375,10 +361,8 @@ char *patrn; /* String to match to buffer */
/* top of per character compare loop: */ /* top of per character compare loop: */
for (i = 0; i < strlen(patrn); i++) /* Loop for all characters in patrn */ for (i = 0; i < strlen(patrn); i++) { /* Loop for all characters in patrn */
{ if (curoff == llength(curline)) { /* If at end of line */
if (curoff == llength(curline)) /* If at end of line */
{
curline = lforw(curline); /* Skip to the next line */ curline = lforw(curline); /* Skip to the next line */
curoff = 0; /* Start at the beginning of the line */ curoff = 0; /* Start at the beginning of the line */
if (curline == curbp->b_linep) if (curline == curbp->b_linep)
@ -418,10 +402,8 @@ int c; /* character to be echoed */
int col; /* column to be echoed in */ int col; /* column to be echoed in */
{ {
movecursor(term.t_nrow, col); /* Position the cursor */ movecursor(term.t_nrow, col); /* Position the cursor */
if ((c < ' ') || (c == 0x7F)) /* Control character? */ if ((c < ' ') || (c == 0x7F)) { /* Control character? */
{ switch (c) { /* Yes, dispatch special cases */
switch (c) /* Yes, dispatch special cases*/
{
case '\n': /* Newline */ case '\n': /* Newline */
TTputc('<'); TTputc('<');
TTputc('N'); TTputc('N');
@ -477,8 +459,7 @@ int get_char ()
cmd_reexecute = -1; /* Say we're in real mode again */ cmd_reexecute = -1; /* Say we're in real mode again */
update(FALSE); /* Pretty up the screen */ update(FALSE); /* Pretty up the screen */
if (cmd_offset >= CMDBUFLEN-1) /* If we're getting too big ... */ if (cmd_offset >= CMDBUFLEN - 1) { /* If we're getting too big ... */
{
mlwrite("? command too long"); /* Complain loudly and bitterly */ mlwrite("? command too long"); /* Complain loudly and bitterly */
return (metac); /* And force a quit */ return (metac); /* And force a quit */
} }

14
line.c
View File

@ -118,8 +118,8 @@ register int flag;
} }
} }
insspace(f, n) /* insert spaces forward into text */ insspace(f, n)
/* insert spaces forward into text */
int f, n; /* default flag and numeric argument */ int f, n; /* default flag and numeric argument */
{ {
@ -139,7 +139,8 @@ char *instr;
if (instr != NULL) if (instr != NULL)
while ((tmpc = *instr) && status == TRUE) { while ((tmpc = *instr) && status == TRUE) {
status = (tmpc == '\n'? lnewline(): linsert(1, tmpc)); status =
(tmpc == '\n' ? lnewline() : linsert(1, tmpc));
/* Insertion error? */ /* Insertion error? */
if (status != TRUE) { if (status != TRUE) {
@ -270,11 +271,13 @@ char *ostr;
if (ostr != NULL) if (ostr != NULL)
while ((tmpc = *ostr) && status == TRUE) { while ((tmpc = *ostr) && status == TRUE) {
status = (tmpc == '\n'? lnewline(): lowrite(tmpc)); status =
(tmpc == '\n' ? lnewline() : lowrite(tmpc));
/* Insertion error? */ /* Insertion error? */
if (status != TRUE) { if (status != TRUE) {
mlwrite("%%Out of memory while overwriting"); mlwrite
("%%Out of memory while overwriting");
break; break;
} }
ostr++; ostr++;
@ -422,7 +425,6 @@ int kflag; /* put killed text in kill buffer flag */
*/ */
char *getctext() char *getctext()
{ {
register LINE *lp; /* line to copy */ register LINE *lp; /* line to copy */
register int size; /* length of line to return */ register int size; /* length of line to return */

9
lock.c
View File

@ -66,7 +66,6 @@ char *fname; /* file to check for a lock */
/* lockrel: release all the file locks so others may edit */ /* lockrel: release all the file locks so others may edit */
lockrel() lockrel()
{ {
register int i; /* loop index */ register int i; /* loop index */
register int status; /* status of locks */ register int status; /* status of locks */
@ -143,8 +142,8 @@ char *fname; /* file to unlock */
return (FALSE); return (FALSE);
} }
lckerror(errstr) /* report a lock error */ lckerror(errstr)
/* report a lock error */
char *errstr; /* lock error string to print out */ char *errstr; /* lock error string to print out */
{ {
@ -160,7 +159,7 @@ char *errstr; /* lock error string to print out */
} }
#endif #endif
#else #else
lckhello() /* dummy function */ lckhello()
{ { /* dummy function */
} }
#endif #endif

57
main.c
View File

@ -284,8 +284,7 @@ char *argv[]; /* argument strings */
if (gotoflag && searchflag) { if (gotoflag && searchflag) {
update(FALSE); update(FALSE);
mlwrite("(Can not search and goto at the same time!)"); mlwrite("(Can not search and goto at the same time!)");
} } else if (gotoflag) {
else if (gotoflag) {
if (gotoline(TRUE, gline) == FALSE) { if (gotoline(TRUE, gline) == FALSE) {
update(FALSE); update(FALSE);
mlwrite("(Bogus goto argument)"); mlwrite("(Bogus goto argument)");
@ -312,23 +311,18 @@ loop:
lastflag = saveflag; lastflag = saveflag;
#if TYPEAH && PKCODE #if TYPEAH && PKCODE
if (typahead()) if (typahead()) {
{
newc = getcmd(); newc = getcmd();
update(FALSE); update(FALSE);
do do {
{
if (c == newc && (execfunc = getbind(c)) != NULL if (c == newc && (execfunc = getbind(c)) != NULL
&& execfunc != newline && execfunc != newline && execfunc != tab)
&& execfunc != tab)
newc = getcmd(); newc = getcmd();
else else
break; break;
} while (typahead()); } while (typahead());
c = newc; c = newc;
} } else {
else
{
update(FALSE); update(FALSE);
c = getcmd(); c = getcmd();
} }
@ -385,7 +379,8 @@ loop:
n = 4; /* with argument of 4 */ n = 4; /* with argument of 4 */
mflag = 0; /* that can be discarded. */ mflag = 0; /* that can be discarded. */
mlwrite("Arg: 4"); mlwrite("Arg: 4");
while ((c=getcmd()) >='0' && c<='9' || c==reptc || c=='-'){ while ((c = getcmd()) >= '0' && c <= '9' || c == reptc
|| c == '-') {
if (c == reptc) if (c == reptc)
if ((n > 0) == ((n * 4) > 0)) if ((n > 0) == ((n * 4) > 0))
n = n * 4; n = n * 4;
@ -412,7 +407,8 @@ loop:
} }
n = 10 * n + c - '0'; n = 10 * n + c - '0';
} }
mlwrite("Arg: %d", (mflag >=0) ? n : (n ? -n : -1)); mlwrite("Arg: %d",
(mflag >= 0) ? n : (n ? -n : -1));
} }
/* /*
* Make arguments preceded by a minus sign negative and change * Make arguments preceded by a minus sign negative and change
@ -614,7 +610,8 @@ quit(f, n)
if (f != FALSE /* Argument forces it. */ if (f != FALSE /* Argument forces it. */
|| anycb() == FALSE /* All buffers clean. */ || anycb() == FALSE /* All buffers clean. */
/* User says it's OK. */ /* User says it's OK. */
|| (s=mlyesno("Modified buffers exist. Leave anyway")) == TRUE) { || (s =
mlyesno("Modified buffers exist. Leave anyway")) == TRUE) {
#if (FILOCK && BSD) || SVR4 #if (FILOCK && BSD) || SVR4
if (lockrel() != TRUE) { if (lockrel() != TRUE) {
TTputc('\n'); TTputc('\n');
@ -705,7 +702,6 @@ ctrlg(f, n)
VIEW (read-only) mode */ VIEW (read-only) mode */
rdonly() rdonly()
{ {
TTbeep(); TTbeep();
mlwrite("(Key illegal in VIEW mode)"); mlwrite("(Key illegal in VIEW mode)");
@ -713,28 +709,26 @@ rdonly()
} }
resterr() resterr()
{ {
TTbeep(); TTbeep();
mlwrite("(That command is RESTRICTED)"); mlwrite("(That command is RESTRICTED)");
return (FALSE); return (FALSE);
} }
nullproc() /* user function that does NOTHING */ nullproc()
{ /* user function that does NOTHING */
{
} }
meta() /* dummy function for binding to meta prefix */ meta()
{ { /* dummy function for binding to meta prefix */
} }
cex() /* dummy function for binding to control-x prefix */ cex()
{ { /* dummy function for binding to control-x prefix */
} }
unarg() /* dummy function for binding to universal-argument */ unarg()
{ { /* dummy function for binding to universal-argument */
} }
/***** Compiler specific Library functions ****/ /***** Compiler specific Library functions ****/
@ -781,8 +775,8 @@ int maxlen; /* maximum length */
#undef malloc #undef malloc
#undef free #undef free
char *allocate(nbytes) /* allocate nbytes and track */ char *allocate(nbytes)
/* allocate nbytes and track */
unsigned nbytes; /* # of bytes to allocate */ unsigned nbytes; /* # of bytes to allocate */
{ {
@ -800,8 +794,8 @@ unsigned nbytes; /* # of bytes to allocate */
return (mp); return (mp);
} }
release(mp) /* release malloced memory and track */ release(mp)
/* release malloced memory and track */
char *mp; /* chunk of RAM to release */ char *mp; /* chunk of RAM to release */
{ {
@ -819,9 +813,8 @@ char *mp; /* chunk of RAM to release */
} }
#if RAMSHOW #if RAMSHOW
dspram() /* display the amount of RAM currently malloced */ dspram()
{ /* display the amount of RAM currently malloced */
{
char mbuf[20]; char mbuf[20];
char *sp; char *sp;

View File

@ -68,8 +68,7 @@ char *dolock(fname)
mask = umask(0); mask = umask(0);
fd = open(lname, O_RDWR | O_CREAT, 0666); fd = open(lname, O_RDWR | O_CREAT, 0666);
umask(mask); umask(mask);
if (fd < 0) if (fd < 0) {
{
if (errno == EACCES) if (errno == EACCES)
return NULL; return NULL;
#ifdef EROFS #ifdef EROFS
@ -78,8 +77,7 @@ char *dolock(fname)
#endif #endif
return "LOCK ERROR: cannot access lock file"; return "LOCK ERROR: cannot access lock file";
} }
if ((n = read(fd, locker, MAXNAME)) < 1) if ((n = read(fd, locker, MAXNAME)) < 1) {
{
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
/* strcpy(locker, getlogin()); */ /* strcpy(locker, getlogin()); */
cuserid(locker); cuserid(locker);
@ -110,8 +108,7 @@ char *undolock(fname)
static char lname[MAXLOCK]; static char lname[MAXLOCK];
strcat(strcpy(lname, fname), ".lock~"); strcat(strcpy(lname, fname), ".lock~");
if (unlink(lname) != 0) if (unlink(lname) != 0) {
{
if (errno == EACCES || errno == ENOENT) if (errno == EACCES || errno == ENOENT)
return NULL; return NULL;
#ifdef EROFS #ifdef EROFS

View File

@ -53,12 +53,13 @@ ttopen()
| INPCK | INLCR | IGNCR | ICRNL); | INPCK | INLCR | IGNCR | ICRNL);
/* raw CR/NR etc output handling */ /* raw CR/NR etc output handling */
ntermios.c_oflag &= ~(OPOST | ONLCR | OLCUC | OCRNL | ONOCR | ONLRET); ntermios.c_oflag &=
~(OPOST | ONLCR | OLCUC | OCRNL | ONOCR | ONLRET);
/* No signal handling, no echo etc */ /* No signal handling, no echo etc */
ntermios.c_lflag &= ~(ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK ntermios.c_lflag &= ~(ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK
| ECHONL | NOFLSH | TOSTOP | ECHOCTL | ECHOPRT | ECHONL | NOFLSH | TOSTOP | ECHOCTL |
| ECHOKE | FLUSHO | PENDIN | IEXTEN); ECHOPRT | ECHOKE | FLUSHO | PENDIN | IEXTEN);
/* one character, no timeout */ /* one character, no timeout */
ntermios.c_cc[VMIN] = 1; ntermios.c_cc[VMIN] = 1;

157
random.c
View File

@ -116,9 +116,8 @@ showcpos(f, n)
return (TRUE); return (TRUE);
} }
getcline() /* get the current line number */ getcline()
{ /* get the current line number */
{
register LINE *lp; /* current line */ register LINE *lp; /* current line */
register int numlines; /* # of lines before point */ register int numlines; /* # of lines before point */
@ -276,8 +275,8 @@ tab(f, n)
} }
#if AEDIT #if AEDIT
detab(f, n) /* change tabs to spaces */ detab(f, n)
/* change tabs to spaces */
int f, n; /* default flag and numeric repeat count */ int f, n; /* default flag and numeric repeat count */
{ {
@ -299,7 +298,9 @@ int f,n; /* default flag and numeric repeat count */
/* if we have a tab */ /* if we have a tab */
if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') { if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') {
ldelete(1L, FALSE); ldelete(1L, FALSE);
insspace(TRUE, (tabmask+1) - (curwp->w_doto & tabmask)); insspace(TRUE,
(tabmask + 1) -
(curwp->w_doto & tabmask));
} }
forwchar(FALSE, 1); forwchar(FALSE, 1);
} }
@ -314,8 +315,8 @@ int f,n; /* default flag and numeric repeat count */
return (TRUE); return (TRUE);
} }
entab(f, n) /* change spaces to tabs where posible */ entab(f, n)
/* change spaces to tabs where posible */
int f, n; /* default flag and numeric repeat count */ int f, n; /* default flag and numeric repeat count */
{ {
@ -347,7 +348,8 @@ int f,n; /* default flag and numeric repeat count */
/* there is a bug here dealing with mixed space/tabed /* there is a bug here dealing with mixed space/tabed
lines.......it will get fixed */ lines.......it will get fixed */
backchar(TRUE, ccol - fspace); backchar(TRUE, ccol - fspace);
ldelete((long)(ccol - fspace), FALSE); ldelete((long) (ccol - fspace),
FALSE);
linsert(1, '\t'); linsert(1, '\t');
fspace = -1; fspace = -1;
} }
@ -384,8 +386,8 @@ int f,n; /* default flag and numeric repeat count */
return (TRUE); return (TRUE);
} }
trim(f, n) /* trim trailing whitespace from the point to eol */ trim(f, n)
/* trim trailing whitespace from the point to eol */
int f, n; /* default flag and numeric repeat count */ int f, n; /* default flag and numeric repeat count */
{ {
@ -490,9 +492,8 @@ newline(f, n)
return (TRUE); return (TRUE);
} }
cinsert() /* insert a newline and indentation for C */ cinsert()
{ /* insert a newline and indentation for C */
{
register char *cptr; /* string pointer into text to copy */ register char *cptr; /* string pointer into text to copy */
register int tptr; /* index to scan into line */ register int tptr; /* index to scan into line */
register int bracef; /* was there a brace at the end of line? */ register int bracef; /* was there a brace at the end of line? */
@ -533,8 +534,8 @@ cinsert() /* insert a newline and indentation for C */
} }
#if NBRACE #if NBRACE
insbrace(n, c) /* insert a brace into the text here...we are in CMODE */ insbrace(n, c)
/* insert a brace into the text here...we are in CMODE */
int n; /* repeat count */ int n; /* repeat count */
int c; /* brace to insert (always } for now) */ int c; /* brace to insert (always } for now) */
@ -558,16 +559,24 @@ int c; /* brace to insert (always } for now) */
/* chercher le caractere oppose correspondant */ /* chercher le caractere oppose correspondant */
switch (c) { switch (c) {
case '}': oc = '{'; break; case '}':
case ']': oc = '['; break; oc = '{';
case ')': oc = '('; break; break;
default: return(FALSE); case ']':
oc = '[';
break;
case ')':
oc = '(';
break;
default:
return (FALSE);
} }
oldlp = curwp->w_dotp; oldlp = curwp->w_dotp;
oldoff = curwp->w_doto; oldoff = curwp->w_doto;
count = 1; backchar(FALSE, 1); count = 1;
backchar(FALSE, 1);
while (count > 0) { while (count > 0) {
if (curwp->w_doto == llength(curwp->w_dotp)) if (curwp->w_doto == llength(curwp->w_dotp))
@ -575,8 +584,10 @@ int c; /* brace to insert (always } for now) */
else else
ch = lgetc(curwp->w_dotp, curwp->w_doto); ch = lgetc(curwp->w_dotp, curwp->w_doto);
if (ch == c) ++count; if (ch == c)
if (ch == oc) --count; ++count;
if (ch == oc)
--count;
backchar(FALSE, 1); backchar(FALSE, 1);
if (boundry(curwp->w_dotp, curwp->w_doto, REVERSE)) if (boundry(curwp->w_dotp, curwp->w_doto, REVERSE))
@ -591,7 +602,8 @@ int c; /* brace to insert (always } for now) */
curwp->w_doto = 0; /* debut de ligne */ curwp->w_doto = 0; /* debut de ligne */
/* aller au debut de la ligne apres la tabulation */ /* aller au debut de la ligne apres la tabulation */
while ((ch = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ' || ch == '\t') while ((ch = lgetc(curwp->w_dotp, curwp->w_doto)) == ' '
|| ch == '\t')
forwchar(FALSE, 1); forwchar(FALSE, 1);
/* delete back first */ /* delete back first */
@ -614,8 +626,8 @@ int c; /* brace to insert (always } for now) */
return (linsert(n, c)); return (linsert(n, c));
} }
#else #else
insbrace(n, c) /* insert a brace into the text here...we are in CMODE */ insbrace(n, c)
/* insert a brace into the text here...we are in CMODE */
int n; /* repeat count */ int n; /* repeat count */
int c; /* brace to insert (always { for now) */ int c; /* brace to insert (always { for now) */
@ -647,9 +659,8 @@ int c; /* brace to insert (always { for now) */
} }
#endif #endif
inspound() /* insert a # into the text here...we are in CMODE */ inspound()
{ /* insert a # into the text here...we are in CMODE */
{
register int ch; /* last character before input */ register int ch; /* last character before input */
register int i; register int i;
@ -823,8 +834,8 @@ killtext(f, n)
return (ldelete(chunk, TRUE)); return (ldelete(chunk, TRUE));
} }
setmode(f, n) /* prompt and set an editor mode */ setmode(f, n)
/* prompt and set an editor mode */
int f, n; /* default and argument */ int f, n; /* default and argument */
{ {
@ -835,8 +846,8 @@ int f, n; /* default and argument */
#endif #endif
} }
delmode(f, n) /* prompt and delete an editor mode */ delmode(f, n)
/* prompt and delete an editor mode */
int f, n; /* default and argument */ int f, n; /* default and argument */
{ {
@ -847,8 +858,8 @@ int f, n; /* default and argument */
#endif #endif
} }
setgmode(f, n) /* prompt and set a global editor mode */ setgmode(f, n)
/* prompt and set a global editor mode */
int f, n; /* default and argument */ int f, n; /* default and argument */
{ {
@ -859,8 +870,8 @@ int f, n; /* default and argument */
#endif #endif
} }
delgmode(f, n) /* prompt and delete a global editor mode */ delgmode(f, n)
/* prompt and delete a global editor mode */
int f, n; /* default and argument */ int f, n; /* default and argument */
{ {
@ -871,8 +882,8 @@ int f, n; /* default and argument */
#endif #endif
} }
adjustmode(kind, global) /* change the editor mode status */ adjustmode(kind, global)
/* change the editor mode status */
int kind; /* true = set, false = delete */ int kind; /* true = set, false = delete */
int global; /* true = global flag, false = current buffer flag */ int global; /* true = global flag, false = current buffer flag */
{ {
@ -923,17 +934,14 @@ int global; /* true = global flag, false = current buffer flag */
if (strcmp(cbuf, cname[i]) == 0) { if (strcmp(cbuf, cname[i]) == 0) {
/* finding the match, we set the color */ /* finding the match, we set the color */
#if COLOR #if COLOR
if (uflag) if (uflag) {
{
if (global) if (global)
gfcolor = i; gfcolor = i;
#if PKCODE == 0 #if PKCODE == 0
else else
#endif #endif
curwp->w_fcolor = i; curwp->w_fcolor = i;
} } else {
else
{
if (global) if (global)
gbcolor = i; gbcolor = i;
#if PKCODE == 0 #if PKCODE == 0
@ -959,8 +967,7 @@ int global; /* true = global flag, false = current buffer flag */
gmode |= (1 << i); gmode |= (1 << i);
else else
curbp->b_mode |= (1 << i); curbp->b_mode |= (1 << i);
else else if (global)
if (global)
gmode &= ~(1 << i); gmode &= ~(1 << i);
else else
curbp->b_mode &= ~(1 << i); curbp->b_mode &= ~(1 << i);
@ -1002,7 +1009,8 @@ int f, n; /* arguments ignored */
char buf[NPAT]; /* buffer to recieve message into */ char buf[NPAT]; /* buffer to recieve message into */
char nbuf[NPAT * 2]; /* buffer to expand string into */ char nbuf[NPAT * 2]; /* buffer to expand string into */
if ((status = mlreply("Message to write: ", buf, NPAT - 1)) != TRUE) if ((status =
mlreply("Message to write: ", buf, NPAT - 1)) != TRUE)
return (status); return (status);
/* expand all '%' to "%%" so mlwrite won't expect arguments */ /* expand all '%' to "%%" so mlwrite won't expect arguments */
@ -1048,13 +1056,33 @@ int f, n; /* not used */
/* setup proper matching fence */ /* setup proper matching fence */
switch (ch) { switch (ch) {
case '(': ofence = ')'; sdir = FORWARD; break; case '(':
case '{': ofence = '}'; sdir = FORWARD; break; ofence = ')';
case '[': ofence = ']'; sdir = FORWARD; break; sdir = FORWARD;
case ')': ofence = '('; sdir = REVERSE; break; break;
case '}': ofence = '{'; sdir = REVERSE; break; case '{':
case ']': ofence = '['; sdir = REVERSE; break; ofence = '}';
default: TTbeep(); return(FALSE); sdir = FORWARD;
break;
case '[':
ofence = ']';
sdir = FORWARD;
break;
case ')':
ofence = '(';
sdir = REVERSE;
break;
case '}':
ofence = '{';
sdir = REVERSE;
break;
case ']':
ofence = '[';
sdir = REVERSE;
break;
default:
TTbeep();
return (FALSE);
} }
/* set up for scan */ /* set up for scan */
@ -1167,9 +1195,9 @@ char ch; /* fence type to match against */
return (TRUE); return (TRUE);
} }
istring(f, n) /* ask for and insert a string into the current istring(f, n)
/* ask for and insert a string into the current
buffer at the current point */ buffer at the current point */
int f, n; /* ignored arguments */ int f, n; /* ignored arguments */
{ {
@ -1177,7 +1205,8 @@ int f, n; /* ignored arguments */
char tstring[NPAT + 1]; /* string to add */ char tstring[NPAT + 1]; /* string to add */
/* ask for string to insert */ /* ask for string to insert */
status = mlreplyt("String to insert<META>: ", tstring, NPAT, metac); status =
mlreplyt("String to insert<META>: ", tstring, NPAT, metac);
if (status != TRUE) if (status != TRUE)
return (status); return (status);
@ -1188,14 +1217,13 @@ int f, n; /* ignored arguments */
n = -n; n = -n;
/* insert it */ /* insert it */
while (n-- && (status = linstr(tstring))) while (n-- && (status = linstr(tstring)));
;
return (status); return (status);
} }
ovstring(f, n) /* ask for and overwite a string into the current ovstring(f, n)
/* ask for and overwite a string into the current
buffer at the current point */ buffer at the current point */
int f, n; /* ignored arguments */ int f, n; /* ignored arguments */
{ {
@ -1203,7 +1231,8 @@ int f, n; /* ignored arguments */
char tstring[NPAT + 1]; /* string to add */ char tstring[NPAT + 1]; /* string to add */
/* ask for string to insert */ /* ask for string to insert */
status = mlreplyt("String to overwrite<META>: ", tstring, NPAT, metac); status =
mlreplyt("String to overwrite<META>: ", tstring, NPAT, metac);
if (status != TRUE) if (status != TRUE)
return (status); return (status);
@ -1214,8 +1243,6 @@ int f, n; /* ignored arguments */
n = -n; n = -n;
/* insert it */ /* insert it */
while (n-- && (status = lover(tstring))) while (n-- && (status = lover(tstring)));
;
return (status); return (status);
} }

View File

@ -173,10 +173,12 @@ register REGION *rp;
rp->r_linep = curwp->w_dotp; rp->r_linep = curwp->w_dotp;
if (curwp->w_doto < curwp->w_marko) { if (curwp->w_doto < curwp->w_marko) {
rp->r_offset = curwp->w_doto; rp->r_offset = curwp->w_doto;
rp->r_size = (long)(curwp->w_marko-curwp->w_doto); rp->r_size =
(long) (curwp->w_marko - curwp->w_doto);
} else { } else {
rp->r_offset = curwp->w_marko; rp->r_offset = curwp->w_marko;
rp->r_size = (long)(curwp->w_doto-curwp->w_marko); rp->r_size =
(long) (curwp->w_doto - curwp->w_marko);
} }
return (TRUE); return (TRUE);
} }
@ -209,4 +211,3 @@ register REGION *rp;
mlwrite("Bug: lost mark"); mlwrite("Bug: lost mark");
return (FALSE); return (FALSE);
} }

304
search.c
View File

@ -100,8 +100,10 @@ int f, n; /* default flag / numeric argument */
if ((status = readpattern("Search", &pat[0], TRUE)) == TRUE) { if ((status = readpattern("Search", &pat[0], TRUE)) == TRUE) {
do { do {
#if MAGIC #if MAGIC
if ((magical && curwp->w_bufp->b_mode & MDMAGIC) != 0) if ((magical
status = mcscanner(&mcpat[0], FORWARD, PTEND); && curwp->w_bufp->b_mode & MDMAGIC) != 0)
status =
mcscanner(&mcpat[0], FORWARD, PTEND);
else else
#endif #endif
status = scanner(&pat[0], FORWARD, PTEND); status = scanner(&pat[0], FORWARD, PTEND);
@ -135,15 +137,13 @@ int f, n; /* default flag / numeric argument */
/* Make sure a pattern exists, or that we didn't switch /* Make sure a pattern exists, or that we didn't switch
* into MAGIC mode until after we entered the pattern. * into MAGIC mode until after we entered the pattern.
*/ */
if (pat[0] == '\0') if (pat[0] == '\0') {
{
mlwrite("No pattern set"); mlwrite("No pattern set");
return FALSE; return FALSE;
} }
#if MAGIC #if MAGIC
if ((curwp->w_bufp->b_mode & MDMAGIC) != 0 && if ((curwp->w_bufp->b_mode & MDMAGIC) != 0 &&
mcpat[0].mc_type == MCNIL) mcpat[0].mc_type == MCNIL) {
{
if (!mcstr()) if (!mcstr())
return FALSE; return FALSE;
} }
@ -153,8 +153,7 @@ int f, n; /* default flag / numeric argument */
* n is positive (n == 0 will go through once, which * n is positive (n == 0 will go through once, which
* is just fine). * is just fine).
*/ */
do do {
{
#if MAGIC #if MAGIC
if ((magical && curwp->w_bufp->b_mode & MDMAGIC) != 0) if ((magical && curwp->w_bufp->b_mode & MDMAGIC) != 0)
status = mcscanner(&mcpat[0], FORWARD, PTEND); status = mcscanner(&mcpat[0], FORWARD, PTEND);
@ -197,11 +196,14 @@ int f, n; /* default flag / numeric argument */
* n is positive (n == 0 will go through once, which * n is positive (n == 0 will go through once, which
* is just fine). * is just fine).
*/ */
if ((status = readpattern("Reverse search", &pat[0], TRUE)) == TRUE) { if ((status =
readpattern("Reverse search", &pat[0], TRUE)) == TRUE) {
do { do {
#if MAGIC #if MAGIC
if ((magical && curwp->w_bufp->b_mode & MDMAGIC) != 0) if ((magical
status = mcscanner(&tapcm[0], REVERSE, PTBEG); && curwp->w_bufp->b_mode & MDMAGIC) != 0)
status =
mcscanner(&tapcm[0], REVERSE, PTBEG);
else else
#endif #endif
status = scanner(&tap[0], REVERSE, PTBEG); status = scanner(&tap[0], REVERSE, PTBEG);
@ -235,15 +237,13 @@ int f, n; /* default flag / numeric argument */
/* Make sure a pattern exists, or that we didn't switch /* Make sure a pattern exists, or that we didn't switch
* into MAGIC mode until after we entered the pattern. * into MAGIC mode until after we entered the pattern.
*/ */
if (tap[0] == '\0') if (tap[0] == '\0') {
{
mlwrite("No pattern set"); mlwrite("No pattern set");
return FALSE; return FALSE;
} }
#if MAGIC #if MAGIC
if ((curwp->w_bufp->b_mode & MDMAGIC) != 0 && if ((curwp->w_bufp->b_mode & MDMAGIC) != 0 &&
tapcm[0].mc_type == MCNIL) tapcm[0].mc_type == MCNIL) {
{
if (!mcstr()) if (!mcstr())
return FALSE; return FALSE;
} }
@ -253,8 +253,7 @@ int f, n; /* default flag / numeric argument */
* n is positive (n == 0 will go through once, which * n is positive (n == 0 will go through once, which
* is just fine). * is just fine).
*/ */
do do {
{
#if MAGIC #if MAGIC
if ((magical && curwp->w_bufp->b_mode & MDMAGIC) != 0) if ((magical && curwp->w_bufp->b_mode & MDMAGIC) != 0)
status = mcscanner(&tapcm[0], REVERSE, PTBEG); status = mcscanner(&tapcm[0], REVERSE, PTBEG);
@ -308,8 +307,7 @@ int beg_or_end; /* put point at beginning or end of pattern.*/
/* Scan each character until we hit the head link record. /* Scan each character until we hit the head link record.
*/ */
while (!boundry(curline, curoff, direct)) while (!boundry(curline, curoff, direct)) {
{
/* Save the current position in case we need to /* Save the current position in case we need to
* restore it on a match, and initialize matchlen to * restore it on a match, and initialize matchlen to
* zero in case we are doing a search for replacement. * zero in case we are doing a search for replacement.
@ -318,18 +316,15 @@ int beg_or_end; /* put point at beginning or end of pattern.*/
matchoff = curoff; matchoff = curoff;
matchlen = 0; matchlen = 0;
if (amatch(mcpatrn, direct, &curline, &curoff)) if (amatch(mcpatrn, direct, &curline, &curoff)) {
{
/* A SUCCESSFULL MATCH!!! /* A SUCCESSFULL MATCH!!!
* reset the global "." pointers. * reset the global "." pointers.
*/ */
if (beg_or_end == PTEND) /* at end of string */ if (beg_or_end == PTEND) { /* at end of string */
{
curwp->w_dotp = curline; curwp->w_dotp = curline;
curwp->w_doto = curoff; curwp->w_doto = curoff;
} } else { /* at beginning of string */
else /* at beginning of string */
{
curwp->w_dotp = matchline; curwp->w_dotp = matchline;
curwp->w_doto = matchoff; curwp->w_doto = matchoff;
} }
@ -377,33 +372,28 @@ int *pcwoff; /* position within current line */
* for reverse searches. The reverse is true for EOL. * for reverse searches. The reverse is true for EOL.
* So, for a start, we check for them on entry. * So, for a start, we check for them on entry.
*/ */
if (mcptr->mc_type == BOL) if (mcptr->mc_type == BOL) {
{
if (curoff != 0) if (curoff != 0)
return FALSE; return FALSE;
mcptr++; mcptr++;
} }
if (mcptr->mc_type == EOL) if (mcptr->mc_type == EOL) {
{
if (curoff != llength(curline)) if (curoff != llength(curline))
return FALSE; return FALSE;
mcptr++; mcptr++;
} }
while (mcptr->mc_type != MCNIL) while (mcptr->mc_type != MCNIL) {
{
c = nextch(&curline, &curoff, direct); c = nextch(&curline, &curoff, direct);
if (mcptr->mc_type & CLOSURE) if (mcptr->mc_type & CLOSURE) {
{
/* Try to match as many characters as possible /* Try to match as many characters as possible
* against the current meta-character. A * against the current meta-character. A
* newline never matches a closure. * newline never matches a closure.
*/ */
nchars = 0; nchars = 0;
while (c != '\n' && mceq(c, mcptr)) while (c != '\n' && mceq(c, mcptr)) {
{
c = nextch(&curline, &curoff, direct); c = nextch(&curline, &curoff, direct);
nchars++; nchars++;
} }
@ -417,12 +407,12 @@ int *pcwoff; /* position within current line */
*/ */
mcptr++; mcptr++;
for (;;) for (;;) {
{ c = nextch(&curline, &curoff,
c = nextch(&curline, &curoff, direct ^ REVERSE); direct ^ REVERSE);
if (amatch(mcptr, direct, &curline, &curoff)) if (amatch
{ (mcptr, direct, &curline, &curoff)) {
matchlen += nchars; matchlen += nchars;
goto success; goto success;
} }
@ -430,9 +420,8 @@ int *pcwoff; /* position within current line */
if (nchars-- == 0) if (nchars-- == 0)
return FALSE; return FALSE;
} }
} } else { /* Not closure. */
else /* Not closure.*/
{
/* The only way we'd get a BOL metacharacter /* The only way we'd get a BOL metacharacter
* at this point is at the end of the reversed pattern. * at this point is at the end of the reversed pattern.
* The only way we'd get an EOL metacharacter * The only way we'd get an EOL metacharacter
@ -450,23 +439,19 @@ int *pcwoff; /* position within current line */
* '^') match positions, not characters. * '^') match positions, not characters.
*/ */
if (mcptr->mc_type == BOL) if (mcptr->mc_type == BOL)
if (curoff == llength(curline)) if (curoff == llength(curline)) {
{
c = nextch(&curline, &curoff, c = nextch(&curline, &curoff,
direct ^ REVERSE); direct ^ REVERSE);
goto success; goto success;
} } else
else
return FALSE; return FALSE;
if (mcptr->mc_type == EOL) if (mcptr->mc_type == EOL)
if (curoff == 0) if (curoff == 0) {
{
c = nextch(&curline, &curoff, c = nextch(&curline, &curoff,
direct ^ REVERSE); direct ^ REVERSE);
goto success; goto success;
} } else
else
return FALSE; return FALSE;
/* Neither BOL nor EOL, so go through /* Neither BOL nor EOL, so go through
@ -523,8 +508,7 @@ int beg_or_end; /* put point at beginning or end of pattern.*/
/* Scan each character until we hit the head link record. /* Scan each character until we hit the head link record.
*/ */
while (!boundry(curline, curoff, direct)) while (!boundry(curline, curoff, direct)) {
{
/* Save the current position in case we match /* Save the current position in case we match
* the search string at this point. * the search string at this point.
*/ */
@ -536,8 +520,7 @@ int beg_or_end; /* put point at beginning or end of pattern.*/
*/ */
c = nextch(&curline, &curoff, direct); c = nextch(&curline, &curoff, direct);
if (eq(c, patrn[0])) /* if we find it..*/ if (eq(c, patrn[0])) { /* if we find it.. */
{
/* Setup scanning pointers. /* Setup scanning pointers.
*/ */
scanline = curline; scanline = curline;
@ -546,8 +529,7 @@ int beg_or_end; /* put point at beginning or end of pattern.*/
/* Scan through the pattern for a match. /* Scan through the pattern for a match.
*/ */
while (*++patptr != '\0') while (*++patptr != '\0') {
{
c = nextch(&scanline, &scanoff, direct); c = nextch(&scanline, &scanoff, direct);
if (!eq(c, *patptr)) if (!eq(c, *patptr))
@ -557,13 +539,11 @@ int beg_or_end; /* put point at beginning or end of pattern.*/
/* A SUCCESSFULL MATCH!!! /* A SUCCESSFULL MATCH!!!
* reset the global "." pointers * reset the global "." pointers
*/ */
if (beg_or_end == PTEND) /* at end of string */ if (beg_or_end == PTEND) { /* at end of string */
{
curwp->w_dotp = scanline; curwp->w_dotp = scanline;
curwp->w_doto = scanoff; curwp->w_doto = scanoff;
} } else { /* at beginning of string */
else /* at beginning of string */
{
curwp->w_dotp = matchline; curwp->w_dotp = matchline;
curwp->w_doto = matchoff; curwp->w_doto = matchoff;
} }
@ -591,8 +571,7 @@ register int bc;
register int pc; register int pc;
#endif #endif
{ {
if ((curwp->w_bufp->b_mode & MDEXACT) == 0) if ((curwp->w_bufp->b_mode & MDEXACT) == 0) {
{
if (islower(bc)) if (islower(bc))
bc ^= DIFCASE; bc ^= DIFCASE;
@ -632,11 +611,9 @@ int srch;
* Then, if it's the search string, make a reversed pattern. * Then, if it's the search string, make a reversed pattern.
* *Then*, make the meta-pattern, if we are defined that way. * *Then*, make the meta-pattern, if we are defined that way.
*/ */
if ((status = mlreplyt(tpat, tpat, NPAT, metac)) == TRUE) if ((status = mlreplyt(tpat, tpat, NPAT, metac)) == TRUE) {
{
strcpy(apat, tpat); strcpy(apat, tpat);
if (srch) /* If we are doing the search string.*/ if (srch) { /* If we are doing the search string. */
{
/* Reverse string copy, and remember /* Reverse string copy, and remember
* the length for substitution purposes. * the length for substitution purposes.
*/ */
@ -648,16 +625,13 @@ int srch;
* since the pattern in question might have an * since the pattern in question might have an
* invalid meta combination. * invalid meta combination.
*/ */
if ((curwp->w_bufp->b_mode & MDMAGIC) == 0) if ((curwp->w_bufp->b_mode & MDMAGIC) == 0) {
{
mcclear(); mcclear();
rmcclear(); rmcclear();
} } else
else
status = srch ? mcstr() : rmcstr(); status = srch ? mcstr() : rmcstr();
#endif #endif
} } else if (status == FALSE && apat[0] != 0) /* Old one */
else if (status == FALSE && apat[0] != 0) /* Old one */
status = TRUE; status = TRUE;
return (status); return (status);
@ -681,8 +655,7 @@ savematch()
ptr = patmatch = malloc(matchlen + 1); ptr = patmatch = malloc(matchlen + 1);
if (ptr != NULL) if (ptr != NULL) {
{
curoff = matchoff; curoff = matchoff;
curline = matchline; curline = matchline;
@ -761,8 +734,9 @@ int n; /* # of repetitions wanted */
/* Ask the user for the text of a pattern. /* Ask the user for the text of a pattern.
*/ */
if ((status = readpattern( if ((status = readpattern((kind ==
(kind == FALSE ? "Replace" : "Query replace"), &pat[0], TRUE)) FALSE ? "Replace" : "Query replace"),
&pat[0], TRUE))
!= TRUE) != TRUE)
return (status); return (status);
@ -781,8 +755,7 @@ int n; /* # of repetitions wanted */
nlflag = (pat[matchlen - 1] == '\n'); nlflag = (pat[matchlen - 1] == '\n');
nlrepl = FALSE; nlrepl = FALSE;
if (kind) if (kind) {
{
/* Build query replace question string. /* Build query replace question string.
*/ */
strcpy(tpat, "Replace '"); strcpy(tpat, "Replace '");
@ -806,20 +779,17 @@ int n; /* # of repetitions wanted */
nummatch = 0; nummatch = 0;
while ((f == FALSE || n > nummatch) && while ((f == FALSE || n > nummatch) &&
(nlflag == FALSE || nlrepl == FALSE) ) (nlflag == FALSE || nlrepl == FALSE)) {
{
/* Search for the pattern. /* Search for the pattern.
* If we search with a regular expression, * If we search with a regular expression,
* matchlen is reset to the true length of * matchlen is reset to the true length of
* the matched string. * the matched string.
*/ */
#if MAGIC #if MAGIC
if ((magical && curwp->w_bufp->b_mode & MDMAGIC) != 0) if ((magical && curwp->w_bufp->b_mode & MDMAGIC) != 0) {
{
if (!mcscanner(&mcpat[0], FORWARD, PTBEG)) if (!mcscanner(&mcpat[0], FORWARD, PTBEG))
break; break;
} } else
else
#endif #endif
if (!scanner(&pat[0], FORWARD, PTBEG)) if (!scanner(&pat[0], FORWARD, PTBEG))
break; /* all done */ break; /* all done */
@ -832,11 +802,11 @@ int n; /* # of repetitions wanted */
/* Check for query. /* Check for query.
*/ */
if (kind) if (kind) {
{
/* Get the query. /* Get the query.
*/ */
pprompt: mlwrite(&tpat[0], &pat[0], &rpat[0]); pprompt:mlwrite(&tpat[0], &pat[0],
&rpat[0]);
qprompt: qprompt:
update(TRUE); /* show the proposed place to change */ update(TRUE); /* show the proposed place to change */
c = tgetc(); /* and input */ c = tgetc(); /* and input */
@ -844,8 +814,7 @@ qprompt:
/* And respond appropriately. /* And respond appropriately.
*/ */
switch (c) switch (c) {
{
#if PKCODE #if PKCODE
case 'Y': case 'Y':
#endif #endif
@ -872,8 +841,7 @@ qprompt:
/* Restore old position. /* Restore old position.
*/ */
if (lastline == NULL) if (lastline == NULL) {
{
/* There is nothing to undo. /* There is nothing to undo.
*/ */
TTbeep(); TTbeep();
@ -919,13 +887,14 @@ qprompt:
TTbeep(); TTbeep();
case '?': /* help me */ case '?': /* help me */
mlwrite( mlwrite
"(Y)es, (N)o, (!)Do rest, (U)ndo last, (^G)Abort, (.)Abort back, (?)Help: "); ("(Y)es, (N)o, (!)Do rest, (U)ndo last, (^G)Abort, (.)Abort back, (?)Help: ");
goto qprompt; goto qprompt;
} /* end of switch */ } /* end of switch */
} /* end of "if kind" */ }
/* end of "if kind" */
/* /*
* Delete the sucker, and insert its * Delete the sucker, and insert its
* replacement. * replacement.
@ -937,8 +906,7 @@ qprompt:
/* Save our position, since we may /* Save our position, since we may
* undo this. * undo this.
*/ */
if (kind) if (kind) {
{
lastline = curwp->w_dotp; lastline = curwp->w_dotp;
lastoff = curwp->w_doto; lastoff = curwp->w_doto;
} }
@ -1003,10 +971,8 @@ int maxlength; /* maximum chars in destination */
/* Scan through the string. /* Scan through the string.
*/ */
while ((c = *srcstr++) != 0) while ((c = *srcstr++) != 0) {
{ if (c == '\n') { /* it's a newline */
if (c == '\n') /* it's a newline */
{
*deststr++ = '<'; *deststr++ = '<';
*deststr++ = 'N'; *deststr++ = 'N';
*deststr++ = 'L'; *deststr++ = 'L';
@ -1014,8 +980,7 @@ int maxlength; /* maximum chars in destination */
maxlength -= 4; maxlength -= 4;
} }
#if PKCODE #if PKCODE
else if ((c > 0 && c < 0x20) || else if ((c > 0 && c < 0x20) || c == 0x7f) /* control character */
c == 0x7f) /* control character */
#else #else
else if (c < 0x20 || c == 0x7f) /* control character */ else if (c < 0x20 || c == 0x7f) /* control character */
#endif #endif
@ -1023,22 +988,18 @@ int maxlength; /* maximum chars in destination */
*deststr++ = '^'; *deststr++ = '^';
*deststr++ = c ^ 0x40; *deststr++ = c ^ 0x40;
maxlength -= 2; maxlength -= 2;
} } else if (c == '%') {
else if (c == '%')
{
*deststr++ = '%'; *deststr++ = '%';
*deststr++ = '%'; *deststr++ = '%';
maxlength -= 2; maxlength -= 2;
} } else { /* any other character */
else /* any other character */
{
*deststr++ = c; *deststr++ = c;
maxlength--; maxlength--;
} }
/* check for maxlength */ /* check for maxlength */
if (maxlength < 4) if (maxlength < 4) {
{
*deststr++ = '$'; *deststr++ = '$';
*deststr = '\0'; *deststr = '\0';
return (FALSE); return (FALSE);
@ -1061,13 +1022,10 @@ int curoff, dir;
{ {
register int border; register int border;
if (dir == FORWARD) if (dir == FORWARD) {
{
border = (curoff == llength(curline)) && border = (curoff == llength(curline)) &&
(lforw(curline) == curbp->b_linep); (lforw(curline) == curbp->b_linep);
} } else {
else
{
border = (curoff == 0) && border = (curoff == 0) &&
(lback(curline) == curbp->b_linep); (lback(curline) == curbp->b_linep);
} }
@ -1094,26 +1052,20 @@ int dir;
curline = *pcurline; curline = *pcurline;
curoff = *pcuroff; curoff = *pcuroff;
if (dir == FORWARD) if (dir == FORWARD) {
{ if (curoff == llength(curline)) { /* if at EOL */
if (curoff == llength(curline)) /* if at EOL */
{
curline = lforw(curline); /* skip to next line */ curline = lforw(curline); /* skip to next line */
curoff = 0; curoff = 0;
c = '\n'; /* and return a <NL> */ c = '\n'; /* and return a <NL> */
} } else
else
c = lgetc(curline, curoff++); /* get the char */ c = lgetc(curline, curoff++); /* get the char */
} } else { /* Reverse. */
else /* Reverse.*/
{ if (curoff == 0) {
if (curoff == 0)
{
curline = lback(curline); curline = lback(curline);
curoff = llength(curline); curoff = llength(curline);
c = '\n'; c = '\n';
} } else
else
c = lgetc(curline, --curoff); c = lgetc(curline, --curoff);
} }
@ -1157,10 +1109,8 @@ static int mcstr()
mcptr = &mcpat[0]; mcptr = &mcpat[0];
patptr = &pat[0]; patptr = &pat[0];
while ((pchr = *patptr) && status) while ((pchr = *patptr) && status) {
{ switch (pchr) {
switch (pchr)
{
case MC_CCL: case MC_CCL:
status = cclmake(&patptr, mcptr); status = cclmake(&patptr, mcptr);
magical = TRUE; magical = TRUE;
@ -1204,13 +1154,13 @@ static int mcstr()
/* Note: no break between MC_ESC case and the default. /* Note: no break between MC_ESC case and the default.
*/ */
case MC_ESC: case MC_ESC:
if (*(patptr + 1) != '\0') if (*(patptr + 1) != '\0') {
{
pchr = *++patptr; pchr = *++patptr;
magical = TRUE; magical = TRUE;
} }
default: default:
litcase: mcptr->mc_type = LITCHAR; litcase:mcptr->mc_type =
LITCHAR;
mcptr->u.lchar = pchr; mcptr->u.lchar = pchr;
does_closure = (pchr != '\n'); does_closure = (pchr != '\n');
break; break;
@ -1232,19 +1182,15 @@ litcase: mcptr->mc_type = LITCHAR;
* freed. So we stomp a MCNIL value there, and call mcclear() * freed. So we stomp a MCNIL value there, and call mcclear()
* to free any other bitmaps. * to free any other bitmaps.
*/ */
if (status) if (status) {
{
rtpcm = &tapcm[0]; rtpcm = &tapcm[0];
while (--mj >= 0) while (--mj >= 0) {
{
#if MSC | TURBO | VMS | USG | BSD | V7 #if MSC | TURBO | VMS | USG | BSD | V7
*rtpcm++ = *--mcptr; *rtpcm++ = *--mcptr;
#endif #endif
} }
rtpcm->mc_type = MCNIL; rtpcm->mc_type = MCNIL;
} } else {
else
{
(--mcptr)->mc_type = MCNIL; (--mcptr)->mc_type = MCNIL;
mcclear(); mcclear();
} }
@ -1270,10 +1216,8 @@ static int rmcstr()
mj = 0; mj = 0;
rmagical = FALSE; rmagical = FALSE;
while (*patptr && status == TRUE) while (*patptr && status == TRUE) {
{ switch (*patptr) {
switch (*patptr)
{
case MC_DITTO: case MC_DITTO:
/* If there were non-magical characters /* If there were non-magical characters
@ -1282,11 +1226,10 @@ static int rmcstr()
* array before processing the current * array before processing the current
* meta-character. * meta-character.
*/ */
if (mj != 0) if (mj != 0) {
{
rmcptr->mc_type = LITCHAR; rmcptr->mc_type = LITCHAR;
if ((rmcptr->rstr = malloc(mj + 1)) == NULL) if ((rmcptr->rstr =
{ malloc(mj + 1)) == NULL) {
mlwrite("%%Out of memory"); mlwrite("%%Out of memory");
status = FALSE; status = FALSE;
break; break;
@ -1307,8 +1250,7 @@ static int rmcstr()
* of one, because we have to count the * of one, because we have to count the
* current character. * current character.
*/ */
if ((rmcptr->rstr = malloc(mj + 2)) == NULL) if ((rmcptr->rstr = malloc(mj + 2)) == NULL) {
{
mlwrite("%%Out of memory"); mlwrite("%%Out of memory");
status = FALSE; status = FALSE;
break; break;
@ -1335,11 +1277,9 @@ static int rmcstr()
patptr++; patptr++;
} }
if (rmagical && mj > 0) if (rmagical && mj > 0) {
{
rmcptr->mc_type = LITCHAR; rmcptr->mc_type = LITCHAR;
if ((rmcptr->rstr = malloc(mj + 1)) == NULL) if ((rmcptr->rstr = malloc(mj + 1)) == NULL) {
{
mlwrite("%%Out of memory."); mlwrite("%%Out of memory.");
status = FALSE; status = FALSE;
} }
@ -1359,8 +1299,7 @@ mcclear()
mcptr = &mcpat[0]; mcptr = &mcpat[0];
while (mcptr->mc_type != MCNIL) while (mcptr->mc_type != MCNIL) {
{
if ((mcptr->mc_type & MASKCL) == CCL || if ((mcptr->mc_type & MASKCL) == CCL ||
(mcptr->mc_type & MASKCL) == NCCL) (mcptr->mc_type & MASKCL) == NCCL)
free(mcptr->u.cclmap); free(mcptr->u.cclmap);
@ -1378,8 +1317,7 @@ rmcclear()
rmcptr = &rmcpat[0]; rmcptr = &rmcpat[0];
while (rmcptr->mc_type != MCNIL) while (rmcptr->mc_type != MCNIL) {
{
if (rmcptr->mc_type == LITCHAR) if (rmcptr->mc_type == LITCHAR)
free(rmcptr->rstr); free(rmcptr->rstr);
rmcptr++; rmcptr++;
@ -1402,8 +1340,7 @@ MC *mt;
#if PKCODE #if PKCODE
bc = bc & 0xFF; bc = bc & 0xFF;
#endif #endif
switch (mt->mc_type & MASKCL) switch (mt->mc_type & MASKCL) {
{
case LITCHAR: case LITCHAR:
result = eq(bc, mt->u.lchar); result = eq(bc, mt->u.lchar);
break; break;
@ -1413,11 +1350,9 @@ MC *mt;
break; break;
case CCL: case CCL:
if (!(result = biteq(bc, mt->u.cclmap))) if (!(result = biteq(bc, mt->u.cclmap))) {
{
if ((curwp->w_bufp->b_mode & MDEXACT) == 0 && if ((curwp->w_bufp->b_mode & MDEXACT) == 0 &&
(isletter(bc))) (isletter(bc))) {
{
result = biteq(CHCASE(bc), mt->u.cclmap); result = biteq(CHCASE(bc), mt->u.cclmap);
} }
} }
@ -1427,8 +1362,7 @@ MC *mt;
result = !biteq(bc, mt->u.cclmap); result = !biteq(bc, mt->u.cclmap);
if ((curwp->w_bufp->b_mode & MDEXACT) == 0 && if ((curwp->w_bufp->b_mode & MDEXACT) == 0 &&
(isletter(bc))) (isletter(bc))) {
{
result &= !biteq(CHCASE(bc), mt->u.cclmap); result &= !biteq(CHCASE(bc), mt->u.cclmap);
} }
break; break;
@ -1457,8 +1391,7 @@ MC *mcptr;
register char *patptr; register char *patptr;
register int pchr, ochr; register int pchr, ochr;
if ((bmap = clearbits()) == NULL) if ((bmap = clearbits()) == NULL) {
{
mlwrite("%%Out of memory"); mlwrite("%%Out of memory");
return FALSE; return FALSE;
} }
@ -1472,21 +1405,16 @@ MC *mcptr;
* character as a first character. Anything * character as a first character. Anything
* else gets set in the bitmap. * else gets set in the bitmap.
*/ */
if (*++patptr == MC_NCCL) if (*++patptr == MC_NCCL) {
{
patptr++; patptr++;
mcptr->mc_type = NCCL; mcptr->mc_type = NCCL;
} } else
else
mcptr->mc_type = CCL; mcptr->mc_type = CCL;
if ((ochr = *patptr) == MC_ECCL) if ((ochr = *patptr) == MC_ECCL) {
{
mlwrite("%%No characters in character class"); mlwrite("%%No characters in character class");
return (FALSE); return (FALSE);
} } else {
else
{
if (ochr == MC_ESC) if (ochr == MC_ESC)
ochr = *++patptr; ochr = *++patptr;
@ -1494,10 +1422,8 @@ MC *mcptr;
patptr++; patptr++;
} }
while (ochr != '\0' && (pchr = *patptr) != MC_ECCL) while (ochr != '\0' && (pchr = *patptr) != MC_ECCL) {
{ switch (pchr) {
switch (pchr)
{
/* Range character loses its meaning /* Range character loses its meaning
* if it is the last character in * if it is the last character in
* the class. * the class.
@ -1505,8 +1431,7 @@ MC *mcptr;
case MC_RCCL: case MC_RCCL:
if (*(patptr + 1) == MC_ECCL) if (*(patptr + 1) == MC_ECCL)
setbit(pchr, bmap); setbit(pchr, bmap);
else else {
{
pchr = *++patptr; pchr = *++patptr;
while (++ochr <= pchr) while (++ochr <= pchr)
setbit(ochr, bmap); setbit(ochr, bmap);
@ -1527,8 +1452,7 @@ MC *mcptr;
*ppatptr = patptr; *ppatptr = patptr;
if (ochr == '\0') if (ochr == '\0') {
{
mlwrite("%%Character class not ended"); mlwrite("%%Character class not ended");
free(bmap); free(bmap);
return FALSE; return FALSE;

20
spawn.c
View File

@ -104,8 +104,8 @@ spawncli(f, n)
#if BSD | __hpux | SVR4 #if BSD | __hpux | SVR4
bktoshell() /* suspend MicroEMACS and wait to wake up */ bktoshell()
{ { /* suspend MicroEMACS and wait to wake up */
int pid; int pid;
vttidy(); vttidy();
@ -180,8 +180,7 @@ spawn(f, n)
if (clexec == FALSE) { if (clexec == FALSE) {
mlputs("(End)"); /* Pause. */ mlputs("(End)"); /* Pause. */
TTflush(); TTflush();
while ((s = tgetc()) != '\r' && s != ' ') while ((s = tgetc()) != '\r' && s != ' ');
;
mlputs("\r\n"); mlputs("\r\n");
} }
TTkopen(); TTkopen();
@ -197,7 +196,6 @@ spawn(f, n)
*/ */
execprg(f, n) execprg(f, n)
{ {
register int s; register int s;
char line[NLINE]; char line[NLINE];
@ -245,8 +243,7 @@ execprg(f, n)
TTopen(); TTopen();
mlputs("(End)"); /* Pause. */ mlputs("(End)"); /* Pause. */
TTflush(); TTflush();
while ((s = tgetc()) != '\r' && s != ' ') while ((s = tgetc()) != '\r' && s != ' ');
;
sgarbf = TRUE; sgarbf = TRUE;
return (TRUE); return (TRUE);
#endif #endif
@ -279,12 +276,14 @@ pipecmd(f, n)
return (resterr()); return (resterr());
#if MSDOS #if MSDOS
if ((tmp = getenv("TMP")) == NULL && (tmp = getenv("TEMP")) == NULL) if ((tmp = getenv("TMP")) == NULL
&& (tmp = getenv("TEMP")) == NULL)
strcpy(filnam, "command"); strcpy(filnam, "command");
else { else {
strcpy(filnam, tmp); strcpy(filnam, tmp);
len = strlen(tmp); len = strlen(tmp);
if (len <= 0 || filnam[len-1] != '\\' && filnam[len-1] != '/') if (len <= 0 || filnam[len - 1] != '\\'
&& filnam[len - 1] != '/')
strcat(filnam, "\\"); strcat(filnam, "\\");
strcat(filnam, "command"); strcat(filnam, "command");
} }
@ -322,7 +321,6 @@ pipecmd(f, n)
return (FALSE); return (FALSE);
} }
#if MSDOS #if MSDOS
strcat(line, " >>"); strcat(line, " >>");
strcat(line, filnam); strcat(line, filnam);
@ -380,7 +378,6 @@ pipecmd(f, n)
* Bound to ^X # * Bound to ^X #
*/ */
filter(f, n) filter(f, n)
{ {
register int s; /* return status from CLI */ register int s; /* return status from CLI */
register BUFFER *bp; /* pointer to buffer to zot */ register BUFFER *bp; /* pointer to buffer to zot */
@ -418,7 +415,6 @@ filter(f, n)
strcpy(bp->b_fname, tmpnam); strcpy(bp->b_fname, tmpnam);
return (FALSE); return (FALSE);
} }
#if MSDOS #if MSDOS
strcat(line, " <fltinp >fltout"); strcat(line, " <fltinp >fltout");
movecursor(term.t_nrow - 1, 0); movecursor(term.t_nrow - 1, 0);

64
tcap.c
View File

@ -107,7 +107,6 @@ TERM term = {
}; };
tcapopen() tcapopen()
{ {
char *getenv(); char *getenv();
char *t, *p, *tgetstr(); char *t, *p, *tgetstr();
@ -117,18 +116,16 @@ tcapopen()
int int_col, int_row; int int_col, int_row;
#if PKCODE && USE_BROKEN_OPTIMIZATION #if PKCODE && USE_BROKEN_OPTIMIZATION
if (! term_init_ok) if (!term_init_ok) {
{
#endif #endif
if ((tv_stype = getenv("TERM")) == NULL) if ((tv_stype = getenv("TERM")) == NULL) {
{
puts("Environment variable TERM not defined!"); puts("Environment variable TERM not defined!");
exit(1); exit(1);
} }
if ((tgetent(tcbuf, tv_stype)) != 1) if ((tgetent(tcbuf, tv_stype)) != 1) {
{ sprintf(err_str, "Unknown terminal type %s!",
sprintf(err_str, "Unknown terminal type %s!", tv_stype); tv_stype);
puts(err_str); puts(err_str);
exit(1); exit(1);
} }
@ -138,16 +135,17 @@ tcapopen()
term.t_nrow = int_row - 1; term.t_nrow = int_row - 1;
term.t_ncol = int_col; term.t_ncol = int_col;
if ((term.t_nrow <= 0) && (term.t_nrow=(short)tgetnum("li")-1) == -1){ if ((term.t_nrow <= 0)
&& (term.t_nrow = (short) tgetnum("li") - 1) == -1) {
puts("termcap entry incomplete (lines)"); puts("termcap entry incomplete (lines)");
exit(1); exit(1);
} }
if ((term.t_ncol <= 0) && (term.t_ncol=(short)tgetnum("co")) == -1){ if ((term.t_ncol <= 0)
&& (term.t_ncol = (short) tgetnum("co")) == -1) {
puts("Termcap entry incomplete (columns)"); puts("Termcap entry incomplete (columns)");
exit(1); exit(1);
} }
#ifdef SIGWINCH #ifdef SIGWINCH
term.t_mrow = MAXROW; term.t_mrow = MAXROW;
term.t_mcol = MAXCOL; term.t_mcol = MAXCOL;
@ -180,8 +178,7 @@ tcapopen()
TE = tgetstr("te", &p); TE = tgetstr("te", &p);
#endif #endif
if(CL == NULL || CM == NULL || UP == NULL) if (CL == NULL || CM == NULL || UP == NULL) {
{
puts("Incomplete termcap entry\n"); puts("Incomplete termcap entry\n");
exit(1); exit(1);
} }
@ -206,8 +203,7 @@ tcapopen()
} }
#endif #endif
if (p >= &tcapbuf[TCAPSLEN]) if (p >= &tcapbuf[TCAPSLEN]) {
{
puts("Terminal description too big!\n"); puts("Terminal description too big!\n");
exit(1); exit(1);
} }
@ -221,7 +217,6 @@ tcapopen()
#if PKCODE #if PKCODE
tcapclose() tcapclose()
{ {
putpad(tgoto(CM, 0, term.t_nrow)); putpad(tgoto(CM, 0, term.t_nrow));
putpad(TE); putpad(TE);
@ -231,7 +226,6 @@ tcapclose()
#endif #endif
tcapkopen() tcapkopen()
{ {
#if PKCODE #if PKCODE
putpad(TI); putpad(TI);
@ -241,7 +235,6 @@ tcapkopen()
} }
tcapkclose() tcapkclose()
{ {
} }
@ -261,8 +254,8 @@ tcapeeop()
putpad(CL); putpad(CL);
} }
tcaprev(state) /* change reverse video status */ tcaprev(state)
/* change reverse video status */
int state; /* FALSE = normal video, TRUE = reverse video */ int state; /* FALSE = normal video, TRUE = reverse video */
{ {
@ -270,14 +263,12 @@ int state; /* FALSE = normal video, TRUE = reverse video */
if (state) { if (state) {
if (SO != NULL) if (SO != NULL)
putpad(SO); putpad(SO);
} else } else if (SE != NULL)
if (SE != NULL)
putpad(SE); putpad(SE);
} }
tcapcres() /* change screen resolution */ tcapcres()
{ /* change screen resolution */
{
return (TRUE); return (TRUE);
} }
@ -287,7 +278,8 @@ tcapcres() /* change screen resolution */
tcapscroll_reg(from, to, howmanylines) tcapscroll_reg(from, to, howmanylines)
{ {
int i; int i;
if (to == from) return; if (to == from)
return;
if (to < from) { if (to < from) {
tcapscrollregion(to, from + howmanylines - 1); tcapscrollregion(to, from + howmanylines - 1);
tcapmove(from + howmanylines - 1, 0); tcapmove(from + howmanylines - 1, 0);
@ -306,7 +298,8 @@ tcapscroll_reg(from,to,howmanylines)
tcapscroll_delins(from, to, howmanylines) tcapscroll_delins(from, to, howmanylines)
{ {
int i; int i;
if (to == from) return; if (to == from)
return;
if (to < from) { if (to < from) {
tcapmove(to, 0); tcapmove(to, 0);
for (i = from - to; i > 0; i--) for (i = from - to; i > 0; i--)
@ -333,19 +326,18 @@ tcapscrollregion(top,bot)
#endif #endif
spal(dummy) /* change palette string */ spal(dummy)
{ /* change palette string */
{
/* Does nothing here */ /* Does nothing here */
} }
#if COLOR #if COLOR
tcapfcol() /* no colors here, ignore this */ tcapfcol()
{ { /* no colors here, ignore this */
} }
tcapbcol() /* no colors here, ignore this */ tcapbcol()
{ { /* no colors here, ignore this */
} }
#endif #endif
@ -368,8 +360,8 @@ char *str;
#if FNLABEL #if FNLABEL
fnclabel(f, n) /* label a function key */ fnclabel(f, n)
/* label a function key */
int f, n; /* default flag, numeric argument [unused] */ int f, n; /* default flag, numeric argument [unused] */
{ {

View File

@ -64,14 +64,17 @@ struct sgttyb nstate; /* values for editor mode */
struct tchars otchars; /* Saved terminal special character set */ struct tchars otchars; /* Saved terminal special character set */
#if XONXOFF #if XONXOFF
struct tchars ntchars = { 0xff, 0xff, 0x11, 0x13, 0xff, 0xff }; struct tchars ntchars = { 0xff, 0xff, 0x11, 0x13, 0xff, 0xff };
/* A lot of nothing and XON/XOFF */ /* A lot of nothing and XON/XOFF */
#else #else
struct tchars ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; struct tchars ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
/* A lot of nothing */ /* A lot of nothing */
#endif #endif
#if BSD & PKCODE #if BSD & PKCODE
struct ltchars oltchars; /* Saved terminal local special character set */ struct ltchars oltchars; /* Saved terminal local special character set */
struct ltchars nltchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; struct ltchars nltchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
/* A lot of nothing */ /* A lot of nothing */
#endif #endif
@ -295,7 +298,8 @@ ttflush()
status = SS$_NORMAL; status = SS$_NORMAL;
if (nobuf != 0) { if (nobuf != 0) {
status = SYS$QIOW(EFN, iochan, IO$_WRITELBLK|IO$M_NOFORMAT, status =
SYS$QIOW(EFN, iochan, IO$_WRITELBLK | IO$M_NOFORMAT,
iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0); iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0);
if (status == SS$_NORMAL) if (status == SS$_NORMAL)
status = iosb[0] & 0xFFFF; status = iosb[0] & 0xFFFF;
@ -357,7 +361,8 @@ ttgetc()
nibuf = (iosb[0] >> 16) + (iosb[1] >> 16); nibuf = (iosb[0] >> 16) + (iosb[1] >> 16);
if (nibuf == 0) { if (nibuf == 0) {
status = SYS$QIOW(EFN, iochan, IO$_READLBLK, status = SYS$QIOW(EFN, iochan, IO$_READLBLK,
iosb, 0, 0, ibuf, 1, 0, term, 0, 0); iosb, 0, 0, ibuf, 1, 0, term, 0,
0);
if (status != SS$_NORMAL if (status != SS$_NORMAL
|| (status = (iosb[0] & 0xFFFF)) != SS$_NORMAL) || (status = (iosb[0] & 0xFFFF)) != SS$_NORMAL)
if (status != SS$_DATAOVERUN) if (status != SS$_DATAOVERUN)
@ -392,13 +397,11 @@ ttgetc()
#if USG #if USG
if (kbdqp) if (kbdqp)
kbdqp = FALSE; kbdqp = FALSE;
else else {
{
if (kbdpoll && fcntl(0, F_SETFL, kbdflgs) < 0) if (kbdpoll && fcntl(0, F_SETFL, kbdflgs) < 0)
return FALSE; return FALSE;
kbdpoll = FALSE; kbdpoll = FALSE;
while (read(0, &kbdq, 1) != 1) while (read(0, &kbdq, 1) != 1);
;
} }
return (kbdq & 255); return (kbdq & 255);
#endif #endif
@ -410,7 +413,6 @@ ttgetc()
*/ */
typahead() typahead()
{ {
#if MSDOS & (MSC | TURBO) #if MSDOS & (MSC | TURBO)
if (kbhit() != 0) if (kbhit() != 0)
@ -430,8 +432,7 @@ typahead()
#endif #endif
#if USG #if USG
if( !kbdqp ) if (!kbdqp) {
{
if (!kbdpoll && fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0) if (!kbdpoll && fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0)
return (FALSE); return (FALSE);
#if PKCODE #if PKCODE

32
vmsvt.c
View File

@ -61,9 +61,11 @@ TERM term = {
#else #else
24 - 1, /* Max number of rows allowable */ 24 - 1, /* Max number of rows allowable */
#endif #endif
/* Filled in */ - 1, /* Current number of rows used */ /* Filled in */ -1,
/* Current number of rows used */
MAXCOL, /* Max number of columns */ MAXCOL, /* Max number of columns */
/* Filled in */ 0, /* Current number of columns */ /* Filled in */ 0,
/* Current number of columns */
64, /* Min margin for extended lines */ 64, /* Min margin for extended lines */
8, /* Size of scroll region */ 8, /* Size of scroll region */
100, /* # times thru update to pause */ 100, /* # times thru update to pause */
@ -133,8 +135,9 @@ int col; /* Column position */
&max_buffer_length, /* Maximum buffer length */ &max_buffer_length, /* Maximum buffer length */
&ret_length, /* Return length */ &ret_length, /* Return length */
buffer, /* Capability data buffer */ buffer, /* Capability data buffer */
arg_list) /* Argument list array */ arg_list)
/* Argument list array */
/* We'll know soon enough if this doesn't work */ /* We'll know soon enough if this doesn't work */
&1) == 0) { &1) == 0) {
ttputs("OOPS"); ttputs("OOPS");
@ -153,7 +156,8 @@ int col; /* Column position */
vmsscroll_reg(from, to, howmany) vmsscroll_reg(from, to, howmany)
{ {
int i; int i;
if (to == from) return; if (to == from)
return;
if (to < from) { if (to < from) {
vmsscrollregion(to, from + howmany - 1); vmsscrollregion(to, from + howmany - 1);
vmsmove(from + howmany - 1, 0); vmsmove(from + howmany - 1, 0);
@ -193,8 +197,9 @@ int bot; /* Bottom position */
&max_buffer_length, /* Maximum buffer length */ &max_buffer_length, /* Maximum buffer length */
&ret_length, /* Return length */ &ret_length, /* Return length */
buffer, /* Capability data buffer */ buffer, /* Capability data buffer */
arg_list) /* Argument list array */ arg_list)
/* Argument list array */
/* We'll know soon enough if this doesn't work */ /* We'll know soon enough if this doesn't work */
&1) == 0) { &1) == 0) {
ttputs("OOPS"); ttputs("OOPS");
@ -316,21 +321,21 @@ int request_code; /* Request code */
&max_buffer_length, /* Maximum buffer length */ &max_buffer_length, /* Maximum buffer length */
&ret_length, /* Return length */ &ret_length, /* Return length */
buffer, /* Capability data buffer */ buffer, /* Capability data buffer */
arg_list) /* Argument list array */ arg_list)
/* Argument list array */
/* If this doesn't work, try again with no arguments */ /* If this doesn't work, try again with no arguments */
&1) == 0 && (smg$get_term_data( /* Get terminal data */
& 1) == 0 &&
(smg$get_term_data( /* Get terminal data */
&termtype, /* Terminal table address */ &termtype, /* Terminal table address */
&request_code, /* Request code */ &request_code, /* Request code */
&max_buffer_length, /* Maximum buffer length */ &max_buffer_length, /* Maximum buffer length */
&ret_length, /* Return length */ &ret_length, /* Return length */
buffer) /* Capability data buffer */ buffer)
/* Capability data buffer */
/* Return NULL pointer if capability is not available */ /* Return NULL pointer if capability is not available */
&1) == 0) &1) == 0)
return NULL; return NULL;
@ -421,7 +426,8 @@ vmsopen()
vmsgtty(); vmsgtty();
if (tc.t_type == TT$_UNKNOWN) { if (tc.t_type == TT$_UNKNOWN) {
printf("Terminal type is unknown!\n"); printf("Terminal type is unknown!\n");
printf("Try set your terminal type with SET TERMINAL/INQUIRE\n"); printf
("Try set your terminal type with SET TERMINAL/INQUIRE\n");
printf("Or get help on SET TERMINAL/DEVICE_TYPE\n"); printf("Or get help on SET TERMINAL/DEVICE_TYPE\n");
exit(3); exit(3);
} }

29
vt52.c
View File

@ -103,33 +103,31 @@ vt52eeop()
ttputc('J'); ttputc('J');
} }
vt52rev(status) /* set the reverse video state */ vt52rev(status)
/* set the reverse video state */
int status; /* TRUE = reverse video, FALSE = normal video */ int status; /* TRUE = reverse video, FALSE = normal video */
{ {
/* can't do this here, so we won't */ /* can't do this here, so we won't */
} }
vt52cres() /* change screen resolution - (not here though) */ vt52cres()
{ /* change screen resolution - (not here though) */
{
return (TRUE); return (TRUE);
} }
spal() /* change palette string */ spal()
{ /* change palette string */
{
/* Does nothing here */ /* Does nothing here */
} }
#if COLOR #if COLOR
vt52fcol() /* set the forground color [NOT IMPLIMENTED] */ vt52fcol()
{ { /* set the forground color [NOT IMPLIMENTED] */
} }
vt52bcol() /* set the background color [NOT IMPLIMENTED] */ vt52bcol()
{ { /* set the background color [NOT IMPLIMENTED] */
} }
#endif #endif
@ -160,19 +158,17 @@ vt52open()
} }
vt52kopen() vt52kopen()
{ {
} }
vt52kclose() vt52kclose()
{ {
} }
#if FNLABEL #if FNLABEL
fnclabel(f, n) /* label a function key */ fnclabel(f, n)
/* label a function key */
int f, n; /* default flag, numeric argument [unused] */ int f, n; /* default flag, numeric argument [unused] */
{ {
@ -183,7 +179,6 @@ int f,n; /* default flag, numeric argument [unused] */
#else #else
vt52hello() vt52hello()
{ {
} }

View File

@ -32,8 +32,7 @@ refresh(f, n)
{ {
if (f == FALSE) if (f == FALSE)
sgarbf = TRUE; sgarbf = TRUE;
else else {
{
curwp->w_force = 0; /* Center dot. */ curwp->w_force = 0; /* Center dot. */
curwp->w_flag |= WFFORCE; curwp->w_flag |= WFFORCE;
} }
@ -81,8 +80,7 @@ int f, n; /* default flag and numeric argument */
mlwrite("Window number out of range"); mlwrite("Window number out of range");
return (FALSE); return (FALSE);
} }
} else } else if ((wp = curwp->w_wndp) == NULL)
if ((wp = curwp->w_wndp) == NULL)
wp = wheadp; wp = wheadp;
curwp = wp; curwp = wp;
curbp = wp->w_bufp; curbp = wp->w_bufp;
@ -152,13 +150,10 @@ mvupwind(f, n)
lp = curwp->w_linep; lp = curwp->w_linep;
if (n < 0) if (n < 0) {
{
while (n++ && lp != curbp->b_linep) while (n++ && lp != curbp->b_linep)
lp = lforw(lp); lp = lforw(lp);
} } else {
else
{
while (n-- && lback(lp) != curbp->b_linep) while (n-- && lback(lp) != curbp->b_linep)
lp = lback(lp); lp = lback(lp);
} }
@ -166,8 +161,7 @@ mvupwind(f, n)
curwp->w_linep = lp; curwp->w_linep = lp;
curwp->w_flag |= WFHARD; /* Mode line is OK. */ curwp->w_flag |= WFHARD; /* Mode line is OK. */
for (i = 0; i < curwp->w_ntrows; ++i) for (i = 0; i < curwp->w_ntrows; ++i) {
{
if (lp == curwp->w_dotp) if (lp == curwp->w_dotp)
return (TRUE); return (TRUE);
if (lp == curbp->b_linep) if (lp == curbp->b_linep)
@ -480,7 +474,8 @@ shrinkwind(f, n)
} }
if (curwp->w_wndp == adjwp) { /* Grow below. */ if (curwp->w_wndp == adjwp) { /* Grow below. */
lp = adjwp->w_linep; lp = adjwp->w_linep;
for (i=0; i<n && lback(lp)!=adjwp->w_bufp->b_linep; ++i) for (i = 0; i < n && lback(lp) != adjwp->w_bufp->b_linep;
++i)
lp = lback(lp); lp = lback(lp);
adjwp->w_linep = lp; adjwp->w_linep = lp;
adjwp->w_toprow -= n; adjwp->w_toprow -= n;
@ -531,8 +526,7 @@ int f, n; /* default flag and numeric argument */
* Pick the uppermost window that isn't the current window. An LRU algorithm * Pick the uppermost window that isn't the current window. An LRU algorithm
* might be better. Return a pointer, or NULL on error. * might be better. Return a pointer, or NULL on error.
*/ */
WINDOW * WINDOW *wpopup()
wpopup()
{ {
register WINDOW *wp; register WINDOW *wp;
@ -545,32 +539,28 @@ wpopup()
return (wp); return (wp);
} }
scrnextup(f, n) /* scroll the next window up (back) a page */ scrnextup(f, n)
{ /* scroll the next window up (back) a page */
{
nextwind(FALSE, 1); nextwind(FALSE, 1);
backpage(f, n); backpage(f, n);
prevwind(FALSE, 1); prevwind(FALSE, 1);
} }
scrnextdw(f, n) /* scroll the next window down (forward) a page */ scrnextdw(f, n)
{ /* scroll the next window down (forward) a page */
{
nextwind(FALSE, 1); nextwind(FALSE, 1);
forwpage(f, n); forwpage(f, n);
prevwind(FALSE, 1); prevwind(FALSE, 1);
} }
savewnd(f, n) /* save ptr to current window */ savewnd(f, n)
{ /* save ptr to current window */
{
swindow = curwp; swindow = curwp;
return (TRUE); return (TRUE);
} }
restwnd(f, n) /* restore the saved screen */ restwnd(f, n)
{ /* restore the saved screen */
{
register WINDOW *wp; register WINDOW *wp;
/* find the window */ /* find the window */
@ -589,8 +579,8 @@ restwnd(f, n) /* restore the saved screen */
return (FALSE); return (FALSE);
} }
newsize(f, n) /* resize the screen, re-writing the screen */ newsize(f, n)
/* resize the screen, re-writing the screen */
int f; /* default flag */ int f; /* default flag */
int n; /* numeric argument */ int n; /* numeric argument */
@ -659,7 +649,8 @@ int n; /* numeric argument */
/* need to change this window size? */ /* need to change this window size? */
lastline = wp->w_toprow + wp->w_ntrows - 1; lastline = wp->w_toprow + wp->w_ntrows - 1;
if (lastline >= n - 2) { if (lastline >= n - 2) {
wp->w_ntrows = n - wp->w_toprow - 2; wp->w_ntrows =
n - wp->w_toprow - 2;
wp->w_flag |= WFHARD | WFMODE; wp->w_flag |= WFHARD | WFMODE;
} }
} }
@ -674,8 +665,8 @@ int n; /* numeric argument */
return (TRUE); return (TRUE);
} }
newwidth(f, n) /* resize the screen, re-writing the screen */ newwidth(f, n)
/* resize the screen, re-writing the screen */
int f; /* default flag */ int f; /* default flag */
int n; /* numeric argument */ int n; /* numeric argument */
@ -708,9 +699,8 @@ int n; /* numeric argument */
return (TRUE); return (TRUE);
} }
int getwpos() /* get screen offset of current line in current window */ int getwpos()
{ /* get screen offset of current line in current window */
{
register int sline; /* screen line from top of window */ register int sline; /* screen line from top of window */
register LINE *lp; /* scannile line pointer */ register LINE *lp; /* scannile line pointer */
@ -730,4 +720,3 @@ cknewwindow()
{ {
execute(META | SPEC | 'X', FALSE, 1); execute(META | SPEC | 'X', FALSE, 1);
} }

19
word.c
View File

@ -220,7 +220,8 @@ capword(f, n)
if (c >= 'A' && c <= 'Z') { if (c >= 'A' && c <= 'Z') {
#endif #endif
c += 'a' - 'A'; c += 'a' - 'A';
lputc(curwp->w_dotp, curwp->w_doto, c); lputc(curwp->w_dotp, curwp->w_doto,
c);
lchange(WFHARD); lchange(WFHARD);
} }
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
@ -307,8 +308,8 @@ delfword(f, n)
/* skip whitespace and newlines */ /* skip whitespace and newlines */
while ((curwp->w_doto == llength(curwp->w_dotp)) || while ((curwp->w_doto == llength(curwp->w_dotp)) ||
((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ') || ((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ')
(c == '\t')) { || (c == '\t')) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
break; break;
++size; ++size;
@ -388,9 +389,9 @@ inword()
} }
#if WORDPRO #if WORDPRO
fillpara(f, n) /* Fill the current paragraph according to the current fillpara(f, n)
/* Fill the current paragraph according to the current
fill column */ fill column */
int f, n; /* deFault flag and Numeric argument */ int f, n; /* deFault flag and Numeric argument */
{ {
@ -484,9 +485,9 @@ int f, n; /* deFault flag and Numeric argument */
} }
#if PKCODE #if PKCODE
justpara(f, n) /* Fill the current paragraph according to the current justpara(f, n)
/* Fill the current paragraph according to the current
fill column and cursor position */ fill column and cursor position */
int f, n; /* deFault flag and Numeric argument */ int f, n; /* deFault flag and Numeric argument */
{ {
@ -592,8 +593,8 @@ int f, n; /* deFault flag and Numeric argument */
} }
#endif #endif
killpara(f, n) /* delete n paragraphs starting with the current one */ killpara(f, n)
/* delete n paragraphs starting with the current one */
int f; /* default flag */ int f; /* default flag */
int n; /* # of paras to delete */ int n; /* # of paras to delete */