1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 07:16:23 -05:00

uemacs: Fix return statements

Return statement is not a function so remove superfluous use of parenthesis.

Cc: Thiago Farina <tfransosi@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Pekka Enberg 2010-08-29 13:03:55 +03:00 committed by Linus Torvalds
parent 3246438f73
commit 0f05e53f99
28 changed files with 760 additions and 760 deletions

4
ansi.c
View File

@ -176,7 +176,7 @@ void ansirev(int state)
/* Change screen resolution. */ /* Change screen resolution. */
int ansicres() int ansicres()
{ {
return (TRUE); return TRUE;
} }
/* Change pallette settings. */ /* Change pallette settings. */
@ -252,7 +252,7 @@ void ansikclose(void)
int fnclabel(int f, int n) int fnclabel(int f, int n)
{ {
/* On machines with no function keys...don't bother. */ /* On machines with no function keys...don't bother. */
return (TRUE); return TRUE;
} }
#endif #endif
#endif #endif

View File

@ -68,7 +68,7 @@ int backchar(int f, int n)
while (n--) { while (n--) {
if (curwp->w_doto == 0) { if (curwp->w_doto == 0) {
if ((lp = lback(curwp->w_dotp)) == curbp->b_linep) if ((lp = lback(curwp->w_dotp)) == curbp->b_linep)
return (FALSE); return FALSE;
curwp->w_dotp = lp; curwp->w_dotp = lp;
curwp->w_doto = llength(lp); curwp->w_doto = llength(lp);
curwp->w_flag |= WFMOVE; curwp->w_flag |= WFMOVE;
@ -100,7 +100,7 @@ int forwchar(int f, int n)
while (n--) { while (n--) {
if (curwp->w_doto == llength(curwp->w_dotp)) { if (curwp->w_doto == llength(curwp->w_dotp)) {
if (curwp->w_dotp == curbp->b_linep) if (curwp->w_dotp == curbp->b_linep)
return (FALSE); return FALSE;
curwp->w_dotp = lforw(curwp->w_dotp); curwp->w_dotp = lforw(curwp->w_dotp);
curwp->w_doto = 0; curwp->w_doto = 0;
curwp->w_flag |= WFMOVE; curwp->w_flag |= WFMOVE;
@ -125,7 +125,7 @@ int gotoline(int f, int n)
if ((status = if ((status =
mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) { mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) {
mlwrite("(Aborted)"); mlwrite("(Aborted)");
return (status); return status;
} }
n = atoi(arg); n = atoi(arg);
} }

78
bind.c
View File

@ -29,18 +29,18 @@ int help(int f, int n)
fname = flook(pathname[1], FALSE); fname = flook(pathname[1], FALSE);
if (fname == NULL) { if (fname == NULL) {
mlwrite("(Help file is not online)"); mlwrite("(Help file is not online)");
return (FALSE); return FALSE;
} }
} }
/* split the current window to make room for the help stuff */ /* split the current window to make room for the help stuff */
if (splitwind(FALSE, 1) == FALSE) if (splitwind(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
if (bp == NULL) { if (bp == NULL) {
/* and read the stuff in */ /* and read the stuff in */
if (getfile(fname, FALSE) == FALSE) if (getfile(fname, FALSE) == FALSE)
return (FALSE); return FALSE;
} else } else
swbuffer(bp); swbuffer(bp);
@ -52,7 +52,7 @@ int help(int f, int n)
wp->w_flag |= WFMODE; wp->w_flag |= WFMODE;
wp = wp->w_wndp; wp = wp->w_wndp;
} }
return (TRUE); return TRUE;
} }
int deskey(int f, int n) int deskey(int f, int n)
@ -78,7 +78,7 @@ int deskey(int f, int n)
/* output the command sequence */ /* output the command sequence */
ostring(ptr); ostring(ptr);
return (TRUE); return TRUE;
} }
/* /*
@ -102,7 +102,7 @@ int bindtokey(int f, int n)
kfunc = getname(); kfunc = getname();
if (kfunc == NULL) { if (kfunc == NULL) {
mlwrite("(No such function)"); mlwrite("(No such function)");
return (FALSE); return FALSE;
} }
ostring(" "); ostring(" ");
@ -157,7 +157,7 @@ int bindtokey(int f, int n)
/* if we run out of binding room, bitch */ /* if we run out of binding room, bitch */
if (ktp >= &keytab[NBINDS]) { if (ktp >= &keytab[NBINDS]) {
mlwrite("Binding table FULL!"); mlwrite("Binding table FULL!");
return (FALSE); return FALSE;
} }
ktp->k_code = c; /* add keycode */ ktp->k_code = c; /* add keycode */
@ -166,7 +166,7 @@ int bindtokey(int f, int n)
ktp->k_code = 0; ktp->k_code = 0;
ktp->k_fp = NULL; ktp->k_fp = NULL;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -195,9 +195,9 @@ int unbindkey(int f, int n)
/* if it isn't bound, bitch */ /* if it isn't bound, bitch */
if (unbindchar(c) == FALSE) { if (unbindchar(c) == FALSE) {
mlwrite("(Key not bound)"); mlwrite("(Key not bound)");
return (FALSE); return FALSE;
} }
return (TRUE); return TRUE;
} }
@ -225,7 +225,7 @@ int unbindchar(int c)
/* if it isn't bound, bitch */ /* if it isn't bound, bitch */
if (!found) if (!found)
return (FALSE); return FALSE;
/* save the pointer and scan to the end of the table */ /* save the pointer and scan to the end of the table */
sktp = ktp; sktp = ktp;
@ -240,7 +240,7 @@ int unbindchar(int c)
/* null out the last one */ /* null out the last one */
ktp->k_code = 0; ktp->k_code = 0;
ktp->k_fp = NULL; ktp->k_fp = NULL;
return (TRUE); return TRUE;
} }
/* describe bindings /* describe bindings
@ -251,7 +251,7 @@ int desbind(int f, int n)
#if APROP #if APROP
{ {
buildlist(TRUE, ""); buildlist(TRUE, "");
return (TRUE); return TRUE;
} }
int apro(int f, int n) int apro(int f, int n)
@ -261,9 +261,9 @@ int apro(int f, int n)
status = mlreply("Apropos string: ", mstring, NSTRING - 1); status = mlreply("Apropos string: ", mstring, NSTRING - 1);
if (status != TRUE) if (status != TRUE)
return (status); return status;
return (buildlist(FALSE, mstring)); return buildlist(FALSE, mstring);
} }
/* /*
@ -284,13 +284,13 @@ int buildlist(int type, char *mstring)
/* split the current window to make room for the binding list */ /* split the current window to make room for the binding list */
if (splitwind(FALSE, 1) == FALSE) if (splitwind(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
/* and get a buffer for it */ /* and get a buffer for it */
bp = bfind("*Binding list*", TRUE, 0); bp = bfind("*Binding list*", TRUE, 0);
if (bp == NULL || bclear(bp) == FALSE) { if (bp == NULL || bclear(bp) == FALSE) {
mlwrite("Can not display binding list"); mlwrite("Can not display binding list");
return (FALSE); return FALSE;
} }
/* let us know this is in progress */ /* let us know this is in progress */
@ -346,7 +346,7 @@ int buildlist(int type, char *mstring)
/* and add it as a line into the buffer */ /* and add it as a line into the buffer */
if (linstr(outseq) != TRUE) if (linstr(outseq) != TRUE)
return (FALSE); return FALSE;
cpos = 0; /* and clear the line */ cpos = 0; /* and clear the line */
} }
@ -358,7 +358,7 @@ int buildlist(int type, char *mstring)
outseq[cpos++] = '\n'; outseq[cpos++] = '\n';
outseq[cpos] = 0; outseq[cpos] = 0;
if (linstr(outseq) != TRUE) if (linstr(outseq) != TRUE)
return (FALSE); return FALSE;
} }
fail: /* and on to the next name */ fail: /* and on to the next name */
@ -375,7 +375,7 @@ int buildlist(int type, char *mstring)
wp = wp->w_wndp; wp = wp->w_wndp;
} }
mlwrite(""); /* clear the mode line */ mlwrite(""); /* clear the mode line */
return (TRUE); return TRUE;
} }
#if APROP #if APROP
@ -408,12 +408,12 @@ int strinc(char *source, char *sub)
/* yes, return a success */ /* yes, return a success */
if (*tp == 0) if (*tp == 0)
return (TRUE); return TRUE;
/* no, onward */ /* no, onward */
sp++; sp++;
} }
return (FALSE); return FALSE;
} }
#endif #endif
@ -430,7 +430,7 @@ unsigned int getckey(int mflag)
/* check to see if we are executing a command line */ /* check to see if we are executing a command line */
if (clexec) { if (clexec) {
macarg(tok); /* get the next token */ macarg(tok); /* get the next token */
return (stock(tok)); return stock(tok);
} }
/* or the normal way */ /* or the normal way */
@ -438,7 +438,7 @@ unsigned int getckey(int mflag)
c = get1key(); c = get1key();
else else
c = getcmd(); c = getcmd();
return (c); return c;
} }
/* /*
@ -458,10 +458,10 @@ int startup(char *sfname)
/* if it isn't around, don't sweat it */ /* if it isn't around, don't sweat it */
if (fname == NULL) if (fname == NULL)
return (TRUE); return TRUE;
/* otherwise, execute the sucker */ /* otherwise, execute the sucker */
return (dofile(fname)); return dofile(fname);
} }
/* /*
@ -493,7 +493,7 @@ char *flook(char *fname, int hflag)
/* and try it out */ /* and try it out */
if (ffropen(fspec) == FIOSUC) { if (ffropen(fspec) == FIOSUC) {
ffclose(); ffclose();
return (fspec); return fspec;
} }
} }
} }
@ -502,7 +502,7 @@ char *flook(char *fname, int hflag)
/* always try the current directory first */ /* always try the current directory first */
if (ffropen(fname) == FIOSUC) { if (ffropen(fname) == FIOSUC) {
ffclose(); ffclose();
return (fname); return fname;
} }
#if ENVFUNC #if ENVFUNC
/* get the PATH variable */ /* get the PATH variable */
@ -524,7 +524,7 @@ char *flook(char *fname, int hflag)
/* and try it out */ /* and try it out */
if (ffropen(fspec) == FIOSUC) { if (ffropen(fspec) == FIOSUC) {
ffclose(); ffclose();
return (fspec); return fspec;
} }
if (*path == PATHCHR) if (*path == PATHCHR)
@ -540,11 +540,11 @@ char *flook(char *fname, int hflag)
/* and try it out */ /* and try it out */
if (ffropen(fspec) == FIOSUC) { if (ffropen(fspec) == FIOSUC) {
ffclose(); ffclose();
return (fspec); return fspec;
} }
} }
return (NULL); /* no such luck */ return NULL; /* no such luck */
} }
/* /*
@ -601,12 +601,12 @@ int (*getbind(int c))(int, int)
ktp = &keytab[0]; /* Look in key table. */ ktp = &keytab[0]; /* Look in key table. */
while (ktp->k_fp != NULL) { while (ktp->k_fp != NULL) {
if (ktp->k_code == c) if (ktp->k_code == c)
return (ktp->k_fp); return ktp->k_fp;
++ktp; ++ktp;
} }
/* no such binding */ /* no such binding */
return (NULL); return NULL;
} }
/* /*
@ -622,10 +622,10 @@ char *getfname(fn_t func)
nptr = &names[0]; nptr = &names[0];
while (nptr->n_func != NULL) { while (nptr->n_func != NULL) {
if (nptr->n_func == func) if (nptr->n_func == func)
return (nptr->n_name); return nptr->n_name;
++nptr; ++nptr;
} }
return (NULL); return NULL;
} }
/* /*
@ -642,10 +642,10 @@ int (*fncmatch(char *fname)) (int, int)
ffp = &names[0]; ffp = &names[0];
while (ffp->n_func != NULL) { while (ffp->n_func != NULL) {
if (strcmp(fname, ffp->n_name) == 0) if (strcmp(fname, ffp->n_name) == 0)
return (ffp->n_func); return ffp->n_func;
++ffp; ++ffp;
} }
return (NULL); return NULL;
} }
/* /*
@ -696,7 +696,7 @@ unsigned int stock(char *keyname)
/* the final sequence... */ /* the final sequence... */
c |= *keyname; c |= *keyname;
return (c); return c;
} }
/* /*
@ -712,5 +712,5 @@ char *transbind(char *skey)
if (bindname == NULL) if (bindname == NULL)
bindname = "ERROR"; bindname = "ERROR";
return (bindname); return bindname;
} }

View File

@ -27,10 +27,10 @@ int usebuffer(int f, int n)
char bufn[NBUFN]; char bufn[NBUFN];
if ((s = mlreply("Use buffer: ", bufn, NBUFN)) != TRUE) if ((s = mlreply("Use buffer: ", bufn, NBUFN)) != TRUE)
return (s); return s;
if ((bp = bfind(bufn, TRUE, 0)) == NULL) if ((bp = bfind(bufn, TRUE, 0)) == NULL)
return (FALSE); return FALSE;
return (swbuffer(bp)); return swbuffer(bp);
} }
/* /*
@ -47,7 +47,7 @@ int nextbuffer(int f, int n)
if (f == FALSE) if (f == FALSE)
n = 1; n = 1;
if (n < 1) if (n < 1)
return (FALSE); return FALSE;
bbp = curbp; bbp = curbp;
while (n-- > 0) { while (n-- > 0) {
@ -63,14 +63,14 @@ int nextbuffer(int f, int n)
/* don't get caught in an infinite loop! */ /* don't get caught in an infinite loop! */
if (bp == bbp) if (bp == bbp)
return (FALSE); return FALSE;
} }
bbp = bp; bbp = bp;
} }
return (swbuffer(bp)); return swbuffer(bp);
} }
/* /*
@ -104,7 +104,7 @@ int swbuffer(struct buffer *bp)
curwp->w_markp = bp->b_markp; curwp->w_markp = bp->b_markp;
curwp->w_marko = bp->b_marko; curwp->w_marko = bp->b_marko;
cknewwindow(); cknewwindow();
return (TRUE); return TRUE;
} }
wp = wheadp; /* Look for old. */ wp = wheadp; /* Look for old. */
while (wp != NULL) { while (wp != NULL) {
@ -118,7 +118,7 @@ int swbuffer(struct buffer *bp)
wp = wp->w_wndp; wp = wp->w_wndp;
} }
cknewwindow(); cknewwindow();
return (TRUE); return TRUE;
} }
/* /*
@ -136,12 +136,12 @@ int killbuffer(int f, int n)
char bufn[NBUFN]; char bufn[NBUFN];
if ((s = mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE) if ((s = mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE)
return (s); return s;
if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */ if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */
return (TRUE); return TRUE;
if (bp->b_flag & BFINVS) /* Deal with special buffers */ if (bp->b_flag & BFINVS) /* Deal with special buffers */
return (TRUE); /* by doing nothing. */ return TRUE; /* by doing nothing. */
return (zotbuf(bp)); return zotbuf(bp);
} }
/* /*
@ -155,10 +155,10 @@ int zotbuf(struct buffer *bp)
if (bp->b_nwnd != 0) { /* Error if on screen. */ if (bp->b_nwnd != 0) { /* Error if on screen. */
mlwrite("Buffer is being displayed"); mlwrite("Buffer is being displayed");
return (FALSE); return FALSE;
} }
if ((s = bclear(bp)) != TRUE) /* Blow text away. */ if ((s = bclear(bp)) != TRUE) /* Blow text away. */
return (s); return s;
free((char *) bp->b_linep); /* Release header line. */ free((char *) bp->b_linep); /* Release header line. */
bp1 = NULL; /* Find the header. */ bp1 = NULL; /* Find the header. */
bp2 = bheadp; bp2 = bheadp;
@ -172,7 +172,7 @@ int zotbuf(struct buffer *bp)
else else
bp1->b_bufp = bp2; bp1->b_bufp = bp2;
free((char *) bp); /* Release buffer block */ free((char *) bp); /* Release buffer block */
return (TRUE); return TRUE;
} }
/* /*
@ -188,7 +188,7 @@ int namebuffer(int f, int n)
/* 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) != ask:if (mlreply("Change buffer name to: ", bufn, NBUFN) !=
TRUE) TRUE)
return (FALSE); return FALSE;
/* and check for duplicates */ /* and check for duplicates */
bp = bheadp; bp = bheadp;
@ -204,7 +204,7 @@ int namebuffer(int f, int n)
strcpy(curbp->b_bname, bufn); /* copy buffer name to structure */ strcpy(curbp->b_bname, bufn); /* copy buffer name to structure */
curwp->w_flag |= WFMODE; /* make mode line replot */ curwp->w_flag |= WFMODE; /* make mode line replot */
mlerase(); mlerase();
return (TRUE); return TRUE;
} }
/* /*
@ -224,10 +224,10 @@ int listbuffers(int f, int n)
int s; int s;
if ((s = makelist(f)) != TRUE) if ((s = makelist(f)) != TRUE)
return (s); return s;
if (blistp->b_nwnd == 0) { /* Not on screen yet. */ if (blistp->b_nwnd == 0) { /* Not on screen yet. */
if ((wp = wpopup()) == NULL) if ((wp = wpopup()) == NULL)
return (FALSE); return FALSE;
bp = wp->w_bufp; bp = wp->w_bufp;
if (--bp->b_nwnd == 0) { if (--bp->b_nwnd == 0) {
bp->b_dotp = wp->w_dotp; bp->b_dotp = wp->w_dotp;
@ -250,7 +250,7 @@ int listbuffers(int f, int n)
} }
wp = wp->w_wndp; wp = wp->w_wndp;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -280,12 +280,12 @@ int makelist(int iflag)
blistp->b_flag &= ~BFCHG; /* Don't complain! */ blistp->b_flag &= ~BFCHG; /* Don't complain! */
if ((s = bclear(blistp)) != TRUE) /* Blow old text away */ if ((s = bclear(blistp)) != TRUE) /* Blow old text away */
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("--- ----- ---- ------ ----") == || addline("--- ----- ---- ------ ----") ==
FALSE) FALSE)
return (FALSE); return FALSE;
bp = bheadp; /* For all buffers */ bp = bheadp; /* For all buffers */
/* build line to report global mode settings */ /* build line to report global mode settings */
@ -303,7 +303,7 @@ int makelist(int iflag)
*cp1++ = '.'; *cp1++ = '.';
strcpy(cp1, " Global Modes"); strcpy(cp1, " Global Modes");
if (addline(line) == FALSE) if (addline(line) == FALSE)
return (FALSE); return FALSE;
/* output the list of buffers */ /* output the list of buffers */
while (bp != NULL) { while (bp != NULL) {
@ -367,10 +367,10 @@ int makelist(int iflag)
} }
*cp1 = 0; /* Add to the buffer. */ *cp1 = 0; /* Add to the buffer. */
if (addline(line) == FALSE) if (addline(line) == FALSE)
return (FALSE); return FALSE;
bp = bp->b_bufp; bp = bp->b_bufp;
} }
return (TRUE); /* All done */ return TRUE; /* All done */
} }
void ltoa(char *buf, int width, long num) void ltoa(char *buf, int width, long num)
@ -400,7 +400,7 @@ int addline(char *text)
ntext = strlen(text); ntext = strlen(text);
if ((lp = lalloc(ntext)) == NULL) if ((lp = lalloc(ntext)) == NULL)
return (FALSE); return FALSE;
for (i = 0; i < ntext; ++i) for (i = 0; i < ntext; ++i)
lputc(lp, i, text[i]); lputc(lp, i, text[i]);
blistp->b_linep->l_bp->l_fp = lp; /* Hook onto the end */ blistp->b_linep->l_bp->l_fp = lp; /* Hook onto the end */
@ -409,7 +409,7 @@ int addline(char *text)
lp->l_fp = blistp->b_linep; lp->l_fp = blistp->b_linep;
if (blistp->b_dotp == blistp->b_linep) /* If "." is at the end */ if (blistp->b_dotp == blistp->b_linep) /* If "." is at the end */
blistp->b_dotp = lp; /* move it to new line */ blistp->b_dotp = lp; /* move it to new line */
return (TRUE); return TRUE;
} }
/* /*
@ -430,10 +430,10 @@ int anycb(void)
while (bp != NULL) { while (bp != NULL) {
if ((bp->b_flag & BFINVS) == 0 if ((bp->b_flag & BFINVS) == 0
&& (bp->b_flag & BFCHG) != 0) && (bp->b_flag & BFCHG) != 0)
return (TRUE); return TRUE;
bp = bp->b_bufp; bp = bp->b_bufp;
} }
return (FALSE); return FALSE;
} }
/* /*
@ -452,15 +452,15 @@ struct buffer *bfind(char *bname, int cflag, int bflag)
bp = bheadp; bp = bheadp;
while (bp != NULL) { while (bp != NULL) {
if (strcmp(bname, bp->b_bname) == 0) if (strcmp(bname, bp->b_bname) == 0)
return (bp); return bp;
bp = bp->b_bufp; bp = bp->b_bufp;
} }
if (cflag != FALSE) { if (cflag != FALSE) {
if ((bp = (struct buffer *)malloc(sizeof(struct buffer))) == NULL) if ((bp = (struct buffer *)malloc(sizeof(struct buffer))) == NULL)
return (NULL); return NULL;
if ((lp = lalloc(0)) == NULL) { if ((lp = lalloc(0)) == NULL) {
free((char *) bp); free((char *) bp);
return (NULL); return NULL;
} }
/* find the place in the list to insert this buffer */ /* find the place in the list to insert this buffer */
if (bheadp == NULL || strcmp(bheadp->b_bname, bname) > 0) { if (bheadp == NULL || strcmp(bheadp->b_bname, bname) > 0) {
@ -498,7 +498,7 @@ struct buffer *bfind(char *bname, int cflag, int bflag)
lp->l_fp = lp; lp->l_fp = lp;
lp->l_bp = lp; lp->l_bp = lp;
} }
return (bp); return bp;
} }
/* /*
@ -519,7 +519,7 @@ int bclear(struct buffer *bp)
if ((bp->b_flag & BFINVS) == 0 /* Not scratch buffer. */ if ((bp->b_flag & BFINVS) == 0 /* Not scratch buffer. */
&& (bp->b_flag & BFCHG) != 0 /* Something changed */ && (bp->b_flag & BFCHG) != 0 /* Something changed */
&& (s = mlyesno("Discard changes")) != TRUE) && (s = mlyesno("Discard changes")) != TRUE)
return (s); return s;
bp->b_flag &= ~BFCHG; /* Not changed */ bp->b_flag &= ~BFCHG; /* Not changed */
while ((lp = lforw(bp->b_linep)) != bp->b_linep) while ((lp = lforw(bp->b_linep)) != bp->b_linep)
lfree(lp); lfree(lp);
@ -527,7 +527,7 @@ int bclear(struct buffer *bp)
bp->b_doto = 0; bp->b_doto = 0;
bp->b_markp = NULL; /* Invalidate "mark" */ bp->b_markp = NULL; /* Invalidate "mark" */
bp->b_marko = 0; bp->b_marko = 0;
return (TRUE); return TRUE;
} }
/* /*
@ -539,5 +539,5 @@ int unmark(int f, int n)
{ {
curbp->b_flag &= ~BFCHG; curbp->b_flag &= ~BFCHG;
curwp->w_flag |= WFMODE; curwp->w_flag |= WFMODE;
return (TRUE); return TRUE;
} }

View File

@ -34,7 +34,7 @@ int set_encryption_key(int f, int n)
status = mlreply("Encryption String: ", key, NPAT - 1); status = mlreply("Encryption String: ", key, NPAT - 1);
disinp = odisinp; disinp = odisinp;
if (status != TRUE) if (status != TRUE)
return (status); return status;
/* and encrypt it */ /* and encrypt it */
myencrypt((char *) NULL, 0); myencrypt((char *) NULL, 0);
@ -43,7 +43,7 @@ int set_encryption_key(int f, int n)
/* and save it off */ /* and save it off */
strcpy(curbp->b_key, key); strcpy(curbp->b_key, key);
mlwrite(" "); /* clear it off the bottom line */ mlwrite(" "); /* clear it off the bottom line */
return (TRUE); return TRUE;
} }
/********** /**********
@ -214,7 +214,7 @@ static int mod95(int val)
val -= 95; val -= 95;
while (val < 0) while (val < 0)
val += 95; val += 95;
return (val); return val;
} }
#else #else
static void myennocrypt(void) static void myennocrypt(void)

View File

@ -242,7 +242,7 @@ static void vteeol(void)
int upscreen(int f, int n) int upscreen(int f, int n)
{ {
update(TRUE); update(TRUE);
return (TRUE); return TRUE;
} }
#if SCROLLCODE #if SCROLLCODE
@ -264,11 +264,11 @@ int update(int force)
#if TYPEAH && ! PKCODE #if TYPEAH && ! PKCODE
if (force == FALSE && typahead()) if (force == FALSE && typahead())
return (TRUE); return TRUE;
#endif #endif
#if VISMAC == 0 #if VISMAC == 0
if (force == FALSE && kbdmode == PLAY) if (force == FALSE && kbdmode == PLAY)
return (TRUE); return TRUE;
#endif #endif
displaying = TRUE; displaying = TRUE;
@ -352,7 +352,7 @@ int update(int force)
while (chg_width || chg_height) while (chg_width || chg_height)
newscreensize(chg_height, chg_width); newscreensize(chg_height, chg_width);
#endif #endif
return (TRUE); return TRUE;
} }
/* /*
@ -395,7 +395,7 @@ static int reframe(struct window *wp)
break; break;
} }
#endif #endif
return (TRUE); return TRUE;
} }
/* if we are at the end of the file, reframe */ /* if we are at the end of the file, reframe */
@ -441,7 +441,7 @@ static int reframe(struct window *wp)
wp->w_linep = lp; wp->w_linep = lp;
wp->w_flag |= WFHARD; wp->w_flag |= WFHARD;
wp->w_flag &= ~WFFORCE; wp->w_flag &= ~WFFORCE;
return (TRUE); return TRUE;
} }
/* /*
@ -657,7 +657,7 @@ int updupd(int force)
if ((vp1->v_flag & VFCHG) != 0) { if ((vp1->v_flag & VFCHG) != 0) {
#if TYPEAH && ! PKCODE #if TYPEAH && ! PKCODE
if (force == FALSE && typahead()) if (force == FALSE && typahead())
return (TRUE); return TRUE;
#endif #endif
#if MEMMAP && ! SCROLLCODE #if MEMMAP && ! SCROLLCODE
updateline(i, vp1); updateline(i, vp1);
@ -666,7 +666,7 @@ int updupd(int force)
#endif #endif
} }
} }
return (TRUE); return TRUE;
} }
#if SCROLLCODE #if SCROLLCODE
@ -774,7 +774,7 @@ static int scrolls(int inserts)
} }
#endif #endif
if (2 * count < abs(from - to)) if (2 * count < abs(from - to))
return (FALSE); return FALSE;
scrscroll(from, to, count); scrscroll(from, to, count);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
vpp = pscreen[to + i]; vpp = pscreen[to + i];
@ -805,9 +805,9 @@ static int scrolls(int inserts)
vscreen[i]->v_flag |= VFCHG; vscreen[i]->v_flag |= VFCHG;
} }
#endif #endif
return (TRUE); return TRUE;
} }
return (FALSE); return FALSE;
} }
/* move the "count" lines starting at "from" to "to" */ /* move the "count" lines starting at "from" to "to" */
@ -827,7 +827,7 @@ static int texttest(int vrow, int prow)
struct video *vpv = vscreen[vrow]; /* virtual screen image */ struct video *vpv = vscreen[vrow]; /* virtual screen image */
struct video *vpp = pscreen[prow]; /* physical screen image */ struct video *vpp = pscreen[prow]; /* physical screen image */
return (!memcmp(vpv->v_text, vpp->v_text, term.t_ncol)); return !memcmp(vpv->v_text, vpp->v_text, term.t_ncol);
} }
/* /*
@ -838,8 +838,8 @@ static int endofline(char *s, int n)
int i; int i;
for (i = n - 1; i >= 0; i--) for (i = n - 1; i >= 0; i--)
if (s[i] != ' ') if (s[i] != ' ')
return (i + 1); return i + 1;
return (0); return 0;
} }
#endif /* SCROLLCODE */ #endif /* SCROLLCODE */
@ -1009,7 +1009,7 @@ static int updateline(int row, struct video *vp1, struct video *vp2)
vp1->v_fcolor = vp1->v_rfcolor; vp1->v_fcolor = vp1->v_rfcolor;
vp1->v_bcolor = vp1->v_rbcolor; vp1->v_bcolor = vp1->v_rbcolor;
#endif #endif
return (TRUE); return TRUE;
} }
#endif #endif
@ -1028,7 +1028,7 @@ static int updateline(int row, struct video *vp1, struct video *vp2)
/* if both lines are the same, no update needs to be done */ /* if both lines are the same, no update needs to be done */
if (cp1 == &vp1->v_text[term.t_ncol]) { if (cp1 == &vp1->v_text[term.t_ncol]) {
vp1->v_flag &= ~VFCHG; /* flag this line is changed */ vp1->v_flag &= ~VFCHG; /* flag this line is changed */
return (TRUE); return TRUE;
} }
/* find out if there is a match on the right */ /* find out if there is a match on the right */
@ -1074,7 +1074,7 @@ static int updateline(int row, struct video *vp1, struct video *vp2)
TTrev(FALSE); TTrev(FALSE);
#endif #endif
vp1->v_flag &= ~VFCHG; /* flag this line as updated */ vp1->v_flag &= ~VFCHG; /* flag this line as updated */
return (TRUE); return TRUE;
#endif #endif
} }
#endif #endif

