Run "indent -kr -i8" on the sources

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

37
ansi.c
View File

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

16
basic.c
View File

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

39
bind.c
View File

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

View File

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

View File

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

View File

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

515
ebind.h
View File

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

8
edef.h
View File

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

23
epath.h
View File

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

View File

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

476
eval.c
View File

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

120
exec.c
View File

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

22
file.c
View File

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

View File

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

89
ibmpc.c
View File

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

104
input.c
View File

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

View File

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

14
line.c
View File

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

9
lock.c
View File

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

57
main.c
View File

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

View File

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

View File

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

157
random.c
View File

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

View File

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

304
search.c
View File

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

20
spawn.c
View File

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

64
tcap.c
View File

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

View File

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

32
vmsvt.c
View File

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

29
vt52.c
View File

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

View File

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

19
word.c
View File

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