272
eval.c
View File

@ -46,22 +46,22 @@ char *gtfun(char *fname)
/* return errorm on a bad reference */ /* return errorm on a bad reference */
if (fnum == ARRAY_SIZE(funcs)) if (fnum == ARRAY_SIZE(funcs))
return (errorm); return errorm;
/* if needed, retrieve the first argument */ /* if needed, retrieve the first argument */
if (funcs[fnum].f_type >= MONAMIC) { if (funcs[fnum].f_type >= MONAMIC) {
if ((status = macarg(arg1)) != TRUE) if ((status = macarg(arg1)) != TRUE)
return (errorm); return errorm;
/* if needed, retrieve the second argument */ /* if needed, retrieve the second argument */
if (funcs[fnum].f_type >= DYNAMIC) { if (funcs[fnum].f_type >= DYNAMIC) {
if ((status = macarg(arg2)) != TRUE) if ((status = macarg(arg2)) != TRUE)
return (errorm); return errorm;
/* if needed, retrieve the third argument */ /* if needed, retrieve the third argument */
if (funcs[fnum].f_type >= TRINAMIC) if (funcs[fnum].f_type >= TRINAMIC)
if ((status = macarg(arg3)) != TRUE) if ((status = macarg(arg3)) != TRUE)
return (errorm); return errorm;
} }
} }
@ -69,22 +69,22 @@ char *gtfun(char *fname)
/* and now evaluate it! */ /* and now evaluate it! */
switch (fnum) { switch (fnum) {
case UFADD: case UFADD:
return (itoa(atoi(arg1) + atoi(arg2))); return itoa(atoi(arg1) + atoi(arg2));
case UFSUB: case UFSUB:
return (itoa(atoi(arg1) - atoi(arg2))); return itoa(atoi(arg1) - atoi(arg2));
case UFTIMES: case UFTIMES:
return (itoa(atoi(arg1) * atoi(arg2))); return itoa(atoi(arg1) * atoi(arg2));
case UFDIV: case UFDIV:
return (itoa(atoi(arg1) / atoi(arg2))); return itoa(atoi(arg1) / atoi(arg2));
case UFMOD: case UFMOD:
return (itoa(atoi(arg1) % atoi(arg2))); return itoa(atoi(arg1) % atoi(arg2));
case UFNEG: case UFNEG:
return (itoa(-atoi(arg1))); return itoa(-atoi(arg1));
case UFCAT: case UFCAT:
strcpy(result, arg1); strcpy(result, arg1);
return (strcat(result, arg2)); return strcat(result, arg2);
case UFLEFT: case UFLEFT:
return (strncpy(result, arg1, atoi(arg2))); return strncpy(result, arg1, atoi(arg2));
case UFRIGHT: case UFRIGHT:
return (strcpy(result, return (strcpy(result,
&arg1[(strlen(arg1) - atoi(arg2))])); &arg1[(strlen(arg1) - atoi(arg2))]));
@ -92,73 +92,73 @@ char *gtfun(char *fname)
return (strncpy(result, &arg1[atoi(arg2) - 1], return (strncpy(result, &arg1[atoi(arg2) - 1],
atoi(arg3))); atoi(arg3)));
case UFNOT: case UFNOT:
return (ltos(stol(arg1) == FALSE)); return ltos(stol(arg1) == FALSE);
case UFEQUAL: case UFEQUAL:
return (ltos(atoi(arg1) == atoi(arg2))); return ltos(atoi(arg1) == atoi(arg2));
case UFLESS: case UFLESS:
return (ltos(atoi(arg1) < atoi(arg2))); return ltos(atoi(arg1) < atoi(arg2));
case UFGREATER: case UFGREATER:
return (ltos(atoi(arg1) > atoi(arg2))); return ltos(atoi(arg1) > atoi(arg2));
case UFSEQUAL: case UFSEQUAL:
return (ltos(strcmp(arg1, arg2) == 0)); return ltos(strcmp(arg1, arg2) == 0);
case UFSLESS: case UFSLESS:
return (ltos(strcmp(arg1, arg2) < 0)); return ltos(strcmp(arg1, arg2) < 0);
case UFSGREAT: case UFSGREAT:
return (ltos(strcmp(arg1, arg2) > 0)); return ltos(strcmp(arg1, arg2) > 0);
case UFIND: case UFIND:
return (strcpy(result, getval(arg1))); return strcpy(result, getval(arg1));
case UFAND: case UFAND:
return (ltos(stol(arg1) && stol(arg2))); return ltos(stol(arg1) && stol(arg2));
case UFOR: case UFOR:
return (ltos(stol(arg1) || stol(arg2))); return ltos(stol(arg1) || stol(arg2));
case UFLENGTH: case UFLENGTH:
return (itoa(strlen(arg1))); return itoa(strlen(arg1));
case UFUPPER: case UFUPPER:
return (mkupper(arg1)); return mkupper(arg1);
case UFLOWER: case UFLOWER:
return (mklower(arg1)); return mklower(arg1);
case UFTRUTH: case UFTRUTH:
return (ltos(atoi(arg1) == 42)); return ltos(atoi(arg1) == 42);
case UFASCII: case UFASCII:
return (itoa((int) arg1[0])); return itoa((int) arg1[0]);
case UFCHR: case UFCHR:
result[0] = atoi(arg1); result[0] = atoi(arg1);
result[1] = 0; result[1] = 0;
return (result); return result;
case UFGTKEY: case UFGTKEY:
result[0] = tgetc(); result[0] = tgetc();
result[1] = 0; result[1] = 0;
return (result); return result;
case UFRND: case UFRND:
return (itoa((ernd() % abs(atoi(arg1))) + 1)); return itoa((ernd() % abs(atoi(arg1))) + 1);
case UFABS: case UFABS:
return (itoa(abs(atoi(arg1)))); return itoa(abs(atoi(arg1)));
case UFSINDEX: case UFSINDEX:
return (itoa(sindex(arg1, arg2))); return itoa(sindex(arg1, arg2));
case UFENV: case UFENV:
#if ENVFUNC #if ENVFUNC
tsp = getenv(arg1); tsp = getenv(arg1);
return (tsp == NULL ? "" : tsp); return tsp == NULL ? "" : tsp;
#else #else
return (""); return "";
#endif #endif
case UFBIND: case UFBIND:
return (transbind(arg1)); return transbind(arg1);
case UFEXIST: case UFEXIST:
return (ltos(fexist(arg1))); 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: case UFBAND:
return (itoa(atoi(arg1) & atoi(arg2))); return itoa(atoi(arg1) & atoi(arg2));
case UFBOR: case UFBOR:
return (itoa(atoi(arg1) | atoi(arg2))); return itoa(atoi(arg1) | atoi(arg2));
case UFBXOR: case UFBXOR:
return (itoa(atoi(arg1) ^ atoi(arg2))); return itoa(atoi(arg1) ^ atoi(arg2));
case UFBNOT: case UFBNOT:
return (itoa(~atoi(arg1))); return itoa(~atoi(arg1));
case UFXLATE: case UFXLATE:
return (xlat(arg1, arg2, arg3)); return xlat(arg1, arg2, arg3);
} }
exit(-11); /* never should get here */ exit(-11); /* never should get here */
@ -177,13 +177,13 @@ char *gtusr(char *vname)
/* scan the list looking for the user var name */ /* scan the list looking for the user var name */
for (vnum = 0; vnum < MAXVARS; vnum++) { for (vnum = 0; vnum < MAXVARS; vnum++) {
if (uv[vnum].u_name[0] == 0) if (uv[vnum].u_name[0] == 0)
return (errorm); return errorm;
if (strcmp(vname, uv[vnum].u_name) == 0) if (strcmp(vname, uv[vnum].u_name) == 0)
return (uv[vnum].u_value); return uv[vnum].u_value;
} }
/* return errorm if we run off the end */ /* return errorm if we run off the end */
return (errorm); return errorm;
} }
extern char *getkill(void); extern char *getkill(void);
@ -209,109 +209,109 @@ char *gtenv(char *vname)
char *ename = getenv(vname); char *ename = getenv(vname);
if (ename != NULL) if (ename != NULL)
return (ename); return ename;
else else
return (errorm); return errorm;
} }
#else #else
return (errorm); return errorm;
#endif #endif
/* otherwise, fetch the appropriate value */ /* otherwise, fetch the appropriate value */
switch (vnum) { switch (vnum) {
case EVFILLCOL: case EVFILLCOL:
return (itoa(fillcol)); return itoa(fillcol);
case EVPAGELEN: case EVPAGELEN:
return (itoa(term.t_nrow + 1)); return itoa(term.t_nrow + 1);
case EVCURCOL: case EVCURCOL:
return (itoa(getccol(FALSE))); return itoa(getccol(FALSE));
case EVCURLINE: case EVCURLINE:
return (itoa(getcline())); return itoa(getcline());
case EVRAM: case EVRAM:
return (itoa((int) (envram / 1024l))); return itoa((int) (envram / 1024l));
case EVFLICKER: case EVFLICKER:
return (ltos(flickcode)); return ltos(flickcode);
case EVCURWIDTH: case EVCURWIDTH:
return (itoa(term.t_ncol)); return itoa(term.t_ncol);
case EVCBUFNAME: case EVCBUFNAME:
return (curbp->b_bname); return curbp->b_bname;
case EVCFNAME: case EVCFNAME:
return (curbp->b_fname); return curbp->b_fname;
case EVSRES: case EVSRES:
return (sres); return sres;
case EVDEBUG: case EVDEBUG:
return (ltos(macbug)); return ltos(macbug);
case EVSTATUS: case EVSTATUS:
return (ltos(cmdstatus)); return ltos(cmdstatus);
case EVPALETTE: case EVPALETTE:
return (palstr); return palstr;
case EVASAVE: case EVASAVE:
return (itoa(gasave)); return itoa(gasave);
case EVACOUNT: case EVACOUNT:
return (itoa(gacount)); return itoa(gacount);
case EVLASTKEY: case EVLASTKEY:
return (itoa(lastkey)); 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: case EVDISCMD:
return (ltos(discmd)); return ltos(discmd);
case EVVERSION: case EVVERSION:
return (VERSION); return VERSION;
case EVPROGNAME: case EVPROGNAME:
return (PROGRAM_NAME_LONG); return PROGRAM_NAME_LONG;
case EVSEED: case EVSEED:
return (itoa(seed)); return itoa(seed);
case EVDISINP: case EVDISINP:
return (ltos(disinp)); return ltos(disinp);
case EVWLINE: case EVWLINE:
return (itoa(curwp->w_ntrows)); return itoa(curwp->w_ntrows);
case EVCWLINE: case EVCWLINE:
return (itoa(getwpos())); return itoa(getwpos());
case EVTARGET: case EVTARGET:
saveflag = lastflag; saveflag = lastflag;
return (itoa(curgoal)); return itoa(curgoal);
case EVSEARCH: case EVSEARCH:
return (pat); return pat;
case EVREPLACE: case EVREPLACE:
return (rpat); return rpat;
case EVMATCH: case EVMATCH:
return ((patmatch == NULL) ? "" : patmatch); return (patmatch == NULL) ? "" : patmatch;
case EVKILL: case EVKILL:
return (getkill()); return getkill();
case EVCMODE: case EVCMODE:
return (itoa(curbp->b_mode)); return itoa(curbp->b_mode);
case EVGMODE: case EVGMODE:
return (itoa(gmode)); return itoa(gmode);
case EVTPAUSE: case EVTPAUSE:
return (itoa(term.t_pause)); 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: case EVLWIDTH:
return (itoa(llength(curwp->w_dotp))); return itoa(llength(curwp->w_dotp));
case EVLINE: case EVLINE:
return (getctext()); return getctext();
case EVGFLAGS: case EVGFLAGS:
return (itoa(gflags)); return itoa(gflags);
case EVRVAL: case EVRVAL:
return (itoa(rval)); return itoa(rval);
case EVTAB: case EVTAB:
return (itoa(tabmask + 1)); return itoa(tabmask + 1);
case EVOVERLAP: case EVOVERLAP:
return (itoa(overlap)); return itoa(overlap);
case EVSCROLLCOUNT: case EVSCROLLCOUNT:
return (itoa(scrollcount)); return itoa(scrollcount);
#if SCROLLCODE #if SCROLLCODE
case EVSCROLL: case EVSCROLL:
return (ltos(term.t_scroll != NULL)); return ltos(term.t_scroll != NULL);
#else #else
case EVSCROLL: case EVSCROLL:
return (ltos(0)); return ltos(0);
#endif #endif
} }
exit(-12); /* again, we should never get here */ exit(-12); /* again, we should never get here */
@ -338,7 +338,7 @@ char *getkill(void)
} }
/* and return the constructed value */ /* and return the constructed value */
return (value); return value;
} }
/* /*
@ -362,7 +362,7 @@ int setvar(int f, int n)
if (clexec == FALSE) { if (clexec == FALSE) {
status = mlreply("Variable to set: ", &var[0], NVSIZE); status = mlreply("Variable to set: ", &var[0], NVSIZE);
if (status != TRUE) if (status != TRUE)
return (status); return status;
} else { /* macro line argument */ } else { /* macro line argument */
/* grab token and skip it */ /* grab token and skip it */
execstr = token(execstr, var, NVSIZE + 1); execstr = token(execstr, var, NVSIZE + 1);
@ -374,7 +374,7 @@ int setvar(int f, int n)
/* if its not legal....bitch */ /* if its not legal....bitch */
if (vd.v_type == -1) { if (vd.v_type == -1) {
mlwrite("%%No such variable as '%s'", var); mlwrite("%%No such variable as '%s'", var);
return (FALSE); return FALSE;
} }
/* get the value for that variable */ /* get the value for that variable */
@ -383,7 +383,7 @@ int setvar(int f, int n)
else { else {
status = mlreply("Value: ", &value[0], NSTRING); status = mlreply("Value: ", &value[0], NSTRING);
if (status != TRUE) if (status != TRUE)
return (status); return status;
} }
/* and set the appropriate value */ /* and set the appropriate value */
@ -438,7 +438,7 @@ int setvar(int f, int n)
#endif #endif
/* and return it */ /* and return it */
return (status); return status;
} }
/* /*
@ -526,7 +526,7 @@ int svar(VDESC *var, char *value)
free(uv[vnum].u_value); free(uv[vnum].u_value);
sp = malloc(strlen(value) + 1); sp = malloc(strlen(value) + 1);
if (sp == NULL) if (sp == NULL)
return (FALSE); return FALSE;
strcpy(sp, value); strcpy(sp, value);
uv[vnum].u_value = sp; uv[vnum].u_value = sp;
break; break;
@ -672,7 +672,7 @@ int svar(VDESC *var, char *value)
} }
break; break;
} }
return (status); return status;
} }
/* /*
@ -710,7 +710,7 @@ char *itoa(int i)
*(--sp) = '-'; /* and install the minus sign */ *(--sp) = '-'; /* and install the minus sign */
} }
return (sp); return sp;
} }
/* /*
@ -727,33 +727,33 @@ int gettyp(char *token)
/* no blanks!!! */ /* no blanks!!! */
if (c == 0) if (c == 0)
return (TKNUL); return TKNUL;
/* a numeric literal? */ /* a numeric literal? */
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
return (TKLIT); return TKLIT;
switch (c) { switch (c) {
case '"': case '"':
return (TKSTR); return TKSTR;
case '!': case '!':
return (TKDIR); return TKDIR;
case '@': case '@':
return (TKARG); return TKARG;
case '#': case '#':
return (TKBUF); return TKBUF;
case '$': case '$':
return (TKENV); return TKENV;
case '%': case '%':
return (TKVAR); return TKVAR;
case '&': case '&':
return (TKFUN); return TKFUN;
case '*': case '*':
return (TKLBL); return TKLBL;
default: default:
return (TKCMD); return TKCMD;
} }
} }
@ -772,7 +772,7 @@ char *getval(char *token)
switch (gettyp(token)) { switch (gettyp(token)) {
case TKNUL: case TKNUL:
return (""); return "";
case TKARG: /* interactive argument */ case TKARG: /* interactive argument */
strcpy(token, getval(&token[1])); strcpy(token, getval(&token[1]));
@ -781,8 +781,8 @@ char *getval(char *token)
status = getstring(token, buf, NSTRING, ctoec('\n')); status = getstring(token, buf, NSTRING, ctoec('\n'));
discmd = distmp; discmd = distmp;
if (status == ABORT) if (status == ABORT)
return (errorm); return errorm;
return (buf); return buf;
case TKBUF: /* buffer contents fetch */ case TKBUF: /* buffer contents fetch */
@ -790,7 +790,7 @@ char *getval(char *token)
strcpy(token, getval(&token[1])); strcpy(token, getval(&token[1]));
bp = bfind(token, FALSE, 0); bp = bfind(token, FALSE, 0);
if (bp == NULL) if (bp == NULL)
return (errorm); return errorm;
/* if the buffer is displayed, get the window /* if the buffer is displayed, get the window
vars instead of the buffer vars */ vars instead of the buffer vars */
@ -801,7 +801,7 @@ char *getval(char *token)
/* make sure we are not at the end */ /* make sure we are not at the end */
if (bp->b_linep == bp->b_dotp) if (bp->b_linep == bp->b_dotp)
return (errorm); return errorm;
/* grab the line as an argument */ /* grab the line as an argument */
blen = bp->b_dotp->l_used - bp->b_doto; blen = bp->b_dotp->l_used - bp->b_doto;
@ -822,26 +822,26 @@ char *getval(char *token)
} }
/* and return the spoils */ /* and return the spoils */
return (buf); return buf;
case TKVAR: case TKVAR:
return (gtusr(token + 1)); return gtusr(token + 1);
case TKENV: case TKENV:
return (gtenv(token + 1)); return gtenv(token + 1);
case TKFUN: case TKFUN:
return (gtfun(token + 1)); return gtfun(token + 1);
case TKDIR: case TKDIR:
return (errorm); return errorm;
case TKLBL: case TKLBL:
return (errorm); return errorm;
case TKLIT: case TKLIT:
return (token); return token;
case TKSTR: case TKSTR:
return (token + 1); return token + 1;
case TKCMD: case TKCMD:
return (token); return token;
} }
return (errorm); return errorm;
} }
/* /*
@ -853,12 +853,12 @@ int stol(char *val)
{ {
/* check for logical values */ /* check for logical values */
if (val[0] == 'F') if (val[0] == 'F')
return (FALSE); return FALSE;
if (val[0] == 'T') if (val[0] == 'T')
return (TRUE); return TRUE;
/* check for numeric truth (!= 0) */ /* check for numeric truth (!= 0) */
return ((atoi(val) != 0)); return (atoi(val) != 0);
} }
/* /*
@ -869,9 +869,9 @@ int stol(char *val)
char *ltos(int val) char *ltos(int val)
{ {
if (val) if (val)
return (truem); return truem;
else else
return (falsem); return falsem;
} }
/* /*
@ -889,7 +889,7 @@ char *mkupper(char *str)
*sp += 'A' - 'a'; *sp += 'A' - 'a';
++sp; ++sp;
} }
return (str); return str;
} }
/* /*
@ -907,7 +907,7 @@ char *mklower(char *str)
*sp += 'a' - 'A'; *sp += 'a' - 'A';
++sp; ++sp;
} }
return (str); return str;
} }
/* /*
@ -915,7 +915,7 @@ char *mklower(char *str)
*/ */
int abs(int x) int abs(int x)
{ {
return (x < 0 ? -x : x); return x < 0 ? -x : x;
} }
/* /*
@ -924,7 +924,7 @@ int abs(int x)
int ernd(void) int ernd(void)
{ {
seed = abs(seed * 1721 + 10007); seed = abs(seed * 1721 + 10007);
return (seed); return seed;
} }
/* /*
@ -954,12 +954,12 @@ int sindex(char *source, char *pattern)
/* was it a match? */ /* was it a match? */
if (*cp == 0) if (*cp == 0)
return ((int) (sp - source) + 1); return (int) (sp - source) + 1;
++sp; ++sp;
} }
/* no match at all.. */ /* no match at all.. */
return (0); return 0;
} }
/* /*
@ -998,5 +998,5 @@ char *xlat(char *source, char *lookup, char *trans)
/* terminate and return the result */ /* terminate and return the result */
*rp = 0; *rp = 0;
return (result); return result;
} }

98
exec.c
View File

@ -29,7 +29,7 @@ int namedcmd(int f, int n)
kfunc = getname(); kfunc = getname();
if (kfunc == NULL) { if (kfunc == NULL) {
mlwrite("(No such function)"); mlwrite("(No such function)");
return (FALSE); return FALSE;
} }
/* and then execute the command */ /* and then execute the command */
@ -50,10 +50,10 @@ int execcmd(int f, int n)
/* get the line wanted */ /* get the line wanted */
if ((status = mlreply(": ", cmdstr, NSTRING)) != TRUE) if ((status = mlreply(": ", cmdstr, NSTRING)) != TRUE)
return (status); return status;
execlevel = 0; execlevel = 0;
return (docmd(cmdstr)); return docmd(cmdstr);
} }
/* /*
@ -81,7 +81,7 @@ int docmd(char *cline)
/* if we are scanning and not executing..go back here */ /* if we are scanning and not executing..go back here */
if (execlevel) if (execlevel)
return (TRUE); return TRUE;
oldestr = execstr; /* save last ptr to string to execute */ oldestr = execstr; /* save last ptr to string to execute */
execstr = cline; /* and set this one as current */ execstr = cline; /* and set this one as current */
@ -94,7 +94,7 @@ int docmd(char *cline)
if ((status = macarg(tkn)) != TRUE) { /* and grab the first token */ if ((status = macarg(tkn)) != TRUE) { /* and grab the first token */
execstr = oldestr; execstr = oldestr;
return (status); return status;
} }
/* process leadin argument */ /* process leadin argument */
@ -106,7 +106,7 @@ int docmd(char *cline)
/* and now get the command to execute */ /* and now get the command to execute */
if ((status = macarg(tkn)) != TRUE) { if ((status = macarg(tkn)) != TRUE) {
execstr = oldestr; execstr = oldestr;
return (status); return status;
} }
} }
@ -114,7 +114,7 @@ int docmd(char *cline)
if ((fnc = fncmatch(tkn)) == NULL) { if ((fnc = fncmatch(tkn)) == NULL) {
mlwrite("(No such Function)"); mlwrite("(No such Function)");
execstr = oldestr; execstr = oldestr;
return (FALSE); return FALSE;
} }
/* save the arguments and go execute the command */ /* save the arguments and go execute the command */
@ -124,7 +124,7 @@ int docmd(char *cline)
cmdstatus = status; /* save the status */ cmdstatus = status; /* save the status */
clexec = oldcle; /* restore clexec flag */ clexec = oldcle; /* restore clexec flag */
execstr = oldestr; execstr = oldestr;
return (status); return status;
} }
/* /*
@ -199,7 +199,7 @@ char *token(char *src, char *tok, int size)
if (*src) if (*src)
++src; ++src;
*tok = 0; *tok = 0;
return (src); return src;
} }
/* /*
@ -216,7 +216,7 @@ int macarg(char *tok)
clexec = TRUE; /* get the argument */ clexec = TRUE; /* get the argument */
status = nextarg("", tok, NSTRING, ctoec('\n')); status = nextarg("", tok, NSTRING, ctoec('\n'));
clexec = savcle; /* restore execution mode */ clexec = savcle; /* restore execution mode */
return (status); return status;
} }
/* /*
@ -232,14 +232,14 @@ int nextarg(char *prompt, char *buffer, int size, int terminator)
{ {
/* if we are interactive, go get it! */ /* if we are interactive, go get it! */
if (clexec == FALSE) if (clexec == FALSE)
return (getstring(prompt, buffer, size, terminator)); return getstring(prompt, buffer, size, terminator);
/* grab token and advance past */ /* grab token and advance past */
execstr = token(execstr, buffer, size); execstr = token(execstr, buffer, size);
/* evaluate it */ /* evaluate it */
strcpy(buffer, getval(buffer)); strcpy(buffer, getval(buffer));
return (TRUE); return TRUE;
} }
/* /*
@ -258,13 +258,13 @@ int storemac(int f, int n)
/* must have a numeric argument to this function */ /* must have a numeric argument to this function */
if (f == FALSE) { if (f == FALSE) {
mlwrite("No macro specified"); mlwrite("No macro specified");
return (FALSE); return FALSE;
} }
/* range check the macro number */ /* range check the macro number */
if (n < 1 || n > 40) { if (n < 1 || n > 40) {
mlwrite("Macro number out of range"); mlwrite("Macro number out of range");
return (FALSE); return FALSE;
} }
/* construct the macro buffer name */ /* construct the macro buffer name */
@ -275,7 +275,7 @@ int storemac(int f, int n)
/* set up the new macro buffer */ /* set up the new macro buffer */
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) { if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
mlwrite("Can not create macro"); mlwrite("Can not create macro");
return (FALSE); return FALSE;
} }
/* and make sure it is empty */ /* and make sure it is empty */
@ -284,7 +284,7 @@ int storemac(int f, int n)
/* and set the macro store pointers to it */ /* and set the macro store pointers to it */
mstore = TRUE; mstore = TRUE;
bstore = bp; bstore = bp;
return (TRUE); return TRUE;
} }
#if PROC #if PROC
@ -304,12 +304,12 @@ int storeproc(int f, int n)
/* a numeric argument means its a numbered macro */ /* a numeric argument means its a numbered macro */
if (f == TRUE) if (f == TRUE)
return (storemac(f, n)); return storemac(f, n);
/* get the name of the procedure */ /* get the name of the procedure */
if ((status = if ((status =
mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE) mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE)
return (status); return status;
/* construct the macro buffer name */ /* construct the macro buffer name */
bname[0] = '*'; bname[0] = '*';
@ -318,7 +318,7 @@ int storeproc(int f, int n)
/* set up the new macro buffer */ /* set up the new macro buffer */
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) { if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
mlwrite("Can not create macro"); mlwrite("Can not create macro");
return (FALSE); return FALSE;
} }
/* and make sure it is empty */ /* and make sure it is empty */
@ -327,7 +327,7 @@ int storeproc(int f, int n)
/* and set the macro store pointers to it */ /* and set the macro store pointers to it */
mstore = TRUE; mstore = TRUE;
bstore = bp; bstore = bp;
return (TRUE); return TRUE;
} }
/* /*
@ -345,7 +345,7 @@ int execproc(int f, int n)
/* find out what buffer the user wants to execute */ /* find out what buffer the user wants to execute */
if ((status = if ((status =
mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE) mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE)
return (status); return status;
/* construct the buffer name */ /* construct the buffer name */
bufn[0] = '*'; bufn[0] = '*';
@ -354,14 +354,14 @@ int execproc(int f, int n)
/* find the pointer to that buffer */ /* find the pointer to that buffer */
if ((bp = bfind(bufn, FALSE, 0)) == NULL) { if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
mlwrite("No such procedure"); mlwrite("No such procedure");
return (FALSE); return FALSE;
} }
/* and now execute it as asked */ /* and now execute it as asked */
while (n-- > 0) while (n-- > 0)
if ((status = dobuf(bp)) != TRUE) if ((status = dobuf(bp)) != TRUE)
return (status); return status;
return (TRUE); return TRUE;
} }
#endif #endif
@ -379,19 +379,19 @@ int execbuf(int f, int n)
/* find out what buffer the user wants to execute */ /* find out what buffer the user wants to execute */
if ((status = mlreply("Execute buffer: ", bufn, NBUFN)) != TRUE) if ((status = mlreply("Execute buffer: ", bufn, NBUFN)) != TRUE)
return (status); return status;
/* find the pointer to that buffer */ /* find the pointer to that buffer */
if ((bp = bfind(bufn, FALSE, 0)) == NULL) { if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
mlwrite("No such buffer"); mlwrite("No such buffer");
return (FALSE); return FALSE;
} }
/* and now execute it as asked */ /* and now execute it as asked */
while (n-- > 0) while (n-- > 0)
if ((status = dobuf(bp)) != TRUE) if ((status = dobuf(bp)) != TRUE)
return (status); return status;
return (TRUE); return TRUE;
} }
/* /*
@ -472,7 +472,7 @@ int dobuf(struct buffer *bp)
failexit:freewhile failexit:freewhile
(scanner); (scanner);
freewhile(whlist); freewhile(whlist);
return (FALSE); return FALSE;
} }
whtemp->w_begin = lp; whtemp->w_begin = lp;
whtemp->w_type = BTWHILE; whtemp->w_type = BTWHILE;
@ -539,7 +539,7 @@ int dobuf(struct buffer *bp)
if ((einit = eline = malloc(linlen + 1)) == NULL) { if ((einit = eline = malloc(linlen + 1)) == NULL) {
mlwrite("%%Out of Memory during macro execution"); mlwrite("%%Out of Memory during macro execution");
freewhile(whlist); freewhile(whlist);
return (FALSE); return FALSE;
} }
strncpy(eline, lp->l_text, linlen); strncpy(eline, lp->l_text, linlen);
eline[linlen] = 0; /* make sure it ends */ eline[linlen] = 0; /* make sure it ends */
@ -597,7 +597,7 @@ int dobuf(struct buffer *bp)
if ((c = get1key()) == abortc) { if ((c = get1key()) == abortc) {
mlforce("(Macro aborted)"); mlforce("(Macro aborted)");
freewhile(whlist); freewhile(whlist);
return (FALSE); return FALSE;
} }
if (c == metac) if (c == metac)
@ -619,7 +619,7 @@ int dobuf(struct buffer *bp)
if (dirnum == NUMDIRS) { if (dirnum == NUMDIRS) {
mlwrite("%%Unknown Directive"); mlwrite("%%Unknown Directive");
freewhile(whlist); freewhile(whlist);
return (FALSE); return FALSE;
} }
/* service only the !ENDM macro here */ /* service only the !ENDM macro here */
@ -640,7 +640,7 @@ int dobuf(struct buffer *bp)
if ((mp = lalloc(linlen)) == NULL) { if ((mp = lalloc(linlen)) == NULL) {
mlwrite mlwrite
("Out of memory while storing macro"); ("Out of memory while storing macro");
return (FALSE); return FALSE;
} }
/* copy the text into the new line */ /* copy the text into the new line */
@ -708,7 +708,7 @@ int dobuf(struct buffer *bp)
mlwrite mlwrite
("%%Internal While loop error"); ("%%Internal While loop error");
freewhile(whlist); freewhile(whlist);
return (FALSE); return FALSE;
} }
/* reset the line pointer back.. */ /* reset the line pointer back.. */
@ -749,7 +749,7 @@ int dobuf(struct buffer *bp)
} }
mlwrite("%%No such label"); mlwrite("%%No such label");
freewhile(whlist); freewhile(whlist);
return (FALSE); return FALSE;
} }
goto onward; goto onward;
@ -777,7 +777,7 @@ int dobuf(struct buffer *bp)
mlwrite mlwrite
("%%Internal While loop error"); ("%%Internal While loop error");
freewhile(whlist); freewhile(whlist);
return (FALSE); return FALSE;
} }
/* reset the line pointer back.. */ /* reset the line pointer back.. */
@ -815,7 +815,7 @@ int dobuf(struct buffer *bp)
free(einit); free(einit);
execlevel = 0; execlevel = 0;
freewhile(whlist); freewhile(whlist);
return (status); return status;
} }
onward: /* on to the next line */ onward: /* on to the next line */
@ -826,7 +826,7 @@ int dobuf(struct buffer *bp)
eexec: /* exit the current function */ eexec: /* exit the current function */
execlevel = 0; execlevel = 0;
freewhile(whlist); freewhile(whlist);
return (TRUE); return TRUE;
} }
/* /*
@ -856,7 +856,7 @@ int execfile(int f, int n)
if ((status = if ((status =
mlreply("File to execute: ", fname, NSTRING - 1)) != TRUE) mlreply("File to execute: ", fname, NSTRING - 1)) != TRUE)
return (status); return status;
#if 1 #if 1
/* look up the path for the file */ /* look up the path for the file */
@ -864,15 +864,15 @@ int execfile(int f, int n)
/* if it isn't around */ /* if it isn't around */
if (fspec == NULL) if (fspec == NULL)
return (FALSE); return FALSE;
#endif #endif
/* otherwise, execute it */ /* otherwise, execute it */
while (n-- > 0) while (n-- > 0)
if ((status = dofile(fspec)) != TRUE) if ((status = dofile(fspec)) != TRUE)
return (status); return status;
return (TRUE); return TRUE;
} }
/* /*
@ -892,7 +892,7 @@ int dofile(char *fname)
makename(bname, fname); /* derive the name of the buffer */ makename(bname, fname); /* derive the name of the buffer */
unqname(bname); /* make sure we don't stomp things */ unqname(bname); /* make sure we don't stomp things */
if ((bp = bfind(bname, TRUE, 0)) == NULL) /* get the needed buffer */ if ((bp = bfind(bname, TRUE, 0)) == NULL) /* get the needed buffer */
return (FALSE); return FALSE;
bp->b_mode = MDVIEW; /* mark the buffer as read only */ bp->b_mode = MDVIEW; /* mark the buffer as read only */
cb = curbp; /* save the old buffer */ cb = curbp; /* save the old buffer */
@ -900,18 +900,18 @@ int dofile(char *fname)
/* and try to read in the file to execute */ /* and try to read in the file to execute */
if ((status = readin(fname, FALSE)) != TRUE) { if ((status = readin(fname, FALSE)) != TRUE) {
curbp = cb; /* restore the current buffer */ curbp = cb; /* restore the current buffer */
return (status); return status;
} }
/* go execute it! */ /* go execute it! */
curbp = cb; /* restore the current buffer */ curbp = cb; /* restore the current buffer */
if ((status = dobuf(bp)) != TRUE) if ((status = dobuf(bp)) != TRUE)
return (status); return status;
/* if not displayed, remove the now unneeded buffer and exit */ /* if not displayed, remove the now unneeded buffer and exit */
if (bp->b_nwnd == 0) if (bp->b_nwnd == 0)
zotbuf(bp); zotbuf(bp);
return (TRUE); return TRUE;
} }
/* /*
@ -934,14 +934,14 @@ int cbuf(int f, int n, int bufnum)
/* find the pointer to that buffer */ /* find the pointer to that buffer */
if ((bp = bfind(bufname, FALSE, 0)) == NULL) { if ((bp = bfind(bufname, FALSE, 0)) == NULL) {
mlwrite("Macro not defined"); mlwrite("Macro not defined");
return (FALSE); return FALSE;
} }
/* and now execute it as asked */ /* and now execute it as asked */
while (n-- > 0) while (n-- > 0)
if ((status = dobuf(bp)) != TRUE) if ((status = dobuf(bp)) != TRUE)
return (status); return status;
return (TRUE); return TRUE;
} }
int cbuf1(int f, int n) int cbuf1(int f, int n)

88
file.c
View File

@ -26,10 +26,10 @@ int fileread(int f, int n)
char fname[NFILEN]; char fname[NFILEN];
if (restflag) /* don't allow this command if restricted */ if (restflag) /* don't allow this command if restricted */
return (resterr()); return resterr();
if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE) if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE)
return (s); return s;
return (readin(fname, TRUE)); return readin(fname, TRUE);
} }
/* /*
@ -45,14 +45,14 @@ int insfile(int f, int n)
char fname[NFILEN]; char fname[NFILEN];
if (restflag) /* don't allow this command if restricted */ if (restflag) /* don't allow this command if restricted */
return (resterr()); return resterr();
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if ((s = mlreply("Insert file: ", fname, NFILEN)) != TRUE) if ((s = mlreply("Insert file: ", fname, NFILEN)) != TRUE)
return (s); return s;
if ((s = ifile(fname)) != TRUE) if ((s = ifile(fname)) != TRUE)
return (s); return s;
return (reposition(TRUE, -1)); return reposition(TRUE, -1);
} }
/* /*
@ -70,10 +70,10 @@ int filefind(int f, int n)
int s; /* status return */ int s; /* status return */
if (restflag) /* don't allow this command if restricted */ if (restflag) /* don't allow this command if restricted */
return (resterr()); return resterr();
if ((s = mlreply("Find file: ", fname, NFILEN)) != TRUE) if ((s = mlreply("Find file: ", fname, NFILEN)) != TRUE)
return (s); return s;
return (getfile(fname, TRUE)); return getfile(fname, TRUE);
} }
int viewfile(int f, int n) int viewfile(int f, int n)
@ -83,9 +83,9 @@ int viewfile(int f, int n)
struct window *wp; /* scan for windows that need updating */ struct window *wp; /* scan for windows that need updating */
if (restflag) /* don't allow this command if restricted */ if (restflag) /* don't allow this command if restricted */
return (resterr()); return resterr();
if ((s = mlreply("View file: ", fname, NFILEN)) != TRUE) if ((s = mlreply("View file: ", fname, NFILEN)) != TRUE)
return (s); return s;
s = getfile(fname, FALSE); s = getfile(fname, FALSE);
if (s) { /* if we succeed, put it in view mode */ if (s) { /* if we succeed, put it in view mode */
curwp->w_bufp->b_mode |= MDVIEW; curwp->w_bufp->b_mode |= MDVIEW;
@ -97,7 +97,7 @@ int viewfile(int f, int n)
wp = wp->w_wndp; wp = wp->w_wndp;
} }
} }
return (s); return s;
} }
#if CRYPT #if CRYPT
@ -113,7 +113,7 @@ static int resetkey(void)
if (curbp->b_key[0] == 0) { if (curbp->b_key[0] == 0) {
s = set_encryption_key(FALSE, 0); s = set_encryption_key(FALSE, 0);
if (s != TRUE) if (s != TRUE)
return (s); return s;
} }
/* let others know... */ /* let others know... */
@ -129,7 +129,7 @@ static int resetkey(void)
myencrypt(curbp->b_key, strlen(curbp->b_key)); myencrypt(curbp->b_key, strlen(curbp->b_key));
} }
return (TRUE); return TRUE;
} }
#endif #endif
@ -162,7 +162,7 @@ int getfile(char *fname, int lockfl)
curwp->w_flag |= WFMODE | WFHARD; curwp->w_flag |= WFMODE | WFHARD;
cknewwindow(); cknewwindow();
mlwrite("(Old buffer)"); mlwrite("(Old buffer)");
return (TRUE); return TRUE;
} }
} }
makename(bname, fname); /* New buffer name. */ makename(bname, fname); /* New buffer name. */
@ -170,7 +170,7 @@ int getfile(char *fname, int lockfl)
/* old buffer name conflict code */ /* old buffer name conflict code */
s = mlreply("Buffer name: ", bname, NBUFN); s = mlreply("Buffer name: ", bname, NBUFN);
if (s == ABORT) /* ^G to just quit */ if (s == ABORT) /* ^G to just quit */
return (s); return s;
if (s == FALSE) { /* CR to clobber it */ if (s == FALSE) { /* CR to clobber it */
makename(bname, fname); makename(bname, fname);
break; break;
@ -178,7 +178,7 @@ int getfile(char *fname, int lockfl)
} }
if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) { if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) {
mlwrite("Cannot create buffer"); mlwrite("Cannot create buffer");
return (FALSE); return FALSE;
} }
if (--curbp->b_nwnd == 0) { /* Undisplay. */ if (--curbp->b_nwnd == 0) { /* Undisplay. */
curbp->b_dotp = curwp->w_dotp; curbp->b_dotp = curwp->w_dotp;
@ -228,17 +228,17 @@ int readin(char *fname, int lockfl)
goto out; goto out;
} }
#else #else
return (ABORT); return ABORT;
#endif #endif
#endif #endif
#if CRYPT #if CRYPT
s = resetkey(); s = resetkey();
if (s != TRUE) if (s != TRUE)
return (s); return s;
#endif #endif
bp = curbp; /* Cheap. */ bp = curbp; /* Cheap. */
if ((s = bclear(bp)) != TRUE) /* Might be old. */ if ((s = bclear(bp)) != TRUE) /* Might be old. */
return (s); return s;
bp->b_flag &= ~(BFINVS | BFCHG); bp->b_flag &= ~(BFINVS | BFCHG);
strcpy(bp->b_fname, fname); strcpy(bp->b_fname, fname);
@ -310,12 +310,12 @@ int readin(char *fname, int lockfl)
} }
} }
if (s == FIOERR || s == FIOFNF) /* False if error. */ if (s == FIOERR || s == FIOFNF) /* False if error. */
return (FALSE); return FALSE;
#if 0 #if 0
if (s == ABORT) if (s == ABORT)
return (ABORT); return ABORT;
#endif #endif
return (TRUE); return TRUE;
} }
/* /*
@ -398,9 +398,9 @@ int filewrite(int f, int n)
char fname[NFILEN]; char fname[NFILEN];
if (restflag) /* don't allow this command if restricted */ if (restflag) /* don't allow this command if restricted */
return (resterr()); return resterr();
if ((s = mlreply("Write file: ", fname, NFILEN)) != TRUE) if ((s = mlreply("Write file: ", fname, NFILEN)) != TRUE)
return (s); return s;
if ((s = writeout(fname)) == TRUE) { if ((s = writeout(fname)) == TRUE) {
strcpy(curbp->b_fname, fname); strcpy(curbp->b_fname, fname);
curbp->b_flag &= ~BFCHG; curbp->b_flag &= ~BFCHG;
@ -411,7 +411,7 @@ int filewrite(int f, int n)
wp = wp->w_wndp; wp = wp->w_wndp;
} }
} }
return (s); return s;
} }
/* /*
@ -428,19 +428,19 @@ int filesave(int f, int n)
int s; int s;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */ if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */
return (TRUE); return TRUE;
if (curbp->b_fname[0] == 0) { /* Must have a name. */ if (curbp->b_fname[0] == 0) { /* Must have a name. */
mlwrite("No file name"); mlwrite("No file name");
return (FALSE); return FALSE;
} }
/* complain about truncated files */ /* complain about truncated files */
if ((curbp->b_flag & BFTRUNC) != 0) { if ((curbp->b_flag & BFTRUNC) != 0) {
if (mlyesno("Truncated file ... write it out") == FALSE) { if (mlyesno("Truncated file ... write it out") == FALSE) {
mlwrite("(Aborted)"); mlwrite("(Aborted)");
return (FALSE); return FALSE;
} }
} }
@ -453,7 +453,7 @@ int filesave(int f, int n)
wp = wp->w_wndp; wp = wp->w_wndp;
} }
} }
return (s); return s;
} }
/* /*
@ -473,14 +473,14 @@ int writeout(char *fn)
#if CRYPT #if CRYPT
s = resetkey(); s = resetkey();
if (s != TRUE) if (s != TRUE)
return (s); return s;
#endif #endif
/* turn off ALL keyboard translation in case we get a dos error */ /* turn off ALL keyboard translation in case we get a dos error */
TTkclose(); TTkclose();
if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */ if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */
TTkopen(); TTkopen();
return (FALSE); return FALSE;
} }
mlwrite("(Writing...)"); /* tell us were writing */ mlwrite("(Writing...)"); /* tell us were writing */
lp = lforw(curbp->b_linep); /* First line. */ lp = lforw(curbp->b_linep); /* First line. */
@ -503,8 +503,8 @@ int writeout(char *fn)
ffclose(); /* if a write error. */ ffclose(); /* if a write error. */
TTkopen(); TTkopen();
if (s != FIOSUC) /* Some sort of error. */ if (s != FIOSUC) /* Some sort of error. */
return (FALSE); return FALSE;
return (TRUE); return TRUE;
} }
/* /*
@ -523,9 +523,9 @@ int filename(int f, int n)
char fname[NFILEN]; char fname[NFILEN];
if (restflag) /* don't allow this command if restricted */ if (restflag) /* don't allow this command if restricted */
return (resterr()); return resterr();
if ((s = mlreply("Name: ", fname, NFILEN)) == ABORT) if ((s = mlreply("Name: ", fname, NFILEN)) == ABORT)
return (s); return s;
if (s == FALSE) if (s == FALSE)
strcpy(curbp->b_fname, ""); strcpy(curbp->b_fname, "");
else else
@ -537,7 +537,7 @@ int filename(int f, int n)
wp = wp->w_wndp; wp = wp->w_wndp;
} }
curbp->b_mode &= ~MDVIEW; /* no longer read only mode */ curbp->b_mode &= ~MDVIEW; /* no longer read only mode */
return (TRUE); return TRUE;
} }
/* /*
@ -565,14 +565,14 @@ int ifile(char *fname)
goto out; goto out;
if (s == FIOFNF) { /* File not found. */ if (s == FIOFNF) { /* File not found. */
mlwrite("(No such file)"); mlwrite("(No such file)");
return (FALSE); return FALSE;
} }
mlwrite("(Inserting file)"); mlwrite("(Inserting file)");
#if CRYPT #if CRYPT
s = resetkey(); s = resetkey();
if (s != TRUE) if (s != TRUE)
return (s); return s;
#endif #endif
/* back up a line and save the mark here */ /* back up a line and save the mark here */
curwp->w_dotp = lback(curwp->w_dotp); curwp->w_dotp = lback(curwp->w_dotp);
@ -632,6 +632,6 @@ int ifile(char *fname)
curbp->b_marko = curwp->w_marko; curbp->b_marko = curwp->w_marko;
if (s == FIOERR) /* False if error. */ if (s == FIOERR) /* False if error. */
return (FALSE); return FALSE;
return (TRUE); return TRUE;
} }

View File

@ -20,9 +20,9 @@ static int eofflag; /* end-of-file flag */
int ffropen(char *fn) int ffropen(char *fn)
{ {
if ((ffp = fopen(fn, "r")) == NULL) if ((ffp = fopen(fn, "r")) == NULL)
return (FIOFNF); return FIOFNF;
eofflag = FALSE; eofflag = FALSE;
return (FIOSUC); return FIOSUC;
} }
/* /*
@ -40,9 +40,9 @@ int ffwopen(char *fn)
if ((ffp = fopen(fn, "w")) == NULL) { if ((ffp = fopen(fn, "w")) == NULL) {
#endif #endif
mlwrite("Cannot open file for writing"); mlwrite("Cannot open file for writing");
return (FIOERR); return FIOERR;
} }
return (FIOSUC); return FIOSUC;
} }
/* /*
@ -64,12 +64,12 @@ int ffclose(void)
#if V7 | USG | BSD | (MSDOS & (MSC | TURBO)) #if V7 | USG | BSD | (MSDOS & (MSC | TURBO))
if (fclose(ffp) != FALSE) { if (fclose(ffp) != FALSE) {
mlwrite("Error closing file"); mlwrite("Error closing file");
return (FIOERR); return FIOERR;
} }
return (FIOSUC); return FIOSUC;
#else #else
fclose(ffp); fclose(ffp);
return (FIOSUC); return FIOSUC;
#endif #endif
} }
@ -102,10 +102,10 @@ int ffputline(char *buf, int nbuf)
if (ferror(ffp)) { if (ferror(ffp)) {
mlwrite("Write I/O error"); mlwrite("Write I/O error");
return (FIOERR); return FIOERR;
} }
return (FIOSUC); return FIOSUC;
} }
/* /*
@ -122,7 +122,7 @@ int ffgetline(void)
/* if we are at the end...return it */ /* if we are at the end...return it */
if (eofflag) if (eofflag)
return (FIOEOF); return FIOEOF;
/* dump fline if it ended up too big */ /* dump fline if it ended up too big */
if (flen > NSTRING) { if (flen > NSTRING) {
@ -133,7 +133,7 @@ int ffgetline(void)
/* if we don't have an fline, allocate one */ /* if we don't have an fline, allocate one */
if (fline == NULL) if (fline == NULL)
if ((fline = malloc(flen = NSTRING)) == NULL) if ((fline = malloc(flen = NSTRING)) == NULL)
return (FIOMEM); return FIOMEM;
/* read the line in */ /* read the line in */
#if PKCODE #if PKCODE
@ -166,7 +166,7 @@ int ffgetline(void)
if (i >= flen) { if (i >= flen) {
if ((tmpline = if ((tmpline =
malloc(flen + NSTRING)) == NULL) malloc(flen + NSTRING)) == NULL)
return (FIOMEM); return FIOMEM;
strncpy(tmpline, fline, flen); strncpy(tmpline, fline, flen);
flen += NSTRING; flen += NSTRING;
free(fline); free(fline);
@ -182,13 +182,13 @@ int ffgetline(void)
if (c == EOF) { if (c == EOF) {
if (ferror(ffp)) { if (ferror(ffp)) {
mlwrite("File read error"); mlwrite("File read error");
return (FIOERR); return FIOERR;
} }
if (i != 0) if (i != 0)
eofflag = TRUE; eofflag = TRUE;
else else
return (FIOEOF); return FIOEOF;
} }
/* terminate and decrypt the string */ /* terminate and decrypt the string */
@ -197,7 +197,7 @@ int ffgetline(void)
if (cryptflag) if (cryptflag)
myencrypt(fline, strlen(fline)); myencrypt(fline, strlen(fline));
#endif #endif
return (FIOSUC); return FIOSUC;
} }
/* /*
@ -214,9 +214,9 @@ int fexist(char *fname)
/* if it fails, just return false! */ /* if it fails, just return false! */
if (fp == NULL) if (fp == NULL)
return (FALSE); return FALSE;
/* otherwise, close it and report true */ /* otherwise, close it and report true */
fclose(fp); fclose(fp);
return (TRUE); return TRUE;
} }

View File

@ -348,11 +348,11 @@ static int scinit(int type)
/* if we have nothing to do....don't do it */ /* if we have nothing to do....don't do it */
if (dtype == type) if (dtype == type)
return (TRUE); return TRUE;
/* if we try to switch to EGA and there is none, don't */ /* if we try to switch to EGA and there is none, don't */
if (type == CDEGA && egaexist != TRUE) if (type == CDEGA && egaexist != TRUE)
return (FALSE); return FALSE;
/* if we had the EGA open... close it */ /* if we had the EGA open... close it */
if (dtype == CDEGA) if (dtype == CDEGA)
@ -395,7 +395,7 @@ static int scinit(int type)
addr.laddr = scadd + (long) (NCOL * i * 2); addr.laddr = scadd + (long) (NCOL * i * 2);
scptr[i] = addr.paddr; scptr[i] = addr.paddr;
} }
return (TRUE); return TRUE;
} }
/* getboard: Determine which type of display board is attached. /* getboard: Determine which type of display board is attached.
@ -425,7 +425,7 @@ int getboard(void)
rg.x.bx = 0xff10; rg.x.bx = 0xff10;
int86(0x10, &rg, &rg); /* If EGA, bh=0-1 and bl=0-3 */ int86(0x10, &rg, &rg); /* If EGA, bh=0-1 and bl=0-3 */
egaexist = !(rg.x.bx & 0xfefc); /* Yes, it's EGA */ egaexist = !(rg.x.bx & 0xfefc); /* Yes, it's EGA */
return (type); return type;
} }
/* init the computer to work with the EGA */ /* init the computer to work with the EGA */

52
input.c
View File

@ -44,13 +44,13 @@ int mlyesno(char *prompt)
c = tgetc(); c = tgetc();
if (c == ectoc(abortc)) /* Bail out! */ if (c == ectoc(abortc)) /* Bail out! */
return (ABORT); return ABORT;
if (c == 'y' || c == 'Y') if (c == 'y' || c == 'Y')
return (TRUE); return TRUE;
if (c == 'n' || c == 'N') if (c == 'n' || c == 'N')
return (FALSE); return FALSE;
} }
} }
@ -64,12 +64,12 @@ int mlyesno(char *prompt)
int mlreply(char *prompt, char *buf, int nbuf) int mlreply(char *prompt, char *buf, int nbuf)
{ {
return (nextarg(prompt, buf, nbuf, ctoec('\n'))); return nextarg(prompt, buf, nbuf, ctoec('\n'));
} }
int mlreplyt(char *prompt, char *buf, int nbuf, int eolchar) int mlreplyt(char *prompt, char *buf, int nbuf, int eolchar)
{ {
return (nextarg(prompt, buf, nbuf, eolchar)); return nextarg(prompt, buf, nbuf, eolchar);
} }
/* /*
@ -83,7 +83,7 @@ int ectoc(int c)
c = c & ~(CONTROL | 0x40); c = c & ~(CONTROL | 0x40);
if (c & SPEC) if (c & SPEC)
c = c & 255; c = c & 255;
return (c); return c;
} }
/* /*
@ -95,7 +95,7 @@ int ctoec(int c)
{ {
if (c >= 0x00 && c <= 0x1F) if (c >= 0x00 && c <= 0x1F)
c = CONTROL | (c + '@'); c = CONTROL | (c + '@');
return (c); return c;
} }
/* /*
@ -120,7 +120,7 @@ fn_t getname(void)
if (clexec) { if (clexec) {
if (macarg(buf) != TRUE) if (macarg(buf) != TRUE)
return NULL; return NULL;
return (fncmatch(&buf[0])); return fncmatch(&buf[0]);
} }
/* build a name string from the keyboard */ /* build a name string from the keyboard */
@ -132,7 +132,7 @@ fn_t getname(void)
buf[cpos] = 0; buf[cpos] = 0;
/* and match it off */ /* and match it off */
return (fncmatch(&buf[0])); return fncmatch(&buf[0]);
} else if (c == ectoc(abortc)) { /* Bell, abort */ } else if (c == ectoc(abortc)) { /* Bell, abort */
ctrlg(FALSE, 0); ctrlg(FALSE, 0);
@ -178,7 +178,7 @@ fn_t getname(void)
while (*sp) while (*sp)
TTputc(*sp++); TTputc(*sp++);
TTflush(); TTflush();
return (ffp->n_func); return ffp->n_func;
} else { } else {
/* << << << << << << << << << << << << << << << << << */ /* << << << << << << << << << << << << << << << << << */
/* try for a partial match against the list */ /* try for a partial match against the list */
@ -258,7 +258,7 @@ int tgetc(void)
/* if there is some left... */ /* if there is some left... */
if (kbdptr < kbdend) if (kbdptr < kbdend)
return ((int) *kbdptr++); return (int) *kbdptr++;
/* at the end of last repitition? */ /* at the end of last repitition? */
if (--kbdrep < 1) { if (--kbdrep < 1) {
@ -271,7 +271,7 @@ int tgetc(void)
/* reset the macro to the begining for the next rep */ /* reset the macro to the begining for the next rep */
kbdptr = &kbdm[0]; kbdptr = &kbdm[0];
return ((int) *kbdptr++); return (int) *kbdptr++;
} }
} }
@ -294,7 +294,7 @@ int tgetc(void)
} }
/* and finally give the char back */ /* and finally give the char back */
return (c); return c;
} }
/* GET1KEY: Get one keystroke. The only prefixs legal here /* GET1KEY: Get one keystroke. The only prefixs legal here
@ -313,13 +313,13 @@ int get1key(void)
c = tgetc(); c = tgetc();
if (c >= 0x00 && c <= 0x1F) /* control key? */ if (c >= 0x00 && c <= 0x1F) /* control key? */
c = CONTROL | (c + '@'); c = CONTROL | (c + '@');
return (SPEC | c); return SPEC | c;
} }
#endif #endif
if (c >= 0x00 && c <= 0x1F) /* C0 control -> C- */ if (c >= 0x00 && c <= 0x1F) /* C0 control -> C- */
c = CONTROL | (c + '@'); c = CONTROL | (c + '@');
return (c); return c;
} }
/* GETCMD: Get a command from the keyboard. Process all applicable /* GETCMD: Get a command from the keyboard. Process all applicable
@ -348,12 +348,12 @@ int getcmd(void)
handle_CSI: handle_CSI:
c = get1key(); c = get1key();
if (c >= 'A' && c <= 'D') if (c >= 'A' && c <= 'D')
return (SPEC | c | cmask); return SPEC | c | cmask;
if (c >= 'E' && c <= 'z' && c != 'i' && c != 'c') if (c >= 'E' && c <= 'z' && c != 'i' && c != 'c')
return (SPEC | c | cmask); return SPEC | c | cmask;
d = get1key(); d = get1key();
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': case '1':
c = d + 32; c = d + 32;
@ -376,7 +376,7 @@ handle_CSI:
} 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;
} }
#endif #endif
#if VT220 #if VT220
@ -389,7 +389,7 @@ handle_CSI:
c ^= DIFCASE; c ^= DIFCASE;
if (c >= 0x00 && c <= 0x1F) /* control key */ if (c >= 0x00 && c <= 0x1F) /* control key */
c = CONTROL | (c + '@'); c = CONTROL | (c + '@');
return (META | c); return META | c;
} }
#if PKCODE #if PKCODE
else if (c == metac) { else if (c == metac) {
@ -404,7 +404,7 @@ handle_CSI:
c ^= DIFCASE; c ^= DIFCASE;
if (c >= 0x00 && c <= 0x1F) /* control key */ if (c >= 0x00 && c <= 0x1F) /* control key */
c = CONTROL | (c + '@'); c = CONTROL | (c + '@');
return (META | c); return META | c;
} }
#endif #endif
@ -425,11 +425,11 @@ handle_CSI:
c -= 0x20; c -= 0x20;
if (c >= 0x00 && c <= 0x1F) /* control key */ if (c >= 0x00 && c <= 0x1F) /* control key */
c = CONTROL | (c + '@'); c = CONTROL | (c + '@');
return (CTLX | c); return CTLX | c;
} }
/* otherwise, just return it */ /* otherwise, just return it */
return (c); return c;
} }
/* A more generalized prompt/reply function allowing the caller /* A more generalized prompt/reply function allowing the caller
@ -492,9 +492,9 @@ int getstring(char *prompt, char *buf, int nbuf, int eolchar)
/* if we default the buffer, return FALSE */ /* if we default the buffer, return FALSE */
if (buf[0] == 0) if (buf[0] == 0)
return (FALSE); return FALSE;
return (TRUE); return TRUE;
} }
/* change from command form back to character form */ /* change from command form back to character form */
@ -504,7 +504,7 @@ int getstring(char *prompt, char *buf, int nbuf, int eolchar)
/* Abort the input? */ /* Abort the input? */
ctrlg(FALSE, 0); ctrlg(FALSE, 0);
TTflush(); TTflush();
return (ABORT); return ABORT;
} else if ((c == 0x7F || c == 0x08) && quotef == FALSE) { } else if ((c == 0x7F || c == 0x08) && quotef == FALSE) {
/* rubout/erase */ /* rubout/erase */
if (cpos != 0) { if (cpos != 0) {

View File

@ -75,7 +75,7 @@ int risearch(int f, int n)
#if PKCODE #if PKCODE
matchlen = strlen(pat); matchlen = strlen(pat);
#endif #endif
return (TRUE); return TRUE;
} }
/* /*
@ -107,7 +107,7 @@ int fisearch(int f, int n)
#if PKCODE #if PKCODE
matchlen = strlen(pat); matchlen = strlen(pat);
#endif #endif
return (TRUE); return TRUE;
} }
/* /*
@ -193,11 +193,11 @@ int isearch(int f, int n)
/* 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 */
case IS_REVERSE: /* If backward search */ case IS_REVERSE: /* If backward search */
case IS_FORWARD: /* If forward search */ case IS_FORWARD: /* If forward search */
@ -225,7 +225,7 @@ int isearch(int f, int n)
case IS_BACKSP: /* If a backspace: */ case IS_BACKSP: /* If a backspace: */
case IS_RUBOUT: /* or if a Rubout: */ case IS_RUBOUT: /* or if a Rubout: */
if (cmd_offset <= 1) /* Anything to delete? */ if (cmd_offset <= 1) /* Anything to delete? */
return (TRUE); /* No, just exit */ return TRUE; /* No, just exit */
--cmd_offset; /* Back up over the Rubout */ --cmd_offset; /* Back up over the Rubout */
cmd_buff[--cmd_offset] = '\0'; /* Yes, delete last char */ cmd_buff[--cmd_offset] = '\0'; /* Yes, delete last char */
curwp->w_dotp = curline; /* Reset the line pointer */ curwp->w_dotp = curline; /* Reset the line pointer */
@ -240,7 +240,7 @@ int isearch(int f, int n)
default: /* All other chars */ default: /* All other chars */
if (c < ' ') { /* Is it printable? *//* Nope. */ if (c < ' ') { /* Is it printable? *//* 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 */
} }
} /* Switch */ } /* Switch */
@ -249,7 +249,7 @@ int isearch(int f, int n)
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? *//* Yup. Complain about it */ if (cpos >= NPAT) { /* too many chars in string? *//* Yup. Complain about it */
mlwrite("? Search string too long"); mlwrite("? Search string too long");
return (TRUE); /* Return an error */ return TRUE; /* Return an error */
} }
pat[cpos] = 0; /* null terminate the buffer */ pat[cpos] = 0; /* null terminate the buffer */
col = echo_char(c, col); /* Echo the character */ col = echo_char(c, col); /* Echo the character */
@ -293,7 +293,7 @@ int checknext(char chr, char *patrn, int dir) /* Check next character in search
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 */
curoff = 0; /* Start at the beginning of the line */ curoff = 0; /* Start at the beginning of the line */
buffchar = '\n'; /* And say the next char is NL */ buffchar = '\n'; /* And say the next char is NL */
} else } else
@ -303,9 +303,9 @@ int checknext(char chr, char *patrn, int dir) /* Check next character in search
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 */
} }
return (status); /* And return the status */ return status; /* And return the status */
} else /* Else, if reverse search: */ } else /* Else, if reverse search: */
return (match_pat(patrn)); /* See if we're in the right place */ return match_pat(patrn); /* See if we're in the right place */
} }
/* /*
@ -335,7 +335,7 @@ int scanmore(char *patrn, int dir) /* search forward or back for a pattern
TTflush(); /* see that the feep feeps */ TTflush(); /* see that the feep feeps */
} }
return (sts); /* else, don't even try */ return sts; /* else, don't even try */
} }
/* /*
@ -368,14 +368,14 @@ int match_pat(char *patrn) /* See if the pattern string matches string at "."
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)
return (FALSE); /* Abort if at end of buffer */ return FALSE; /* Abort if at end of buffer */
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 (!eq(buffchar, patrn[i])) /* Is it what we're looking for? */ if (!eq(buffchar, patrn[i])) /* Is it what we're looking for? */
return (FALSE); /* Nope, just punt it then */ return FALSE; /* Nope, just punt it then */
} }
return (TRUE); /* Everything matched? Let's celebrate */ return TRUE; /* Everything matched? Let's celebrate */
} }
/* /*
@ -394,7 +394,7 @@ int promptpattern(char *prompt)
if (!clexec) { if (!clexec) {
mlwrite(tpat); mlwrite(tpat);
} }
return (strlen(tpat)); return strlen(tpat);
} }
/* /*
@ -439,7 +439,7 @@ static int echo_char(int c, int col)
} else } else
TTputc(c); /* Otherwise, output raw char */ TTputc(c); /* Otherwise, output raw char */
TTflush(); /* Flush the output */ TTflush(); /* Flush the output */
return (++col); /* return the new column no */ return ++col; /* return the new column no */
} }
/* /*
@ -456,7 +456,7 @@ int get_char(void)
if (cmd_reexecute >= 0) /* Is there an offset? */ if (cmd_reexecute >= 0) /* Is there an offset? */
if ((c = cmd_buff[cmd_reexecute++]) != 0) if ((c = cmd_buff[cmd_reexecute++]) != 0)
return (c); /* Yes, return any character */ return c; /* Yes, return any character */
/* We're not re-executing (or aren't any more). Try for a real char */ /* We're not re-executing (or aren't any more). Try for a real char */
@ -464,12 +464,12 @@ int get_char(void)
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 */
} }
c = get1key(); /* Get the next character */ c = get1key(); /* Get the next character */
cmd_buff[cmd_offset++] = c; /* Save the char for next time */ cmd_buff[cmd_offset++] = c; /* Save the char for next time */
cmd_buff[cmd_offset] = '\0'; /* And terminate the buffer */ cmd_buff[cmd_offset] = '\0'; /* And terminate the buffer */
return (c); /* Return the character */ return c; /* Return the character */
} }
/* /*
@ -486,7 +486,7 @@ int uneat(void)
term.t_getchar = saved_get_char; /* restore the routine address */ term.t_getchar = saved_get_char; /* restore the routine address */
c = eaten_char; /* Get the re-eaten char */ c = eaten_char; /* Get the re-eaten char */
eaten_char = -1; /* Clear the old char */ eaten_char = -1; /* Clear the old char */
return (c); /* and return the last char */ return c; /* and return the last char */
} }
void reeat(int c) void reeat(int c)

74
line.c
View File

@ -34,11 +34,11 @@ struct line *lalloc(int used)
size = NBLOCK; /* line is for type-in. */ size = NBLOCK; /* line is for type-in. */
if ((lp = (struct line *)malloc(sizeof(struct line) + size)) == NULL) { if ((lp = (struct line *)malloc(sizeof(struct line) + size)) == NULL) {
mlwrite("(OUT OF MEMORY)"); mlwrite("(OUT OF MEMORY)");
return (NULL); return NULL;
} }
lp->l_size = size; lp->l_size = size;
lp->l_used = used; lp->l_used = used;
return (lp); return lp;
} }
/* /*
@ -119,7 +119,7 @@ int insspace(int f, int n)
{ {
linsert(n, ' '); linsert(n, ' ');
backchar(f, n); backchar(f, n);
return (TRUE); return TRUE;
} }
/* /*
@ -143,7 +143,7 @@ int linstr(char *instr)
} }
instr++; instr++;
} }
return (status); return status;
} }
/* /*
@ -168,16 +168,16 @@ int linsert(int n, int c)
struct window *wp; struct window *wp;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
lchange(WFEDIT); lchange(WFEDIT);
lp1 = curwp->w_dotp; /* Current line */ lp1 = curwp->w_dotp; /* Current line */
if (lp1 == curbp->b_linep) { /* At the end: special */ if (lp1 == curbp->b_linep) { /* At the end: special */
if (curwp->w_doto != 0) { if (curwp->w_doto != 0) {
mlwrite("bug: linsert"); mlwrite("bug: linsert");
return (FALSE); return FALSE;
} }
if ((lp2 = lalloc(n)) == NULL) /* Allocate new line */ if ((lp2 = lalloc(n)) == NULL) /* Allocate new line */
return (FALSE); return FALSE;
lp3 = lp1->l_bp; /* Previous line */ lp3 = lp1->l_bp; /* Previous line */
lp3->l_fp = lp2; /* Link in */ lp3->l_fp = lp2; /* Link in */
lp2->l_fp = lp1; lp2->l_fp = lp1;
@ -187,12 +187,12 @@ int linsert(int n, int c)
lp2->l_text[i] = c; lp2->l_text[i] = c;
curwp->w_dotp = lp2; curwp->w_dotp = lp2;
curwp->w_doto = n; curwp->w_doto = n;
return (TRUE); return TRUE;
} }
doto = curwp->w_doto; /* Save for later. */ doto = curwp->w_doto; /* Save for later. */
if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */ if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */
if ((lp2 = lalloc(lp1->l_used + n)) == NULL) if ((lp2 = lalloc(lp1->l_used + n)) == NULL)
return (FALSE); return FALSE;
cp1 = &lp1->l_text[0]; cp1 = &lp1->l_text[0];
cp2 = &lp2->l_text[0]; cp2 = &lp2->l_text[0];
while (cp1 != &lp1->l_text[doto]) while (cp1 != &lp1->l_text[doto])
@ -231,7 +231,7 @@ int linsert(int n, int c)
} }
wp = wp->w_wndp; wp = wp->w_wndp;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -245,7 +245,7 @@ int lowrite(int c)
(lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || (lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
((curwp->w_doto) & tabmask) == tabmask)) ((curwp->w_doto) & tabmask) == tabmask))
ldelete(1L, FALSE); ldelete(1L, FALSE);
return (linsert(1, c)); return linsert(1, c);
} }
/* /*
@ -269,7 +269,7 @@ int lover(char *ostr)
} }
ostr++; ostr++;
} }
return (status); return status;
} }
/* /*
@ -290,7 +290,7 @@ int lnewline(void)
struct window *wp; struct window *wp;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
#if SCROLLCODE #if SCROLLCODE
lchange(WFHARD | WFINS); lchange(WFHARD | WFINS);
#else #else
@ -299,7 +299,7 @@ int lnewline(void)
lp1 = curwp->w_dotp; /* Get the address and */ lp1 = curwp->w_dotp; /* Get the address and */
doto = curwp->w_doto; /* offset of "." */ doto = curwp->w_doto; /* offset of "." */
if ((lp2 = lalloc(doto)) == NULL) /* New first half line */ if ((lp2 = lalloc(doto)) == NULL) /* New first half line */
return (FALSE); return FALSE;
cp1 = &lp1->l_text[0]; /* Shuffle text around */ cp1 = &lp1->l_text[0]; /* Shuffle text around */
cp2 = &lp2->l_text[0]; cp2 = &lp2->l_text[0];
while (cp1 != &lp1->l_text[doto]) while (cp1 != &lp1->l_text[doto])
@ -330,7 +330,7 @@ int lnewline(void)
} }
wp = wp->w_wndp; wp = wp->w_wndp;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -352,12 +352,12 @@ int ldelete(long n, int kflag)
struct window *wp; struct window *wp;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
while (n != 0) { while (n != 0) {
dotp = curwp->w_dotp; dotp = curwp->w_dotp;
doto = curwp->w_doto; doto = curwp->w_doto;
if (dotp == curbp->b_linep) /* Hit end of buffer. */ if (dotp == curbp->b_linep) /* Hit end of buffer. */
return (FALSE); return FALSE;
chunk = dotp->l_used - doto; /* Size of chunk. */ chunk = dotp->l_used - doto; /* Size of chunk. */
if (chunk > n) if (chunk > n)
chunk = n; chunk = n;
@ -369,7 +369,7 @@ int ldelete(long n, int kflag)
#endif #endif
if (ldelnewline() == FALSE if (ldelnewline() == FALSE
|| (kflag != FALSE && kinsert('\n') == FALSE)) || (kflag != FALSE && kinsert('\n') == FALSE))
return (FALSE); return FALSE;
--n; --n;
continue; continue;
} }
@ -379,7 +379,7 @@ int ldelete(long n, int kflag)
if (kflag != FALSE) { /* Kill? */ if (kflag != FALSE) { /* Kill? */
while (cp1 != cp2) { while (cp1 != cp2) {
if (kinsert(*cp1) == FALSE) if (kinsert(*cp1) == FALSE)
return (FALSE); return FALSE;
++cp1; ++cp1;
} }
cp1 = &dotp->l_text[doto]; cp1 = &dotp->l_text[doto];
@ -403,7 +403,7 @@ int ldelete(long n, int kflag)
} }
n -= chunk; n -= chunk;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -430,7 +430,7 @@ char *getctext(void)
while (size--) while (size--)
*dp++ = *sp++; *dp++ = *sp++;
*dp = 0; *dp = 0;
return (rline); return rline;
} }
/* /*
@ -446,14 +446,14 @@ int putctext(char *iline)
/* delete the current line */ /* delete the current line */
curwp->w_doto = 0; /* starting at the beginning of the line */ curwp->w_doto = 0; /* starting at the beginning of the line */
if ((status = killtext(TRUE, 1)) != TRUE) if ((status = killtext(TRUE, 1)) != TRUE)
return (status); return status;
/* insert the new line */ /* insert the new line */
if ((status = linstr(iline)) != TRUE) if ((status = linstr(iline)) != TRUE)
return (status); return status;
status = lnewline(); status = lnewline();
backline(TRUE, 1); backline(TRUE, 1);
return (status); return status;
} }
/* /*
@ -475,13 +475,13 @@ int ldelnewline(void)
struct window *wp; struct window *wp;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
lp1 = curwp->w_dotp; lp1 = curwp->w_dotp;
lp2 = lp1->l_fp; lp2 = lp1->l_fp;
if (lp2 == curbp->b_linep) { /* At the buffer end. */ if (lp2 == curbp->b_linep) { /* At the buffer end. */
if (lp1->l_used == 0) /* Blank line. */ if (lp1->l_used == 0) /* Blank line. */
lfree(lp1); lfree(lp1);
return (TRUE); return TRUE;
} }
if (lp2->l_used <= lp1->l_size - lp1->l_used) { if (lp2->l_used <= lp1->l_size - lp1->l_used) {
cp1 = &lp1->l_text[lp1->l_used]; cp1 = &lp1->l_text[lp1->l_used];
@ -506,10 +506,10 @@ int ldelnewline(void)
lp1->l_fp = lp2->l_fp; lp1->l_fp = lp2->l_fp;
lp2->l_fp->l_bp = lp1; lp2->l_fp->l_bp = lp1;
free((char *) lp2); free((char *) lp2);
return (TRUE); return TRUE;
} }
if ((lp3 = lalloc(lp1->l_used + lp2->l_used)) == NULL) if ((lp3 = lalloc(lp1->l_used + lp2->l_used)) == NULL)
return (FALSE); return FALSE;
cp1 = &lp1->l_text[0]; cp1 = &lp1->l_text[0];
cp2 = &lp3->l_text[0]; cp2 = &lp3->l_text[0];
while (cp1 != &lp1->l_text[lp1->l_used]) while (cp1 != &lp1->l_text[lp1->l_used])
@ -541,7 +541,7 @@ int ldelnewline(void)
} }
free((char *) lp1); free((char *) lp1);
free((char *) lp2); free((char *) lp2);
return (TRUE); return TRUE;
} }
/* /*
@ -582,7 +582,7 @@ int kinsert(int c)
/* check to see if we need a new chunk */ /* check to see if we need a new chunk */
if (kused >= KBLOCK) { if (kused >= KBLOCK) {
if ((nchunk = (struct kill *)malloc(sizeof(struct kill))) == NULL) if ((nchunk = (struct kill *)malloc(sizeof(struct kill))) == NULL)
return (FALSE); return FALSE;
if (kbufh == NULL) /* set head ptr if first time */ if (kbufh == NULL) /* set head ptr if first time */
kbufh = nchunk; kbufh = nchunk;
if (kbufp != NULL) /* point the current to this new one */ if (kbufp != NULL) /* point the current to this new one */
@ -594,7 +594,7 @@ int kinsert(int c)
/* and now insert the character */ /* and now insert the character */
kbufp->d_chunk[kused++] = c; kbufp->d_chunk[kused++] = c;
return (TRUE); return TRUE;
} }
/* /*
@ -610,12 +610,12 @@ int yank(int f, int n)
struct kill *kp; /* pointer into kill buffer */ struct kill *kp; /* pointer into kill buffer */
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
/* make sure there is something to yank */ /* make sure there is something to yank */
if (kbufh == NULL) if (kbufh == NULL)
return (TRUE); /* not an error, just nothing */ return TRUE; /* not an error, just nothing */
/* for each time.... */ /* for each time.... */
while (n--) { while (n--) {
@ -629,14 +629,14 @@ int yank(int f, int n)
while (i--) { while (i--) {
if ((c = *sp++) == '\n') { if ((c = *sp++) == '\n') {
if (lnewline() == FALSE) if (lnewline() == FALSE)
return (FALSE); return FALSE;
} else { } else {
if (linsert(1, c) == FALSE) if (linsert(1, c) == FALSE)
return (FALSE); return FALSE;
} }
} }
kp = kp->d_next; kp = kp->d_next;
} }
} }
return (TRUE); return TRUE;
} }

26
lock.c
View File

@ -31,20 +31,20 @@ int lockchk(char *fname)
if (numlocks > 0) if (numlocks > 0)
for (i = 0; i < numlocks; ++i) for (i = 0; i < numlocks; ++i)
if (strcmp(fname, lname[i]) == 0) if (strcmp(fname, lname[i]) == 0)
return (TRUE); return TRUE;
/* if we have a full locking table, bitch and leave */ /* if we have a full locking table, bitch and leave */
if (numlocks == NLOCKS) { if (numlocks == NLOCKS) {
mlwrite("LOCK ERROR: Lock table full"); mlwrite("LOCK ERROR: Lock table full");
return (ABORT); return ABORT;
} }
/* next, try to lock it */ /* next, try to lock it */
status = lock(fname); status = lock(fname);
if (status == ABORT) /* file is locked, no override */ if (status == ABORT) /* file is locked, no override */
return (ABORT); return ABORT;
if (status == FALSE) /* locked, overriden, dont add to table */ if (status == FALSE) /* locked, overriden, dont add to table */
return (TRUE); return TRUE;
/* we have now locked it, add it to our table */ /* we have now locked it, add it to our table */
lname[++numlocks - 1] = (char *) malloc(strlen(fname) + 1); lname[++numlocks - 1] = (char *) malloc(strlen(fname) + 1);
@ -52,12 +52,12 @@ int lockchk(char *fname)
undolock(fname); /* free the lock */ undolock(fname); /* free the lock */
mlwrite("Cannot lock, out of memory"); mlwrite("Cannot lock, out of memory");
--numlocks; --numlocks;
return (ABORT); return ABORT;
} }
/* everthing is cool, add it to the table */ /* everthing is cool, add it to the table */
strcpy(lname[numlocks - 1], fname); strcpy(lname[numlocks - 1], fname);
return (TRUE); return TRUE;
} }
/* /*
@ -78,7 +78,7 @@ int lockrel(void)
free(lname[i]); free(lname[i]);
} }
numlocks = 0; numlocks = 0;
return (status); return status;
} }
/* /*
@ -99,12 +99,12 @@ int lock(char *fname)
/* attempt to lock the file */ /* attempt to lock the file */
locker = dolock(fname); locker = dolock(fname);
if (locker == NULL) /* we win */ if (locker == NULL) /* we win */
return (TRUE); return TRUE;
/* file failed...abort */ /* file failed...abort */
if (strncmp(locker, "LOCK", 4) == 0) { if (strncmp(locker, "LOCK", 4) == 0) {
lckerror(locker); lckerror(locker);
return (ABORT); return ABORT;
} }
/* someone else has it....override? */ /* someone else has it....override? */
@ -113,9 +113,9 @@ int lock(char *fname)
strcat(msg, ", override?"); strcat(msg, ", override?");
status = mlyesno(msg); /* ask them */ status = mlyesno(msg); /* ask them */
if (status == TRUE) if (status == TRUE)
return (FALSE); return FALSE;
else else
return (ABORT); return ABORT;
} }
/* /*
@ -132,11 +132,11 @@ int unlock(char *fname)
/* unclock and return */ /* unclock and return */
locker = undolock(fname); locker = undolock(fname);
if (locker == NULL) if (locker == NULL)
return (TRUE); return TRUE;
/* report the error and come back */ /* report the error and come back */
lckerror(locker); lckerror(locker);
return (FALSE); return FALSE;
} }
/* /*

48
main.c
View File

@ -313,7 +313,7 @@ int main(int argc, char **argv)
#if CALLED #if CALLED
/* if we were called as a subroutine and want to leave, do so */ /* if we were called as a subroutine and want to leave, do so */
if (eexitflag) if (eexitflag)
return (eexitval); return eexitval;
#endif #endif
/* execute the "command" macro...normally null */ /* execute the "command" macro...normally null */
@ -494,7 +494,7 @@ int execute(int c, int f, int n)
thisflag = 0; thisflag = 0;
status = (*execfunc) (f, n); status = (*execfunc) (f, n);
lastflag = thisflag; lastflag = thisflag;
return (status); return status;
} }
/* /*
@ -523,7 +523,7 @@ int execute(int c, int f, int n)
#endif #endif
if (n <= 0) { /* Fenceposts. */ if (n <= 0) { /* Fenceposts. */
lastflag = 0; lastflag = 0;
return (n < 0 ? FALSE : TRUE); return n < 0 ? FALSE : TRUE;
} }
thisflag = 0; /* For the future. */ thisflag = 0; /* For the future. */
@ -561,12 +561,12 @@ int execute(int c, int f, int n)
} }
lastflag = thisflag; lastflag = thisflag;
return (status); return status;
} }
TTbeep(); TTbeep();
mlwrite("(Key not bound)"); /* complain */ mlwrite("(Key not bound)"); /* complain */
lastflag = 0; /* Fake last flags. */ lastflag = 0; /* Fake last flags. */
return (FALSE); return FALSE;
} }
/* /*
@ -594,13 +594,13 @@ int quickexit(int f, int n)
#endif #endif
if ((status = filesave(f, n)) != TRUE) { if ((status = filesave(f, n)) != TRUE) {
curbp = oldcb; /* restore curbp */ curbp = oldcb; /* restore curbp */
return (status); return status;
} }
} }
bp = bp->b_bufp; /* on to the next buffer */ bp = bp->b_bufp; /* on to the next buffer */
} }
quit(f, n); /* conditionally quit */ quit(f, n); /* conditionally quit */
return (TRUE); return TRUE;
} }
static void emergencyexit(int signr) static void emergencyexit(int signr)
@ -638,7 +638,7 @@ int quit(int f, int n)
exit(GOOD); exit(GOOD);
} }
mlwrite(""); mlwrite("");
return (s); return s;
} }
/* /*
@ -650,13 +650,13 @@ int ctlxlp(int f, int n)
{ {
if (kbdmode != STOP) { if (kbdmode != STOP) {
mlwrite("%%Macro already active"); mlwrite("%%Macro already active");
return (FALSE); return FALSE;
} }
mlwrite("(Start macro)"); mlwrite("(Start macro)");
kbdptr = &kbdm[0]; kbdptr = &kbdm[0];
kbdend = kbdptr; kbdend = kbdptr;
kbdmode = RECORD; kbdmode = RECORD;
return (TRUE); return TRUE;
} }
/* /*
@ -667,13 +667,13 @@ int ctlxrp(int f, int n)
{ {
if (kbdmode == STOP) { if (kbdmode == STOP) {
mlwrite("%%Macro not active"); mlwrite("%%Macro not active");
return (FALSE); return FALSE;
} }
if (kbdmode == RECORD) { if (kbdmode == RECORD) {
mlwrite("(End macro)"); mlwrite("(End macro)");
kbdmode = STOP; kbdmode = STOP;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -685,14 +685,14 @@ int ctlxe(int f, int n)
{ {
if (kbdmode != STOP) { if (kbdmode != STOP) {
mlwrite("%%Macro already active"); mlwrite("%%Macro already active");
return (FALSE); return FALSE;
} }
if (n <= 0) if (n <= 0)
return (TRUE); return TRUE;
kbdrep = n; /* remember how many times to execute */ kbdrep = n; /* remember how many times to execute */
kbdmode = PLAY; /* start us in play mode */ kbdmode = PLAY; /* start us in play mode */
kbdptr = &kbdm[0]; /* at the beginning */ kbdptr = &kbdm[0]; /* at the beginning */
return (TRUE); return TRUE;
} }
/* /*
@ -705,7 +705,7 @@ int ctrlg(int f, int n)
TTbeep(); TTbeep();
kbdmode = STOP; kbdmode = STOP;
mlwrite("(Aborted)"); mlwrite("(Aborted)");
return (ABORT); return ABORT;
} }
/* /*
@ -716,38 +716,38 @@ int rdonly(void)
{ {
TTbeep(); TTbeep();
mlwrite("(Key illegal in VIEW mode)"); mlwrite("(Key illegal in VIEW mode)");
return (FALSE); return FALSE;
} }
int resterr(void) int resterr(void)
{ {
TTbeep(); TTbeep();
mlwrite("(That command is RESTRICTED)"); mlwrite("(That command is RESTRICTED)");
return (FALSE); return FALSE;
} }
/* user function that does NOTHING */ /* user function that does NOTHING */
int nullproc(int f, int n) int nullproc(int f, int n)
{ {
return (TRUE); return TRUE;
} }
/* dummy function for binding to meta prefix */ /* dummy function for binding to meta prefix */
int metafn(int f, int n) int metafn(int f, int n)
{ {
return (TRUE); return TRUE;
} }
/* dummy function for binding to control-x prefix */ /* dummy function for binding to control-x prefix */
int cex(int f, int n) int cex(int f, int n)
{ {
return (TRUE); return TRUE;
} }
/* dummy function for binding to universal-argument */ /* dummy function for binding to universal-argument */
int unarg(int f, int n) int unarg(int f, int n)
{ {
return (TRUE); return TRUE;
} }
/***** Compiler specific Library functions ****/ /***** Compiler specific Library functions ****/
@ -781,7 +781,7 @@ unsigned nbytes; /* # of bytes to allocate */
#endif #endif
} }
return (mp); return mp;
} }
release(mp) release(mp)
@ -869,7 +869,7 @@ int cexit(int status)
#if CALLED #if CALLED
eexitflag = TRUE; /* flag a program exit */ eexitflag = TRUE; /* flag a program exit */
eexitval = status; eexitval = status;
return (status); return status;
#else #else
#undef exit #undef exit
exit(status); exit(status);

View File

@ -28,7 +28,7 @@
int gethostname(char *name, int namelen) int gethostname(char *name, int namelen)
{ {
return (sysinfo(SI_HOSTNAME, name, namelen)); return sysinfo(SI_HOSTNAME, name, namelen);
} }
#endif #endif

View File

@ -130,7 +130,7 @@ int ttputc(int c)
} }
} }
fputc(c, stdout); fputc(c, stdout);
return (TRUE); return TRUE;
} }
/* /*

154
random.c
View File

@ -20,7 +20,7 @@ int setfillcol(int f, int n)
{ {
fillcol = n; fillcol = n;
mlwrite("(Fill column is %d)", n); mlwrite("(Fill column is %d)", n);
return (TRUE); return TRUE;
} }
/* /*
@ -92,7 +92,7 @@ int showcpos(int f, int n)
mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x", mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x",
predlines + 1, numlines + 1, col, ecol, predlines + 1, numlines + 1, col, ecol,
predchars, numchars, ratio, curchar); predchars, numchars, ratio, curchar);
return (TRUE); return TRUE;
} }
int getcline(void) int getcline(void)
@ -114,7 +114,7 @@ int getcline(void)
} }
/* and return the resulting count */ /* and return the resulting count */
return (numlines + 1); return numlines + 1;
} }
/* /*
@ -134,7 +134,7 @@ int getccol(int bflg)
++col; ++col;
++col; ++col;
} }
return (col); return col;
} }
/* /*
@ -171,7 +171,7 @@ int setccol(int pos)
curwp->w_doto = i; curwp->w_doto = i;
/* and tell weather we made it */ /* and tell weather we made it */
return (col >= pos); return col >= pos;
} }
/* /*
@ -189,19 +189,19 @@ int twiddle(int f, int n)
int cr; int cr;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
dotp = curwp->w_dotp; dotp = curwp->w_dotp;
doto = curwp->w_doto; doto = curwp->w_doto;
if (doto == llength(dotp) && --doto < 0) if (doto == llength(dotp) && --doto < 0)
return (FALSE); return FALSE;
cr = lgetc(dotp, doto); cr = lgetc(dotp, doto);
if (--doto < 0) if (--doto < 0)
return (FALSE); return FALSE;
cl = lgetc(dotp, doto); cl = lgetc(dotp, doto);
lputc(dotp, doto + 0, cr); lputc(dotp, doto + 0, cr);
lputc(dotp, doto + 1, cl); lputc(dotp, doto + 1, cl);
lchange(WFEDIT); lchange(WFEDIT);
return (TRUE); return TRUE;
} }
/* /*
@ -216,19 +216,19 @@ int quote(int f, int n)
int c; int c;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
c = tgetc(); c = tgetc();
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
if (n == 0) if (n == 0)
return (TRUE); return TRUE;
if (c == '\n') { if (c == '\n') {
do { do {
s = lnewline(); s = lnewline();
} while (s == TRUE && --n); } while (s == TRUE && --n);
return (s); return s;
} }
return (linsert(n, c)); return linsert(n, c);
} }
/* /*
@ -241,14 +241,14 @@ int quote(int f, int n)
int insert_tab(int f, int n) int insert_tab(int f, int n)
{ {
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
if (n == 0 || n > 1) { if (n == 0 || n > 1) {
tabsize = n; tabsize = n;
return (TRUE); return TRUE;
} }
if (!tabsize) if (!tabsize)
return (linsert(1, '\t')); return linsert(1, '\t');
return (linsert(tabsize - (getccol(FALSE) % tabsize), ' ')); return linsert(tabsize - (getccol(FALSE) % tabsize), ' ');
} }
#if AEDIT #if AEDIT
@ -262,7 +262,7 @@ int detab(int f, int n)
int inc; /* increment to next line [sgn(n)] */ int inc; /* increment to next line [sgn(n)] */
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (f == FALSE) if (f == FALSE)
n = 1; n = 1;
@ -291,7 +291,7 @@ int detab(int f, int n)
curwp->w_doto = 0; /* to the begining of the line */ curwp->w_doto = 0; /* to the begining of the line */
thisflag &= ~CFCPCN; /* flag that this resets the goal column */ thisflag &= ~CFCPCN; /* flag that this resets the goal column */
lchange(WFEDIT); /* yes, we have made at least an edit */ lchange(WFEDIT); /* yes, we have made at least an edit */
return (TRUE); return TRUE;
} }
/* /*
@ -307,7 +307,7 @@ int entab(int f, int n)
char cchar; /* current character */ char cchar; /* current character */
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (f == FALSE) if (f == FALSE)
n = 1; n = 1;
@ -365,7 +365,7 @@ int entab(int f, int n)
curwp->w_doto = 0; /* to the begining of the line */ curwp->w_doto = 0; /* to the begining of the line */
thisflag &= ~CFCPCN; /* flag that this resets the goal column */ thisflag &= ~CFCPCN; /* flag that this resets the goal column */
lchange(WFEDIT); /* yes, we have made at least an edit */ lchange(WFEDIT); /* yes, we have made at least an edit */
return (TRUE); return TRUE;
} }
/* /*
@ -381,7 +381,7 @@ int trim(int f, int n)
int inc; /* increment to next line [sgn(n)] */ int inc; /* increment to next line [sgn(n)] */
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (f == FALSE) if (f == FALSE)
n = 1; n = 1;
@ -408,7 +408,7 @@ int trim(int f, int n)
} }
lchange(WFEDIT); lchange(WFEDIT);
thisflag &= ~CFCPCN; /* flag that this resets the goal column */ thisflag &= ~CFCPCN; /* flag that this resets the goal column */
return (TRUE); return TRUE;
} }
#endif #endif
@ -423,18 +423,18 @@ int openline(int f, int n)
int s; int s;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
if (n == 0) if (n == 0)
return (TRUE); return TRUE;
i = n; /* Insert newlines. */ i = n; /* Insert newlines. */
do { do {
s = lnewline(); s = lnewline();
} while (s == TRUE && --i); } while (s == TRUE && --i);
if (s == TRUE) /* Then back up overtop */ if (s == TRUE) /* Then back up overtop */
s = backchar(f, n); /* of them all. */ s = backchar(f, n); /* of them all. */
return (s); return s;
} }
/* /*
@ -446,14 +446,14 @@ int insert_newline(int f, int n)
int s; int s;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
/* if we are in C mode and this is a default <NL> */ /* if we are in C mode and this is a default <NL> */
if (n == 1 && (curbp->b_mode & MDCMOD) && if (n == 1 && (curbp->b_mode & MDCMOD) &&
curwp->w_dotp != curbp->b_linep) curwp->w_dotp != curbp->b_linep)
return (cinsert()); return cinsert();
/* /*
* If a newline was typed, fill column is defined, the argument is non- * If a newline was typed, fill column is defined, the argument is non-
@ -468,12 +468,12 @@ int insert_newline(int f, int n)
/* insert some lines */ /* insert some lines */
while (n--) { while (n--) {
if ((s = lnewline()) != TRUE) if ((s = lnewline()) != TRUE)
return (s); return s;
#if SCROLLCODE #if SCROLLCODE
curwp->w_flag |= WFINS; curwp->w_flag |= WFINS;
#endif #endif
} }
return (TRUE); return TRUE;
} }
int cinsert(void) int cinsert(void)
@ -502,7 +502,7 @@ int cinsert(void)
/* put in the newline */ /* put in the newline */
if (lnewline() == FALSE) if (lnewline() == FALSE)
return (FALSE); return FALSE;
/* and the saved indentation */ /* and the saved indentation */
linstr(ichar); linstr(ichar);
@ -514,7 +514,7 @@ int cinsert(void)
#if SCROLLCODE #if SCROLLCODE
curwp->w_flag |= WFINS; curwp->w_flag |= WFINS;
#endif #endif
return (TRUE); return TRUE;
} }
#if NBRACE #if NBRACE
@ -540,7 +540,7 @@ int insbrace(int n, int c)
for (i = curwp->w_doto - 1; i >= 0; --i) { for (i = curwp->w_doto - 1; i >= 0; --i) {
ch = lgetc(curwp->w_dotp, i); ch = lgetc(curwp->w_dotp, i);
if (ch != ' ' && ch != '\t') if (ch != ' ' && ch != '\t')
return (linsert(n, c)); return linsert(n, c);
} }
/* chercher le caractere oppose correspondant */ /* chercher le caractere oppose correspondant */
@ -555,7 +555,7 @@ int insbrace(int n, int c)
oc = '('; oc = '(';
break; break;
default: default:
return (FALSE); return FALSE;
} }
oldlp = curwp->w_dotp; oldlp = curwp->w_dotp;
@ -583,7 +583,7 @@ int insbrace(int n, int c)
if (count != 0) { /* no match */ if (count != 0) { /* no match */
curwp->w_dotp = oldlp; curwp->w_dotp = oldlp;
curwp->w_doto = oldoff; curwp->w_doto = oldoff;
return (linsert(n, c)); return linsert(n, c);
} }
curwp->w_doto = 0; /* debut de ligne */ curwp->w_doto = 0; /* debut de ligne */
@ -609,7 +609,7 @@ int insbrace(int n, int c)
} }
/* and insert the required brace(s) */ /* and insert the required brace(s) */
return (linsert(n, c)); return linsert(n, c);
} }
#else #else
@ -628,13 +628,13 @@ int insbrace(int n, int c)
/* if we are at the beginning of the line, no go */ /* if we are at the beginning of the line, no go */
if (curwp->w_doto == 0) if (curwp->w_doto == 0)
return (linsert(n, c)); return linsert(n, c);
/* scan to see if all space before this is white space */ /* scan to see if all space before this is white space */
for (i = curwp->w_doto - 1; i >= 0; --i) { for (i = curwp->w_doto - 1; i >= 0; --i) {
ch = lgetc(curwp->w_dotp, i); ch = lgetc(curwp->w_dotp, i);
if (ch != ' ' && ch != '\t') if (ch != ' ' && ch != '\t')
return (linsert(n, c)); return linsert(n, c);
} }
/* delete back first */ /* delete back first */
@ -645,7 +645,7 @@ int insbrace(int n, int c)
backdel(FALSE, 1); backdel(FALSE, 1);
/* and insert the required brace(s) */ /* and insert the required brace(s) */
return (linsert(n, c)); return linsert(n, c);
} }
#endif #endif
@ -656,13 +656,13 @@ int inspound(void)
/* if we are at the beginning of the line, no go */ /* if we are at the beginning of the line, no go */
if (curwp->w_doto == 0) if (curwp->w_doto == 0)
return (linsert(1, '#')); return linsert(1, '#');
/* scan to see if all space before this is white space */ /* scan to see if all space before this is white space */
for (i = curwp->w_doto - 1; i >= 0; --i) { for (i = curwp->w_doto - 1; i >= 0; --i) {
ch = lgetc(curwp->w_dotp, i); ch = lgetc(curwp->w_dotp, i);
if (ch != ' ' && ch != '\t') if (ch != ' ' && ch != '\t')
return (linsert(1, '#')); return linsert(1, '#');
} }
/* delete back first */ /* delete back first */
@ -670,7 +670,7 @@ int inspound(void)
backdel(FALSE, 1); backdel(FALSE, 1);
/* and insert the required pound */ /* and insert the required pound */
return (linsert(1, '#')); return linsert(1, '#');
} }
/* /*
@ -688,7 +688,7 @@ int deblank(int f, int n)
long nld; long nld;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
lp1 = curwp->w_dotp; lp1 = curwp->w_dotp;
while (llength(lp1) == 0 && (lp2 = lback(lp1)) != curbp->b_linep) while (llength(lp1) == 0 && (lp2 = lback(lp1)) != curbp->b_linep)
lp1 = lp2; lp1 = lp2;
@ -697,10 +697,10 @@ int deblank(int f, int n)
while ((lp2 = lforw(lp2)) != curbp->b_linep && llength(lp2) == 0) while ((lp2 = lforw(lp2)) != curbp->b_linep && llength(lp2) == 0)
++nld; ++nld;
if (nld == 0) if (nld == 0)
return (TRUE); return TRUE;
curwp->w_dotp = lforw(lp1); curwp->w_dotp = lforw(lp1);
curwp->w_doto = 0; curwp->w_doto = 0;
return (ldelete(nld, FALSE)); return ldelete(nld, FALSE);
} }
/* /*
@ -718,9 +718,9 @@ int indent(int f, int n)
int i; int i;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
while (n--) { while (n--) {
nicol = 0; nicol = 0;
for (i = 0; i < llength(curwp->w_dotp); ++i) { for (i = 0; i < llength(curwp->w_dotp); ++i) {
@ -734,9 +734,9 @@ int indent(int f, int n)
if (lnewline() == FALSE if (lnewline() == FALSE
|| ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE) || ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE)
|| ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE)) || ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE))
return (FALSE); return FALSE;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -748,15 +748,15 @@ int indent(int f, int n)
int forwdel(int f, int n) int forwdel(int f, int n)
{ {
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (backdel(f, -n)); return backdel(f, -n);
if (f != FALSE) { /* Really a kill. */ if (f != FALSE) { /* Really a kill. */
if ((lastflag & CFKILL) == 0) if ((lastflag & CFKILL) == 0)
kdelete(); kdelete();
thisflag |= CFKILL; thisflag |= CFKILL;
} }
return (ldelete((long) n, f)); return ldelete((long) n, f);
} }
/* /*
@ -770,9 +770,9 @@ int backdel(int f, int n)
int s; int s;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (forwdel(f, -n)); return forwdel(f, -n);
if (f != FALSE) { /* Really a kill. */ if (f != FALSE) { /* Really a kill. */
if ((lastflag & CFKILL) == 0) if ((lastflag & CFKILL) == 0)
kdelete(); kdelete();
@ -780,7 +780,7 @@ int backdel(int f, int n)
} }
if ((s = backchar(f, n)) == TRUE) if ((s = backchar(f, n)) == TRUE)
s = ldelete((long) n, f); s = ldelete((long) n, f);
return (s); return s;
} }
/* /*
@ -797,7 +797,7 @@ int killtext(int f, int n)
long chunk; long chunk;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */ if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */
kdelete(); /* last wasn't a kill. */ kdelete(); /* last wasn't a kill. */
thisflag |= CFKILL; thisflag |= CFKILL;
@ -813,15 +813,15 @@ int killtext(int f, int n)
nextp = lforw(curwp->w_dotp); nextp = lforw(curwp->w_dotp);
while (--n) { while (--n) {
if (nextp == curbp->b_linep) if (nextp == curbp->b_linep)
return (FALSE); return FALSE;
chunk += llength(nextp) + 1; chunk += llength(nextp) + 1;
nextp = lforw(nextp); nextp = lforw(nextp);
} }
} else { } else {
mlwrite("neg kill"); mlwrite("neg kill");
return (FALSE); return FALSE;
} }
return (ldelete(chunk, TRUE)); return ldelete(chunk, TRUE);
} }
/* /*
@ -912,7 +912,7 @@ int adjustmode(int kind, int global)
status = mlreply(prompt, cbuf, NPAT - 1); status = mlreply(prompt, cbuf, NPAT - 1);
if (status != TRUE) if (status != TRUE)
return (status); return status;
/* make it uppercase */ /* make it uppercase */
@ -954,7 +954,7 @@ int adjustmode(int kind, int global)
curwp->w_flag |= WFCOLR; curwp->w_flag |= WFCOLR;
#endif #endif
mlerase(); mlerase();
return (TRUE); return TRUE;
} }
} }
@ -976,12 +976,12 @@ int adjustmode(int kind, int global)
if (global == 0) if (global == 0)
upmode(); upmode();
mlerase(); /* erase the junk */ mlerase(); /* erase the junk */
return (TRUE); return TRUE;
} }
} }
mlwrite("No such mode!"); mlwrite("No such mode!");
return (FALSE); return FALSE;
} }
/* /*
@ -993,7 +993,7 @@ int adjustmode(int kind, int global)
int clrmes(int f, int n) int clrmes(int f, int n)
{ {
mlforce(""); mlforce("");
return (TRUE); return TRUE;
} }
/* /*
@ -1012,7 +1012,7 @@ int writemsg(int f, int n)
if ((status = if ((status =
mlreply("Message to write: ", buf, NPAT - 1)) != TRUE) 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 */
sp = buf; sp = buf;
@ -1026,7 +1026,7 @@ int writemsg(int f, int n)
/* write the message out */ /* write the message out */
mlforce(nbuf); mlforce(nbuf);
return (TRUE); return TRUE;
} }
#if CFENCE #if CFENCE
@ -1083,7 +1083,7 @@ int getfence(int f, int n)
break; break;
default: default:
TTbeep(); TTbeep();
return (FALSE); return FALSE;
} }
/* set up for scan */ /* set up for scan */
@ -1118,14 +1118,14 @@ int getfence(int f, int n)
else else
forwchar(FALSE, 1); forwchar(FALSE, 1);
curwp->w_flag |= WFMOVE; curwp->w_flag |= WFMOVE;
return (TRUE); return TRUE;
} }
/* restore the current position */ /* restore the current position */
curwp->w_dotp = oldlp; curwp->w_dotp = oldlp;
curwp->w_doto = oldoff; curwp->w_doto = oldoff;
TTbeep(); TTbeep();
return (FALSE); return FALSE;
} }
#endif #endif
@ -1193,7 +1193,7 @@ int fmatch(int ch)
/* restore the current position */ /* restore the current position */
curwp->w_dotp = oldlp; curwp->w_dotp = oldlp;
curwp->w_doto = oldoff; curwp->w_doto = oldoff;
return (TRUE); return TRUE;
} }
/* /*
@ -1211,7 +1211,7 @@ int istring(int f, int n)
status = status =
mlreplyt("String to insert<META>: ", tstring, NPAT, metac); mlreplyt("String to insert<META>: ", tstring, NPAT, metac);
if (status != TRUE) if (status != TRUE)
return (status); return status;
if (f == FALSE) if (f == FALSE)
n = 1; n = 1;
@ -1221,7 +1221,7 @@ int istring(int f, int n)
/* insert it */ /* insert it */
while (n-- && (status = linstr(tstring))); while (n-- && (status = linstr(tstring)));
return (status); return status;
} }
/* /*
@ -1239,7 +1239,7 @@ int ovstring(int f, int n)
status = status =
mlreplyt("String to overwrite<META>: ", tstring, NPAT, metac); mlreplyt("String to overwrite<META>: ", tstring, NPAT, metac);
if (status != TRUE) if (status != TRUE)
return (status); return status;
if (f == FALSE) if (f == FALSE)
n = 1; n = 1;
@ -1249,5 +1249,5 @@ int ovstring(int f, int n)
/* insert it */ /* insert it */
while (n-- && (status = lover(tstring))); while (n-- && (status = lover(tstring)));
return (status); return status;
} }

View File

@ -26,15 +26,15 @@ int killregion(int f, int n)
struct region region; struct region region;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if ((s = getregion(&region)) != TRUE) if ((s = getregion(&region)) != TRUE)
return (s); return s;
if ((lastflag & CFKILL) == 0) /* This is a kill type */ if ((lastflag & CFKILL) == 0) /* This is a kill type */
kdelete(); /* command, so do magic */ kdelete(); /* command, so do magic */
thisflag |= CFKILL; /* kill buffer stuff. */ thisflag |= CFKILL; /* kill buffer stuff. */
curwp->w_dotp = region.r_linep; curwp->w_dotp = region.r_linep;
curwp->w_doto = region.r_offset; curwp->w_doto = region.r_offset;
return (ldelete(region.r_size, TRUE)); return ldelete(region.r_size, TRUE);
} }
/* /*
@ -51,7 +51,7 @@ int copyregion(int f, int n)
struct region region; struct region region;
if ((s = getregion(&region)) != TRUE) if ((s = getregion(&region)) != TRUE)
return (s); return s;
if ((lastflag & CFKILL) == 0) /* Kill type command. */ if ((lastflag & CFKILL) == 0) /* Kill type command. */
kdelete(); kdelete();
thisflag |= CFKILL; thisflag |= CFKILL;
@ -60,17 +60,17 @@ int copyregion(int f, int n)
while (region.r_size--) { while (region.r_size--) {
if (loffs == llength(linep)) { /* End of line. */ if (loffs == llength(linep)) { /* End of line. */
if ((s = kinsert('\n')) != TRUE) if ((s = kinsert('\n')) != TRUE)
return (s); return s;
linep = lforw(linep); linep = lforw(linep);
loffs = 0; loffs = 0;
} else { /* Middle of line. */ } else { /* Middle of line. */
if ((s = kinsert(lgetc(linep, loffs))) != TRUE) if ((s = kinsert(lgetc(linep, loffs))) != TRUE)
return (s); return s;
++loffs; ++loffs;
} }
} }
mlwrite("(region copied)"); mlwrite("(region copied)");
return (TRUE); return TRUE;
} }
/* /*
@ -90,9 +90,9 @@ int lowerregion(int f, int n)
struct region region; struct region region;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if ((s = getregion(&region)) != TRUE) if ((s = getregion(&region)) != TRUE)
return (s); return s;
lchange(WFHARD); lchange(WFHARD);
linep = region.r_linep; linep = region.r_linep;
loffs = region.r_offset; loffs = region.r_offset;
@ -107,7 +107,7 @@ int lowerregion(int f, int n)
++loffs; ++loffs;
} }
} }
return (TRUE); return TRUE;
} }
/* /*
@ -127,9 +127,9 @@ int upperregion(int f, int n)
struct region region; struct region region;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if ((s = getregion(&region)) != TRUE) if ((s = getregion(&region)) != TRUE)
return (s); return s;
lchange(WFHARD); lchange(WFHARD);
linep = region.r_linep; linep = region.r_linep;
loffs = region.r_offset; loffs = region.r_offset;
@ -144,7 +144,7 @@ int upperregion(int f, int n)
++loffs; ++loffs;
} }
} }
return (TRUE); return TRUE;
} }
/* /*
@ -167,7 +167,7 @@ int getregion(struct region *rp)
if (curwp->w_markp == NULL) { if (curwp->w_markp == NULL) {
mlwrite("No mark set in this window"); mlwrite("No mark set in this window");
return (FALSE); return FALSE;
} }
if (curwp->w_dotp == curwp->w_markp) { if (curwp->w_dotp == curwp->w_markp) {
rp->r_linep = curwp->w_dotp; rp->r_linep = curwp->w_dotp;
@ -180,7 +180,7 @@ int getregion(struct region *rp)
rp->r_size = rp->r_size =
(long) (curwp->w_doto - curwp->w_marko); (long) (curwp->w_doto - curwp->w_marko);
} }
return (TRUE); return TRUE;
} }
blp = curwp->w_dotp; blp = curwp->w_dotp;
bsize = (long) curwp->w_doto; bsize = (long) curwp->w_doto;
@ -193,7 +193,7 @@ int getregion(struct region *rp)
rp->r_linep = curwp->w_dotp; rp->r_linep = curwp->w_dotp;
rp->r_offset = curwp->w_doto; rp->r_offset = curwp->w_doto;
rp->r_size = fsize + curwp->w_marko; rp->r_size = fsize + curwp->w_marko;
return (TRUE); return TRUE;
} }
fsize += llength(flp) + 1; fsize += llength(flp) + 1;
} }
@ -204,10 +204,10 @@ int getregion(struct region *rp)
rp->r_linep = blp; rp->r_linep = blp;
rp->r_offset = curwp->w_marko; rp->r_offset = curwp->w_marko;
rp->r_size = bsize - curwp->w_marko; rp->r_size = bsize - curwp->w_marko;
return (TRUE); return TRUE;
} }
} }
} }
mlwrite("Bug: lost mark"); mlwrite("Bug: lost mark");
return (FALSE); return FALSE;
} }

View File

@ -89,7 +89,7 @@ int forwsearch(int f, int n)
* Otherwise proceed by asking for the search string. * Otherwise proceed by asking for the search string.
*/ */
if (n < 0) if (n < 0)
return (backsearch(f, -n)); return backsearch(f, -n);
/* Ask the user for the text of a pattern. If the /* Ask the user for the text of a pattern. If the
* response is TRUE (responses other than FALSE are * response is TRUE (responses other than FALSE are
@ -117,7 +117,7 @@ int forwsearch(int f, int n)
else else
mlwrite("Not found"); mlwrite("Not found");
} }
return (status); return status;
} }
/* /*
@ -132,7 +132,7 @@ int forwhunt(int f, int n)
int status = TRUE; int status = TRUE;
if (n < 0) /* search backwards */ if (n < 0) /* search backwards */
return (backhunt(f, -n)); return backhunt(f, -n);
/* 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.
@ -170,7 +170,7 @@ int forwhunt(int f, int n)
else else
mlwrite("Not found"); mlwrite("Not found");
return (status); return status;
} }
/* /*
@ -189,7 +189,7 @@ int backsearch(int f, int n)
* Otherwise proceed by asking for the search string. * Otherwise proceed by asking for the search string.
*/ */
if (n < 0) if (n < 0)
return (forwsearch(f, -n)); return forwsearch(f, -n);
/* Ask the user for the text of a pattern. If the /* Ask the user for the text of a pattern. If the
* response is TRUE (responses other than FALSE are * response is TRUE (responses other than FALSE are
@ -218,7 +218,7 @@ int backsearch(int f, int n)
else else
mlwrite("Not found"); mlwrite("Not found");
} }
return (status); return status;
} }
/* /*
@ -234,7 +234,7 @@ int backhunt(int f, int n)
int status = TRUE; int status = TRUE;
if (n < 0) if (n < 0)
return (forwhunt(f, -n)); return forwhunt(f, -n);
/* 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.
@ -272,7 +272,7 @@ int backhunt(int f, int n)
else else
mlwrite("Not found"); mlwrite("Not found");
return (status); return status;
} }
#if MAGIC #if MAGIC
@ -579,7 +579,7 @@ int eq(unsigned char bc, unsigned char pc)
pc ^= DIFCASE; pc ^= DIFCASE;
} }
return (bc == pc); return bc == pc;
} }
/* /*
@ -631,7 +631,7 @@ static int readpattern(char *prompt, char *apat, int srch)
} 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;
} }
/* /*
@ -686,7 +686,7 @@ void rvstrcpy(char *rvstr, char *str)
*/ */
int sreplace(int f, int n) int sreplace(int f, int n)
{ {
return (replaces(FALSE, f, n)); return replaces(FALSE, f, n);
} }
/* /*
@ -697,7 +697,7 @@ int sreplace(int f, int n)
*/ */
int qreplace(int f, int n) int qreplace(int f, int n)
{ {
return (replaces(TRUE, f, n)); return replaces(TRUE, f, n);
} }
/* /*
@ -724,12 +724,12 @@ static int replaces(int kind, int f, int n)
int lastoff; /* offset (for 'u' query option) */ int lastoff; /* offset (for 'u' query option) */
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
/* Check for negative repetitions. /* Check for negative repetitions.
*/ */
if (f && n < 0) if (f && n < 0)
return (FALSE); return FALSE;
/* Ask the user for the text of a pattern. /* Ask the user for the text of a pattern.
*/ */
@ -737,12 +737,12 @@ static int replaces(int kind, int f, int n)
FALSE ? "Replace" : "Query replace"), FALSE ? "Replace" : "Query replace"),
&pat[0], TRUE)) &pat[0], TRUE))
!= TRUE) != TRUE)
return (status); return status;
/* Ask for the replacement string. /* Ask for the replacement string.
*/ */
if ((status = readpattern("with", &rpat[0], FALSE)) == ABORT) if ((status = readpattern("with", &rpat[0], FALSE)) == ABORT)
return (status); return status;
/* Find the length of the replacement string. /* Find the length of the replacement string.
*/ */
@ -860,7 +860,7 @@ static int replaces(int kind, int f, int n)
#endif #endif
status = delins(rlength, patmatch, FALSE); status = delins(rlength, patmatch, FALSE);
if (status != TRUE) if (status != TRUE)
return (status); return status;
/* Record one less substitution, /* Record one less substitution,
* backup, save our place, and * backup, save our place, and
@ -880,7 +880,7 @@ static int replaces(int kind, int f, int n)
case BELL: /* abort! and stay */ case BELL: /* abort! and stay */
mlwrite("Aborted!"); mlwrite("Aborted!");
return (FALSE); return FALSE;
default: /* bitch and beep */ default: /* bitch and beep */
TTbeep(); TTbeep();
@ -900,7 +900,7 @@ static int replaces(int kind, int f, int n)
*/ */
status = delins(matchlen, &rpat[0], TRUE); status = delins(matchlen, &rpat[0], TRUE);
if (status != TRUE) if (status != TRUE)
return (status); return status;
/* Save our position, since we may /* Save our position, since we may
* undo this. * undo this.
@ -916,7 +916,7 @@ static int replaces(int kind, int f, int n)
/* And report the results. /* And report the results.
*/ */
mlwrite("%d substitutions", numsub); mlwrite("%d substitutions", numsub);
return (TRUE); return TRUE;
} }
/* /*
@ -952,7 +952,7 @@ int delins(int dlength, char *instr, int use_meta)
#endif #endif
status = linstr(instr); status = linstr(instr);
return (status); return status;
} }
/* /*
@ -999,11 +999,11 @@ int expandp(char *srcstr, char *deststr, int maxlength)
if (maxlength < 4) { if (maxlength < 4) {
*deststr++ = '$'; *deststr++ = '$';
*deststr = '\0'; *deststr = '\0';
return (FALSE); return FALSE;
} }
} }
*deststr = '\0'; *deststr = '\0';
return (TRUE); return TRUE;
} }
/* /*
@ -1024,7 +1024,7 @@ int boundry(struct line *curline, int curoff, int dir)
border = (curoff == 0) && border = (curoff == 0) &&
(lback(curline) == curbp->b_linep); (lback(curline) == curbp->b_linep);
} }
return (border); return border;
} }
/* /*
@ -1064,7 +1064,7 @@ static int nextch(struct line **pcurline, int *pcuroff, int dir)
*pcurline = curline; *pcurline = curline;
*pcuroff = curoff; *pcuroff = curoff;
return (c); return c;
} }
#if MAGIC #if MAGIC
@ -1187,7 +1187,7 @@ static int mcstr(void)
mcclear(); mcclear();
} }
return (status); return status;
} }
/* /*
@ -1365,7 +1365,7 @@ static int mceq(int bc, MC *mt)
} /* End of switch. */ } /* End of switch. */
return (result); return result;
} }
extern BITMAP clearbits(void); extern BITMAP clearbits(void);
@ -1403,7 +1403,7 @@ static int cclmake(char **ppatptr, MC *mcptr)
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;
@ -1461,7 +1461,7 @@ static int biteq(int bc, BITMAP cclmap)
if (bc >= HICHAR) if (bc >= HICHAR)
return FALSE; return FALSE;
return ((*(cclmap + (bc >> 3)) & BIT(bc & 7)) ? TRUE : FALSE); return (*(cclmap + (bc >> 3)) & BIT(bc & 7)) ? TRUE : FALSE;
} }
/* /*
@ -1476,7 +1476,7 @@ static BITMAP clearbits(void)
for (j = 0; j < HIBYTE; j++) for (j = 0; j < HIBYTE; j++)
*cclmap++ = 0; *cclmap++ = 0;
return (cclstart); return cclstart;
} }
/* /*

86
spawn.c
View File

@ -49,7 +49,7 @@ int spawncli(int f, int n)
/* don't allow this command if restricted */ /* don't allow this command if restricted */
if (restflag) if (restflag)
return (resterr()); return resterr();
#if VMS #if VMS
movecursor(term.t_nrow, 0); /* In last line. */ movecursor(term.t_nrow, 0); /* In last line. */
@ -61,7 +61,7 @@ int spawncli(int f, int n)
mlputs("\r\n(Returning from DCL)\r\n"); mlputs("\r\n(Returning from DCL)\r\n");
TTflush(); TTflush();
sleep(1); sleep(1);
return (TRUE); return TRUE;
#endif #endif
#if MSDOS & (MSC | TURBO) #if MSDOS & (MSC | TURBO)
movecursor(term.t_nrow, 0); /* Seek to last line. */ movecursor(term.t_nrow, 0); /* Seek to last line. */
@ -70,7 +70,7 @@ int spawncli(int f, int n)
shellprog(""); shellprog("");
TTkopen(); TTkopen();
sgarbf = TRUE; sgarbf = TRUE;
return (TRUE); return TRUE;
#endif #endif
#if V7 | USG | BSD #if V7 | USG | BSD
movecursor(term.t_nrow, 0); /* Seek to last line. */ movecursor(term.t_nrow, 0); /* Seek to last line. */
@ -98,7 +98,7 @@ int spawncli(int f, int n)
chg_height = term.t_nrow + 1; chg_height = term.t_nrow + 1;
term.t_nrow = term.t_ncol = 0; term.t_nrow = term.t_ncol = 0;
#endif #endif
return (TRUE); return TRUE;
#endif #endif
} }
@ -114,7 +114,7 @@ int bktoshell(int f, int n)
kill(pid,SIGTSTP); kill(pid,SIGTSTP);
******************************/ ******************************/
kill(0, SIGTSTP); kill(0, SIGTSTP);
return (TRUE); return TRUE;
} }
void rtfrmshell(void) void rtfrmshell(void)
@ -137,11 +137,11 @@ int spawn(int f, int n)
/* don't allow this command if restricted */ /* don't allow this command if restricted */
if (restflag) if (restflag)
return (resterr()); return resterr();
#if VMS #if VMS
if ((s = mlreply("!", line, NLINE)) != TRUE) if ((s = mlreply("!", line, NLINE)) != TRUE)
return (s); return s;
movecursor(term.t_nrow, 0); movecursor(term.t_nrow, 0);
TTflush(); TTflush();
s = sys(line); /* Run the command. */ s = sys(line); /* Run the command. */
@ -151,11 +151,11 @@ int spawn(int f, int n)
tgetc(); tgetc();
} }
sgarbf = TRUE; sgarbf = TRUE;
return (s); return s;
#endif #endif
#if MSDOS #if MSDOS
if ((s = mlreply("!", line, NLINE)) != TRUE) if ((s = mlreply("!", line, NLINE)) != TRUE)
return (s); return s;
movecursor(term.t_nrow, 0); movecursor(term.t_nrow, 0);
TTkclose(); TTkclose();
shellprog(line); shellprog(line);
@ -166,11 +166,11 @@ int spawn(int f, int n)
tgetc(); tgetc();
} }
sgarbf = TRUE; sgarbf = TRUE;
return (TRUE); return TRUE;
#endif #endif
#if V7 | USG | BSD #if V7 | USG | BSD
if ((s = mlreply("!", line, NLINE)) != TRUE) if ((s = mlreply("!", line, NLINE)) != TRUE)
return (s); return s;
TTflush(); TTflush();
TTclose(); /* stty to old modes */ TTclose(); /* stty to old modes */
TTkclose(); TTkclose();
@ -186,7 +186,7 @@ int spawn(int f, int n)
} }
TTkopen(); TTkopen();
sgarbf = TRUE; sgarbf = TRUE;
return (TRUE); return TRUE;
#endif #endif
} }
@ -203,23 +203,23 @@ int execprg(int f, int n)
/* don't allow this command if restricted */ /* don't allow this command if restricted */
if (restflag) if (restflag)
return (resterr()); return resterr();
#if VMS #if VMS
if ((s = mlreply("!", line, NLINE)) != TRUE) if ((s = mlreply("!", line, NLINE)) != TRUE)
return (s); return s;
TTflush(); TTflush();
s = sys(line); /* Run the command. */ s = sys(line); /* Run the command. */
mlputs("\r\n\n(End)"); /* Pause. */ mlputs("\r\n\n(End)"); /* Pause. */
TTflush(); TTflush();
tgetc(); tgetc();
sgarbf = TRUE; sgarbf = TRUE;
return (s); return s;
#endif #endif
#if MSDOS #if MSDOS
if ((s = mlreply("$", line, NLINE)) != TRUE) if ((s = mlreply("$", line, NLINE)) != TRUE)
return (s); return s;
movecursor(term.t_nrow, 0); movecursor(term.t_nrow, 0);
TTkclose(); TTkclose();
execprog(line); execprog(line);
@ -230,12 +230,12 @@ int execprg(int f, int n)
tgetc(); tgetc();
} }
sgarbf = TRUE; sgarbf = TRUE;
return (TRUE); return TRUE;
#endif #endif
#if V7 | USG | BSD #if V7 | USG | BSD
if ((s = mlreply("!", line, NLINE)) != TRUE) if ((s = mlreply("!", line, NLINE)) != TRUE)
return (s); return s;
TTputc('\n'); /* Already have '\r' */ TTputc('\n'); /* Already have '\r' */
TTflush(); TTflush();
TTclose(); /* stty to old modes */ TTclose(); /* stty to old modes */
@ -246,7 +246,7 @@ int execprg(int f, int n)
TTflush(); TTflush();
while ((s = tgetc()) != '\r' && s != ' '); while ((s = tgetc()) != '\r' && s != ' ');
sgarbf = TRUE; sgarbf = TRUE;
return (TRUE); return TRUE;
#endif #endif
} }
@ -272,7 +272,7 @@ int pipecmd(int f, int n)
/* don't allow this command if restricted */ /* don't allow this command if restricted */
if (restflag) if (restflag)
return (resterr()); return resterr();
#if MSDOS #if MSDOS
if ((tmp = getenv("TMP")) == NULL if ((tmp = getenv("TMP")) == NULL
@ -290,12 +290,12 @@ int pipecmd(int f, int n)
#if VMS #if VMS
mlwrite("Not available under VMS"); mlwrite("Not available under VMS");
return (FALSE); return FALSE;
#endif #endif
/* get the command to pipe in */ /* get the command to pipe in */
if ((s = mlreply("@", line, NLINE)) != TRUE) if ((s = mlreply("@", line, NLINE)) != TRUE)
return (s); return s;
/* get rid of the command output buffer if it exists */ /* get rid of the command output buffer if it exists */
if ((bp = bfind(bname, FALSE, 0)) != FALSE) { if ((bp = bfind(bname, FALSE, 0)) != FALSE) {
@ -318,7 +318,7 @@ int pipecmd(int f, int n)
} }
if (zotbuf(bp) != TRUE) if (zotbuf(bp) != TRUE)
return (FALSE); return FALSE;
} }
#if MSDOS #if MSDOS
strcat(line, " >>"); strcat(line, " >>");
@ -349,15 +349,15 @@ int pipecmd(int f, int n)
#endif #endif
if (s != TRUE) if (s != TRUE)
return (s); return s;
/* split the current window to make room for the command output */ /* split the current window to make room for the command output */
if (splitwind(FALSE, 1) == FALSE) if (splitwind(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
/* and read the stuff in */ /* and read the stuff in */
if (getfile(filnam, FALSE) == FALSE) if (getfile(filnam, FALSE) == FALSE)
return (FALSE); return FALSE;
/* make this window in VIEW mode, update all mode lines */ /* make this window in VIEW mode, update all mode lines */
curwp->w_bufp->b_mode |= MDVIEW; curwp->w_bufp->b_mode |= MDVIEW;
@ -369,7 +369,7 @@ int pipecmd(int f, int n)
/* and get rid of the temporary file */ /* and get rid of the temporary file */
unlink(filnam); unlink(filnam);
return (TRUE); return TRUE;
} }
/* /*
@ -389,19 +389,19 @@ int filter_buffer(int f, int n)
/* don't allow this command if restricted */ /* don't allow this command if restricted */
if (restflag) if (restflag)
return (resterr()); return resterr();
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
#if VMS #if VMS
mlwrite("Not available under VMS"); mlwrite("Not available under VMS");
return (FALSE); return FALSE;
#endif #endif
/* get the filter name and its args */ /* get the filter name and its args */
if ((s = mlreply("#", line, NLINE)) != TRUE) if ((s = mlreply("#", line, NLINE)) != TRUE)
return (s); return s;
/* setup the proper file names */ /* setup the proper file names */
bp = curbp; bp = curbp;
@ -412,7 +412,7 @@ int filter_buffer(int f, int n)
if (writeout(filnam1) != TRUE) { if (writeout(filnam1) != TRUE) {
mlwrite("(Cannot write filter file)"); mlwrite("(Cannot write filter file)");
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");
@ -442,7 +442,7 @@ int filter_buffer(int f, int n)
strcpy(bp->b_fname, tmpnam); strcpy(bp->b_fname, tmpnam);
unlink(filnam1); unlink(filnam1);
unlink(filnam2); unlink(filnam2);
return (s); return s;
} }
/* reset file name */ /* reset file name */
@ -452,7 +452,7 @@ int filter_buffer(int f, int n)
/* and get rid of the temporary file */ /* and get rid of the temporary file */
unlink(filnam1); unlink(filnam1);
unlink(filnam2); unlink(filnam2);
return (TRUE); return TRUE;
} }
#if VMS #if VMS
@ -473,7 +473,7 @@ int sys(char *cmd)
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
oldmode, sizeof(oldmode), 0, 0, 0, 0); oldmode, sizeof(oldmode), 0, 0, 0, 0);
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
return (FALSE); return FALSE;
cdscp = NULL; /* Assume DCL. */ cdscp = NULL; /* Assume DCL. */
if (cmd != NULL) { /* Build descriptor. */ if (cmd != NULL) { /* Build descriptor. */
cdsc.dsc$a_pointer = cmd; cdsc.dsc$a_pointer = cmd;
@ -488,10 +488,10 @@ int sys(char *cmd)
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
newmode, sizeof(newmode), 0, 0, 0, 0); newmode, sizeof(newmode), 0, 0, 0, 0);
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
return (FALSE); return FALSE;
if ((substatus & STS$M_SUCCESS) == 0) /* Command failed. */ if ((substatus & STS$M_SUCCESS) == 0) /* Command failed. */
return (FALSE); return FALSE;
return (TRUE); return TRUE;
} }
#endif #endif
@ -518,7 +518,7 @@ int shellprog(char *cmd)
/* get name of system shell */ /* get name of system shell */
if ((shell = getenv("COMSPEC")) == NULL) { if ((shell = getenv("COMSPEC")) == NULL) {
return (FALSE); /* No shell located */ return FALSE; /* No shell located */
} }
/* trim leading whitespace off the command */ /* trim leading whitespace off the command */
@ -536,9 +536,9 @@ int shellprog(char *cmd)
comline[strlen(comline)] = swchar; comline[strlen(comline)] = swchar;
strcat(comline, "c "); strcat(comline, "c ");
strcat(comline, cmd); strcat(comline, cmd);
return (execprog(comline)); return execprog(comline);
} else } else
return (execprog(shell)); return execprog(shell);
} }
/* /*
@ -583,7 +583,7 @@ int execprog(char *cmd)
if ((sp = flook(strcat(prog, ".exe"), TRUE)) == NULL) { if ((sp = flook(strcat(prog, ".exe"), TRUE)) == NULL) {
strcpy(&prog[strlen(prog) - 4], ".com"); strcpy(&prog[strlen(prog) - 4], ".com");
if ((sp = flook(prog, TRUE)) == NULL) if ((sp = flook(prog, TRUE)) == NULL)
return (FALSE); return FALSE;
} }
strcpy(prog, sp); strcpy(prog, sp);
@ -616,6 +616,6 @@ int execprog(char *cmd)
rval = -_doserrno; /* failed child call */ rval = -_doserrno; /* failed child call */
#endif #endif
#endif #endif
return ((rval < 0) ? FALSE : TRUE); return (rval < 0) ? FALSE : TRUE;
} }
#endif #endif

4
tcap.c
View File

@ -271,7 +271,7 @@ static void tcaprev(int state)
static int tcapcres(char *res) static int tcapcres(char *res)
{ /* change screen resolution */ { /* change screen resolution */
return (TRUE); return TRUE;
} }
#if SCROLLCODE #if SCROLLCODE
@ -362,7 +362,7 @@ static void putpad(char *str)
static int fnclabel(int f, int n) static int fnclabel(int f, int n)
{ {
/* on machines with no function keys...don't bother */ /* on machines with no function keys...don't bother */
return (TRUE); return TRUE;
} }
#endif #endif
#else #else

View File

@ -370,7 +370,7 @@ ttgetc()
nibuf = (iosb[0] >> 16) + (iosb[1] >> 16); nibuf = (iosb[0] >> 16) + (iosb[1] >> 16);
} }
} }
return (ibuf[ibufi++] & 0xFF); /* Allow multinational */ return ibuf[ibufi++] & 0xFF; /* Allow multinational */
#endif #endif
#if MSDOS & (MSC | TURBO) #if MSDOS & (MSC | TURBO)
@ -380,18 +380,18 @@ ttgetc()
if (nxtchar >= 0) { if (nxtchar >= 0) {
c = nxtchar; c = nxtchar;
nxtchar = -1; nxtchar = -1;
return (c); return c;
} }
/* call the dos to get a char */ /* call the dos to get a char */
rg.h.ah = 7; /* dos Direct Console Input call */ rg.h.ah = 7; /* dos Direct Console Input call */
intdos(&rg, &rg); intdos(&rg, &rg);
c = rg.h.al; /* grab the char */ c = rg.h.al; /* grab the char */
return (c & 255); return c & 255;
#endif #endif
#if V7 | BSD #if V7 | BSD
return (255 & fgetc(stdin)); /* 8BIT P.K. */ return 255 & fgetc(stdin); /* 8BIT P.K. */
#endif #endif
#if USG #if USG
@ -403,7 +403,7 @@ ttgetc()
kbdpoll = FALSE; kbdpoll = FALSE;
while (read(0, &kbdq, 1) != 1); while (read(0, &kbdq, 1) != 1);
} }
return (kbdq & 255); return kbdq & 255;
#endif #endif
} }
@ -416,35 +416,35 @@ typahead()
{ {
#if MSDOS & (MSC | TURBO) #if MSDOS & (MSC | TURBO)
if (kbhit() != 0) if (kbhit() != 0)
return (TRUE); return TRUE;
else else
return (FALSE); return FALSE;
#endif #endif
#if BSD #if BSD
int x; /* holds # of pending chars */ int x; /* holds # of pending chars */
return ((ioctl(0, FIONREAD, &x) < 0) ? 0 : x); return (ioctl(0, FIONREAD, &x) < 0) ? 0 : x;
#endif #endif
#if PKCODE & VMS #if PKCODE & VMS
return (ibufi < nibuf); return ibufi < nibuf;
#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
kbdpoll = 1; kbdpoll = 1;
#endif #endif
kbdqp = (1 == read(0, &kbdq, 1)); kbdqp = (1 == read(0, &kbdq, 1));
} }
return (kbdqp); return kbdqp;
#endif #endif
#if !UNIX & !VMS & !MSDOS #if !UNIX & !VMS & !MSDOS
return (FALSE); return FALSE;
#endif #endif
} }
#endif #endif

View File

@ -497,7 +497,7 @@ fnclabel(f, n) /* label a function key */
int f, n; /* default flag, numeric argument [unused] */ int f, n; /* default flag, numeric argument [unused] */
{ {
/* on machines with no function keys...don't bother */ /* on machines with no function keys...don't bother */
return (TRUE); return TRUE;
} }
#endif #endif

4
vt52.c
View File

@ -112,7 +112,7 @@ int status; /* TRUE = reverse video, FALSE = normal video */
vt52cres() vt52cres()
{ /* change screen resolution - (not here though) */ { /* change screen resolution - (not here though) */
return (TRUE); return TRUE;
} }
spal() spal()
@ -172,7 +172,7 @@ int f, n; /* default flag, numeric argument [unused] */
{ {
/* on machines with no function keys...don't bother */ /* on machines with no function keys...don't bother */
return (TRUE); return TRUE;
} }
#endif #endif
#endif #endif

View File

@ -22,7 +22,7 @@ int reposition(int f, int n)
n = 0; n = 0;
curwp->w_force = n; curwp->w_force = n;
curwp->w_flag |= WFFORCE; curwp->w_flag |= WFFORCE;
return (TRUE); return TRUE;
} }
/* /*
@ -38,7 +38,7 @@ int redraw(int f, int n)
curwp->w_flag |= WFFORCE; curwp->w_flag |= WFFORCE;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -78,7 +78,7 @@ int nextwind(int f, int n)
wp = wp->w_wndp; wp = wp->w_wndp;
} else { } else {
mlwrite("Window number out of range"); mlwrite("Window number out of range");
return (FALSE); return FALSE;
} }
} else if ((wp = curwp->w_wndp) == NULL) } else if ((wp = curwp->w_wndp) == NULL)
wp = wheadp; wp = wheadp;
@ -86,7 +86,7 @@ int nextwind(int f, int n)
curbp = wp->w_bufp; curbp = wp->w_bufp;
cknewwindow(); cknewwindow();
upmode(); upmode();
return (TRUE); return TRUE;
} }
/* /*
@ -101,7 +101,7 @@ int prevwind(int f, int n)
/* if we have an argument, we mean the nth window from the bottom */ /* if we have an argument, we mean the nth window from the bottom */
if (f) if (f)
return (nextwind(f, -n)); return nextwind(f, -n);
wp1 = wheadp; wp1 = wheadp;
wp2 = curwp; wp2 = curwp;
@ -116,7 +116,7 @@ int prevwind(int f, int n)
curbp = wp1->w_bufp; curbp = wp1->w_bufp;
cknewwindow(); cknewwindow();
upmode(); upmode();
return (TRUE); return TRUE;
} }
/* /*
@ -128,7 +128,7 @@ int prevwind(int f, int n)
*/ */
int mvdnwind(int f, int n) int mvdnwind(int f, int n)
{ {
return (mvupwind(f, -n)); return mvupwind(f, -n);
} }
/* /*
@ -158,7 +158,7 @@ int mvupwind(int f, int n)
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)
break; break;
lp = lforw(lp); lp = lforw(lp);
@ -172,7 +172,7 @@ int mvupwind(int f, int n)
curwp->w_dotp = lp; curwp->w_dotp = lp;
curwp->w_doto = 0; curwp->w_doto = 0;
return (TRUE); return TRUE;
} }
/* /*
@ -220,7 +220,7 @@ int onlywind(int f, int n)
curwp->w_ntrows = term.t_nrow - 1; curwp->w_ntrows = term.t_nrow - 1;
curwp->w_linep = lp; curwp->w_linep = lp;
curwp->w_flag |= WFMODE | WFHARD; curwp->w_flag |= WFMODE | WFHARD;
return (TRUE); return TRUE;
} }
/* /*
@ -238,7 +238,7 @@ int delwind(int f, int n)
/* if there is only one window, don't delete it */ /* if there is only one window, don't delete it */
if (wheadp->w_wndp == NULL) { if (wheadp->w_wndp == NULL) {
mlwrite("Can not delete this window"); mlwrite("Can not delete this window");
return (FALSE); return FALSE;
} }
/* find window before curwp in linked list */ /* find window before curwp in linked list */
@ -262,7 +262,7 @@ int delwind(int f, int n)
wp = wp->w_wndp; wp = wp->w_wndp;
} }
if (wp == NULL) if (wp == NULL)
return (FALSE); return FALSE;
wp->w_toprow = 0; wp->w_toprow = 0;
wp->w_ntrows += target; wp->w_ntrows += target;
} else { } else {
@ -274,7 +274,7 @@ int delwind(int f, int n)
wp = wp->w_wndp; wp = wp->w_wndp;
} }
if (wp == NULL) if (wp == NULL)
return (FALSE); return FALSE;
wp->w_ntrows += 1 + curwp->w_ntrows; wp->w_ntrows += 1 + curwp->w_ntrows;
} }
@ -295,7 +295,7 @@ int delwind(int f, int n)
curbp = wp->w_bufp; curbp = wp->w_bufp;
cknewwindow(); cknewwindow();
upmode(); upmode();
return (TRUE); return TRUE;
} }
/* /*
@ -319,11 +319,11 @@ int splitwind(int f, int n)
if (curwp->w_ntrows < 3) { if (curwp->w_ntrows < 3) {
mlwrite("Cannot split a %d line window", curwp->w_ntrows); mlwrite("Cannot split a %d line window", curwp->w_ntrows);
return (FALSE); return FALSE;
} }
if ((wp = (struct window *)malloc(sizeof(struct window))) == NULL) { if ((wp = (struct window *)malloc(sizeof(struct window))) == NULL) {
mlwrite("(OUT OF MEMORY)"); mlwrite("(OUT OF MEMORY)");
return (FALSE); return FALSE;
} }
++curbp->b_nwnd; /* Displayed twice. */ ++curbp->b_nwnd; /* Displayed twice. */
wp->w_bufp = curbp; wp->w_bufp = curbp;
@ -380,7 +380,7 @@ int splitwind(int f, int n)
wp->w_linep = lp; /* if necessary. */ wp->w_linep = lp; /* if necessary. */
curwp->w_flag |= WFMODE | WFHARD; curwp->w_flag |= WFMODE | WFHARD;
wp->w_flag |= WFMODE | WFHARD; wp->w_flag |= WFMODE | WFHARD;
return (TRUE); return TRUE;
} }
/* /*
@ -396,10 +396,10 @@ int enlargewind(int f, int n)
int i; int i;
if (n < 0) if (n < 0)
return (shrinkwind(f, -n)); return shrinkwind(f, -n);
if (wheadp->w_wndp == NULL) { if (wheadp->w_wndp == NULL) {
mlwrite("Only one window"); mlwrite("Only one window");
return (FALSE); return FALSE;
} }
if ((adjwp = curwp->w_wndp) == NULL) { if ((adjwp = curwp->w_wndp) == NULL) {
adjwp = wheadp; adjwp = wheadp;
@ -408,7 +408,7 @@ int enlargewind(int f, int n)
} }
if (adjwp->w_ntrows <= n) { if (adjwp->w_ntrows <= n) {
mlwrite("Impossible change"); mlwrite("Impossible change");
return (FALSE); return FALSE;
} }
if (curwp->w_wndp == adjwp) { /* Shrink below. */ if (curwp->w_wndp == adjwp) { /* Shrink below. */
lp = adjwp->w_linep; lp = adjwp->w_linep;
@ -432,7 +432,7 @@ int enlargewind(int f, int n)
curwp->w_flag |= WFMODE | WFHARD; curwp->w_flag |= WFMODE | WFHARD;
adjwp->w_flag |= WFMODE | WFHARD; adjwp->w_flag |= WFMODE | WFHARD;
#endif #endif
return (TRUE); return TRUE;
} }
/* /*
@ -447,10 +447,10 @@ int shrinkwind(int f, int n)
int i; int i;
if (n < 0) if (n < 0)
return (enlargewind(f, -n)); return enlargewind(f, -n);
if (wheadp->w_wndp == NULL) { if (wheadp->w_wndp == NULL) {
mlwrite("Only one window"); mlwrite("Only one window");
return (FALSE); return FALSE;
} }
if ((adjwp = curwp->w_wndp) == NULL) { if ((adjwp = curwp->w_wndp) == NULL) {
adjwp = wheadp; adjwp = wheadp;
@ -459,7 +459,7 @@ int shrinkwind(int f, int n)
} }
if (curwp->w_ntrows <= n) { if (curwp->w_ntrows <= n) {
mlwrite("Impossible change"); mlwrite("Impossible change");
return (FALSE); return FALSE;
} }
if (curwp->w_wndp == adjwp) { /* Grow below. */ if (curwp->w_wndp == adjwp) { /* Grow below. */
lp = adjwp->w_linep; lp = adjwp->w_linep;
@ -484,7 +484,7 @@ int shrinkwind(int f, int n)
curwp->w_flag |= WFMODE | WFHARD; curwp->w_flag |= WFMODE | WFHARD;
adjwp->w_flag |= WFMODE | WFHARD; adjwp->w_flag |= WFMODE | WFHARD;
#endif #endif
return (TRUE); return TRUE;
} }
/* /*
@ -498,16 +498,16 @@ int resize(int f, int n)
/* must have a non-default argument, else ignore call */ /* must have a non-default argument, else ignore call */
if (f == FALSE) if (f == FALSE)
return (TRUE); return TRUE;
/* find out what to do */ /* find out what to do */
clines = curwp->w_ntrows; clines = curwp->w_ntrows;
/* already the right size? */ /* already the right size? */
if (clines == n) if (clines == n)
return (TRUE); return TRUE;
return (enlargewind(TRUE, n - clines)); return enlargewind(TRUE, n - clines);
} }
/* /*
@ -521,11 +521,11 @@ struct window *wpopup(void)
if (wheadp->w_wndp == NULL /* Only 1 window */ if (wheadp->w_wndp == NULL /* Only 1 window */
&& splitwind(FALSE, 0) == FALSE) /* and it won't split */ && splitwind(FALSE, 0) == FALSE) /* and it won't split */
return (NULL); return NULL;
wp = wheadp; /* Find window to use */ wp = wheadp; /* Find window to use */
while (wp != NULL && wp == curwp) while (wp != NULL && wp == curwp)
wp = wp->w_wndp; wp = wp->w_wndp;
return (wp); return wp;
} }
int scrnextup(int f, int n) int scrnextup(int f, int n)
@ -533,7 +533,7 @@ int scrnextup(int f, int n)
nextwind(FALSE, 1); nextwind(FALSE, 1);
backpage(f, n); backpage(f, n);
prevwind(FALSE, 1); prevwind(FALSE, 1);
return (TRUE); return TRUE;
} }
int scrnextdw(int f, int n) int scrnextdw(int f, int n)
@ -541,13 +541,13 @@ int scrnextdw(int f, int n)
nextwind(FALSE, 1); nextwind(FALSE, 1);
forwpage(f, n); forwpage(f, n);
prevwind(FALSE, 1); prevwind(FALSE, 1);
return (TRUE); return TRUE;
} }
int savewnd(int f, int n) int savewnd(int f, int n)
{ /* save ptr to current window */ { /* save ptr to current window */
swindow = curwp; swindow = curwp;
return (TRUE); return TRUE;
} }
int restwnd(int f, int n) int restwnd(int f, int n)
@ -561,13 +561,13 @@ int restwnd(int f, int n)
curwp = wp; curwp = wp;
curbp = wp->w_bufp; curbp = wp->w_bufp;
upmode(); upmode();
return (TRUE); return TRUE;
} }
wp = wp->w_wndp; wp = wp->w_wndp;
} }
mlwrite("(No such window exists)"); mlwrite("(No such window exists)");
return (FALSE); return FALSE;
} }
/* /*
@ -590,11 +590,11 @@ int newsize(int f, int n)
/* make sure it's in range */ /* make sure it's in range */
if (n < 3 || n > term.t_mrow + 1) { if (n < 3 || n > term.t_mrow + 1) {
mlwrite("%%Screen size out of range"); mlwrite("%%Screen size out of range");
return (FALSE); return FALSE;
} }
if (term.t_nrow == n - 1) if (term.t_nrow == n - 1)
return (TRUE); return TRUE;
else if (term.t_nrow < n - 1) { else if (term.t_nrow < n - 1) {
/* go to the last window */ /* go to the last window */
@ -655,7 +655,7 @@ int newsize(int f, int n)
/* screen is garbage */ /* screen is garbage */
term.t_nrow = n - 1; term.t_nrow = n - 1;
sgarbf = TRUE; sgarbf = TRUE;
return (TRUE); return TRUE;
} }
/* /*
@ -675,7 +675,7 @@ int newwidth(int f, int n)
/* make sure it's in range */ /* make sure it's in range */
if (n < 10 || n > term.t_mcol) { if (n < 10 || n > term.t_mcol) {
mlwrite("%%Screen width out of range"); mlwrite("%%Screen width out of range");
return (FALSE); return FALSE;
} }
/* otherwise, just re-width it (no big deal) */ /* otherwise, just re-width it (no big deal) */
@ -691,7 +691,7 @@ int newwidth(int f, int n)
} }
sgarbf = TRUE; sgarbf = TRUE;
return (TRUE); return TRUE;
} }
int getwpos(void) int getwpos(void)
@ -708,7 +708,7 @@ int getwpos(void)
} }
/* and return the value */ /* and return the value */
return (sline); return sline;
} }
void cknewwindow(void) void cknewwindow(void)

124
word.c
View File

@ -30,7 +30,7 @@ int wrapword(int f, int n)
/* backup from the <NL> 1 char */ /* backup from the <NL> 1 char */
if (!backchar(0, 1)) if (!backchar(0, 1))
return (FALSE); return FALSE;
/* back up until we aren't in a word, /* back up until we aren't in a word,
make sure there is a break in the line */ make sure there is a break in the line */
@ -39,28 +39,28 @@ int wrapword(int f, int n)
&& (c != '\t')) { && (c != '\t')) {
cnt++; cnt++;
if (!backchar(0, 1)) if (!backchar(0, 1))
return (FALSE); return FALSE;
/* if we make it to the beginning, start a new line */ /* if we make it to the beginning, start a new line */
if (curwp->w_doto == 0) { if (curwp->w_doto == 0) {
gotoeol(FALSE, 0); gotoeol(FALSE, 0);
return (lnewline()); return lnewline();
} }
} }
/* delete the forward white space */ /* delete the forward white space */
if (!forwdel(0, 1)) if (!forwdel(0, 1))
return (FALSE); return FALSE;
/* put in a end of line */ /* put in a end of line */
if (!lnewline()) if (!lnewline())
return (FALSE); return FALSE;
/* and past the first word */ /* and past the first word */
while (cnt-- > 0) { while (cnt-- > 0) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
return (TRUE); return TRUE;
} }
/* /*
@ -71,20 +71,20 @@ int wrapword(int f, int n)
int backword(int f, int n) int backword(int f, int n)
{ {
if (n < 0) if (n < 0)
return (forwword(f, -n)); return forwword(f, -n);
if (backchar(FALSE, 1) == FALSE) if (backchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
while (n--) { while (n--) {
while (inword() == FALSE) { while (inword() == FALSE) {
if (backchar(FALSE, 1) == FALSE) if (backchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
while (inword() != FALSE) { while (inword() != FALSE) {
if (backchar(FALSE, 1) == FALSE) if (backchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
} }
return (forwchar(FALSE, 1)); return forwchar(FALSE, 1);
} }
/* /*
@ -94,19 +94,19 @@ int backword(int f, int n)
int forwword(int f, int n) int forwword(int f, int n)
{ {
if (n < 0) if (n < 0)
return (backword(f, -n)); return backword(f, -n);
while (n--) { while (n--) {
while (inword() == TRUE) { while (inword() == TRUE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
while (inword() == FALSE) { while (inword() == FALSE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
} }
return (TRUE); return TRUE;
} }
/* /*
@ -119,13 +119,13 @@ int upperword(int f, int n)
int c; int c;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
while (n--) { while (n--) {
while (inword() == FALSE) { while (inword() == FALSE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
while (inword() != FALSE) { while (inword() != FALSE) {
c = lgetc(curwp->w_dotp, curwp->w_doto); c = lgetc(curwp->w_dotp, curwp->w_doto);
@ -139,10 +139,10 @@ int upperword(int f, int n)
lchange(WFHARD); lchange(WFHARD);
} }
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
} }
return (TRUE); return TRUE;
} }
/* /*
@ -155,13 +155,13 @@ int lowerword(int f, int n)
int c; int c;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
while (n--) { while (n--) {
while (inword() == FALSE) { while (inword() == FALSE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
while (inword() != FALSE) { while (inword() != FALSE) {
c = lgetc(curwp->w_dotp, curwp->w_doto); c = lgetc(curwp->w_dotp, curwp->w_doto);
@ -175,10 +175,10 @@ int lowerword(int f, int n)
lchange(WFHARD); lchange(WFHARD);
} }
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
} }
return (TRUE); return TRUE;
} }
/* /*
@ -192,13 +192,13 @@ int capword(int f, int n)
int c; int c;
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
while (n--) { while (n--) {
while (inword() == FALSE) { while (inword() == FALSE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
if (inword() != FALSE) { if (inword() != FALSE) {
c = lgetc(curwp->w_dotp, curwp->w_doto); c = lgetc(curwp->w_dotp, curwp->w_doto);
@ -212,7 +212,7 @@ int capword(int f, int n)
lchange(WFHARD); lchange(WFHARD);
} }
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
while (inword() != FALSE) { while (inword() != FALSE) {
c = lgetc(curwp->w_dotp, curwp->w_doto); c = lgetc(curwp->w_dotp, curwp->w_doto);
#if PKCODE #if PKCODE
@ -226,11 +226,11 @@ int capword(int f, int n)
lchange(WFHARD); lchange(WFHARD);
} }
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
} }
} }
} }
return (TRUE); return TRUE;
} }
/* /*
@ -248,11 +248,11 @@ int delfword(int f, int n)
/* don't allow this command if we are in read only mode */ /* don't allow this command if we are in read only mode */
if (curbp->b_mode & MDVIEW) if (curbp->b_mode & MDVIEW)
return (rdonly()); return rdonly();
/* ignore the command if there is a negative argument */ /* ignore the command if there is a negative argument */
if (n < 0) if (n < 0)
return (FALSE); return FALSE;
/* Clear the kill buffer if last command wasn't a kill */ /* Clear the kill buffer if last command wasn't a kill */
if ((lastflag & CFKILL) == 0) if ((lastflag & CFKILL) == 0)
@ -269,7 +269,7 @@ int delfword(int f, int n)
/* get us into a word.... */ /* get us into a word.... */
while (inword() == FALSE) { while (inword() == FALSE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
++size; ++size;
} }
@ -277,7 +277,7 @@ int delfword(int f, int n)
/* skip one word, no whitespace! */ /* skip one word, no whitespace! */
while (inword() == TRUE) { while (inword() == TRUE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
++size; ++size;
} }
} else { } else {
@ -287,14 +287,14 @@ int delfword(int f, int n)
/* if we are at EOL; skip to the beginning of the next */ /* if we are at EOL; skip to the beginning of the next */
while (curwp->w_doto == llength(curwp->w_dotp)) { while (curwp->w_doto == llength(curwp->w_dotp)) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
++size; ++size;
} }
/* move forward till we are at the end of the word */ /* move forward till we are at the end of the word */
while (inword() == TRUE) { while (inword() == TRUE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
++size; ++size;
} }
@ -302,7 +302,7 @@ int delfword(int f, int n)
if (n != 0) if (n != 0)
while (inword() == FALSE) { while (inword() == FALSE) {
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
++size; ++size;
} }
} }
@ -320,7 +320,7 @@ int delfword(int f, int n)
/* restore the original position and delete the words */ /* restore the original position and delete the words */
curwp->w_dotp = dotp; curwp->w_dotp = dotp;
curwp->w_doto = doto; curwp->w_doto = doto;
return (ldelete(size, TRUE)); return ldelete(size, TRUE);
} }
/* /*
@ -334,11 +334,11 @@ int delbword(int f, int n)
/* don't allow this command if we are in read only mode */ /* don't allow this command if we are in read only mode */
if (curbp->b_mode & MDVIEW) if (curbp->b_mode & MDVIEW)
return (rdonly()); return rdonly();
/* ignore the command if there is a nonpositive argument */ /* ignore the command if there is a nonpositive argument */
if (n <= 0) if (n <= 0)
return (FALSE); return FALSE;
/* Clear the kill buffer if last command wasn't a kill */ /* Clear the kill buffer if last command wasn't a kill */
if ((lastflag & CFKILL) == 0) if ((lastflag & CFKILL) == 0)
@ -346,12 +346,12 @@ int delbword(int f, int n)
thisflag |= CFKILL; /* this command is a kill */ thisflag |= CFKILL; /* this command is a kill */
if (backchar(FALSE, 1) == FALSE) if (backchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
size = 0; size = 0;
while (n--) { while (n--) {
while (inword() == FALSE) { while (inword() == FALSE) {
if (backchar(FALSE, 1) == FALSE) if (backchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
++size; ++size;
} }
while (inword() != FALSE) { while (inword() != FALSE) {
@ -361,8 +361,8 @@ int delbword(int f, int n)
} }
} }
if (forwchar(FALSE, 1) == FALSE) if (forwchar(FALSE, 1) == FALSE)
return (FALSE); return FALSE;
bckdel:return (ldelete(size, TRUE)); bckdel:return ldelete(size, TRUE);
} }
/* /*
@ -374,19 +374,19 @@ int inword(void)
int c; int c;
if (curwp->w_doto == llength(curwp->w_dotp)) if (curwp->w_doto == llength(curwp->w_dotp))
return (FALSE); return FALSE;
c = lgetc(curwp->w_dotp, curwp->w_doto); c = lgetc(curwp->w_dotp, curwp->w_doto);
#if PKCODE #if PKCODE
if (isletter(c)) if (isletter(c))
#else #else
if (c >= 'a' && c <= 'z') if (c >= 'a' && c <= 'z')
return (TRUE); return TRUE;
if (c >= 'A' && c <= 'Z') if (c >= 'A' && c <= 'Z')
#endif #endif
return (TRUE); return TRUE;
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
return (TRUE); return TRUE;
return (FALSE); return FALSE;
} }
#if WORDPRO #if WORDPRO
@ -410,10 +410,10 @@ int fillpara(int f, int n)
char wbuf[NSTRING]; /* buffer for current word */ char wbuf[NSTRING]; /* buffer for current word */
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (fillcol == 0) { /* no fill column set */ if (fillcol == 0) { /* no fill column set */
mlwrite("No fill column set"); mlwrite("No fill column set");
return (FALSE); return FALSE;
} }
#if PKCODE #if PKCODE
justflag = FALSE; justflag = FALSE;
@ -484,7 +484,7 @@ int fillpara(int f, int n)
} }
/* and add a last newline for the end of our new paragraph */ /* and add a last newline for the end of our new paragraph */
lnewline(); lnewline();
return (TRUE); return TRUE;
} }
#if PKCODE #if PKCODE
@ -507,17 +507,17 @@ int justpara(int f, int n)
int leftmarg; /* left marginal */ int leftmarg; /* left marginal */
if (curbp->b_mode & MDVIEW) /* don't allow this command if */ if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */ return rdonly(); /* we are in read only mode */
if (fillcol == 0) { /* no fill column set */ if (fillcol == 0) { /* no fill column set */
mlwrite("No fill column set"); mlwrite("No fill column set");
return (FALSE); return FALSE;
} }
justflag = TRUE; justflag = TRUE;
leftmarg = curwp->w_doto; leftmarg = curwp->w_doto;
if (leftmarg + 10 > fillcol) { if (leftmarg + 10 > fillcol) {
leftmarg = 0; leftmarg = 0;
mlwrite("Column too narrow"); mlwrite("Column too narrow");
return (FALSE); return FALSE;
} }
/* record the pointer to the line just past the EOP */ /* record the pointer to the line just past the EOP */
@ -593,7 +593,7 @@ int justpara(int f, int n)
curwp->w_doto = llength(curwp->w_dotp); curwp->w_doto = llength(curwp->w_dotp);
justflag = FALSE; justflag = FALSE;
return (TRUE); return TRUE;
} }
#endif #endif
@ -622,12 +622,12 @@ int killpara(int f, int n)
/* and delete it */ /* and delete it */
if ((status = killregion(FALSE, 1)) != TRUE) if ((status = killregion(FALSE, 1)) != TRUE)
return (status); return status;
/* and clean up the 2 extra lines */ /* and clean up the 2 extra lines */
ldelete(2L, TRUE); ldelete(2L, TRUE);
} }
return (TRUE); return TRUE;
} }
@ -655,7 +655,7 @@ int wordcount(int f, int n)
/* make sure we have a region to count */ /* make sure we have a region to count */
if ((status = getregion(&region)) != TRUE) if ((status = getregion(&region)) != TRUE)
return (status); return status;
lp = region.r_linep; lp = region.r_linep;
offset = region.r_offset; offset = region.r_offset;
size = region.r_size; size = region.r_size;
@ -701,6 +701,6 @@ int wordcount(int f, int n)
mlwrite("Words %D Chars %D Lines %d Avg chars/word %f", mlwrite("Words %D Chars %D Lines %d Avg chars/word %f",
nwords, nchars, nlines + 1, avgch); nwords, nchars, nlines + 1, avgch);
return (TRUE); return TRUE;
} }
#endif #endif