From 435dd32ae2d9a5543318e5c4b5d29de672cae1b5 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 30 Sep 2005 15:26:09 -0700 Subject: [PATCH] Run "indent -kr -i8" on the sources Let's see how nasty it is to clean things up. For real. --- ansi.c | 213 ++++++----- basic.c | 360 +++++++++---------- bind.c | 251 +++++++------ buffer.c | 565 ++++++++++++++--------------- crypt.c | 24 +- display.c | 1014 ++++++++++++++++++++++++++--------------------------- ebind.h | 529 ++++++++++++++++++---------- edef.h | 386 ++++++++++---------- efunc.h | 688 ++++++++++++++++++------------------ epath.h | 23 +- estruct.h | 455 ++++++++++++------------ eval.c | 962 ++++++++++++++++++++++++++++---------------------- evar.h | 18 +- exec.c | 424 +++++++++++----------- file.c | 566 +++++++++++++++--------------- fileio.c | 168 +++++---- ibmpc.c | 323 +++++++++-------- input.c | 366 ++++++++++--------- isearch.c | 597 +++++++++++++++---------------- line.c | 256 +++++++------- lock.c | 59 ++-- main.c | 597 ++++++++++++++++--------------- pklock.c | 41 +-- posix.c | 33 +- random.c | 825 ++++++++++++++++++++++--------------------- region.c | 265 +++++++------- search.c | 1008 ++++++++++++++++++++++++---------------------------- spawn.c | 396 +++++++++++---------- tcap.c | 392 ++++++++++----------- termio.c | 351 ++++++++++--------- vmsvt.c | 292 +++++++-------- vt52.c | 167 +++++---- window.c | 601 ++++++++++++++++--------------- word.c | 245 ++++++------- 34 files changed, 6805 insertions(+), 6655 deletions(-) diff --git a/ansi.c b/ansi.c index 1f582b3..f678ff9 100644 --- a/ansi.c +++ b/ansi.c @@ -7,7 +7,7 @@ * modified by Petri Kutvonen */ -#define termdef 1 /* don't define "term" external */ +#define termdef 1 /* don't define "term" external */ #include #include "estruct.h" @@ -15,40 +15,40 @@ #if ANSI -#define NROW 25 /* Screen size. */ -#define NCOL 80 /* Edit if you want to. */ +#define NROW 25 /* Screen size. */ +#define NCOL 80 /* Edit if you want to. */ #if PKCODE #define MROW 64 #endif -#define NPAUSE 100 /* # times thru update to pause */ -#define MARGIN 8 /* size of minimim margin and */ -#define SCRSIZ 64 /* scroll size for extended lines */ -#define BEL 0x07 /* BEL character. */ -#define ESC 0x1B /* ESC character. */ +#define NPAUSE 100 /* # times thru update to pause */ +#define MARGIN 8 /* size of minimim margin and */ +#define SCRSIZ 64 /* scroll size for extended lines */ +#define BEL 0x07 /* BEL character. */ +#define ESC 0x1B /* ESC character. */ -extern int ttopen(); /* Forward references. */ -extern int ttgetc(); -extern int ttputc(); -extern int ttflush(); -extern int ttclose(); -extern int ansimove(); -extern int ansieeol(); -extern int ansieeop(); -extern int ansibeep(); -extern int ansiopen(); -extern int ansirev(); -extern int ansiclose(); -extern int ansikopen(); -extern int ansikclose(); -extern int ansicres(); +extern int ttopen(); /* Forward references. */ +extern int ttgetc(); +extern int ttputc(); +extern int ttflush(); +extern int ttclose(); +extern int ansimove(); +extern int ansieeol(); +extern int ansieeop(); +extern int ansibeep(); +extern int ansiopen(); +extern int ansirev(); +extern int ansiclose(); +extern int ansikopen(); +extern int ansikclose(); +extern int ansicres(); #if COLOR -extern int ansifcol(); -extern int ansibcol(); +extern int ansifcol(); +extern int ansibcol(); -int cfcolor = -1; /* current forground color */ -int cbcolor = -1; /* current background color */ +int cfcolor = -1; /* current forground color */ +int cbcolor = -1; /* current background color */ #endif @@ -56,85 +56,85 @@ int cbcolor = -1; /* current background color */ * Standard terminal interface dispatch table. Most of the fields point into * "termio" code. */ -TERM term = { +TERM term = { #if PKCODE - MROW-1, + MROW - 1, #else - NROW-1, + NROW - 1, #endif - NROW-1, - NCOL, - NCOL, + NROW - 1, + NCOL, + NCOL, MARGIN, SCRSIZ, NPAUSE, - ansiopen, - ansiclose, + ansiopen, + ansiclose, ansikopen, ansikclose, - ttgetc, - ttputc, - ttflush, - ansimove, - ansieeol, - ansieeop, - ansibeep, + ttgetc, + ttputc, + ttflush, + ansimove, + ansieeol, + ansieeop, + ansibeep, ansirev, ansicres #if COLOR - , ansifcol, + , ansifcol, ansibcol #endif #if SCROLLCODE - , NULL + , NULL #endif }; #if COLOR -ansifcol(color) /* set the current output color */ - -int color; /* color to set */ +ansifcol(color) + /* set the current output color */ +int color; /* color to set */ { if (color == cfcolor) return; ttputc(ESC); ttputc('['); - ansiparm(color+30); + ansiparm(color + 30); ttputc('m'); cfcolor = color; } -ansibcol(color) /* set the current background color */ - -int color; /* color to set */ +ansibcol(color) + /* set the current background color */ +int color; /* color to set */ { if (color == cbcolor) return; ttputc(ESC); ttputc('['); - ansiparm(color+40); + ansiparm(color + 40); ttputc('m'); - cbcolor = color; + cbcolor = color; } #endif ansimove(row, col) { - ttputc(ESC); - ttputc('['); - ansiparm(row+1); - ttputc(';'); - ansiparm(col+1); - ttputc('H'); + ttputc(ESC); + ttputc('['); + ansiparm(row + 1); + ttputc(';'); + ansiparm(col + 1); + ttputc('H'); } ansieeol() { - ttputc(ESC); - ttputc('['); - ttputc('K'); + ttputc(ESC); + ttputc('['); + ttputc('K'); } ansieeop() @@ -143,14 +143,14 @@ ansieeop() ansifcol(gfcolor); ansibcol(gbcolor); #endif - ttputc(ESC); - ttputc('['); - ttputc('J'); + ttputc(ESC); + ttputc('['); + ttputc('J'); } -ansirev(state) /* change reverse video state */ - -int state; /* TRUE = reverse, FALSE = normal */ +ansirev(state) + /* change reverse video state */ +int state; /* TRUE = reverse, FALSE = normal */ { #if COLOR @@ -159,7 +159,7 @@ int state; /* TRUE = reverse, FALSE = normal */ ttputc(ESC); ttputc('['); - ttputc(state ? '7': '0'); + ttputc(state ? '7' : '0'); ttputc('m'); #if COLOR if (state == FALSE) { @@ -173,62 +173,59 @@ int state; /* TRUE = reverse, FALSE = normal */ #endif } -ansicres() /* change screen resolution */ - -{ - return(TRUE); +ansicres() +{ /* change screen resolution */ + return (TRUE); } -spal(dummy) /* change pallette settings */ - -{ +spal(dummy) +{ /* change pallette settings */ /* none for now */ } ansibeep() { - ttputc(BEL); - ttflush(); + ttputc(BEL); + ttflush(); } ansiparm(n) -register int n; +register int n; { - register int q,r; + register int q, r; - q = n/10; - if (q != 0) { - r = q/10; + q = n / 10; + if (q != 0) { + r = q / 10; if (r != 0) { - ttputc((r%10)+'0'); + ttputc((r % 10) + '0'); } - ttputc((q%10) + '0'); - } - ttputc((n%10) + '0'); + ttputc((q % 10) + '0'); + } + ttputc((n % 10) + '0'); } ansiopen() { #if V7 | USG | BSD - register char *cp; - char *getenv(); + register char *cp; + char *getenv(); - if ((cp = getenv("TERM")) == NULL) { - puts("Shell variable TERM not defined!"); - exit(1); - } - if (strcmp(cp, "vt100") != 0) { - puts("Terminal type not 'vt100'!"); - exit(1); - } + if ((cp = getenv("TERM")) == NULL) { + puts("Shell variable TERM not defined!"); + exit(1); + } + if (strcmp(cp, "vt100") != 0) { + puts("Terminal type not 'vt100'!"); + exit(1); + } #endif strcpy(sres, "NORMAL"); revexist = TRUE; - ttopen(); + ttopen(); } ansiclose() - { #if COLOR ansifcol(7); @@ -237,24 +234,22 @@ 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 */ - -int f,n; /* default flag, numeric argument [unused] */ +fnclabel(f, n) + /* label a function key */ +int f, n; /* default flag, numeric argument [unused] */ { /* on machines with no function keys...don't bother */ - return(TRUE); + return (TRUE); } #endif #else diff --git a/basic.c b/basic.c index 7414744..868b95c 100644 --- a/basic.c +++ b/basic.c @@ -20,8 +20,8 @@ */ gotobol(f, n) { - curwp->w_doto = 0; - return (TRUE); + curwp->w_doto = 0; + return (TRUE); } /* @@ -31,23 +31,23 @@ gotobol(f, n) * line pointer for dot changes. */ backchar(f, n) -register int n; +register int n; { - register LINE *lp; + register LINE *lp; - if (n < 0) - return (forwchar(f, -n)); - while (n--) { - if (curwp->w_doto == 0) { - if ((lp=lback(curwp->w_dotp)) == curbp->b_linep) - return (FALSE); - curwp->w_dotp = lp; - curwp->w_doto = llength(lp); - curwp->w_flag |= WFMOVE; - } else - curwp->w_doto--; - } - return (TRUE); + if (n < 0) + return (forwchar(f, -n)); + while (n--) { + if (curwp->w_doto == 0) { + if ((lp = lback(curwp->w_dotp)) == curbp->b_linep) + return (FALSE); + curwp->w_dotp = lp; + curwp->w_doto = llength(lp); + curwp->w_flag |= WFMOVE; + } else + curwp->w_doto--; + } + return (TRUE); } /* @@ -55,8 +55,8 @@ register int n; */ gotoeol(f, n) { - curwp->w_doto = llength(curwp->w_dotp); - return (TRUE); + curwp->w_doto = llength(curwp->w_dotp); + return (TRUE); } /* @@ -66,47 +66,47 @@ gotoeol(f, n) * buffer. Set the flag if the line pointer for dot changes. */ forwchar(f, n) -register int n; +register int n; { - if (n < 0) - return (backchar(f, -n)); - while (n--) { - if (curwp->w_doto == llength(curwp->w_dotp)) { - if (curwp->w_dotp == curbp->b_linep) - return (FALSE); - curwp->w_dotp = lforw(curwp->w_dotp); - curwp->w_doto = 0; - curwp->w_flag |= WFMOVE; - } else - curwp->w_doto++; - } - return (TRUE); + if (n < 0) + return (backchar(f, -n)); + while (n--) { + if (curwp->w_doto == llength(curwp->w_dotp)) { + if (curwp->w_dotp == curbp->b_linep) + return (FALSE); + curwp->w_dotp = lforw(curwp->w_dotp); + curwp->w_doto = 0; + curwp->w_flag |= WFMOVE; + } else + curwp->w_doto++; + } + return (TRUE); } -gotoline(f, n) /* move to a particular line. - argument (n) must be a positive integer for - this to actually do anything */ - -{ +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); + return (status); } n = atoi(arg); } if (n < 1) /* if a bogus argument...then leave */ - return(FALSE); + return (FALSE); /* first, we go to the start of the buffer */ - curwp->w_dotp = lforw(curbp->b_linep); - curwp->w_doto = 0; - return(forwline(f, n-1)); + curwp->w_dotp = lforw(curbp->b_linep); + curwp->w_doto = 0; + return (forwline(f, n - 1)); } /* @@ -116,10 +116,10 @@ gotoline(f, n) /* move to a particular line. */ gotobob(f, n) { - curwp->w_dotp = lforw(curbp->b_linep); - curwp->w_doto = 0; - curwp->w_flag |= WFHARD; - return (TRUE); + curwp->w_dotp = lforw(curbp->b_linep); + curwp->w_doto = 0; + curwp->w_flag |= WFHARD; + return (TRUE); } /* @@ -129,10 +129,10 @@ gotobob(f, n) */ gotoeob(f, n) { - curwp->w_dotp = curbp->b_linep; - curwp->w_doto = 0; - curwp->w_flag |= WFHARD; - return (TRUE); + curwp->w_dotp = curbp->b_linep; + curwp->w_doto = 0; + curwp->w_flag |= WFHARD; + return (TRUE); } /* @@ -143,33 +143,33 @@ gotoeob(f, n) */ forwline(f, n) { - register LINE *dlp; + register LINE *dlp; - if (n < 0) - return (backline(f, -n)); + if (n < 0) + return (backline(f, -n)); /* if we are on the last line as we start....fail the command */ if (curwp->w_dotp == curbp->b_linep) - return(FALSE); + return (FALSE); /* if the last command was not note a line move, reset the goal column */ - if ((lastflag&CFCPCN) == 0) - curgoal = getccol(FALSE); + if ((lastflag & CFCPCN) == 0) + curgoal = getccol(FALSE); /* flag this command as a line move */ - thisflag |= CFCPCN; + thisflag |= CFCPCN; /* and move the point down */ - dlp = curwp->w_dotp; - while (n-- && dlp!=curbp->b_linep) - dlp = lforw(dlp); + dlp = curwp->w_dotp; + while (n-- && dlp != curbp->b_linep) + dlp = lforw(dlp); /* reseting the current position */ - curwp->w_dotp = dlp; - curwp->w_doto = getgoal(dlp); - curwp->w_flag |= WFMOVE; - return (TRUE); + curwp->w_dotp = dlp; + curwp->w_doto = getgoal(dlp); + curwp->w_flag |= WFMOVE; + return (TRUE); } /* @@ -180,48 +180,48 @@ forwline(f, n) */ backline(f, n) { - register LINE *dlp; + register LINE *dlp; - if (n < 0) - return (forwline(f, -n)); + if (n < 0) + return (forwline(f, -n)); /* if we are on the last line as we start....fail the command */ if (lback(curwp->w_dotp) == curbp->b_linep) - return(FALSE); + return (FALSE); /* if the last command was not note a line move, reset the goal column */ - if ((lastflag&CFCPCN) == 0) - curgoal = getccol(FALSE); + if ((lastflag & CFCPCN) == 0) + curgoal = getccol(FALSE); /* flag this command as a line move */ - thisflag |= CFCPCN; + thisflag |= CFCPCN; /* and move the point up */ - dlp = curwp->w_dotp; - while (n-- && lback(dlp)!=curbp->b_linep) - dlp = lback(dlp); + dlp = curwp->w_dotp; + while (n-- && lback(dlp) != curbp->b_linep) + dlp = lback(dlp); /* reseting the current position */ - curwp->w_dotp = dlp; - curwp->w_doto = getgoal(dlp); - curwp->w_flag |= WFMOVE; - return (TRUE); + curwp->w_dotp = dlp; + curwp->w_doto = getgoal(dlp); + curwp->w_flag |= WFMOVE; + return (TRUE); } #if WORDPRO -gotobop(f, n) /* go back to the beginning of the current paragraph - here we look for a or or - combination to delimit the beginning of a paragraph */ - -int f, n; /* default Flag & Numeric argument */ +gotobop(f, n) + /* go back to the beginning of the current paragraph + here we look for a or or + combination to delimit the beginning of a paragraph */ +int f, n; /* default Flag & Numeric argument */ { register int suc; /* success of last backchar */ - if (n < 0) /* the other way...*/ - return(gotoeop(f, -n)); + if (n < 0) /* the other way... */ + return (gotoeop(f, -n)); while (n-- > 0) { /* for each one asked for */ @@ -232,16 +232,16 @@ int f, n; /* default Flag & Numeric argument */ curwp->w_doto = 0; /* and go to the B-O-Line */ /* and scan back until we hit a or - or a */ + or a */ while (lback(curwp->w_dotp) != curbp->b_linep) if (llength(curwp->w_dotp) != 0 && #if PKCODE ((justflag == TRUE) || #endif - lgetc(curwp->w_dotp, curwp->w_doto) != TAB && - lgetc(curwp->w_dotp, curwp->w_doto) != ' ') + lgetc(curwp->w_dotp, curwp->w_doto) != TAB && + lgetc(curwp->w_dotp, curwp->w_doto) != ' ') #if PKCODE - ) + ) #endif curwp->w_dotp = lback(curwp->w_dotp); else @@ -253,20 +253,20 @@ int f, n; /* default Flag & Numeric argument */ suc = forwchar(FALSE, 1); } curwp->w_flag |= WFMOVE; /* force screen update */ - return(TRUE); + return (TRUE); } -gotoeop(f, n) /* go forword to the end of the current paragraph - here we look for a or or - combination to delimit the beginning of a paragraph */ - -int f, n; /* default Flag & Numeric argument */ +gotoeop(f, n) + /* go forword to the end of the current paragraph + here we look for a or or + combination to delimit the beginning of a paragraph */ +int f, n; /* default Flag & Numeric argument */ { register int suc; /* success of last backchar */ - if (n < 0) /* the other way...*/ - return(gotobop(f, -n)); + if (n < 0) /* the other way... */ + return (gotobop(f, -n)); while (n-- > 0) { /* for each one asked for */ @@ -279,16 +279,16 @@ int f, n; /* default Flag & Numeric argument */ curwp->w_dotp = lforw(curwp->w_dotp); /* and scan forword until we hit a or - or a */ + or a */ while (curwp->w_dotp != curbp->b_linep) { if (llength(curwp->w_dotp) != 0 && #if PKCODE ((justflag == TRUE) || #endif - lgetc(curwp->w_dotp, curwp->w_doto) != TAB && - lgetc(curwp->w_dotp, curwp->w_doto) != ' ') + lgetc(curwp->w_dotp, curwp->w_doto) != TAB && + lgetc(curwp->w_dotp, curwp->w_doto) != ' ') #if PKCODE - ) + ) #endif curwp->w_dotp = lforw(curwp->w_dotp); else @@ -303,7 +303,7 @@ int f, n; /* default Flag & Numeric argument */ curwp->w_doto = llength(curwp->w_dotp); /* and to the EOL */ } curwp->w_flag |= WFMOVE; /* force screen update */ - return(TRUE); + return (TRUE); } #endif @@ -313,29 +313,29 @@ int f, n; /* default Flag & Numeric argument */ * Used by "C-N" and "C-P". */ getgoal(dlp) -register LINE *dlp; +register LINE *dlp; { - register int c; - register int col; - register int newcol; - register int dbo; + register int c; + register int col; + register int newcol; + register int dbo; - col = 0; - dbo = 0; - while (dbo != llength(dlp)) { - c = lgetc(dlp, dbo); - newcol = col; - if (c == '\t') - newcol |= tabmask; - else if (c<0x20 || c==0x7F) - ++newcol; - ++newcol; - if (newcol > curgoal) - break; - col = newcol; - ++dbo; - } - return (dbo); + col = 0; + dbo = 0; + while (dbo != llength(dlp)) { + c = lgetc(dlp, dbo); + newcol = col; + if (c == '\t') + newcol |= tabmask; + else if (c < 0x20 || c == 0x7F) + ++newcol; + ++newcol; + if (newcol > curgoal) + break; + col = newcol; + ++dbo; + } + return (dbo); } /* @@ -345,11 +345,11 @@ register LINE *dlp; * this zaps the top line in the display window, we have to do a hard update. */ forwpage(f, n) -register int n; +register int n; { - register LINE *lp; + register LINE *lp; - if (f == FALSE) { + if (f == FALSE) { #if SCROLLCODE if (term.t_scroll != NULL) if (overlap == 0) @@ -358,27 +358,27 @@ register int n; n = curwp->w_ntrows - overlap; else #endif - n = curwp->w_ntrows - 2; /* Default scroll. */ - if (n <= 0) /* Forget the overlap */ - n = 1; /* if tiny window. */ - } else if (n < 0) - return (backpage(f, -n)); + n = curwp->w_ntrows - 2; /* Default scroll. */ + if (n <= 0) /* Forget the overlap */ + n = 1; /* if tiny window. */ + } else if (n < 0) + return (backpage(f, -n)); #if CVMVAS - else /* Convert from pages */ - n *= curwp->w_ntrows; /* to lines. */ + else /* Convert from pages */ + n *= curwp->w_ntrows; /* to lines. */ #endif - lp = curwp->w_linep; - while (n-- && lp!=curbp->b_linep) - lp = lforw(lp); - curwp->w_linep = lp; - curwp->w_dotp = lp; - curwp->w_doto = 0; + lp = curwp->w_linep; + while (n-- && lp != curbp->b_linep) + lp = lforw(lp); + curwp->w_linep = lp; + curwp->w_dotp = lp; + curwp->w_doto = 0; #if SCROLLCODE - curwp->w_flag |= WFHARD|WFKILLS; + curwp->w_flag |= WFHARD | WFKILLS; #else curwp->w_flag |= WFHARD; #endif - return (TRUE); + return (TRUE); } /* @@ -388,11 +388,11 @@ register int n; * reason. */ backpage(f, n) -register int n; +register int n; { - register LINE *lp; + register LINE *lp; - if (f == FALSE) { + if (f == FALSE) { #if SCROLLCODE if (term.t_scroll != NULL) if (overlap == 0) @@ -401,27 +401,27 @@ register int n; n = curwp->w_ntrows - overlap; else #endif - n = curwp->w_ntrows - 2; /* Default scroll. */ - if (n <= 0) /* Don't blow up if the */ - n = 1; /* window is tiny. */ - } else if (n < 0) - return (forwpage(f, -n)); + n = curwp->w_ntrows - 2; /* Default scroll. */ + if (n <= 0) /* Don't blow up if the */ + n = 1; /* window is tiny. */ + } else if (n < 0) + return (forwpage(f, -n)); #if CVMVAS - else /* Convert from pages */ - n *= curwp->w_ntrows; /* to lines. */ + else /* Convert from pages */ + n *= curwp->w_ntrows; /* to lines. */ #endif - lp = curwp->w_linep; - while (n-- && lback(lp)!=curbp->b_linep) - lp = lback(lp); - curwp->w_linep = lp; - curwp->w_dotp = lp; - curwp->w_doto = 0; + lp = curwp->w_linep; + while (n-- && lback(lp) != curbp->b_linep) + lp = lback(lp); + curwp->w_linep = lp; + curwp->w_dotp = lp; + curwp->w_doto = 0; #if SCROLLCODE - curwp->w_flag |= WFHARD|WFINS; + curwp->w_flag |= WFHARD | WFINS; #else - curwp->w_flag |= WFHARD; + curwp->w_flag |= WFHARD; #endif - return (TRUE); + return (TRUE); } /* @@ -430,10 +430,10 @@ register int n; */ setmark(f, n) { - curwp->w_markp = curwp->w_dotp; - curwp->w_marko = curwp->w_doto; - mlwrite("(Mark set)"); - return (TRUE); + curwp->w_markp = curwp->w_dotp; + curwp->w_marko = curwp->w_doto; + mlwrite("(Mark set)"); + return (TRUE); } /* @@ -444,19 +444,19 @@ setmark(f, n) */ swapmark(f, n) { - register LINE *odotp; - register int odoto; + register LINE *odotp; + register int odoto; - if (curwp->w_markp == NULL) { - mlwrite("No mark in this window"); - return (FALSE); - } - odotp = curwp->w_dotp; - odoto = curwp->w_doto; - curwp->w_dotp = curwp->w_markp; - curwp->w_doto = curwp->w_marko; - curwp->w_markp = odotp; - curwp->w_marko = odoto; - curwp->w_flag |= WFMOVE; - return (TRUE); + if (curwp->w_markp == NULL) { + mlwrite("No mark in this window"); + return (FALSE); + } + odotp = curwp->w_dotp; + odoto = curwp->w_doto; + curwp->w_dotp = curwp->w_markp; + curwp->w_doto = curwp->w_marko; + curwp->w_markp = odotp; + curwp->w_marko = odoto; + curwp->w_flag |= WFMOVE; + return (TRUE); } diff --git a/bind.c b/bind.c index c12fc67..c5dbaf8 100644 --- a/bind.c +++ b/bind.c @@ -12,12 +12,12 @@ #include "edef.h" #include "epath.h" -extern int meta(), cex(), unarg(), ctrlg(); /* dummy prefix binding functions */ +extern int meta(), cex(), unarg(), ctrlg(); /* dummy prefix binding functions */ -help(f, n) /* give me some help!!!! - bring up a fake buffer and read the help file - into it with view mode */ -{ +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() */ @@ -29,18 +29,18 @@ help(f, n) /* give me some help!!!! fname = flook(pathname[1], FALSE); if (fname == NULL) { mlwrite("(Help file is not online)"); - return(FALSE); + return (FALSE); } } /* split the current window to make room for the help stuff */ if (splitwind(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); if (bp == NULL) { /* and read the stuff in */ if (getfile(fname, FALSE) == FALSE) - return(FALSE); + return (FALSE); } else swbuffer(bp); @@ -52,16 +52,15 @@ help(f, n) /* give me some help!!!! wp->w_flag |= WFMODE; wp = wp->w_wndp; } - return(TRUE); + return (TRUE); } -deskey(f, n) /* describe the command for a certain key */ - -{ +deskey(f, n) +{ /* describe the command for a certain key */ register int c; /* key to describe */ register char *ptr; /* string pointer to scan output strings */ char outseq[NSTRING]; /* output buffer for command sequence */ - int (*getbind())(); + int (*getbind()) (); /* prompt the user to type us a key to describe */ mlwrite(": describe-key "); @@ -86,15 +85,15 @@ deskey(f, n) /* describe the command for a certain key */ bindtokey(f, n) -int f, n; /* command arguments [IGNORED] */ +int f, n; /* command arguments [IGNORED] */ { - register unsigned int c;/* command key to bind */ - register int (*kfunc)();/* ptr to the requested function to bind to */ + register unsigned int c; /* command key to bind */ + register int (*kfunc) (); /* ptr to the requested function to bind to */ register KEYTAB *ktp; /* pointer into the command table */ register int found; /* matched command flag */ char outseq[80]; /* output buffer for keystroke sequence */ - int (*getname())(); + int (*getname()) (); /* prompt the user to type in a key to bind */ mlwrite(": bind-to-key "); @@ -103,13 +102,13 @@ int f, n; /* command arguments [IGNORED] */ kfunc = getname(); if (kfunc == NULL) { mlwrite("(No such function)"); - return(FALSE); + return (FALSE); } ostring(" "); /* get the command sequence to bind */ c = getckey((kfunc == meta) || (kfunc == cex) || - (kfunc == unarg) || (kfunc == ctrlg)); + (kfunc == unarg) || (kfunc == ctrlg)); /* change it to something we can print as well */ cmdstr(c, &outseq[0]); @@ -152,29 +151,29 @@ int f, n; /* command arguments [IGNORED] */ ++ktp; } - if (found) { /* it exists, just change it then */ + if (found) { /* it exists, just change it then */ ktp->k_fp = kfunc; - } else { /* otherwise we need to add it to the end */ + } else { /* otherwise we need to add it to the end */ /* if we run out of binding room, bitch */ if (ktp >= &keytab[NBINDS]) { mlwrite("Binding table FULL!"); - return(FALSE); + return (FALSE); } ktp->k_code = c; /* add keycode */ ktp->k_fp = kfunc; /* and the function pointer */ - ++ktp; /* and make sure the next is null */ + ++ktp; /* and make sure the next is null */ ktp->k_code = 0; ktp->k_fp = NULL; } - return(TRUE); + return (TRUE); } /* unbindkey: delete a key from the key binding table */ unbindkey(f, n) -int f, n; /* command arguments [IGNORED] */ +int f, n; /* command arguments [IGNORED] */ { register int c; /* command key to unbind */ @@ -184,7 +183,7 @@ int f, n; /* command arguments [IGNORED] */ mlwrite(": unbind-key "); /* get the command sequence to unbind */ - c = getckey(FALSE); /* get a command sequence */ + c = getckey(FALSE); /* get a command sequence */ /* change it to something we can print as well */ cmdstr(c, &outseq[0]); @@ -195,14 +194,14 @@ int f, n; /* command arguments [IGNORED] */ /* if it isn't bound, bitch */ if (unbindchar(c) == FALSE) { mlwrite("(Key not bound)"); - return(FALSE); + return (FALSE); } - return(TRUE); + return (TRUE); } unbindchar(c) -int c; /* command key to unbind */ +int c; /* command key to unbind */ { register KEYTAB *ktp; /* pointer into the command table */ @@ -222,50 +221,49 @@ int c; /* command key to unbind */ /* if it isn't bound, bitch */ if (!found) - return(FALSE); + return (FALSE); /* save the pointer and scan to the end of the table */ sktp = ktp; while (ktp->k_fp != NULL) ++ktp; - --ktp; /* backup to the last legit entry */ + --ktp; /* backup to the last legit entry */ /* copy the last entry to the current one */ sktp->k_code = ktp->k_code; - sktp->k_fp = ktp->k_fp; + sktp->k_fp = ktp->k_fp; /* null out the last one */ ktp->k_code = 0; ktp->k_fp = NULL; - return(TRUE); + return (TRUE); } -desbind(f, n) /* describe bindings - bring up a fake buffer and list the key bindings - into it with view mode */ - +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 */ status = mlreply("Apropos string: ", mstring, NSTRING - 1); if (status != TRUE) - return(status); + return (status); - return(buildlist(FALSE, mstring)); + return (buildlist(FALSE, mstring)); } -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 */ +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 */ #endif { @@ -279,34 +277,34 @@ char *mstring; /* match string if a partial list */ /* split the current window to make room for the binding list */ if (splitwind(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); /* and get a buffer for it */ bp = bfind("*Binding list*", TRUE, 0); if (bp == NULL || bclear(bp) == FALSE) { mlwrite("Can not display binding list"); - return(FALSE); + return (FALSE); } /* let us know this is in progress */ mlwrite("(Building binding list)"); /* disconect the current buffer */ - if (--curbp->b_nwnd == 0) { /* Last use. */ - curbp->b_dotp = curwp->w_dotp; - curbp->b_doto = curwp->w_doto; - curbp->b_markp = curwp->w_markp; - curbp->b_marko = curwp->w_marko; - } + if (--curbp->b_nwnd == 0) { /* Last use. */ + curbp->b_dotp = curwp->w_dotp; + curbp->b_doto = curwp->w_doto; + curbp->b_markp = curwp->w_markp; + curbp->b_marko = curwp->w_marko; + } /* connect the current window to this buffer */ - curbp = bp; /* make this buffer current in current window */ + curbp = bp; /* make this buffer current in current window */ bp->b_mode = 0; /* no modes active in binding list */ bp->b_nwnd++; /* mark us as more in use */ wp = curwp; wp->w_bufp = bp; wp->w_linep = bp->b_linep; - wp->w_flag = WFHARD|WFFORCE; + wp->w_flag = WFHARD | WFFORCE; wp->w_dotp = bp->b_dotp; wp->w_doto = bp->b_doto; wp->w_markp = NULL; @@ -341,7 +339,7 @@ char *mstring; /* match string if a partial list */ /* and add it as a line into the buffer */ if (linstr(outseq) != TRUE) - return(FALSE); + return (FALSE); cpos = 0; /* and clear the line */ } @@ -353,36 +351,36 @@ char *mstring; /* match string if a partial list */ outseq[cpos++] = '\n'; outseq[cpos] = 0; if (linstr(outseq) != TRUE) - return(FALSE); + return (FALSE); } -fail: /* and on to the next name */ + fail: /* and on to the next name */ ++nptr; } - curwp->w_bufp->b_mode |= MDVIEW;/* put this buffer view mode */ + curwp->w_bufp->b_mode |= MDVIEW; /* put this buffer view mode */ curbp->b_flag &= ~BFCHG; /* don't flag this as a change */ - wp->w_dotp = lforw(bp->b_linep);/* back to the beginning */ + wp->w_dotp = lforw(bp->b_linep); /* back to the beginning */ wp->w_doto = 0; - wp = wheadp; /* and update ALL mode lines */ + wp = wheadp; /* and update ALL mode lines */ while (wp != NULL) { wp->w_flag |= WFMODE; wp = wp->w_wndp; } - mlwrite(""); /* clear the mode line */ - return(TRUE); + mlwrite(""); /* clear the mode line */ + return (TRUE); } #if APROP -strinc(source, sub) /* does source include sub? */ - -char *source; /* string to search in */ -char *sub; /* substring to look for */ +strinc(source, sub) + /* does source include sub? */ +char *source; /* string to search in */ +char *sub; /* substring to look for */ { - char *sp; /* ptr into source */ - char *nxtsp; /* next ptr into source */ - char *tp; /* ptr into substring */ + char *sp; /* ptr into source */ + char *nxtsp; /* next ptr into source */ + char *tp; /* ptr into substring */ /* for each character in the source string */ sp = source; @@ -400,12 +398,12 @@ char *sub; /* substring to look for */ /* yes, return a success */ if (*tp == 0) - return(TRUE); + return (TRUE); /* no, onward */ sp++; } - return(FALSE); + return (FALSE); } #endif @@ -413,16 +411,16 @@ char *sub; /* substring to look for */ unsigned int getckey(mflag) -int mflag; /* going for a meta sequence? */ +int mflag; /* going for a meta sequence? */ { register unsigned int c; /* character fetched */ - char tok[NSTRING]; /* command incoming */ + char tok[NSTRING]; /* command incoming */ /* check to see if we are executing a command line */ if (clexec) { macarg(tok); /* get the next token */ - return(stock(tok)); + return (stock(tok)); } /* or the normal way */ @@ -430,17 +428,17 @@ int mflag; /* going for a meta sequence? */ c = get1key(); else c = getcmd(); - return(c); + return (c); } /* execute the startup file */ startup(sfname) -char *sfname; /* name of startup file (null if default) */ +char *sfname; /* name of startup file (null if default) */ { - char *fname; /* resulting file name to execute */ + char *fname; /* resulting file name to execute */ /* look up the startup file */ if (*sfname != 0) @@ -450,10 +448,10 @@ char *sfname; /* name of startup file (null if default) */ /* if it isn't around, don't sweat it */ if (fname == NULL) - return(TRUE); + return (TRUE); /* otherwise, execute the sucker */ - return(dofile(fname)); + return (dofile(fname)); } /* Look up the existance of a file along the normal or PATH @@ -463,8 +461,8 @@ char *sfname; /* name of startup file (null if default) */ char *flook(fname, hflag) -char *fname; /* base file name to search for */ -int hflag; /* Look in the HOME environment variable first? */ +char *fname; /* base file name to search for */ +int hflag; /* Look in the HOME environment variable first? */ { register char *home; /* path to home directory */ @@ -487,7 +485,7 @@ int hflag; /* Look in the HOME environment variable first? */ /* and try it out */ if (ffropen(fspec) == FIOSUC) { ffclose(); - return(fspec); + return (fspec); } } } @@ -496,9 +494,8 @@ int hflag; /* Look in the HOME environment variable first? */ /* always try the current directory first */ if (ffropen(fname) == FIOSUC) { ffclose(); - return(fname); + return (fname); } - #if ENVFUNC /* get the PATH variable */ path = getenv("PATH"); @@ -519,7 +516,7 @@ int hflag; /* Look in the HOME environment variable first? */ /* and try it out */ if (ffropen(fspec) == FIOSUC) { ffclose(); - return(fspec); + return (fspec); } if (*path == PATHCHR) @@ -528,27 +525,27 @@ int hflag; /* Look in the HOME environment variable first? */ #endif /* look it up via the old table method */ - for (i=2; i < NPNAMES; i++) { + for (i = 2; i < NPNAMES; i++) { strcpy(fspec, pathname[i]); strcat(fspec, fname); /* and try it out */ if (ffropen(fspec) == FIOSUC) { ffclose(); - return(fspec); + return (fspec); } } - return(NULL); /* no such luck */ + return (NULL); /* no such luck */ } -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 */ +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 */ { - char *ptr; /* pointer into current position in sequence */ + char *ptr; /* pointer into current position in sequence */ ptr = seq; @@ -578,28 +575,28 @@ char *seq; /* destination string for sequence */ /* and output the final sequence */ *ptr++ = c & 255; /* strip the prefixes */ - - *ptr = 0; /* terminate the string */ + + *ptr = 0; /* terminate the string */ } /* This function looks a key binding up in the binding table */ -int (*getbind(c))() +int (*getbind(c)) () -int c; /* key to find what is bound to it */ +int c; /* key to find what is bound to it */ { register KEYTAB *ktp; - ktp = &keytab[0]; /* Look in key table. */ - while (ktp->k_fp != NULL) { - if (ktp->k_code == c) - return(ktp->k_fp); - ++ktp; - } + ktp = &keytab[0]; /* Look in key table. */ + while (ktp->k_fp != NULL) { + if (ktp->k_code == c) + return (ktp->k_fp); + ++ktp; + } /* no such binding */ - return(NULL); + return (NULL); } /* getfname: This function takes a ptr to function and gets the name @@ -608,7 +605,7 @@ int c; /* key to find what is bound to it */ char *getfname(func) -int (*func)(); /* ptr to the requested function to bind to */ +int (*func) (); /* ptr to the requested function to bind to */ { register NBIND *nptr; /* pointer into the name binding table */ @@ -617,16 +614,16 @@ int (*func)(); /* ptr to the requested function to bind to */ nptr = &names[0]; while (nptr->n_func != NULL) { if (nptr->n_func == func) - return(nptr->n_name); + return (nptr->n_name); ++nptr; } - return(NULL); + return (NULL); } -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 */ +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 */ { register NBIND *ffp; /* pointer to entry in name binding table */ @@ -635,17 +632,17 @@ char *fname; /* name to attempt to match */ ffp = &names[0]; while (ffp->n_func != NULL) { if (strcmp(fname, ffp->n_name) == 0) - return(ffp->n_func); + return (ffp->n_func); ++ffp; } - return(NULL); + return (NULL); } /* stock: String key name TO Command Key */ unsigned int stock(keyname) -char *keyname; /* name of key to translate to Command key form */ +char *keyname; /* name of key to translate to Command key form */ { register unsigned int c; /* key sequence to return */ @@ -654,25 +651,25 @@ char *keyname; /* name of key to translate to Command key form */ c = 0; /* first, the META prefix */ - if (*keyname == 'M' && *(keyname+1) == '-') { + if (*keyname == 'M' && *(keyname + 1) == '-') { c = META; keyname += 2; } /* next the function prefix */ - if (*keyname == 'F' && *(keyname+1) == 'N') { + if (*keyname == 'F' && *(keyname + 1) == 'N') { c |= SPEC; keyname += 2; } /* control-x as well... (but not with FN) */ - if (*keyname == '^' && *(keyname+1) == 'X'&& !(c & SPEC)) { + if (*keyname == '^' && *(keyname + 1) == 'X' && !(c & SPEC)) { c |= CTLX; keyname += 2; } /* a control char? */ - if (*keyname == '^' && *(keyname+1) != 0) { + if (*keyname == '^' && *(keyname + 1) != 0) { c |= CONTROL; ++keyname; } @@ -682,27 +679,27 @@ char *keyname; /* name of key to translate to Command key form */ } - /* make sure we are not lower case (not with function keys)*/ + /* make sure we are not lower case (not with function keys) */ if (*keyname >= 'a' && *keyname <= 'z' && !(c & SPEC)) *keyname -= 32; /* the final sequence... */ c |= *keyname; - return(c); + return (c); } -char *transbind(skey) /* string key name to binding name.... */ - -char *skey; /* name of keey to get binding for */ +char *transbind(skey) + /* string key name to binding name.... */ +char *skey; /* name of keey to get binding for */ { char *bindname; unsigned int stock(); - int (*getbind())(); + int (*getbind()) (); bindname = getfname(getbind(stock(skey))); if (bindname == NULL) bindname = "ERROR"; - return(bindname); + return (bindname); } diff --git a/buffer.c b/buffer.c index 93daa25..9607e2c 100644 --- a/buffer.c +++ b/buffer.c @@ -21,29 +21,29 @@ */ usebuffer(f, n) { - register BUFFER *bp; - register int s; - char bufn[NBUFN]; + register BUFFER *bp; + register int s; + char bufn[NBUFN]; - if ((s=mlreply("Use buffer: ", bufn, NBUFN)) != TRUE) - return (s); - if ((bp=bfind(bufn, TRUE, 0)) == NULL) - return (FALSE); - return(swbuffer(bp)); + if ((s = mlreply("Use buffer: ", bufn, NBUFN)) != TRUE) + return (s); + if ((bp = bfind(bufn, TRUE, 0)) == NULL) + return (FALSE); + return (swbuffer(bp)); } -nextbuffer(f, n) /* switch to the next buffer in the buffer list */ - -int f, n; /* default flag, numeric argument */ +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*/ - register BUFFER *bbp; /* eligable buffer to switch to*/ + register BUFFER *bp; /* eligable buffer to switch to */ + register BUFFER *bbp; /* eligable buffer to switch to */ /* make sure the arg is legit */ if (f == FALSE) n = 1; if (n < 1) - return(FALSE); + return (FALSE); bbp = curbp; while (n-- > 0) { @@ -59,60 +59,60 @@ int f, n; /* default flag, numeric argument */ /* don't get caught in an infinite loop! */ if (bp == bbp) - return(FALSE); + return (FALSE); - } + } bbp = bp; } - return(swbuffer(bp)); + return (swbuffer(bp)); } -swbuffer(bp) /* make buffer BP current */ - +swbuffer(bp) + /* make buffer BP current */ BUFFER *bp; { - register WINDOW *wp; + register WINDOW *wp; - if (--curbp->b_nwnd == 0) { /* Last use. */ - curbp->b_dotp = curwp->w_dotp; - curbp->b_doto = curwp->w_doto; - curbp->b_markp = curwp->w_markp; - curbp->b_marko = curwp->w_marko; - } - curbp = bp; /* Switch. */ - if (curbp->b_active != TRUE) { /* buffer not active yet*/ + if (--curbp->b_nwnd == 0) { /* Last use. */ + curbp->b_dotp = curwp->w_dotp; + curbp->b_doto = curwp->w_doto; + curbp->b_markp = curwp->w_markp; + curbp->b_marko = curwp->w_marko; + } + curbp = bp; /* Switch. */ + if (curbp->b_active != TRUE) { /* buffer not active yet */ /* read it in and activate it */ readin(curbp->b_fname, TRUE); curbp->b_dotp = lforw(curbp->b_linep); curbp->b_doto = 0; curbp->b_active = TRUE; - curbp->b_mode |= gmode; /* P.K. */ + curbp->b_mode |= gmode; /* P.K. */ } - curwp->w_bufp = bp; - curwp->w_linep = bp->b_linep; /* For macros, ignored. */ - curwp->w_flag |= WFMODE|WFFORCE|WFHARD; /* Quite nasty. */ - if (bp->b_nwnd++ == 0) { /* First use. */ - curwp->w_dotp = bp->b_dotp; - curwp->w_doto = bp->b_doto; - curwp->w_markp = bp->b_markp; + curwp->w_bufp = bp; + curwp->w_linep = bp->b_linep; /* For macros, ignored. */ + curwp->w_flag |= WFMODE | WFFORCE | WFHARD; /* Quite nasty. */ + if (bp->b_nwnd++ == 0) { /* First use. */ + curwp->w_dotp = bp->b_dotp; + curwp->w_doto = bp->b_doto; + curwp->w_markp = bp->b_markp; curwp->w_marko = bp->b_marko; cknewwindow(); - return (TRUE); - } - wp = wheadp; /* Look for old. */ - while (wp != NULL) { - if (wp!=curwp && wp->w_bufp==bp) { - curwp->w_dotp = wp->w_dotp; - curwp->w_doto = wp->w_doto; - curwp->w_markp = wp->w_markp; - curwp->w_marko = wp->w_marko; - break; - } - wp = wp->w_wndp; - } + return (TRUE); + } + wp = wheadp; /* Look for old. */ + while (wp != NULL) { + if (wp != curwp && wp->w_bufp == bp) { + curwp->w_dotp = wp->w_dotp; + curwp->w_doto = wp->w_doto; + curwp->w_markp = wp->w_markp; + curwp->w_marko = wp->w_marko; + break; + } + wp = wp->w_wndp; + } cknewwindow(); return (TRUE); } @@ -126,63 +126,63 @@ BUFFER *bp; * line and the buffer header. Bound to "C-X K". */ killbuffer(f, n) - { register BUFFER *bp; - register int s; - char bufn[NBUFN]; + register int s; + char bufn[NBUFN]; - if ((s=mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE) - return(s); - if ((bp=bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */ - return (TRUE); - if(bp->b_flag & BFINVS) /* Deal with special buffers */ - return (TRUE); /* by doing nothing. */ - return(zotbuf(bp)); + if ((s = mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE) + return (s); + if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */ + return (TRUE); + if (bp->b_flag & BFINVS) /* Deal with special buffers */ + return (TRUE); /* by doing nothing. */ + return (zotbuf(bp)); } -zotbuf(bp) /* kill the buffer pointed to by bp */ - +zotbuf(bp) + /* kill the buffer pointed to by bp */ register BUFFER *bp; { - register BUFFER *bp1; - register BUFFER *bp2; - register int s; + register BUFFER *bp1; + register BUFFER *bp2; + register int s; - if (bp->b_nwnd != 0) { /* Error if on screen. */ - mlwrite("Buffer is being displayed"); - return (FALSE); - } - if ((s=bclear(bp)) != TRUE) /* Blow text away. */ - return (s); - free((char *) bp->b_linep); /* Release header line. */ - bp1 = NULL; /* Find the header. */ - bp2 = bheadp; - while (bp2 != bp) { - bp1 = bp2; - bp2 = bp2->b_bufp; - } - bp2 = bp2->b_bufp; /* Next one in chain. */ - if (bp1 == NULL) /* Unlink it. */ - bheadp = bp2; - else - bp1->b_bufp = bp2; - free((char *) bp); /* Release buffer block */ - return (TRUE); + if (bp->b_nwnd != 0) { /* Error if on screen. */ + mlwrite("Buffer is being displayed"); + return (FALSE); + } + if ((s = bclear(bp)) != TRUE) /* Blow text away. */ + return (s); + free((char *) bp->b_linep); /* Release header line. */ + bp1 = NULL; /* Find the header. */ + bp2 = bheadp; + while (bp2 != bp) { + bp1 = bp2; + bp2 = bp2->b_bufp; + } + bp2 = bp2->b_bufp; /* Next one in chain. */ + if (bp1 == NULL) /* Unlink it. */ + bheadp = bp2; + else + bp1->b_bufp = bp2; + free((char *) bp); /* Release buffer block */ + return (TRUE); } -namebuffer(f,n) /* Rename the current buffer */ - -int f, n; /* default Flag & Numeric arg */ +namebuffer(f, n) + /* Rename the current buffer */ +int f, n; /* default Flag & Numeric arg */ { register BUFFER *bp; /* pointer to scan through all buffers */ 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) - return(FALSE); + ask:if (mlreply("Change buffer name to: ", bufn, NBUFN) != + TRUE) + return (FALSE); /* and check for duplicates */ bp = bheadp; @@ -190,7 +190,7 @@ ask: if (mlreply("Change buffer name to: ", bufn, NBUFN) != TRUE) if (bp != curbp) { /* if the names the same */ if (strcmp(bufn, bp->b_bname) == 0) - goto ask; /* try again */ + goto ask; /* try again */ } bp = bp->b_bufp; /* onward */ } @@ -198,7 +198,7 @@ ask: if (mlreply("Change buffer name to: ", bufn, NBUFN) != TRUE) strcpy(curbp->b_bname, bufn); /* copy buffer name to structure */ curwp->w_flag |= WFMODE; /* make mode line replot */ mlerase(); - return(TRUE); + return (TRUE); } /* @@ -213,38 +213,38 @@ ask: if (mlreply("Change buffer name to: ", bufn, NBUFN) != TRUE) listbuffers(f, n) { - register WINDOW *wp; - register BUFFER *bp; - register int s; + register WINDOW *wp; + register BUFFER *bp; + register int s; - if ((s=makelist(f)) != TRUE) - return (s); - if (blistp->b_nwnd == 0) { /* Not on screen yet. */ - if ((wp=wpopup()) == NULL) - return (FALSE); - bp = wp->w_bufp; - if (--bp->b_nwnd == 0) { - bp->b_dotp = wp->w_dotp; - bp->b_doto = wp->w_doto; - bp->b_markp = wp->w_markp; - bp->b_marko = wp->w_marko; - } - wp->w_bufp = blistp; - ++blistp->b_nwnd; - } - wp = wheadp; - while (wp != NULL) { - if (wp->w_bufp == blistp) { - wp->w_linep = lforw(blistp->b_linep); - wp->w_dotp = lforw(blistp->b_linep); - wp->w_doto = 0; - wp->w_markp = NULL; - wp->w_marko = 0; - wp->w_flag |= WFMODE|WFHARD; - } - wp = wp->w_wndp; - } - return (TRUE); + if ((s = makelist(f)) != TRUE) + return (s); + if (blistp->b_nwnd == 0) { /* Not on screen yet. */ + if ((wp = wpopup()) == NULL) + return (FALSE); + bp = wp->w_bufp; + if (--bp->b_nwnd == 0) { + bp->b_dotp = wp->w_dotp; + bp->b_doto = wp->w_doto; + bp->b_markp = wp->w_markp; + bp->b_marko = wp->w_marko; + } + wp->w_bufp = blistp; + ++blistp->b_nwnd; + } + wp = wheadp; + while (wp != NULL) { + if (wp->w_bufp == blistp) { + wp->w_linep = lforw(blistp->b_linep); + wp->w_dotp = lforw(blistp->b_linep); + wp->w_doto = 0; + wp->w_markp = NULL; + wp->w_marko = 0; + wp->w_flag |= WFMODE | WFHARD; + } + wp = wp->w_wndp; + } + return (TRUE); } /* @@ -259,28 +259,29 @@ listbuffers(f, n) #define MAXLINE MAXCOL makelist(iflag) -int iflag; /* list hidden buffer flag */ +int iflag; /* list hidden buffer flag */ { - register char *cp1; - register char *cp2; - register int c; - register BUFFER *bp; - register LINE *lp; - register int s; - register int i; - long nbytes; /* # of bytes in current buffer */ - char b[7+1]; - char line[MAXLINE]; + register char *cp1; + register char *cp2; + register int c; + register BUFFER *bp; + register LINE *lp; + register int s; + register int i; + long nbytes; /* # of bytes in current buffer */ + char b[7 + 1]; + char line[MAXLINE]; - blistp->b_flag &= ~BFCHG; /* Don't complain! */ - if ((s=bclear(blistp)) != TRUE) /* Blow old text away */ - return (s); - strcpy(blistp->b_fname, ""); - if (addline("ACT MODES Size Buffer File") == FALSE - || addline("--- ----- ---- ------ ----") == FALSE) - return (FALSE); - bp = bheadp; /* For all buffers */ + blistp->b_flag &= ~BFCHG; /* Don't complain! */ + if ((s = bclear(blistp)) != TRUE) /* Blow old text away */ + return (s); + strcpy(blistp->b_fname, ""); + if (addline("ACT MODES Size Buffer File") == FALSE + || addline("--- ----- ---- ------ ----") == + FALSE) + return (FALSE); + bp = bheadp; /* For all buffers */ /* build line to report global mode settings */ cp1 = &line[0]; @@ -297,36 +298,36 @@ int iflag; /* list hidden buffer flag */ *cp1++ = '.'; strcpy(cp1, " Global Modes"); if (addline(line) == FALSE) - return(FALSE); + return (FALSE); /* output the list of buffers */ - while (bp != NULL) { + while (bp != NULL) { /* skip invisable buffers if iflag is false */ - if (((bp->b_flag&BFINVS) != 0) && (iflag != TRUE)) { - bp = bp->b_bufp; - continue; - } - cp1 = &line[0]; /* Start at left edge */ + if (((bp->b_flag & BFINVS) != 0) && (iflag != TRUE)) { + bp = bp->b_bufp; + continue; + } + cp1 = &line[0]; /* Start at left edge */ /* output status of ACTIVE flag (has the file been read in? */ - if (bp->b_active == TRUE) /* "@" if activated */ - *cp1++ = '@'; - else - *cp1++ = ' '; + if (bp->b_active == TRUE) /* "@" if activated */ + *cp1++ = '@'; + else + *cp1++ = ' '; /* output status of changed flag */ - if ((bp->b_flag&BFCHG) != 0) /* "*" if changed */ - *cp1++ = '*'; - else - *cp1++ = ' '; + if ((bp->b_flag & BFCHG) != 0) /* "*" if changed */ + *cp1++ = '*'; + else + *cp1++ = ' '; /* report if the file is truncated */ - if ((bp->b_flag&BFTRUNC) != 0) - *cp1++ = '#'; - else - *cp1++ = ' '; + if ((bp->b_flag & BFTRUNC) != 0) + *cp1++ = '#'; + else + *cp1++ = ' '; - *cp1++ = ' '; /* space */ + *cp1++ = ' '; /* space */ /* output the mode codes */ for (i = 0; i < NUMMODES; i++) { @@ -335,53 +336,53 @@ int iflag; /* list hidden buffer flag */ else *cp1++ = '.'; } - *cp1++ = ' '; /* Gap. */ - nbytes = 0L; /* Count bytes in buf. */ - lp = lforw(bp->b_linep); - while (lp != bp->b_linep) { - nbytes += (long)llength(lp)+1L; - lp = lforw(lp); - } - ltoa(b, 7, nbytes); /* 6 digit buffer size. */ - cp2 = &b[0]; - while ((c = *cp2++) != 0) - *cp1++ = c; - *cp1++ = ' '; /* Gap. */ - cp2 = &bp->b_bname[0]; /* Buffer name */ - while ((c = *cp2++) != 0) - *cp1++ = c; - cp2 = &bp->b_fname[0]; /* File name */ - if (*cp2 != 0) { - while (cp1 < &line[3+1+5+1+6+4+NBUFN]) - *cp1++ = ' '; - while ((c = *cp2++) != 0) { - if (cp1 < &line[MAXLINE-1]) - *cp1++ = c; - } - } - *cp1 = 0; /* Add to the buffer. */ - if (addline(line) == FALSE) - return (FALSE); - bp = bp->b_bufp; - } - return (TRUE); /* All done */ + *cp1++ = ' '; /* Gap. */ + nbytes = 0L; /* Count bytes in buf. */ + lp = lforw(bp->b_linep); + while (lp != bp->b_linep) { + nbytes += (long) llength(lp) + 1L; + lp = lforw(lp); + } + ltoa(b, 7, nbytes); /* 6 digit buffer size. */ + cp2 = &b[0]; + while ((c = *cp2++) != 0) + *cp1++ = c; + *cp1++ = ' '; /* Gap. */ + cp2 = &bp->b_bname[0]; /* Buffer name */ + while ((c = *cp2++) != 0) + *cp1++ = c; + cp2 = &bp->b_fname[0]; /* File name */ + if (*cp2 != 0) { + while (cp1 < &line[3 + 1 + 5 + 1 + 6 + 4 + NBUFN]) + *cp1++ = ' '; + while ((c = *cp2++) != 0) { + if (cp1 < &line[MAXLINE - 1]) + *cp1++ = c; + } + } + *cp1 = 0; /* Add to the buffer. */ + if (addline(line) == FALSE) + return (FALSE); + bp = bp->b_bufp; + } + return (TRUE); /* All done */ } ltoa(buf, width, num) -char buf[]; -int width; -long num; +char buf[]; +int width; +long num; { - buf[width] = 0; /* End of string. */ - while (num >= 10) { /* Conditional digits. */ - buf[--width] = (int)(num%10L) + '0'; - num /= 10L; - } - buf[--width] = (int)num + '0'; /* Always 1 digit. */ - while (width != 0) /* Pad with blanks. */ - buf[--width] = ' '; + buf[width] = 0; /* End of string. */ + while (num >= 10) { /* Conditional digits. */ + buf[--width] = (int) (num % 10L) + '0'; + num /= 10L; + } + buf[--width] = (int) num + '0'; /* Always 1 digit. */ + while (width != 0) /* Pad with blanks. */ + buf[--width] = ' '; } /* @@ -392,24 +393,24 @@ long num; * FALSE if you ran out of room. */ addline(text) -char *text; +char *text; { - register LINE *lp; - register int i; - register int ntext; + register LINE *lp; + register int i; + register int ntext; - ntext = strlen(text); - if ((lp=lalloc(ntext)) == NULL) - return (FALSE); - for (i=0; ib_linep->l_bp->l_fp = lp; /* Hook onto the end */ - lp->l_bp = blistp->b_linep->l_bp; - blistp->b_linep->l_bp = lp; - lp->l_fp = blistp->b_linep; - if (blistp->b_dotp == blistp->b_linep) /* If "." is at the end */ - blistp->b_dotp = lp; /* move it to new line */ - return (TRUE); + ntext = strlen(text); + if ((lp = lalloc(ntext)) == NULL) + return (FALSE); + for (i = 0; i < ntext; ++i) + lputc(lp, i, text[i]); + blistp->b_linep->l_bp->l_fp = lp; /* Hook onto the end */ + lp->l_bp = blistp->b_linep->l_bp; + blistp->b_linep->l_bp = lp; + lp->l_fp = blistp->b_linep; + if (blistp->b_dotp == blistp->b_linep) /* If "." is at the end */ + blistp->b_dotp = lp; /* move it to new line */ + return (TRUE); } /* @@ -424,15 +425,16 @@ char *text; */ anycb() { - register BUFFER *bp; + register BUFFER *bp; - bp = bheadp; - while (bp != NULL) { - if ((bp->b_flag&BFINVS)==0 && (bp->b_flag&BFCHG)!=0) - return (TRUE); - bp = bp->b_bufp; - } - return (FALSE); + bp = bheadp; + while (bp != NULL) { + if ((bp->b_flag & BFINVS) == 0 + && (bp->b_flag & BFCHG) != 0) + return (TRUE); + bp = bp->b_bufp; + } + return (FALSE); } /* @@ -442,34 +444,33 @@ anycb() * and the "cflag" is TRUE, create it. The "bflag" is * the settings for the flags in in buffer. */ -BUFFER * -bfind(bname, cflag, bflag) -register char *bname; +BUFFER *bfind(bname, cflag, bflag) +register char *bname; { - register BUFFER *bp; + register BUFFER *bp; register BUFFER *sb; /* buffer to insert after */ - register LINE *lp; + register LINE *lp; char *malloc(); - bp = bheadp; - while (bp != NULL) { - if (strcmp(bname, bp->b_bname) == 0) - return (bp); - bp = bp->b_bufp; - } - if (cflag != FALSE) { - if ((bp=(BUFFER *)malloc(sizeof(BUFFER))) == NULL) - return (NULL); - if ((lp=lalloc(0)) == NULL) { - free((char *) bp); - return (NULL); - } + bp = bheadp; + while (bp != NULL) { + if (strcmp(bname, bp->b_bname) == 0) + return (bp); + bp = bp->b_bufp; + } + if (cflag != FALSE) { + if ((bp = (BUFFER *) malloc(sizeof(BUFFER))) == NULL) + return (NULL); + if ((lp = lalloc(0)) == NULL) { + free((char *) bp); + return (NULL); + } /* find the place in the list to insert this buffer */ if (bheadp == NULL || strcmp(bheadp->b_bname, bname) > 0) { /* insert at the beginning */ - bp->b_bufp = bheadp; - bheadp = bp; - } else { + bp->b_bufp = bheadp; + bheadp = bp; + } else { sb = bheadp; while (sb->b_bufp != NULL) { if (strcmp(sb->b_bufp->b_bname, bname) > 0) @@ -478,29 +479,29 @@ register char *bname; } /* and insert it */ - bp->b_bufp = sb->b_bufp; - sb->b_bufp = bp; - } + bp->b_bufp = sb->b_bufp; + sb->b_bufp = bp; + } /* and set up the other buffer fields */ bp->b_active = TRUE; - bp->b_dotp = lp; - bp->b_doto = 0; - bp->b_markp = NULL; - bp->b_marko = 0; - bp->b_flag = bflag; - bp->b_mode = gmode; - bp->b_nwnd = 0; - bp->b_linep = lp; - strcpy(bp->b_fname, ""); - strcpy(bp->b_bname, bname); + bp->b_dotp = lp; + bp->b_doto = 0; + bp->b_markp = NULL; + bp->b_marko = 0; + bp->b_flag = bflag; + bp->b_mode = gmode; + bp->b_nwnd = 0; + bp->b_linep = lp; + strcpy(bp->b_fname, ""); + strcpy(bp->b_bname, bname); #if CRYPT bp->b_key[0] = 0; #endif - lp->l_fp = lp; - lp->l_bp = lp; - } - return (bp); + lp->l_fp = lp; + lp->l_bp = lp; + } + return (bp); } /* @@ -516,29 +517,29 @@ register char *bname; bclear(bp) register BUFFER *bp; { - register LINE *lp; - register int s; + register LINE *lp; + register int s; - if ((bp->b_flag&BFINVS) == 0 /* Not scratch buffer. */ - && (bp->b_flag&BFCHG) != 0 /* Something changed */ - && (s=mlyesno("Discard changes")) != TRUE) - return (s); - bp->b_flag &= ~BFCHG; /* Not changed */ - while ((lp=lforw(bp->b_linep)) != bp->b_linep) - lfree(lp); - bp->b_dotp = bp->b_linep; /* Fix "." */ - bp->b_doto = 0; - bp->b_markp = NULL; /* Invalidate "mark" */ - bp->b_marko = 0; - return (TRUE); + if ((bp->b_flag & BFINVS) == 0 /* Not scratch buffer. */ + && (bp->b_flag & BFCHG) != 0 /* Something changed */ + && (s = mlyesno("Discard changes")) != TRUE) + return (s); + bp->b_flag &= ~BFCHG; /* Not changed */ + while ((lp = lforw(bp->b_linep)) != bp->b_linep) + lfree(lp); + bp->b_dotp = bp->b_linep; /* Fix "." */ + bp->b_doto = 0; + bp->b_markp = NULL; /* Invalidate "mark" */ + bp->b_marko = 0; + return (TRUE); } -unmark(f, n) /* unmark the current buffers change flag */ - -int f, n; /* unused command arguments */ +unmark(f, n) + /* unmark the current buffers change flag */ +int f, n; /* unused command arguments */ { curbp->b_flag &= ~BFCHG; curwp->w_flag |= WFMODE; - return(TRUE); + return (TRUE); } diff --git a/crypt.c b/crypt.c index ffd27dc..8fc56e6 100644 --- a/crypt.c +++ b/crypt.c @@ -13,10 +13,10 @@ static int mod95(); -setkey(f, n) /* reset encryption key of current buffer */ - -int f; /* default flag */ -int n; /* numeric argument */ +setkey(f, n) + /* reset encryption key of current buffer */ +int f; /* default flag */ +int n; /* numeric argument */ { register int status; /* return status */ @@ -30,17 +30,17 @@ int n; /* numeric argument */ /* get the string to use as an encrytion string */ status = mlreply("Encryption String: ", key, NPAT - 1); disinp = odisinp; - if (status != TRUE) - return(status); + if (status != TRUE) + return (status); /* and encrypt it */ - crypt((char *)NULL, 0); + crypt((char *) NULL, 0); crypt(key, strlen(key)); /* and save it off */ strcpy(curbp->b_key, key); mlwrite(" "); /* clear it off the bottom line */ - return(TRUE); + return (TRUE); } /********** @@ -137,8 +137,8 @@ int n; /* numeric argument */ **********/ crypt(bptr, len) -register char *bptr; /* buffer of characters to be encrypted */ -register unsigned len; /* number of characters in the buffer */ +register char *bptr; /* buffer of characters to be encrypted */ +register unsigned len; /* number of characters in the buffer */ { register int cc; /* current character being considered */ @@ -170,7 +170,7 @@ register unsigned len; /* number of characters in the buffer */ so that the left shift here will be more portable and the mod95() faster **/ - cc = mod95((int)(key % 95) - (cc - ' ')) + ' '; + cc = mod95((int) (key % 95) - (cc - ' ')) + ' '; /** the salt will spice up the key a little bit, helping to obscure any patterns in the clear text, particularly when all the @@ -202,7 +202,7 @@ register int val; /* The mathematical MOD does not match the computer MOD */ /* Yes, what I do here may look strange, but it gets the - job done, and portably at that. */ + job done, and portably at that. */ while (val >= 9500) val -= 9500; diff --git a/display.c b/display.c index d0d49f8..daf1fc4 100644 --- a/display.c +++ b/display.c @@ -13,26 +13,26 @@ #include "estruct.h" #include "edef.h" -typedef struct VIDEO { - int v_flag; /* Flags */ +typedef struct VIDEO { + int v_flag; /* Flags */ #if COLOR - int v_fcolor; /* current forground color */ - int v_bcolor; /* current background color */ - int v_rfcolor; /* requested forground color */ - int v_rbcolor; /* requested background color */ + int v_fcolor; /* current forground color */ + int v_bcolor; /* current background color */ + int v_rfcolor; /* requested forground color */ + int v_rbcolor; /* requested background color */ #endif - char v_text[1]; /* Screen data. */ -} VIDEO; + char v_text[1]; /* Screen data. */ +} VIDEO; -#define VFCHG 0x0001 /* Changed flag */ -#define VFEXT 0x0002 /* extended (beyond column 80) */ -#define VFREV 0x0004 /* reverse video status */ -#define VFREQ 0x0008 /* reverse video request */ -#define VFCOL 0x0010 /* color change requested */ +#define VFCHG 0x0001 /* Changed flag */ +#define VFEXT 0x0002 /* extended (beyond column 80) */ +#define VFREV 0x0004 /* reverse video status */ +#define VFREQ 0x0008 /* reverse video request */ +#define VFCOL 0x0010 /* color change requested */ -VIDEO **vscreen; /* Virtual screen. */ +VIDEO **vscreen; /* Virtual screen. */ #if MEMMAP == 0 || SCROLLCODE -VIDEO **pscreen; /* Physical screen. */ +VIDEO **pscreen; /* Physical screen. */ #endif int displaying = TRUE; @@ -54,48 +54,47 @@ int chg_width, chg_height; */ vtinit() { - register int i; - register VIDEO *vp; - char *malloc(); + register int i; + register VIDEO *vp; + char *malloc(); - TTopen(); /* open the screen */ - TTkopen(); /* open the keyboard */ - TTrev(FALSE); - vscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *)); + TTopen(); /* open the screen */ + TTkopen(); /* open the keyboard */ + TTrev(FALSE); + vscreen = (VIDEO **) malloc(term.t_mrow * sizeof(VIDEO *)); - if (vscreen == NULL) - exit(1); + if (vscreen == NULL) + exit(1); #if MEMMAP == 0 || SCROLLCODE - pscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *)); + pscreen = (VIDEO **) malloc(term.t_mrow * sizeof(VIDEO *)); - if (pscreen == NULL) - exit(1); + if (pscreen == NULL) + exit(1); #endif - for (i = 0; i < term.t_mrow; ++i) - { - vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol); + for (i = 0; i < term.t_mrow; ++i) { + vp = (VIDEO *) malloc(sizeof(VIDEO) + term.t_mcol); - if (vp == NULL) - exit(1); + if (vp == NULL) + exit(1); - vp->v_flag = 0; + vp->v_flag = 0; #if COLOR - vp->v_rfcolor = 7; - vp->v_rbcolor = 0; + vp->v_rfcolor = 7; + vp->v_rbcolor = 0; #endif - vscreen[i] = vp; + vscreen[i] = vp; #if MEMMAP == 0 || SCROLLCODE - vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol); + vp = (VIDEO *) malloc(sizeof(VIDEO) + term.t_mcol); - if (vp == NULL) - exit(1); + if (vp == NULL) + exit(1); - vp->v_flag = 0; - pscreen[i] = vp; + vp->v_flag = 0; + pscreen[i] = vp; #endif - } + } } #if CLEAN @@ -125,13 +124,13 @@ vtfree() */ vttidy() { - mlerase(); - movecursor(term.t_nrow, 0); - TTflush(); - TTclose(); - TTkclose(); + mlerase(); + movecursor(term.t_nrow, 0); + TTflush(); + TTclose(); + TTkclose(); #ifdef PKCODE - write(1, "\r", 1); + write(1, "\r", 1); #endif } @@ -142,8 +141,8 @@ vttidy() */ vtmove(row, col) { - vtrow = row; - vtcol = col; + vtrow = row; + vtcol = col; } /* Write a character to the virtual screen. The virtual row and @@ -169,7 +168,7 @@ int c; if (c == '\t') { do { vtputc(' '); - } while (((vtcol + taboff)&tabmask) != 0); + } while (((vtcol + taboff) & tabmask) != 0); } else { vtputc('^'); vtputc(c ^ 0x40); @@ -188,22 +187,21 @@ int c; vteeol() { /* register VIDEO *vp; */ - register char *vcp = vscreen[vtrow]->v_text; + register char *vcp = vscreen[vtrow]->v_text; /* vp = vscreen[vtrow]; */ - while (vtcol < term.t_ncol) + while (vtcol < term.t_ncol) /* vp->v_text[vtcol++] = ' '; */ - vcp[vtcol++] = ' '; + vcp[vtcol++] = ' '; } /* upscreen: user routine to force a screen update always finishes complete update */ upscreen(f, n) - { update(TRUE); - return(TRUE); + return (TRUE); } #if SCROLLCODE @@ -219,42 +217,42 @@ int scrflags; */ update(force) -int force; /* force update past type ahead? */ +int force; /* force update past type ahead? */ { register WINDOW *wp; #if TYPEAH && ! PKCODE if (force == FALSE && typahead()) - return(TRUE); + return (TRUE); #endif #if VISMAC == 0 if (force == FALSE && kbdmode == PLAY) - return(TRUE); + return (TRUE); #endif - displaying = TRUE; + displaying = TRUE; #if SCROLLCODE - /* first, propagate mode line changes to all instances of - a buffer displayed in more than one window */ - wp = wheadp; - while (wp != NULL) { - if (wp->w_flag & WFMODE) { - if (wp->w_bufp->b_nwnd > 1) { - /* make sure all previous windows have this */ - register WINDOW *owp; - owp = wheadp; - while (owp != NULL) { - if (owp->w_bufp == wp->w_bufp) - owp->w_flag |= WFMODE; - owp = owp->w_wndp; - } - } - } - wp = wp->w_wndp; - } + /* first, propagate mode line changes to all instances of + a buffer displayed in more than one window */ + wp = wheadp; + while (wp != NULL) { + if (wp->w_flag & WFMODE) { + if (wp->w_bufp->b_nwnd > 1) { + /* make sure all previous windows have this */ + register WINDOW *owp; + owp = wheadp; + while (owp != NULL) { + if (owp->w_bufp == wp->w_bufp) + owp->w_flag |= WFMODE; + owp = owp->w_wndp; + } + } + } + wp = wp->w_wndp; + } #endif @@ -265,17 +263,18 @@ int force; /* force update past type ahead? */ /* if the window has changed, service it */ reframe(wp); /* check the framing */ #if SCROLLCODE - if (wp->w_flag & (WFKILLS|WFINS)) { - scrflags |= (wp->w_flag & (WFINS|WFKILLS)); - wp->w_flag &= ~(WFKILLS|WFINS); - } + if (wp->w_flag & (WFKILLS | WFINS)) { + scrflags |= + (wp->w_flag & (WFINS | WFKILLS)); + wp->w_flag &= ~(WFKILLS | WFINS); + } #endif if ((wp->w_flag & ~WFMODE) == WFEDIT) updone(wp); /* update EDITed line */ else if (wp->w_flag & ~WFMOVE) updall(wp); /* update all lines */ #if SCROLLCODE - if (scrflags || (wp->w_flag & WFMODE)) + if (scrflags || (wp->w_flag & WFMODE)) #else if (wp->w_flag & WFMODE) #endif @@ -308,12 +307,12 @@ int force; /* force update past type ahead? */ /* update the cursor and flush the buffers */ movecursor(currow, curcol - lbound); TTflush(); - displaying = FALSE; + displaying = FALSE; #if SIGWINCH - while (chg_width || chg_height) - newscreensize(chg_height,chg_width); + while (chg_width || chg_height) + newscreensize(chg_height, chg_width); #endif - return(TRUE); + return (TRUE); } /* reframe: check to see if the cursor is on in the window @@ -330,16 +329,16 @@ WINDOW *wp; /* if not a requested reframe, check for a needed one */ if ((wp->w_flag & WFFORCE) == 0) { #if SCROLLCODE - /* loop from one line above the window to one line after */ - lp = wp->w_linep; - lp0 = lback(lp); - if (lp0 == wp->w_bufp->b_linep) - i = 0; - else { - i = -1; - lp = lp0; - } - for (; i <= (int)(wp->w_ntrows); i++) + /* loop from one line above the window to one line after */ + lp = wp->w_linep; + lp0 = lback(lp); + if (lp0 == wp->w_bufp->b_linep) + i = 0; + else { + i = -1; + lp = lp0; + } + for (; i <= (int) (wp->w_ntrows); i++) #else lp = wp->w_linep; for (i = 0; i < wp->w_ntrows; i++) @@ -348,16 +347,16 @@ WINDOW *wp; /* if the line is in the window, no reframe */ if (lp == wp->w_dotp) { #if SCROLLCODE - /* if not _quite_ in, we'll reframe gently */ - if ( i < 0 || i == wp->w_ntrows) { - /* if the terminal can't help, then - we're simply outside */ - if (term.t_scroll == NULL) + /* if not _quite_ in, we'll reframe gently */ + if (i < 0 || i == wp->w_ntrows) { + /* if the terminal can't help, then + we're simply outside */ + if (term.t_scroll == NULL) i = wp->w_force; break; - } + } #endif - return(TRUE); + return (TRUE); } /* if we are at the end of the file, reframe */ @@ -368,19 +367,18 @@ WINDOW *wp; lp = lforw(lp); } } - #if SCROLLCODE - if (i == -1) { /* we're just above the window */ - i = scrollcount; /* put dot at first line */ - scrflags |= WFINS; - } else if (i == wp->w_ntrows) { /* we're just below the window */ - i = -scrollcount; /* put dot at last line */ - scrflags |= WFKILLS; - } else /* put dot where requested */ + if (i == -1) { /* we're just above the window */ + i = scrollcount; /* put dot at first line */ + scrflags |= WFINS; + } else if (i == wp->w_ntrows) { /* we're just below the window */ + i = -scrollcount; /* put dot at last line */ + scrflags |= WFKILLS; + } else /* put dot where requested */ #endif - i = wp->w_force; /* (is 0, unless reposition() was called) */ + i = wp->w_force; /* (is 0, unless reposition() was called) */ - wp->w_flag |= WFMODE; + wp->w_flag |= WFMODE; /* how far back to reframe? */ if (i > 0) { /* only one screen worth of lines max */ @@ -404,14 +402,14 @@ WINDOW *wp; wp->w_linep = lp; wp->w_flag |= WFHARD; wp->w_flag &= ~WFFORCE; - return(TRUE); + return (TRUE); } /* updone: update the current line to the virtual screen */ updone(wp) -WINDOW *wp; /* window to update current line in */ +WINDOW *wp; /* window to update current line in */ { register LINE *lp; /* line to update */ @@ -430,7 +428,7 @@ WINDOW *wp; /* window to update current line in */ vscreen[sline]->v_flag |= VFCHG; vscreen[sline]->v_flag &= ~VFREQ; vtmove(sline, 0); - for (i=0; i < llength(lp); ++i) + for (i = 0; i < llength(lp); ++i) vtputc(lgetc(lp, i)); #if COLOR vscreen[sline]->v_rfcolor = wp->w_fcolor; @@ -443,7 +441,7 @@ WINDOW *wp; /* window to update current line in */ updall(wp) -WINDOW *wp; /* window to update lines in */ +WINDOW *wp; /* window to update lines in */ { register LINE *lp; /* line to update */ @@ -461,7 +459,7 @@ WINDOW *wp; /* window to update lines in */ vtmove(sline, 0); if (lp != wp->w_bufp->b_linep) { /* if we are not at the end */ - for (i=0; i < llength(lp); ++i) + for (i = 0; i < llength(lp); ++i) vtputc(lgetc(lp, i)); lp = lforw(lp); } @@ -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,15 +499,14 @@ updpos() c = lgetc(lp, i++); if (c == '\t') curcol |= tabmask; - else - if (c < 0x20 || c == 0x7f) - ++curcol; + else if (c < 0x20 || c == 0x7f) + ++curcol; ++curcol; } /* if extended, flag so and update the virtual line image */ - if (curcol >= term.t_ncol - 1) { + if (curcol >= term.t_ncol - 1) { vscreen[currow]->v_flag |= (VFEXT | VFCHG); updext(); } else @@ -520,11 +516,10 @@ updpos() /* upddex: de-extend any line that derserves it */ upddex() - { register WINDOW *wp; register LINE *lp; - register int i,j; + register int i, j; wp = wheadp; @@ -535,7 +530,7 @@ upddex() while (i < wp->w_toprow + wp->w_ntrows) { if (vscreen[i]->v_flag & VFEXT) { if ((wp != curwp) || (lp != wp->w_dotp) || - (curcol < term.t_ncol - 1)) { + (curcol < term.t_ncol - 1)) { vtmove(i, 0); for (j = 0; j < llength(lp); ++j) vtputc(lgetc(lp, j)); @@ -558,10 +553,9 @@ upddex() the virtual screen and force a full update */ updgar() - { register char *txt; - register int i,j; + register int i, j; for (i = 0; i < term.t_nrow; ++i) { vscreen[i]->v_flag |= VFCHG; @@ -579,12 +573,12 @@ updgar() #endif } - movecursor(0, 0); /* Erase the screen. */ - (*term.t_eeop)(); - sgarbf = FALSE; /* Erase-page clears */ - mpresf = FALSE; /* the message area. */ + movecursor(0, 0); /* Erase the screen. */ + (*term.t_eeop) (); + sgarbf = FALSE; /* Erase-page clears */ + mpresf = FALSE; /* the message area. */ #if COLOR - mlerase(); /* needs to be cleared if colored */ + mlerase(); /* needs to be cleared if colored */ #endif } @@ -592,28 +586,28 @@ updgar() updupd(force) -int force; /* forced update flag */ +int force; /* forced update flag */ { register VIDEO *vp1; register int i; #if SCROLLCODE - if (scrflags & WFKILLS) - scrolls(FALSE); - if (scrflags & WFINS) - scrolls(TRUE); - scrflags = 0; + if (scrflags & WFKILLS) + scrolls(FALSE); + if (scrflags & WFINS) + scrolls(TRUE); + scrflags = 0; #endif for (i = 0; i < term.t_nrow; ++i) { vp1 = vscreen[i]; - /* for each line that needs to be updated*/ + /* for each line that needs to be updated */ if ((vp1->v_flag & VFCHG) != 0) { #if TYPEAH && ! PKCODE if (force == FALSE && typahead()) - return(TRUE); + return (TRUE); #endif #if MEMMAP && ! SCROLLCODE updateline(i, vp1); @@ -622,71 +616,72 @@ int force; /* forced update flag */ #endif } } - return(TRUE); + return (TRUE); } #if SCROLLCODE /* optimize out scrolls (line breaks, and newlines) */ /* arg. chooses between looking for inserts or deletes */ -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 ; - int rows, cols ; - int first, match, count, ptarget, vtarget, end ; - int longmatch, longcount; - int from, to; +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; + int rows, cols; + int first, match, count, ptarget, vtarget, end; + int longmatch, longcount; + int from, to; - if (!term.t_scroll) /* no way to scroll */ + if (!term.t_scroll) /* no way to scroll */ return FALSE; - rows = term.t_nrow ; - cols = term.t_ncol ; + rows = term.t_nrow; + cols = term.t_ncol; - first = -1 ; + first = -1; for (i = 0; i < rows; i++) { /* find first wrong line */ - if (!texttest(i,i)) { + if (!texttest(i, i)) { first = i; break; } } if (first < 0) - return FALSE; /* no text changes */ + return FALSE; /* no text changes */ - vpv = vscreen[first] ; - vpp = pscreen[first] ; + vpv = vscreen[first]; + vpp = pscreen[first]; if (inserts) { /* determine types of potential scrolls */ - end = endofline(vpv->v_text,cols) ; - if ( end == 0 ) - ptarget = first ; /* newlines */ - else if ( strncmp(vpp->v_text, vpv->v_text, end) == 0 ) - ptarget = first + 1 ; /* broken line newlines */ + end = endofline(vpv->v_text, cols); + if (end == 0) + ptarget = first; /* newlines */ + else if (strncmp(vpp->v_text, vpv->v_text, end) == 0) + ptarget = first + 1; /* broken line newlines */ else - ptarget = first ; + ptarget = first; } else { - vtarget = first + 1 ; + vtarget = first + 1; } /* find the matching shifted area */ - match = -1 ; + match = -1; longmatch = -1; longcount = 0; from = inserts ? ptarget : vtarget; - for (i = from+1; i < rows-longcount /* P.K. */; i++) { - if (inserts ? texttest(i,from) : texttest(from,i) ) { - match = i ; - count = 1 ; - for (j=match+1, k=from+1; j 0 && texttest(first, match-1)) { - vtarget-- ; - match-- ; - count++ ; + if (match > 0 && texttest(first, match - 1)) { + vtarget--; + match--; + count++; } } /* do the scroll */ - if (match>0 && count>2) { /* got a scroll */ + if (match > 0 && count > 2) { /* got a scroll */ /* move the count lines starting at ptarget to match */ if (inserts) { from = ptarget; @@ -721,32 +716,33 @@ 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 - if (2*count < abs(from-to)) - return(FALSE); - scrscroll(from, to, count) ; + } +#endif + if (2 * count < abs(from - to)) + return (FALSE); + scrscroll(from, to, count); for (i = 0; i < count; i++) { - vpp = pscreen[to+i] ; - vpv = vscreen[to+i]; - strncpy(vpp->v_text, vpv->v_text, cols) ; - vpp->v_flag = vpv->v_flag; /* XXX */ + vpp = pscreen[to + i]; + vpv = vscreen[to + i]; + strncpy(vpp->v_text, vpv->v_text, cols); + vpp->v_flag = vpv->v_flag; /* XXX */ if (vpp->v_flag & VFREV) { vpp->v_flag &= ~VFREV; vpp->v_flag |= ~VFREQ; } #if MEMMAP - vscreen[to+i]->v_flag &= ~VFCHG; + vscreen[to + i]->v_flag &= ~VFCHG; #endif } if (inserts) { from = ptarget; to = match; } else { - from = vtarget+count; - to = match+count; + from = vtarget + count; + to = match + count; } #if MEMMAP == 0 for (i = from; i < to; i++) { @@ -757,39 +753,39 @@ scrolls(inserts) /* returns true if it does something */ vscreen[i]->v_flag |= VFCHG; } #endif - return(TRUE) ; + return (TRUE); } - return(FALSE) ; + return (FALSE); } /* move the "count" lines starting at "from" to "to" */ scrscroll(from, to, count) { ttrow = ttcol = -1; - (*term.t_scroll)(from,to,count); + (*term.t_scroll) (from, to, count); } -texttest(vrow,prow) /* return TRUE on text match */ -int vrow, prow ; /* virtual, physical rows */ +texttest(vrow, prow) /* return TRUE on text match */ +int vrow, prow; /* virtual, physical rows */ { -struct VIDEO *vpv = vscreen[vrow] ; /* virtual screen image */ -struct VIDEO *vpp = pscreen[prow] ; /* physical screen image */ + struct VIDEO *vpv = vscreen[vrow]; /* virtual screen image */ + struct VIDEO *vpp = pscreen[prow]; /* physical screen image */ - return (!memcmp(vpv->v_text, vpp->v_text, term.t_ncol)) ; + return (!memcmp(vpv->v_text, vpp->v_text, term.t_ncol)); } /* return the index of the first blank of trailing whitespace */ -int -endofline(s,n) -char *s ; +int endofline(s, n) +char *s; { -int i ; + int i; for (i = n - 1; i >= 0; i--) - if (s[i] != ' ') return(i+1) ; - return(0) ; + if (s[i] != ' ') + return (i + 1); + return (0); } -#endif /* SCROLLCODE */ +#endif /* SCROLLCODE */ /* updext: update the extended line which the cursor is currently on at a column greater than the terminal width. The line @@ -798,7 +794,6 @@ int i ; */ updext() - { register int rcursor; /* real cursor location */ register LINE *lp; /* pointer to current line */ @@ -809,10 +804,10 @@ updext() taboff = lbound = curcol - rcursor + 1; /* scan through the line outputing characters to the virtual screen */ - /* once we reach the left edge */ + /* once we reach the left edge */ vtmove(currow, -lbound); /* start scanning offscreen */ - lp = curwp->w_dotp; /* line to output */ - for (j=0; jw_dotp; /* line to output */ + for (j = 0; j < llength(lp); ++j) /* until the end-of-line */ vtputc(lgetc(lp, j)); /* truncate the virtual line, restore tab offset */ @@ -834,12 +829,12 @@ updext() updateline(row, vp1 #if SCROLLCODE - , vp2 + , vp2 #endif -) + ) -int row; /* row of screen to update */ -struct VIDEO *vp1; /* virtual screen image */ +int row; /* row of screen to update */ +struct VIDEO *vp1; /* virtual screen image */ #if SCROLLCODE struct VIDEO *vp2; @@ -853,12 +848,11 @@ struct VIDEO *vp2; cp1 = &vp1->v_text[0]; cp2 = &vp2->v_text[0]; nch = term.t_ncol; - do - { + do { *cp2 = *cp1; ++cp2; ++cp1; - } + } while (--nch); #endif #if COLOR @@ -879,34 +873,33 @@ struct VIDEO *vp2; updateline(row, vp1, vp2) -int row; /* row of screen to update */ -struct VIDEO *vp1; /* virtual screen image */ -struct VIDEO *vp2; /* physical screen image */ +int row; /* row of screen to update */ +struct VIDEO *vp1; /* virtual screen image */ +struct VIDEO *vp2; /* physical screen image */ { #if RAINBOW /* UPDATELINE specific code for the DEC rainbow 100 micro */ - register char *cp1; - register char *cp2; - register int nch; + register char *cp1; + register char *cp2; + register int nch; - /* since we don't know how to make the rainbow do this, turn it off */ - flags &= (~VFREV & ~VFREQ); + /* since we don't know how to make the rainbow do this, turn it off */ + flags &= (~VFREV & ~VFREQ); - cp1 = &vp1->v_text[0]; /* Use fast video. */ - cp2 = &vp2->v_text[0]; - putline(row+1, 1, cp1); - nch = term.t_ncol; + cp1 = &vp1->v_text[0]; /* Use fast video. */ + cp2 = &vp2->v_text[0]; + putline(row + 1, 1, cp1); + nch = term.t_ncol; - do - { - *cp2 = *cp1; - ++cp2; - ++cp1; - } - while (--nch); - *flags &= ~VFCHG; + do { + *cp2 = *cp1; + ++cp2; + ++cp1; + } + while (--nch); + *flags &= ~VFCHG; #else /* UPDATELINE code for all other versions */ @@ -936,16 +929,17 @@ 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. */ /* set rev video if needed */ if (rev != req) - (*term.t_rev)(req); + (*term.t_rev) (req); /* scan through the line and dump it to the screen and - the virtual screen array */ + the virtual screen array */ cp3 = &vp1->v_text[term.t_ncol]; while (cp1 < cp3) { TTputc(*cp1); @@ -954,7 +948,7 @@ struct VIDEO *vp2; /* physical screen image */ } /* turn rev video off */ if (rev != req) - (*term.t_rev)(FALSE); + (*term.t_rev) (FALSE); /* update the needed flags */ vp1->v_flag &= ~VFCHG; @@ -966,7 +960,7 @@ struct VIDEO *vp2; /* physical screen image */ vp1->v_fcolor = vp1->v_rfcolor; vp1->v_bcolor = vp1->v_rbcolor; #endif - return(TRUE); + return (TRUE); } #endif @@ -984,8 +978,8 @@ struct VIDEO *vp2; /* physical screen image */ */ /* if both lines are the same, no update needs to be done */ if (cp1 == &vp1->v_text[term.t_ncol]) { - vp1->v_flag &= ~VFCHG; /* flag this line is changed */ - return(TRUE); + vp1->v_flag &= ~VFCHG; /* flag this line is changed */ + return (TRUE); } /* find out if there is a match on the right */ @@ -996,19 +990,19 @@ struct VIDEO *vp2; /* physical screen image */ while (cp3[-1] == cp4[-1]) { --cp3; --cp4; - if (cp3[0] != ' ') /* Note if any nonblank */ - nbflag = TRUE; /* in right match. */ + if (cp3[0] != ' ') /* Note if any nonblank */ + nbflag = TRUE; /* in right match. */ } cp5 = cp3; /* Erase to EOL ? */ if (nbflag == FALSE && eolexist == TRUE && (req != TRUE)) { - while (cp5!=cp1 && cp5[-1]==' ') + while (cp5 != cp1 && cp5[-1] == ' ') --cp5; - if (cp3-cp5 <= 3) /* Use only if erase is */ - cp5 = cp3; /* fewer characters. */ + if (cp3 - cp5 <= 3) /* Use only if erase is */ + cp5 = cp3; /* fewer characters. */ } movecursor(row, cp1 - &vp1->v_text[0]); /* Go to start of line. */ @@ -1016,13 +1010,13 @@ struct VIDEO *vp2; /* physical screen image */ TTrev(rev); #endif - while (cp1 != cp5) { /* Ordinary. */ + while (cp1 != cp5) { /* Ordinary. */ TTputc(*cp1); ++ttcol; *cp2++ = *cp1++; } - if (cp5 != cp3) { /* Erase. */ + if (cp5 != cp3) { /* Erase. */ TTeeol(); while (cp1 != cp3) *cp2++ = *cp1++; @@ -1030,8 +1024,8 @@ struct VIDEO *vp2; /* physical screen image */ #if REVSTA TTrev(FALSE); #endif - vp1->v_flag &= ~VFCHG; /* flag this line as updated */ - return(TRUE); + vp1->v_flag &= ~VFCHG; /* flag this line as updated */ + return (TRUE); #endif } #endif @@ -1043,31 +1037,31 @@ struct VIDEO *vp2; /* physical screen image */ * any time there is a dirty window. */ modeline(wp) - WINDOW *wp; +WINDOW *wp; { - register char *cp; - register int c; - register int n; /* cursor position count */ - register BUFFER *bp; - register int i; /* loop index */ - register int lchar; /* character to draw line in buffer with */ - register int firstm; /* is this the first mode? */ - char tline[NLINE]; /* buffer for part of mode line */ + register char *cp; + register int c; + register int n; /* cursor position count */ + register BUFFER *bp; + register int i; /* loop index */ + register int lchar; /* character to draw line in buffer with */ + register int firstm; /* is this the first mode? */ + char tline[NLINE]; /* buffer for part of mode line */ - n = wp->w_toprow+wp->w_ntrows; /* Location. */ - vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL;/* Redraw next time. */ + n = wp->w_toprow + wp->w_ntrows; /* Location. */ + vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL; /* Redraw next time. */ #if COLOR - vscreen[n]->v_rfcolor = 0; /* black on */ - vscreen[n]->v_rbcolor = 7; /* white.....*/ + vscreen[n]->v_rfcolor = 0; /* black on */ + vscreen[n]->v_rbcolor = 7; /* white..... */ #endif - vtmove(n, 0); /* Seek to right line. */ - if (wp == curwp) /* mark the current buffer */ + vtmove(n, 0); /* Seek to right line. */ + if (wp == curwp) /* mark the current buffer */ #if PKCODE - lchar = '-'; + lchar = '-'; #else - lchar = '='; + lchar = '='; #endif - else + else #if REVSTA if (revexist) lchar = ' '; @@ -1075,47 +1069,44 @@ modeline(wp) #endif lchar = '-'; - bp = wp->w_bufp; + bp = wp->w_bufp; #if PKCODE == 0 - if ((bp->b_flag&BFTRUNC) != 0) - vtputc('#'); - else + if ((bp->b_flag & BFTRUNC) != 0) + vtputc('#'); + else #endif - vtputc(lchar); + vtputc(lchar); - if ((bp->b_flag&BFCHG) != 0) /* "*" if changed. */ - vtputc('*'); - else - vtputc(lchar); + if ((bp->b_flag & BFCHG) != 0) /* "*" if changed. */ + vtputc('*'); + else + vtputc(lchar); - n = 2; + n = 2; - strcpy(tline, " "); - strcat(tline, PROGNAME); - strcat(tline, " "); - strcat(tline, VERSION); - strcat(tline, ": "); - cp = &tline[0]; - while ((c = *cp++) != 0) - { - vtputc(c); - ++n; - } + strcpy(tline, " "); + strcat(tline, PROGNAME); + strcat(tline, " "); + strcat(tline, VERSION); + strcat(tline, ": "); + cp = &tline[0]; + while ((c = *cp++) != 0) { + vtputc(c); + ++n; + } - cp = &bp->b_bname[0]; - while ((c = *cp++) != 0) - { - vtputc(c); - ++n; - } + cp = &bp->b_bname[0]; + while ((c = *cp++) != 0) { + vtputc(c); + ++n; + } - strcpy(tline, " ("); + strcpy(tline, " ("); - /* display the modes */ + /* display the modes */ firstm = TRUE; - if ((bp->b_flag&BFTRUNC) != 0) - { + if ((bp->b_flag & BFTRUNC) != 0) { firstm = FALSE; strcat(tline, "Truncated"); } @@ -1126,68 +1117,63 @@ modeline(wp) firstm = FALSE; strcat(tline, mode2name[i]); } - strcat(tline,") "); + strcat(tline, ") "); - cp = &tline[0]; - while ((c = *cp++) != 0) - { - vtputc(c); - ++n; - } + cp = &tline[0]; + while ((c = *cp++) != 0) { + vtputc(c); + ++n; + } #if 0 - vtputc(lchar); - vtputc((wp->w_flag&WFCOLR) != 0 ? 'C' : lchar); - vtputc((wp->w_flag&WFMODE) != 0 ? 'M' : lchar); - vtputc((wp->w_flag&WFHARD) != 0 ? 'H' : lchar); - vtputc((wp->w_flag&WFEDIT) != 0 ? 'E' : lchar); - vtputc((wp->w_flag&WFMOVE) != 0 ? 'V' : lchar); - vtputc((wp->w_flag&WFFORCE) != 0 ? 'F' : lchar); - vtputc(lchar); - n += 8; + vtputc(lchar); + vtputc((wp->w_flag & WFCOLR) != 0 ? 'C' : lchar); + vtputc((wp->w_flag & WFMODE) != 0 ? 'M' : lchar); + vtputc((wp->w_flag & WFHARD) != 0 ? 'H' : lchar); + vtputc((wp->w_flag & WFEDIT) != 0 ? 'E' : lchar); + vtputc((wp->w_flag & WFMOVE) != 0 ? 'V' : lchar); + vtputc((wp->w_flag & WFFORCE) != 0 ? 'F' : lchar); + vtputc(lchar); + n += 8; #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. */ + if (bp->b_fname[0] != 0) /* File name. */ #endif - { + { #if PKCODE == 0 - cp = "File: "; + cp = "File: "; - while ((c = *cp++) != 0) - { - vtputc(c); - ++n; - } + while ((c = *cp++) != 0) { + vtputc(c); + ++n; + } #endif - cp = &bp->b_fname[0]; + cp = &bp->b_fname[0]; - while ((c = *cp++) != 0) - { - vtputc(c); - ++n; - } + while ((c = *cp++) != 0) { + vtputc(c); + ++n; + } - vtputc(' '); - ++n; - } + vtputc(' '); + ++n; + } - while (n < term.t_ncol) /* Pad to full width. */ - { - vtputc(lchar); - ++n; - } + while (n < term.t_ncol) { /* Pad to full width. */ + vtputc(lchar); + ++n; + } - { /* determine if top line, bottom line, or both are visible */ + { /* determine if top line, bottom line, or both are visible */ LINE *lp = wp->w_linep; int rows = wp->w_ntrows; char *msg = NULL; - vtcol = n - 7; /* strlen(" top ") plus a couple */ + vtcol = n - 7; /* strlen(" top ") plus a couple */ while (rows--) { lp = lforw(lp); if (lp == wp->w_bufp->b_linep) { @@ -1205,26 +1191,26 @@ modeline(wp) msg = " Top "; } } - if (!msg) - { + if (!msg) { LINE *lp; int numlines, predlines, ratio; - lp = lforw(bp->b_linep); - numlines = 0; - while (lp != bp->b_linep) { + lp = lforw(bp->b_linep); + numlines = 0; + while (lp != bp->b_linep) { if (lp == wp->w_linep) { predlines = numlines; } ++numlines; lp = lforw(lp); - } + } if (wp->w_dotp == bp->b_linep) { msg = " Bot "; } 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) - { - vtputc(c); + while ((c = *cp++) != 0) { + vtputc(c); ++n; - } + } } } -upmode() /* update all the mode lines */ - -{ +upmode() +{ /* update all the mode lines */ register WINDOW *wp; wp = wheadp; @@ -1259,14 +1243,13 @@ upmode() /* update all the mode lines */ * random calls. Update "ttrow" and "ttcol". */ movecursor(row, col) - { - if (row!=ttrow || col!=ttcol) - { - ttrow = row; - ttcol = col; - TTmove(row, col); - } - } +{ + if (row != ttrow || col != ttcol) { + ttrow = row; + ttcol = col; + TTmove(row, col); + } +} /* * Erase the message line. This is a special routine because the message line @@ -1274,28 +1257,28 @@ movecursor(row, col) * immediately; the terminal buffer is flushed via a call to the flusher. */ mlerase() - { - int i; +{ + int i; - movecursor(term.t_nrow, 0); - if (discmd == FALSE) - return; + movecursor(term.t_nrow, 0); + if (discmd == FALSE) + return; #if COLOR - TTforg(7); - TTbacg(0); + TTforg(7); + TTbacg(0); #endif - if (eolexist == TRUE) - TTeeol(); - else { - for (i = 0; i < term.t_ncol - 1; i++) - TTputc(' '); - movecursor(term.t_nrow, 1); /* force the move! */ - movecursor(term.t_nrow, 0); - } - TTflush(); - mpresf = FALSE; - } + if (eolexist == TRUE) + TTeeol(); + else { + for (i = 0; i < term.t_ncol - 1; i++) + TTputc(' '); + movecursor(term.t_nrow, 1); /* force the move! */ + movecursor(term.t_nrow, 0); + } + TTflush(); + mpresf = FALSE; +} /* * Write a message into the message line. Keep track of the physical cursor @@ -1306,8 +1289,8 @@ mlerase() mlwrite(fmt, arg) -char *fmt; /* format string for output */ -char *arg; /* pointer to first argument to print */ +char *fmt; /* format string for output */ +char *arg; /* pointer to first argument to print */ { register int c; /* current char in format string */ @@ -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); @@ -1341,43 +1323,43 @@ char *arg; /* pointer to first argument to print */ c = *fmt++; switch (c) { #if PKCODE - case '*': - ap = *(char **)ap; - break; + case '*': + ap = *(char **) ap; + break; #endif - case 'd': - mlputi(*(int *)ap, 10); - ap += sizeof(int); - break; + case 'd': + mlputi(*(int *) ap, 10); + ap += sizeof(int); + break; - case 'o': - mlputi(*(int *)ap, 8); - ap += sizeof(int); - break; + case 'o': + mlputi(*(int *) ap, 8); + ap += sizeof(int); + break; - case 'x': - mlputi(*(int *)ap, 16); - ap += sizeof(int); - break; + case 'x': + mlputi(*(int *) ap, 16); + ap += sizeof(int); + break; - case 'D': - mlputli(*(long *)ap, 10); - ap += sizeof(long); - break; + case 'D': + mlputli(*(long *) ap, 10); + ap += sizeof(long); + break; - case 's': - mlputs(*(char **)ap); - ap += sizeof(char *); - break; + case 's': + mlputs(*(char **) ap); + ap += sizeof(char *); + break; - case 'f': - mlputf(*(int *)ap); - ap += sizeof(int); - break; + case 'f': + mlputf(*(int *) ap); + ap += sizeof(int); + break; - default: - TTputc(c); - ++ttcol; + default: + TTputc(c); + ++ttcol; } } } @@ -1396,7 +1378,7 @@ char *arg; /* pointer to first argument to print */ mlforce(s) -char *s; /* string to force out */ +char *s; /* string to force out */ { register int oldcmd; /* original command display flag */ @@ -1413,63 +1395,60 @@ char *s; /* string to force out */ * things will get screwed up a little. */ mlputs(s) - char *s; - { - register int c; +char *s; +{ + register int c; - while ((c = *s++) != 0) - { - TTputc(c); - ++ttcol; - } - } + while ((c = *s++) != 0) { + TTputc(c); + ++ttcol; + } +} /* * Write out an integer, in the specified radix. Update the physical cursor * position. */ mlputi(i, r) - { - register int q; - static char hexdigits[] = "0123456789ABCDEF"; +{ + register int q; + static char hexdigits[] = "0123456789ABCDEF"; - if (i < 0) - { - i = -i; - TTputc('-'); - } + if (i < 0) { + i = -i; + TTputc('-'); + } - q = i/r; + q = i / r; - if (q != 0) - mlputi(q, r); + if (q != 0) + mlputi(q, r); - TTputc(hexdigits[i%r]); - ++ttcol; - } + TTputc(hexdigits[i % r]); + ++ttcol; +} /* * do the same except as a long integer. */ mlputli(l, r) - long l; - { - register long q; +long l; +{ + register long q; - if (l < 0) - { - l = -l; - TTputc('-'); - } + if (l < 0) { + l = -l; + TTputc('-'); + } - q = l/r; + q = l / r; - if (q != 0) - mlputli(q, r); + if (q != 0) + mlputli(q, r); - TTputc((int)(l%r)+'0'); - ++ttcol; - } + TTputc((int) (l % r) + '0'); + ++ttcol; +} /* * write out a scaled integer with two decimal places @@ -1477,11 +1456,11 @@ mlputli(l, r) mlputf(s) -int s; /* scaled integer to output */ +int s; /* scaled integer to output */ { - int i; /* integer portion of number */ - int f; /* fractional portion of number */ + int i; /* integer portion of number */ + int f; /* fractional portion of number */ /* break it up */ i = s / 100; @@ -1493,79 +1472,78 @@ int s; /* scaled integer to output */ TTputc((f / 10) + '0'); TTputc((f % 10) + '0'); ttcol += 3; -} +} #if RAINBOW putline(row, col, buf) - int row, col; - char buf[]; - { - int n; +int row, col; +char buf[]; +{ + int n; - n = strlen(buf); - if (col + n - 1 > term.t_ncol) - n = term.t_ncol - col + 1; - Put_Data(row, col, n, buf); - } + n = strlen(buf); + if (col + n - 1 > term.t_ncol) + n = term.t_ncol - col + 1; + Put_Data(row, col, n, buf); +} #endif /* Get terminal size from system. Store number of lines into *heightp and width into *widthp. If zero or a negative number is stored, the value is not valid. */ - -getscreensize (widthp, heightp) + +getscreensize(widthp, heightp) int *widthp, *heightp; -{ +{ #ifdef TIOCGWINSZ - struct winsize size; - *widthp = 0; - *heightp = 0; - if (ioctl (0, TIOCGWINSZ, &size) < 0) - return; - *widthp = size.ws_col; - *heightp = size.ws_row; + struct winsize size; + *widthp = 0; + *heightp = 0; + if (ioctl(0, TIOCGWINSZ, &size) < 0) + return; + *widthp = size.ws_col; + *heightp = size.ws_row; #else - *widthp = 0; - *heightp = 0; -#endif -} - + *widthp = 0; + *heightp = 0; +#endif +} + #ifdef SIGWINCH void sizesignal(signr) int signr; { - int w, h; - extern int errno; - int old_errno = errno; - - getscreensize (&w, &h); - - if (h && w && (h-1 != term.t_nrow || w != term.t_ncol)) - newscreensize(h, w); + int w, h; + extern int errno; + int old_errno = errno; - signal (SIGWINCH, sizesignal); - errno = old_errno; + getscreensize(&w, &h); + + if (h && w && (h - 1 != term.t_nrow || w != term.t_ncol)) + newscreensize(h, w); + + signal(SIGWINCH, sizesignal); + errno = old_errno; } - -newscreensize (h, w) + +newscreensize(h, w) int h, w; -{ - /* do the change later */ - if (displaying) { - chg_width = w; - chg_height = h; - return; - } - chg_width = chg_height = 0; - if (h - 1 < term.t_mrow) - newsize(TRUE,h); - if (w < term.t_mcol) - newwidth(TRUE,w); - - update(TRUE); - return TRUE; -} - -#endif +{ + /* do the change later */ + if (displaying) { + chg_width = w; + chg_height = h; + return; + } + chg_width = chg_height = 0; + if (h - 1 < term.t_mrow) + newsize(TRUE, h); + if (w < term.t_mcol) + newwidth(TRUE, w); + update(TRUE); + return TRUE; +} + +#endif diff --git a/ebind.h b/ebind.h index 432462a..6e25fdb 100644 --- a/ebind.h +++ b/ebind.h @@ -11,239 +11,408 @@ * characters of the command. This explains the funny location of the * 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. */ +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. */ #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 */ - SPEC|META|'C', nullproc, /* every command input */ - SPEC|META|'R', nullproc, /* on file read */ - SPEC|META|'X', nullproc, /* on window change P.K. */ + SPEC | META | 'W', wrapword, /* called on word wrap */ + SPEC | META | 'C', nullproc, /* every command input */ + SPEC | META | 'R', nullproc, /* on file read */ + SPEC | META | 'X', nullproc, /* on window change P.K. */ - {0, NULL} + {0, NULL} }; - - diff --git a/edef.h b/edef.h index 67aa375..65fff82 100644 --- a/edef.h +++ b/edef.h @@ -36,114 +36,116 @@ unsigned int stock(); /* initialized global definitions */ -int fillcol = 72; /* Current fill column */ -short kbdm[NKBDM]; /* Macro */ -char *execstr = NULL; /* pointer to string to execute */ -char golabel[NPAT] = ""; /* current line to go to */ -int execlevel = 0; /* execution IF level */ -int eolexist = TRUE; /* does clear to EOL exist */ -int revexist = FALSE; /* does reverse video exist? */ -int flickcode = FALSE; /* do flicker supression? */ -char *modename[] = { /* name of modes */ +int fillcol = 72; /* Current fill column */ +short kbdm[NKBDM]; /* Macro */ +char *execstr = NULL; /* pointer to string to execute */ +char golabel[NPAT] = ""; /* current line to go to */ +int execlevel = 0; /* execution IF level */ +int eolexist = TRUE; /* does clear to EOL exist */ +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"}; -char *mode2name[] = { /* name of modes */ + "MAGIC", "CRYPT", "ASAVE" +}; +char *mode2name[] = { /* name of modes */ "Wrap", "Cmode", "Spell", "Exact", "View", "Over", - "Magic", "Crypt", "Asave"}; -char modecode[] = "WCSEVOMYA"; /* letters to represent modes */ -int gmode = 0; /* global editor mode */ -int gflags = GFREAD; /* global control flag */ + "Magic", "Crypt", "Asave" +}; +char modecode[] = "WCSEVOMYA"; /* letters to represent modes */ +int gmode = 0; /* global editor mode */ +int gflags = GFREAD; /* global control flag */ #if PKCODE & IBMPC -int gfcolor = 8; /* global forgrnd color (white) */ +int gfcolor = 8; /* global forgrnd color (white) */ #else -int gfcolor = 7; /* global forgrnd color (white) */ +int gfcolor = 7; /* global forgrnd color (white) */ #endif -int gbcolor = 0; /* global backgrnd color (black)*/ -int gasave = 256; /* global ASAVE size */ -int gacount = 256; /* count until next ASAVE */ -int sgarbf = TRUE; /* TRUE if screen is garbage */ -int mpresf = FALSE; /* TRUE if message in last line */ -int clexec = FALSE; /* command line execution flag */ -int mstore = FALSE; /* storing text to macro flag */ -int discmd = TRUE; /* display command flag */ -int disinp = TRUE; /* display input characters */ -struct BUFFER *bstore = NULL; /* buffer to store macro text to*/ -int vtrow = 0; /* Row location of SW cursor */ -int vtcol = 0; /* Column location of SW cursor */ -int ttrow = HUGE; /* Row location of HW cursor */ -int ttcol = HUGE; /* Column location of HW cursor */ -int lbound = 0; /* leftmost column of current line - being displayed */ -int taboff = 0; /* tab offset for display */ -int metac = CONTROL | '['; /* current meta character */ -int ctlxc = CONTROL | 'X'; /* current control X prefix char */ -int reptc = CONTROL | 'U'; /* current universal repeat char */ -int abortc = CONTROL | 'G'; /* current abort command char */ +int gbcolor = 0; /* global backgrnd color (black) */ +int gasave = 256; /* global ASAVE size */ +int gacount = 256; /* count until next ASAVE */ +int sgarbf = TRUE; /* TRUE if screen is garbage */ +int mpresf = FALSE; /* TRUE if message in last line */ +int clexec = FALSE; /* command line execution flag */ +int mstore = FALSE; /* storing text to macro flag */ +int discmd = TRUE; /* display command flag */ +int disinp = TRUE; /* display input characters */ +struct BUFFER *bstore = NULL; /* buffer to store macro text to */ +int vtrow = 0; /* Row location of SW cursor */ +int vtcol = 0; /* Column location of SW cursor */ +int ttrow = HUGE; /* Row location of HW cursor */ +int ttcol = HUGE; /* Column location of HW cursor */ +int lbound = 0; /* leftmost column of current line + being displayed */ +int taboff = 0; /* tab offset for display */ +int metac = CONTROL | '['; /* current meta character */ +int ctlxc = CONTROL | 'X'; /* current control X prefix char */ +int reptc = CONTROL | 'U'; /* current universal repeat char */ +int abortc = CONTROL | 'G'; /* current abort command char */ -int quotec = 0x11; /* quote char during mlreply() */ -int tabmask = 0x07; /* tabulator mask */ -char *cname[] = { /* names of colors */ +int quotec = 0x11; /* quote char during mlreply() */ +int tabmask = 0x07; /* tabulator mask */ +char *cname[] = { /* names of colors */ "BLACK", "RED", "GREEN", "YELLOW", "BLUE", "MAGENTA", "CYAN", "WHITE" #if PKCODE & IBMPC - ,"HIGH" + , "HIGH" #endif - }; -KILL *kbufp = NULL; /* current kill buffer chunk pointer */ -KILL *kbufh = NULL; /* kill buffer header pointer */ -int kused = KBLOCK; /* # of bytes used in kill buffer */ -WINDOW *swindow = NULL; /* saved window pointer */ -int cryptflag = FALSE; /* currently encrypting? */ -short *kbdptr; /* current position in keyboard buf */ -short *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ -int kbdmode = STOP; /* current keyboard macro mode */ -int kbdrep = 0; /* number of repetitions */ -int restflag = FALSE; /* restricted use? */ -int lastkey = 0; /* last keystoke */ -int seed = 0; /* random number seed */ -long envram = 0l; /* # of bytes current in use by malloc */ -int macbug = FALSE; /* macro debuging flag */ -char errorm[] = "ERROR"; /* error literal */ -char truem[] = "TRUE"; /* true literal */ -char falsem[] = "FALSE"; /* false litereal */ -int cmdstatus = TRUE; /* last command status */ -char palstr[49] = ""; /* palette string */ -int saveflag = 0; /* Flags, saved with the $target var */ -char *fline = NULL; /* dynamic return line */ -int flen = 0; /* current length of fline */ -int rval = 0; /* return value of a subprocess */ +}; +KILL *kbufp = NULL; /* current kill buffer chunk pointer */ +KILL *kbufh = NULL; /* kill buffer header pointer */ +int kused = KBLOCK; /* # of bytes used in kill buffer */ +WINDOW *swindow = NULL; /* saved window pointer */ +int cryptflag = FALSE; /* currently encrypting? */ +short *kbdptr; /* current position in keyboard buf */ +short *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ +int kbdmode = STOP; /* current keyboard macro mode */ +int kbdrep = 0; /* number of repetitions */ +int restflag = FALSE; /* restricted use? */ +int lastkey = 0; /* last keystoke */ +int seed = 0; /* random number seed */ +long envram = 0l; /* # of bytes current in use by malloc */ +int macbug = FALSE; /* macro debuging flag */ +char errorm[] = "ERROR"; /* error literal */ +char truem[] = "TRUE"; /* true literal */ +char falsem[] = "FALSE"; /* false litereal */ +int cmdstatus = TRUE; /* last command status */ +char palstr[49] = ""; /* palette string */ +int saveflag = 0; /* Flags, saved with the $target var */ +char *fline = NULL; /* dynamic return line */ +int flen = 0; /* current length of fline */ +int rval = 0; /* return value of a subprocess */ #if CALLED -int eexitflag = FALSE; /* EMACS exit flag */ -int eexitval = 0; /* and the exit return value */ +int eexitflag = FALSE; /* EMACS exit flag */ +int eexitval = 0; /* and the exit return value */ #endif #if PKCODE -int nullflag = FALSE; /* accept null characters */ -int justflag = FALSE; /* justify, don't fill */ +int nullflag = FALSE; /* accept null characters */ +int justflag = FALSE; /* justify, don't fill */ #endif -int overlap = 0; /* line overlap in forw/back page */ -int scrollcount = 1; /* number of lines to scroll */ +int overlap = 0; /* line overlap in forw/back page */ +int scrollcount = 1; /* number of lines to scroll */ /* uninitialized global definitions */ -int currow; /* Cursor row */ -int curcol; /* Cursor column */ -int thisflag; /* Flags, this command */ -int lastflag; /* Flags, last command */ -int curgoal; /* Goal for C-P, C-N */ -WINDOW *curwp; /* Current window */ -BUFFER *curbp; /* Current buffer */ -WINDOW *wheadp; /* Head of list of windows */ -BUFFER *bheadp; /* Head of list of buffers */ -BUFFER *blistp; /* Buffer for C-X C-B */ +int currow; /* Cursor row */ +int curcol; /* Cursor column */ +int thisflag; /* Flags, this command */ +int lastflag; /* Flags, last command */ +int curgoal; /* Goal for C-P, C-N */ +WINDOW *curwp; /* Current window */ +BUFFER *curbp; /* Current buffer */ +WINDOW *wheadp; /* Head of list of windows */ +BUFFER *bheadp; /* Head of list of buffers */ +BUFFER *blistp; /* Buffer for C-X C-B */ -BUFFER *bfind(); /* Lookup a buffer by name */ -WINDOW *wpopup(); /* Pop up window creation */ -LINE *lalloc(); /* Allocate a line */ -char sres[NBUFN]; /* current screen resolution */ +BUFFER *bfind(); /* Lookup a buffer by name */ +WINDOW *wpopup(); /* Pop up window creation */ +LINE *lalloc(); /* Allocate a line */ +char sres[NBUFN]; /* current screen resolution */ -char pat[NPAT]; /* Search pattern */ -char tap[NPAT]; /* Reversed pattern array. */ -char rpat[NPAT]; /* replacement pattern */ +char pat[NPAT]; /* Search pattern */ +char tap[NPAT]; /* Reversed pattern array. */ +char rpat[NPAT]; /* replacement pattern */ /* The variable matchlen holds the length of the matched * string - used by the replace functions. @@ -152,11 +154,11 @@ char rpat[NPAT]; /* replacement pattern */ * The variables matchline and matchoff hold the line and * offset position of the *start* of match. */ -unsigned int matchlen = 0; -unsigned int mlenold = 0; -char *patmatch = NULL; -LINE *matchline = NULL; -int matchoff = 0; +unsigned int matchlen = 0; +unsigned int mlenold = 0; +char *patmatch = NULL; +LINE *matchline = NULL; +int matchoff = 0; #if MAGIC /* @@ -165,11 +167,11 @@ int matchoff = 0; * if not, then we don't have to use the slower MAGIC mode * search functions. */ -short int magical = FALSE; -short int rmagical = FALSE; -MC mcpat[NPAT]; /* the magic pattern */ -MC tapcm[NPAT]; /* the reversed magic pattern */ -RMC rmcpat[NPAT]; /* the replacement magic array */ +short int magical = FALSE; +short int rmagical = FALSE; +MC mcpat[NPAT]; /* the magic pattern */ +MC tapcm[NPAT]; /* the reversed magic pattern */ +RMC rmcpat[NPAT]; /* the replacement magic array */ #endif @@ -194,102 +196,102 @@ char outline[NSTRING]; /* global string to hold debug line text */ /* initialized global external declarations */ -extern int fillcol; /* Fill column */ -extern short kbdm[]; /* Holds kayboard macro data */ -extern char pat[]; /* Search pattern */ -extern char rpat[]; /* Replacement pattern */ -extern char *execstr; /* pointer to string to execute */ -extern char golabel[]; /* current line to go to */ -extern int execlevel; /* execution IF level */ -extern int eolexist; /* does clear to EOL exist? */ -extern int revexist; /* does reverse video exist? */ -extern int flickcode; /* do flicker supression? */ -extern char *modename[]; /* text names of modes */ -extern char *mode2name[]; /* text names of modes */ -extern char modecode[]; /* letters to represent modes */ -extern KEYTAB keytab[]; /* key bind to functions table */ -extern NBIND names[]; /* name to function table */ -extern int gmode; /* global editor mode */ -extern int gflags; /* global control flag */ -extern int gfcolor; /* global forgrnd color (white) */ -extern int gbcolor; /* global backgrnd color (black)*/ -extern int gasave; /* global ASAVE size */ -extern int gacount; /* count until next ASAVE */ -extern int sgarbf; /* State of screen unknown */ -extern int mpresf; /* Stuff in message line */ -extern int clexec; /* command line execution flag */ -extern int mstore; /* storing text to macro flag */ -extern int discmd; /* display command flag */ -extern int disinp; /* display input characters */ -extern struct BUFFER *bstore; /* buffer to store macro text to*/ -extern int vtrow; /* Row location of SW cursor */ -extern int vtcol; /* Column location of SW cursor */ -extern int ttrow; /* Row location of HW cursor */ -extern int ttcol; /* Column location of HW cursor */ -extern int lbound; /* leftmost column of current line - being displayed */ -extern int taboff; /* tab offset for display */ -extern int metac; /* current meta character */ -extern int ctlxc; /* current control X prefix char */ -extern int reptc; /* current universal repeat char */ -extern int abortc; /* current abort command char */ +extern int fillcol; /* Fill column */ +extern short kbdm[]; /* Holds kayboard macro data */ +extern char pat[]; /* Search pattern */ +extern char rpat[]; /* Replacement pattern */ +extern char *execstr; /* pointer to string to execute */ +extern char golabel[]; /* current line to go to */ +extern int execlevel; /* execution IF level */ +extern int eolexist; /* does clear to EOL exist? */ +extern int revexist; /* does reverse video exist? */ +extern int flickcode; /* do flicker supression? */ +extern char *modename[]; /* text names of modes */ +extern char *mode2name[]; /* text names of modes */ +extern char modecode[]; /* letters to represent modes */ +extern KEYTAB keytab[]; /* key bind to functions table */ +extern NBIND names[]; /* name to function table */ +extern int gmode; /* global editor mode */ +extern int gflags; /* global control flag */ +extern int gfcolor; /* global forgrnd color (white) */ +extern int gbcolor; /* global backgrnd color (black) */ +extern int gasave; /* global ASAVE size */ +extern int gacount; /* count until next ASAVE */ +extern int sgarbf; /* State of screen unknown */ +extern int mpresf; /* Stuff in message line */ +extern int clexec; /* command line execution flag */ +extern int mstore; /* storing text to macro flag */ +extern int discmd; /* display command flag */ +extern int disinp; /* display input characters */ +extern struct BUFFER *bstore; /* buffer to store macro text to */ +extern int vtrow; /* Row location of SW cursor */ +extern int vtcol; /* Column location of SW cursor */ +extern int ttrow; /* Row location of HW cursor */ +extern int ttcol; /* Column location of HW cursor */ +extern int lbound; /* leftmost column of current line + being displayed */ +extern int taboff; /* tab offset for display */ +extern int metac; /* current meta character */ +extern int ctlxc; /* current control X prefix char */ +extern int reptc; /* current universal repeat char */ +extern int abortc; /* current abort command char */ -extern int quotec; /* quote char during mlreply() */ -extern int tabmask; -extern char *cname[]; /* names of colors */ -extern KILL *kbufp; /* current kill buffer chunk pointer */ -extern KILL *kbufh; /* kill buffer header pointer */ -extern int kused; /* # of bytes used in KB */ -extern WINDOW *swindow; /* saved window pointer */ -extern int cryptflag; /* currently encrypting? */ -extern short *kbdptr; /* current position in keyboard buf */ -extern short *kbdend; /* ptr to end of the keyboard */ -extern int kbdmode; /* current keyboard macro mode */ -extern int kbdrep; /* number of repetitions */ -extern int restflag; /* restricted use? */ -extern int lastkey; /* last keystoke */ -extern int seed; /* random number seed */ -extern long envram; /* # of bytes current in use by malloc */ -extern int macbug; /* macro debuging flag */ -extern char errorm[]; /* error literal */ -extern char truem[]; /* true literal */ -extern char falsem[]; /* false litereal */ -extern int cmdstatus; /* last command status */ -extern char palstr[]; /* palette string */ -extern int saveflag; /* Flags, saved with the $target var */ -extern char *fline; /* dynamic return line */ -extern int flen; /* current length of fline */ -extern int rval; /* return value of a subprocess */ +extern int quotec; /* quote char during mlreply() */ +extern int tabmask; +extern char *cname[]; /* names of colors */ +extern KILL *kbufp; /* current kill buffer chunk pointer */ +extern KILL *kbufh; /* kill buffer header pointer */ +extern int kused; /* # of bytes used in KB */ +extern WINDOW *swindow; /* saved window pointer */ +extern int cryptflag; /* currently encrypting? */ +extern short *kbdptr; /* current position in keyboard buf */ +extern short *kbdend; /* ptr to end of the keyboard */ +extern int kbdmode; /* current keyboard macro mode */ +extern int kbdrep; /* number of repetitions */ +extern int restflag; /* restricted use? */ +extern int lastkey; /* last keystoke */ +extern int seed; /* random number seed */ +extern long envram; /* # of bytes current in use by malloc */ +extern int macbug; /* macro debuging flag */ +extern char errorm[]; /* error literal */ +extern char truem[]; /* true literal */ +extern char falsem[]; /* false litereal */ +extern int cmdstatus; /* last command status */ +extern char palstr[]; /* palette string */ +extern int saveflag; /* Flags, saved with the $target var */ +extern char *fline; /* dynamic return line */ +extern int flen; /* current length of fline */ +extern int rval; /* return value of a subprocess */ #if CALLED -extern int eexitflag; /* EMACS exit flag */ -extern int eexitval; /* and the exit return value */ +extern int eexitflag; /* EMACS exit flag */ +extern int eexitval; /* and the exit return value */ #endif #if PKCODE -extern int justflag; /* justify, don't fill */ +extern int justflag; /* justify, don't fill */ #endif -extern int overlap; /* line overlap in forw/back page */ -extern int scrollcount; /* number of lines to scroll */ +extern int overlap; /* line overlap in forw/back page */ +extern int scrollcount; /* number of lines to scroll */ /* uninitialized global external declarations */ -extern int currow; /* Cursor row */ -extern int curcol; /* Cursor column */ -extern int thisflag; /* Flags, this command */ -extern int lastflag; /* Flags, last command */ -extern int curgoal; /* Goal for C-P, C-N */ -extern WINDOW *curwp; /* Current window */ -extern BUFFER *curbp; /* Current buffer */ -extern WINDOW *wheadp; /* Head of list of windows */ -extern BUFFER *bheadp; /* Head of list of buffers */ -extern BUFFER *blistp; /* Buffer for C-X C-B */ +extern int currow; /* Cursor row */ +extern int curcol; /* Cursor column */ +extern int thisflag; /* Flags, this command */ +extern int lastflag; /* Flags, last command */ +extern int curgoal; /* Goal for C-P, C-N */ +extern WINDOW *curwp; /* Current window */ +extern BUFFER *curbp; /* Current buffer */ +extern WINDOW *wheadp; /* Head of list of windows */ +extern BUFFER *bheadp; /* Head of list of buffers */ +extern BUFFER *blistp; /* Buffer for C-X C-B */ -extern BUFFER *bfind(); /* Lookup a buffer by name */ -extern WINDOW *wpopup(); /* Pop up window creation */ -extern LINE *lalloc(); /* Allocate a line */ -extern char sres[NBUFN]; /* current screen resolution */ -extern char pat[]; /* Search pattern */ -extern char tap[]; /* Reversed pattern array. */ -extern char rpat[]; /* replacement pattern */ +extern BUFFER *bfind(); /* Lookup a buffer by name */ +extern WINDOW *wpopup(); /* Pop up window creation */ +extern LINE *lalloc(); /* Allocate a line */ +extern char sres[NBUFN]; /* current screen resolution */ +extern char pat[]; /* Search pattern */ +extern char tap[]; /* Reversed pattern array. */ +extern char rpat[]; /* replacement pattern */ extern unsigned int matchlen; extern unsigned int mlenold; @@ -300,12 +302,12 @@ extern int matchoff; #if MAGIC extern short int magical; extern short int rmagical; -extern MC mcpat[NPAT]; /* the magic pattern */ -extern MC tapcm[NPAT]; /* the reversed magic pattern */ -extern RMC rmcpat[NPAT]; /* the replacement magic array */ +extern MC mcpat[NPAT]; /* the magic pattern */ +extern MC tapcm[NPAT]; /* the reversed magic pattern */ +extern RMC rmcpat[NPAT]; /* the replacement magic array */ #endif -extern char *dname[]; /* directive name table */ +extern char *dname[]; /* directive name table */ #if DEBUGM /* vars needed for macro debugging output */ @@ -317,7 +319,5 @@ extern char outline[]; /* global string to hold debug line text */ /* terminal table defined only in TERM.C */ #ifndef termdef -extern TERM term; /* Terminal information. */ +extern TERM term; /* Terminal information. */ #endif - - diff --git a/efunc.h b/efunc.h index cb8de1e..edd3468 100644 --- a/efunc.h +++ b/efunc.h @@ -12,203 +12,203 @@ /* External function declarations */ -extern int ctrlg(); /* Abort out of things */ -extern int quit(); /* Quit */ -extern int ctlxlp(); /* Begin macro */ -extern int ctlxrp(); /* End macro */ -extern int ctlxe(); /* Execute macro */ -extern int fileread(); /* Get a file, read only */ -extern int filefind(); /* Get a file, read write */ -extern int filewrite(); /* Write a file */ -extern int filesave(); /* Save current file */ -extern int filename(); /* Adjust file name */ -extern int getccol(); /* Get current column */ -extern int gotobol(); /* Move to start of line */ -extern int forwchar(); /* Move forward by characters */ -extern int gotoeol(); /* Move to end of line */ -extern int backchar(); /* Move backward by characters */ -extern int forwline(); /* Move forward by lines */ -extern int backline(); /* Move backward by lines */ -extern int forwpage(); /* Move forward by pages */ -extern int backpage(); /* Move backward by pages */ -extern int gotobob(); /* Move to start of buffer */ -extern int gotoeob(); /* Move to end of buffer */ -extern int setfillcol(); /* Set fill column. */ -extern int setmark(); /* Set mark */ -extern int swapmark(); /* Swap "." and mark */ -extern int forwsearch(); /* Search forward */ -extern int backsearch(); /* Search backwards */ -extern int sreplace(); /* search and replace */ -extern int qreplace(); /* search and replace w/query */ -extern int showcpos(); /* Show the cursor position */ -extern int nextwind(); /* Move to the next window */ -extern int prevwind(); /* Move to the previous window */ -extern int onlywind(); /* Make current window only one */ -extern int splitwind(); /* Split current window */ -extern int mvdnwind(); /* Move window down */ -extern int mvupwind(); /* Move window up */ -extern int enlargewind(); /* Enlarge display window. */ -extern int shrinkwind(); /* Shrink window. */ -extern int listbuffers(); /* Display list of buffers */ -extern int usebuffer(); /* Switch a window to a buffer */ -extern int killbuffer(); /* Make a buffer go away. */ -extern int reposition(); /* Reposition window */ -extern int refresh(); /* Refresh the screen */ -extern int twiddle(); /* Twiddle characters */ -extern int tab(); /* Insert tab */ -extern int newline(); /* Insert CR-LF */ -extern int indent(); /* Insert CR-LF, then indent */ -extern int openline(); /* Open up a blank line */ -extern int deblank(); /* Delete blank lines */ -extern int quote(); /* Insert literal */ -extern int backword(); /* Backup by words */ -extern int forwword(); /* Advance by words */ -extern int forwdel(); /* Forward delete */ -extern int backdel(); /* Backward delete */ -extern int killtext(); /* Kill forward */ -extern int yank(); /* Yank back from killbuffer. */ -extern int upperword(); /* Upper case word. */ -extern int lowerword(); /* Lower case word. */ -extern int upperregion(); /* Upper case region. */ -extern int lowerregion(); /* Lower case region. */ -extern int capword(); /* Initial capitalize word. */ -extern int delfword(); /* Delete forward word. */ -extern int delbword(); /* Delete backward word. */ -extern int killregion(); /* Kill region. */ -extern int copyregion(); /* Copy region to kill buffer. */ -extern int spawncli(); /* Run CLI in a subjob. */ -extern int spawn(); /* Run a command in a subjob. */ +extern int ctrlg(); /* Abort out of things */ +extern int quit(); /* Quit */ +extern int ctlxlp(); /* Begin macro */ +extern int ctlxrp(); /* End macro */ +extern int ctlxe(); /* Execute macro */ +extern int fileread(); /* Get a file, read only */ +extern int filefind(); /* Get a file, read write */ +extern int filewrite(); /* Write a file */ +extern int filesave(); /* Save current file */ +extern int filename(); /* Adjust file name */ +extern int getccol(); /* Get current column */ +extern int gotobol(); /* Move to start of line */ +extern int forwchar(); /* Move forward by characters */ +extern int gotoeol(); /* Move to end of line */ +extern int backchar(); /* Move backward by characters */ +extern int forwline(); /* Move forward by lines */ +extern int backline(); /* Move backward by lines */ +extern int forwpage(); /* Move forward by pages */ +extern int backpage(); /* Move backward by pages */ +extern int gotobob(); /* Move to start of buffer */ +extern int gotoeob(); /* Move to end of buffer */ +extern int setfillcol(); /* Set fill column. */ +extern int setmark(); /* Set mark */ +extern int swapmark(); /* Swap "." and mark */ +extern int forwsearch(); /* Search forward */ +extern int backsearch(); /* Search backwards */ +extern int sreplace(); /* search and replace */ +extern int qreplace(); /* search and replace w/query */ +extern int showcpos(); /* Show the cursor position */ +extern int nextwind(); /* Move to the next window */ +extern int prevwind(); /* Move to the previous window */ +extern int onlywind(); /* Make current window only one */ +extern int splitwind(); /* Split current window */ +extern int mvdnwind(); /* Move window down */ +extern int mvupwind(); /* Move window up */ +extern int enlargewind(); /* Enlarge display window. */ +extern int shrinkwind(); /* Shrink window. */ +extern int listbuffers(); /* Display list of buffers */ +extern int usebuffer(); /* Switch a window to a buffer */ +extern int killbuffer(); /* Make a buffer go away. */ +extern int reposition(); /* Reposition window */ +extern int refresh(); /* Refresh the screen */ +extern int twiddle(); /* Twiddle characters */ +extern int tab(); /* Insert tab */ +extern int newline(); /* Insert CR-LF */ +extern int indent(); /* Insert CR-LF, then indent */ +extern int openline(); /* Open up a blank line */ +extern int deblank(); /* Delete blank lines */ +extern int quote(); /* Insert literal */ +extern int backword(); /* Backup by words */ +extern int forwword(); /* Advance by words */ +extern int forwdel(); /* Forward delete */ +extern int backdel(); /* Backward delete */ +extern int killtext(); /* Kill forward */ +extern int yank(); /* Yank back from killbuffer. */ +extern int upperword(); /* Upper case word. */ +extern int lowerword(); /* Lower case word. */ +extern int upperregion(); /* Upper case region. */ +extern int lowerregion(); /* Lower case region. */ +extern int capword(); /* Initial capitalize word. */ +extern int delfword(); /* Delete forward word. */ +extern int delbword(); /* Delete backward word. */ +extern int killregion(); /* Kill region. */ +extern int copyregion(); /* Copy region to kill buffer. */ +extern int spawncli(); /* Run CLI in a subjob. */ +extern int spawn(); /* Run a command in a subjob. */ #if BSD | __hpux | SVR4 -extern int bktoshell(); /* suspend emacs to parent shell*/ -extern int rtfrmshell(); /* return from a suspended state*/ +extern int bktoshell(); /* suspend emacs to parent shell */ +extern int rtfrmshell(); /* return from a suspended state */ #endif -extern int quickexit(); /* low keystroke style exit. */ -extern int setmode(); /* set an editor mode */ -extern int delmode(); /* delete a mode */ -extern int gotoline(); /* go to a numbered line */ -extern int namebuffer(); /* rename the current buffer */ +extern int quickexit(); /* low keystroke style exit. */ +extern int setmode(); /* set an editor mode */ +extern int delmode(); /* delete a mode */ +extern int gotoline(); /* go to a numbered line */ +extern int namebuffer(); /* rename the current buffer */ #if WORDPRO -extern int gotobop(); /* go to beginning/paragraph */ -extern int gotoeop(); /* go to end/paragraph */ -extern int fillpara(); /* fill current paragraph */ +extern int gotobop(); /* go to beginning/paragraph */ +extern int gotoeop(); /* go to end/paragraph */ +extern int fillpara(); /* fill current paragraph */ #if PKCODE -extern int justpara(); /* justify current paragraph */ +extern int justpara(); /* justify current paragraph */ #endif #endif -extern int help(); /* get the help file here */ -extern int deskey(); /* describe a key's binding */ -extern int viewfile(); /* find a file in view mode */ -extern int insfile(); /* insert a file */ -extern int scrnextup(); /* scroll next window back */ -extern int scrnextdw(); /* scroll next window down */ -extern int bindtokey(); /* bind a function to a key */ -extern int unbindkey(); /* unbind a key's function */ -extern int namedcmd(); /* execute named command */ -extern int desbind(); /* describe bindings */ -extern int execcmd(); /* execute a command line */ -extern int execbuf(); /* exec commands from a buffer */ -extern int execfile(); /* exec commands from a file */ -extern int nextbuffer(); /* switch to the next buffer */ +extern int help(); /* get the help file here */ +extern int deskey(); /* describe a key's binding */ +extern int viewfile(); /* find a file in view mode */ +extern int insfile(); /* insert a file */ +extern int scrnextup(); /* scroll next window back */ +extern int scrnextdw(); /* scroll next window down */ +extern int bindtokey(); /* bind a function to a key */ +extern int unbindkey(); /* unbind a key's function */ +extern int namedcmd(); /* execute named command */ +extern int desbind(); /* describe bindings */ +extern int execcmd(); /* execute a command line */ +extern int execbuf(); /* exec commands from a buffer */ +extern int execfile(); /* exec commands from a file */ +extern int nextbuffer(); /* switch to the next buffer */ #if WORDPRO -extern int killpara(); /* kill the current paragraph */ +extern int killpara(); /* kill the current paragraph */ #endif -extern int setgmode(); /* set a global mode */ -extern int delgmode(); /* delete a global mode */ -extern int insspace(); /* insert a space forword */ -extern int forwhunt(); /* hunt forward for next match */ -extern int backhunt(); /* hunt backwards for next match*/ -extern int pipecmd(); /* pipe command into buffer */ -extern int filter(); /* filter buffer through dos */ -extern int delwind(); /* delete the current window */ -extern int cbuf1(); /* execute numbered comd buffer */ -extern int cbuf2(); -extern int cbuf3(); -extern int cbuf4(); -extern int cbuf5(); -extern int cbuf6(); -extern int cbuf7(); -extern int cbuf8(); -extern int cbuf9(); -extern int cbuf10(); -extern int cbuf11(); -extern int cbuf12(); -extern int cbuf13(); -extern int cbuf14(); -extern int cbuf15(); -extern int cbuf16(); -extern int cbuf17(); -extern int cbuf18(); -extern int cbuf19(); -extern int cbuf20(); -extern int cbuf21(); -extern int cbuf22(); -extern int cbuf23(); -extern int cbuf24(); -extern int cbuf25(); -extern int cbuf26(); -extern int cbuf27(); -extern int cbuf28(); -extern int cbuf29(); -extern int cbuf30(); -extern int cbuf31(); -extern int cbuf32(); -extern int cbuf33(); -extern int cbuf34(); -extern int cbuf35(); -extern int cbuf36(); -extern int cbuf37(); -extern int cbuf38(); -extern int cbuf39(); -extern int cbuf40(); -extern int storemac(); /* store text for macro */ -extern int resize(); /* resize current window */ -extern int clrmes(); /* clear the message line */ -extern int meta(); /* meta prefix dummy function */ -extern int cex(); /* ^X prefix dummy function */ -extern int unarg(); /* ^U repeat arg dummy function */ -extern int istring(); /* insert string in text */ -extern int unmark(); /* unmark current buffer */ +extern int setgmode(); /* set a global mode */ +extern int delgmode(); /* delete a global mode */ +extern int insspace(); /* insert a space forword */ +extern int forwhunt(); /* hunt forward for next match */ +extern int backhunt(); /* hunt backwards for next match */ +extern int pipecmd(); /* pipe command into buffer */ +extern int filter(); /* filter buffer through dos */ +extern int delwind(); /* delete the current window */ +extern int cbuf1(); /* execute numbered comd buffer */ +extern int cbuf2(); +extern int cbuf3(); +extern int cbuf4(); +extern int cbuf5(); +extern int cbuf6(); +extern int cbuf7(); +extern int cbuf8(); +extern int cbuf9(); +extern int cbuf10(); +extern int cbuf11(); +extern int cbuf12(); +extern int cbuf13(); +extern int cbuf14(); +extern int cbuf15(); +extern int cbuf16(); +extern int cbuf17(); +extern int cbuf18(); +extern int cbuf19(); +extern int cbuf20(); +extern int cbuf21(); +extern int cbuf22(); +extern int cbuf23(); +extern int cbuf24(); +extern int cbuf25(); +extern int cbuf26(); +extern int cbuf27(); +extern int cbuf28(); +extern int cbuf29(); +extern int cbuf30(); +extern int cbuf31(); +extern int cbuf32(); +extern int cbuf33(); +extern int cbuf34(); +extern int cbuf35(); +extern int cbuf36(); +extern int cbuf37(); +extern int cbuf38(); +extern int cbuf39(); +extern int cbuf40(); +extern int storemac(); /* store text for macro */ +extern int resize(); /* resize current window */ +extern int clrmes(); /* clear the message line */ +extern int meta(); /* meta prefix dummy function */ +extern int cex(); /* ^X prefix dummy function */ +extern int unarg(); /* ^U repeat arg dummy function */ +extern int istring(); /* insert string in text */ +extern int unmark(); /* unmark current buffer */ #if ISRCH -extern int fisearch(); /* forward incremental search */ -extern int risearch(); /* reverse incremental search */ +extern int fisearch(); /* forward incremental search */ +extern int risearch(); /* reverse incremental search */ #endif #if WORDPRO -extern int wordcount(); /* count words in region */ +extern int wordcount(); /* count words in region */ #endif -extern int savewnd(); /* save current window */ -extern int restwnd(); /* restore current window */ -extern int upscreen(); /* force screen update */ -extern int writemsg(); /* write text on message line */ +extern int savewnd(); /* save current window */ +extern int restwnd(); /* restore current window */ +extern int upscreen(); /* force screen update */ +extern int writemsg(); /* write text on message line */ #if FNLABEL -extern int fnclabel(); /* set function key label */ +extern int fnclabel(); /* set function key label */ #endif #if APROP -extern int apro(); /* apropos fuction */ +extern int apro(); /* apropos fuction */ #endif #if CRYPT -extern int setkey(); /* set encryption key */ +extern int setkey(); /* set encryption key */ #endif -extern int wrapword(); /* wordwrap function */ +extern int wrapword(); /* wordwrap function */ #if CFENCE -extern int getfence(); /* move cursor to a matching fence */ +extern int getfence(); /* move cursor to a matching fence */ #endif -extern int newsize(); /* change the current screen size */ -extern int setvar(); /* set a variables value */ -extern int newwidth(); /* change the current screen width */ +extern int newsize(); /* change the current screen size */ +extern int setvar(); /* set a variables value */ +extern int newwidth(); /* change the current screen width */ #if AEDIT -extern int trim(); /* trim whitespace from end of line */ -extern int detab(); /* detab rest of line */ -extern int entab(); /* entab rest of line */ +extern int trim(); /* trim whitespace from end of line */ +extern int detab(); /* detab rest of line */ +extern int entab(); /* entab rest of line */ #endif #if PROC -extern int storeproc(); /* store names procedure */ -extern int execproc(); /* execute procedure */ +extern int storeproc(); /* store names procedure */ +extern int execproc(); /* execute procedure */ #endif -extern int nullproc(); /* does nothing... */ -extern int ovstring(); /* overwrite a string */ -extern int execprg(); /* execute a program */ +extern int nullproc(); /* does nothing... */ +extern int ovstring(); /* overwrite a string */ +extern int execprg(); /* execute a program */ -extern int cknewwindow(); +extern int cknewwindow(); /* Name to function binding table @@ -217,215 +217,215 @@ extern int cknewwindow(); function. */ -NBIND names[] = { - {"abort-command", ctrlg}, - {"add-mode", setmode}, - {"add-global-mode", setgmode}, +NBIND names[] = { + {"abort-command", ctrlg}, + {"add-mode", setmode}, + {"add-global-mode", setgmode}, #if APROP - {"apropos", apro}, + {"apropos", apro}, #endif - {"backward-character", backchar}, - {"begin-macro", ctlxlp}, - {"beginning-of-file", gotobob}, - {"beginning-of-line", gotobol}, - {"bind-to-key", bindtokey}, - {"buffer-position", showcpos}, - {"case-region-lower", lowerregion}, - {"case-region-upper", upperregion}, - {"case-word-capitalize", capword}, - {"case-word-lower", lowerword}, - {"case-word-upper", upperword}, - {"change-file-name", filename}, - {"change-screen-size", newsize}, - {"change-screen-width", newwidth}, - {"clear-and-redraw", refresh}, - {"clear-message-line", clrmes}, - {"copy-region", copyregion}, + {"backward-character", backchar}, + {"begin-macro", ctlxlp}, + {"beginning-of-file", gotobob}, + {"beginning-of-line", gotobol}, + {"bind-to-key", bindtokey}, + {"buffer-position", showcpos}, + {"case-region-lower", lowerregion}, + {"case-region-upper", upperregion}, + {"case-word-capitalize", capword}, + {"case-word-lower", lowerword}, + {"case-word-upper", upperword}, + {"change-file-name", filename}, + {"change-screen-size", newsize}, + {"change-screen-width", newwidth}, + {"clear-and-redraw", refresh}, + {"clear-message-line", clrmes}, + {"copy-region", copyregion}, #if WORDPRO - {"count-words", wordcount}, + {"count-words", wordcount}, #endif - {"ctlx-prefix", cex}, - {"delete-blank-lines", deblank}, - {"delete-buffer", killbuffer}, - {"delete-mode", delmode}, - {"delete-global-mode", delgmode}, - {"delete-next-character", forwdel}, - {"delete-next-word", delfword}, - {"delete-other-windows", onlywind}, - {"delete-previous-character", backdel}, - {"delete-previous-word", delbword}, - {"delete-window", delwind}, - {"describe-bindings", desbind}, - {"describe-key", deskey}, + {"ctlx-prefix", cex}, + {"delete-blank-lines", deblank}, + {"delete-buffer", killbuffer}, + {"delete-mode", delmode}, + {"delete-global-mode", delgmode}, + {"delete-next-character", forwdel}, + {"delete-next-word", delfword}, + {"delete-other-windows", onlywind}, + {"delete-previous-character", backdel}, + {"delete-previous-word", delbword}, + {"delete-window", delwind}, + {"describe-bindings", desbind}, + {"describe-key", deskey}, #if AEDIT - {"detab-line", detab}, + {"detab-line", detab}, #endif - {"end-macro", ctlxrp}, - {"end-of-file", gotoeob}, - {"end-of-line", gotoeol}, + {"end-macro", ctlxrp}, + {"end-of-file", gotoeob}, + {"end-of-line", gotoeol}, #if AEDIT - {"entab-line", entab}, + {"entab-line", entab}, #endif - {"exchange-point-and-mark", swapmark}, - {"execute-buffer", execbuf}, - {"execute-command-line", execcmd}, - {"execute-file", execfile}, - {"execute-macro", ctlxe}, - {"execute-macro-1", cbuf1}, - {"execute-macro-2", cbuf2}, - {"execute-macro-3", cbuf3}, - {"execute-macro-4", cbuf4}, - {"execute-macro-5", cbuf5}, - {"execute-macro-6", cbuf6}, - {"execute-macro-7", cbuf7}, - {"execute-macro-8", cbuf8}, - {"execute-macro-9", cbuf9}, - {"execute-macro-10", cbuf10}, - {"execute-macro-11", cbuf11}, - {"execute-macro-12", cbuf12}, - {"execute-macro-13", cbuf13}, - {"execute-macro-14", cbuf14}, - {"execute-macro-15", cbuf15}, - {"execute-macro-16", cbuf16}, - {"execute-macro-17", cbuf17}, - {"execute-macro-18", cbuf18}, - {"execute-macro-19", cbuf19}, - {"execute-macro-20", cbuf20}, - {"execute-macro-21", cbuf21}, - {"execute-macro-22", cbuf22}, - {"execute-macro-23", cbuf23}, - {"execute-macro-24", cbuf24}, - {"execute-macro-25", cbuf25}, - {"execute-macro-26", cbuf26}, - {"execute-macro-27", cbuf27}, - {"execute-macro-28", cbuf28}, - {"execute-macro-29", cbuf29}, - {"execute-macro-30", cbuf30}, - {"execute-macro-31", cbuf31}, - {"execute-macro-32", cbuf32}, - {"execute-macro-33", cbuf33}, - {"execute-macro-34", cbuf34}, - {"execute-macro-35", cbuf35}, - {"execute-macro-36", cbuf36}, - {"execute-macro-37", cbuf37}, - {"execute-macro-38", cbuf38}, - {"execute-macro-39", cbuf39}, - {"execute-macro-40", cbuf40}, - {"execute-named-command", namedcmd}, + {"exchange-point-and-mark", swapmark}, + {"execute-buffer", execbuf}, + {"execute-command-line", execcmd}, + {"execute-file", execfile}, + {"execute-macro", ctlxe}, + {"execute-macro-1", cbuf1}, + {"execute-macro-2", cbuf2}, + {"execute-macro-3", cbuf3}, + {"execute-macro-4", cbuf4}, + {"execute-macro-5", cbuf5}, + {"execute-macro-6", cbuf6}, + {"execute-macro-7", cbuf7}, + {"execute-macro-8", cbuf8}, + {"execute-macro-9", cbuf9}, + {"execute-macro-10", cbuf10}, + {"execute-macro-11", cbuf11}, + {"execute-macro-12", cbuf12}, + {"execute-macro-13", cbuf13}, + {"execute-macro-14", cbuf14}, + {"execute-macro-15", cbuf15}, + {"execute-macro-16", cbuf16}, + {"execute-macro-17", cbuf17}, + {"execute-macro-18", cbuf18}, + {"execute-macro-19", cbuf19}, + {"execute-macro-20", cbuf20}, + {"execute-macro-21", cbuf21}, + {"execute-macro-22", cbuf22}, + {"execute-macro-23", cbuf23}, + {"execute-macro-24", cbuf24}, + {"execute-macro-25", cbuf25}, + {"execute-macro-26", cbuf26}, + {"execute-macro-27", cbuf27}, + {"execute-macro-28", cbuf28}, + {"execute-macro-29", cbuf29}, + {"execute-macro-30", cbuf30}, + {"execute-macro-31", cbuf31}, + {"execute-macro-32", cbuf32}, + {"execute-macro-33", cbuf33}, + {"execute-macro-34", cbuf34}, + {"execute-macro-35", cbuf35}, + {"execute-macro-36", cbuf36}, + {"execute-macro-37", cbuf37}, + {"execute-macro-38", cbuf38}, + {"execute-macro-39", cbuf39}, + {"execute-macro-40", cbuf40}, + {"execute-named-command", namedcmd}, #if PROC - {"execute-procedure", execproc}, + {"execute-procedure", execproc}, #endif - {"execute-program", execprg}, - {"exit-emacs", quit}, + {"execute-program", execprg}, + {"exit-emacs", quit}, #if WORDPRO - {"fill-paragraph", fillpara}, + {"fill-paragraph", fillpara}, #endif - {"filter-buffer", filter}, - {"find-file", filefind}, - {"forward-character", forwchar}, - {"goto-line", gotoline}, + {"filter-buffer", filter}, + {"find-file", filefind}, + {"forward-character", forwchar}, + {"goto-line", gotoline}, #if CFENCE - {"goto-matching-fence", getfence}, + {"goto-matching-fence", getfence}, #endif - {"grow-window", enlargewind}, - {"handle-tab", tab}, - {"hunt-forward", forwhunt}, - {"hunt-backward", backhunt}, - {"help", help}, - {"i-shell", spawncli}, + {"grow-window", enlargewind}, + {"handle-tab", tab}, + {"hunt-forward", forwhunt}, + {"hunt-backward", backhunt}, + {"help", help}, + {"i-shell", spawncli}, #if ISRCH - {"incremental-search", fisearch}, + {"incremental-search", fisearch}, #endif - {"insert-file", insfile}, - {"insert-space", insspace}, - {"insert-string", istring}, + {"insert-file", insfile}, + {"insert-space", insspace}, + {"insert-string", istring}, #if WORDPRO #if PKCODE - {"justify-paragraph", justpara}, + {"justify-paragraph", justpara}, #endif - {"kill-paragraph", killpara}, + {"kill-paragraph", killpara}, #endif - {"kill-region", killregion}, - {"kill-to-end-of-line", killtext}, + {"kill-region", killregion}, + {"kill-to-end-of-line", killtext}, #if FNLABEL - {"label-function-key", fnclabel}, + {"label-function-key", fnclabel}, #endif - {"list-buffers", listbuffers}, - {"meta-prefix", meta}, - {"move-window-down", mvdnwind}, - {"move-window-up", mvupwind}, - {"name-buffer", namebuffer}, - {"newline", newline}, - {"newline-and-indent", indent}, - {"next-buffer", nextbuffer}, - {"next-line", forwline}, - {"next-page", forwpage}, + {"list-buffers", listbuffers}, + {"meta-prefix", meta}, + {"move-window-down", mvdnwind}, + {"move-window-up", mvupwind}, + {"name-buffer", namebuffer}, + {"newline", newline}, + {"newline-and-indent", indent}, + {"next-buffer", nextbuffer}, + {"next-line", forwline}, + {"next-page", forwpage}, #if WORDPRO - {"next-paragraph", gotoeop}, + {"next-paragraph", gotoeop}, #endif - {"next-window", nextwind}, - {"next-word", forwword}, - {"nop", nullproc}, - {"open-line", openline}, - {"overwrite-string", ovstring}, - {"pipe-command", pipecmd}, - {"previous-line", backline}, - {"previous-page", backpage}, + {"next-window", nextwind}, + {"next-word", forwword}, + {"nop", nullproc}, + {"open-line", openline}, + {"overwrite-string", ovstring}, + {"pipe-command", pipecmd}, + {"previous-line", backline}, + {"previous-page", backpage}, #if WORDPRO - {"previous-paragraph", gotobop}, + {"previous-paragraph", gotobop}, #endif - {"previous-window", prevwind}, - {"previous-word", backword}, - {"query-replace-string", qreplace}, - {"quick-exit", quickexit}, - {"quote-character", quote}, - {"read-file", fileread}, - {"redraw-display", reposition}, - {"resize-window", resize}, - {"restore-window", restwnd}, - {"replace-string", sreplace}, + {"previous-window", prevwind}, + {"previous-word", backword}, + {"query-replace-string", qreplace}, + {"quick-exit", quickexit}, + {"quote-character", quote}, + {"read-file", fileread}, + {"redraw-display", reposition}, + {"resize-window", resize}, + {"restore-window", restwnd}, + {"replace-string", sreplace}, #if ISRCH - {"reverse-incremental-search", risearch}, + {"reverse-incremental-search", risearch}, #endif #if PROC - {"run", execproc}, + {"run", execproc}, #endif - {"save-file", filesave}, - {"save-window", savewnd}, - {"scroll-next-up", scrnextup}, - {"scroll-next-down", scrnextdw}, - {"search-forward", forwsearch}, - {"search-reverse", backsearch}, - {"select-buffer", usebuffer}, - {"set", setvar}, + {"save-file", filesave}, + {"save-window", savewnd}, + {"scroll-next-up", scrnextup}, + {"scroll-next-down", scrnextdw}, + {"search-forward", forwsearch}, + {"search-reverse", backsearch}, + {"select-buffer", usebuffer}, + {"set", setvar}, #if CRYPT - {"set-encryption-key", setkey}, + {"set-encryption-key", setkey}, #endif - {"set-fill-column", setfillcol}, - {"set-mark", setmark}, - {"shell-command", spawn}, - {"shrink-window", shrinkwind}, - {"split-current-window", splitwind}, - {"store-macro", storemac}, + {"set-fill-column", setfillcol}, + {"set-mark", setmark}, + {"shell-command", spawn}, + {"shrink-window", shrinkwind}, + {"split-current-window", splitwind}, + {"store-macro", storemac}, #if PROC - {"store-procedure", storeproc}, + {"store-procedure", storeproc}, #endif #if BSD | __hpux | SVR4 - {"suspend-emacs", bktoshell}, + {"suspend-emacs", bktoshell}, #endif - {"transpose-characters", twiddle}, + {"transpose-characters", twiddle}, #if AEDIT - {"trim-line", trim}, + {"trim-line", trim}, #endif - {"unbind-key", unbindkey}, - {"universal-argument", unarg}, - {"unmark-buffer", unmark}, - {"update-screen", upscreen}, - {"view-file", viewfile}, - {"wrap-word", wrapword}, - {"write-file", filewrite}, - {"write-message", writemsg}, - {"yank", yank}, + {"unbind-key", unbindkey}, + {"universal-argument", unarg}, + {"unmark-buffer", unmark}, + {"update-screen", upscreen}, + {"view-file", viewfile}, + {"wrap-word", wrapword}, + {"write-file", filewrite}, + {"write-message", writemsg}, + {"yank", yank}, - {"", NULL} + {"", NULL} }; diff --git a/epath.h b/epath.h index fe1d57a..5a3705a 100644 --- a/epath.h +++ b/epath.h @@ -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 *)) diff --git a/estruct.h b/estruct.h index 1e6d6ec..19451c7 100644 --- a/estruct.h +++ b/estruct.h @@ -41,14 +41,14 @@ /* make an intelligent guess about the target system */ #if defined(__TURBOC__) -#define MSDOS 1 /* MS/PC DOS 3.1-4.0 with Turbo C 2.0 */ +#define MSDOS 1 /* MS/PC DOS 3.1-4.0 with Turbo C 2.0 */ #else #define MSDOS 0 #endif #if defined(BSD) || defined(sun) || defined(ultrix) || (defined(vax) && defined(unix)) || defined(ultrix) || defined(__osf__) #ifndef BSD -#define BSD 1 /* Berkeley UNIX */ +#define BSD 1 /* Berkeley UNIX */ #endif #else #define BSD 0 @@ -61,35 +61,35 @@ #endif #if defined(SYSV) || defined(u3b2) || defined(_AIX) || (defined(i386) && defined(unix)) || defined(__hpux) -#define USG 1 /* System V UNIX */ +#define USG 1 /* System V UNIX */ #else #define USG 0 #endif #if defined(VMS) || (defined(vax) && ! defined(unix)) -#define VMS 1 /* VAX/VMS */ +#define VMS 1 /* VAX/VMS */ #else #define VMS 0 #endif -#define V7 0 /* no more */ +#define V7 0 /* no more */ #else -#define MSDOS 1 /* MS-DOS */ -#define V7 0 /* V7 UNIX or Coherent or BSD4.2*/ -#define BSD 0 /* UNIX BSD 4.2 and ULTRIX */ -#define USG 0 /* UNIX system V */ -#define VMS 0 /* VAX/VMS */ +#define MSDOS 1 /* MS-DOS */ +#define V7 0 /* V7 UNIX or Coherent or BSD4.2 */ +#define BSD 0 /* UNIX BSD 4.2 and ULTRIX */ +#define USG 0 /* UNIX system V */ +#define VMS 0 /* VAX/VMS */ -#endif /*autoconf */ +#endif /*autoconf */ #ifndef AUTOCONF /* Compiler definitions */ -#define UNIX 0 /* a random UNIX compiler */ -#define MSC 0 /* MicroSoft C compiler, versions 3 up */ -#define TURBO 1 /* Turbo C/MSDOS */ +#define UNIX 0 /* a random UNIX compiler */ +#define MSC 0 /* MicroSoft C compiler, versions 3 up */ +#define TURBO 1 /* Turbo C/MSDOS */ #else @@ -97,27 +97,27 @@ #define MSC 0 #define TURBO MSDOS -#endif /*autoconf */ +#endif /*autoconf */ /* Debugging options */ -#define RAMSIZE 0 /* dynamic RAM memory usage tracking */ -#define RAMSHOW 0 /* auto dynamic RAM reporting */ +#define RAMSIZE 0 /* dynamic RAM memory usage tracking */ +#define RAMSHOW 0 /* auto dynamic RAM reporting */ #ifndef AUTOCONF /* Special keyboard definitions */ -#define VT220 0 /* Use keypad escapes P.K. */ -#define VT100 0 /* Handle VT100 style keypad. */ +#define VT220 0 /* Use keypad escapes P.K. */ +#define VT100 0 /* Handle VT100 style keypad. */ /* Terminal Output definitions */ -#define ANSI 0 /* ANSI escape sequences */ -#define VMSVT 0 /* various VMS terminal entries */ -#define VT52 0 /* VT52 terminal (Zenith). */ -#define TERMCAP 0 /* Use TERMCAP */ -#define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */ +#define ANSI 0 /* ANSI escape sequences */ +#define VMSVT 0 /* various VMS terminal entries */ +#define VT52 0 /* VT52 terminal (Zenith). */ +#define TERMCAP 0 /* Use TERMCAP */ +#define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */ #else @@ -130,25 +130,25 @@ #define TERMCAP UNIX #define IBMPC MSDOS -#endif /*autoconf */ +#endif /*autoconf */ /* Configuration options */ -#define CVMVAS 1 /* arguments to page forward/back in pages */ -#define CLRMSG 0 /* space clears the message line with no insert */ -#define CFENCE 1 /* fench matching in CMODE */ -#define TYPEAH 1 /* type ahead causes update to be skipped */ -#define DEBUGM 1 /* $debug triggers macro debugging */ -#define VISMAC 0 /* update display during keyboard macros */ -#define CTRLZ 0 /* add a ^Z at end of files under MSDOS only */ -#define ADDCR 0 /* ajout d'un CR en fin de chaque ligne (ST520) */ -#define NBRACE 1 /* new style brace matching command */ -#define REVSTA 1 /* Status line appears in reverse video */ +#define CVMVAS 1 /* arguments to page forward/back in pages */ +#define CLRMSG 0 /* space clears the message line with no insert */ +#define CFENCE 1 /* fench matching in CMODE */ +#define TYPEAH 1 /* type ahead causes update to be skipped */ +#define DEBUGM 1 /* $debug triggers macro debugging */ +#define VISMAC 0 /* update display during keyboard macros */ +#define CTRLZ 0 /* add a ^Z at end of files under MSDOS only */ +#define ADDCR 0 /* ajout d'un CR en fin de chaque ligne (ST520) */ +#define NBRACE 1 /* new style brace matching command */ +#define REVSTA 1 /* Status line appears in reverse video */ #ifndef AUTOCONF -#define COLOR 1 /* color commands and windows */ -#define FILOCK 0 /* file locking under unix BSD 4.2 */ +#define COLOR 1 /* color commands and windows */ +#define FILOCK 0 /* file locking under unix BSD 4.2 */ #else @@ -159,37 +159,37 @@ #define FILOCK BSD #endif -#endif /* autoconf */ +#endif /* autoconf */ -#define ISRCH 1 /* Incremental searches like ITS EMACS */ -#define WORDPRO 1 /* Advanced word processing features */ -#define FNLABEL 0 /* function key label code [HP150] */ -#define APROP 1 /* Add code for Apropos command */ -#define CRYPT 1 /* file encryption enabled? */ -#define MAGIC 1 /* include regular expression matching? */ -#define AEDIT 1 /* advanced editing options: en/detabbing */ -#define PROC 1 /* named procedures */ -#define CLEAN 0 /* de-alloc memory on exit */ -#define CALLED 0 /* is emacs a called subroutine? or stand alone */ +#define ISRCH 1 /* Incremental searches like ITS EMACS */ +#define WORDPRO 1 /* Advanced word processing features */ +#define FNLABEL 0 /* function key label code [HP150] */ +#define APROP 1 /* Add code for Apropos command */ +#define CRYPT 1 /* file encryption enabled? */ +#define MAGIC 1 /* include regular expression matching? */ +#define AEDIT 1 /* advanced editing options: en/detabbing */ +#define PROC 1 /* named procedures */ +#define CLEAN 0 /* de-alloc memory on exit */ +#define CALLED 0 /* is emacs a called subroutine? or stand alone */ -#define ASCII 1 /* always using ASCII char sequences for now */ -#define EBCDIC 0 /* later IBM mainfraim versions will use EBCDIC */ +#define ASCII 1 /* always using ASCII char sequences for now */ +#define EBCDIC 0 /* later IBM mainfraim versions will use EBCDIC */ #ifndef AUTOCONF -#define XONXOFF 0 /* don't disable XON-XOFF flow control P.K. */ -#define NATIONL 0 /* interprete [,],\,{,},| as characters P.K. */ +#define XONXOFF 0 /* don't disable XON-XOFF flow control P.K. */ +#define NATIONL 0 /* interprete [,],\,{,},| as characters P.K. */ #else #define XONXOFF (UNIX | VMS) #define NATIONL (UNIX | VMS) -#endif /* autoconf */ +#endif /* autoconf */ -#define PKCODE 1 /* include my extensions P.K., define always */ -#define IBMCHR MSDOS /* use IBM PC character set P.K. */ -#define SCROLLCODE 1 /* scrolling code P.K. */ +#define PKCODE 1 /* include my extensions P.K., define always */ +#define IBMCHR MSDOS /* use IBM PC character set P.K. */ +#define SCROLLCODE 1 /* scrolling code P.K. */ /* System dependant library redefinitions, structures and includes */ @@ -240,24 +240,24 @@ /* internal constants */ -#define NBINDS 256 /* max # of bound keys */ -#define NFILEN 80 /* # of bytes, file name */ -#define NBUFN 16 /* # of bytes, buffer name */ -#define NLINE 256 /* # of bytes, input line */ -#define NSTRING 128 /* # of bytes, string buffers */ -#define NKBDM 256 /* # of strokes, keyboard macro */ -#define NPAT 128 /* # of bytes, pattern */ -#define HUGE 1000 /* Huge number */ -#define NLOCKS 100 /* max # of file locks active */ -#define NCOLORS 8 /* number of supported colors */ -#define KBLOCK 250 /* sizeof kill buffer chunks */ -#define NBLOCK 16 /* line block chunk size */ -#define NVSIZE 10 /* max #chars in a var name */ +#define NBINDS 256 /* max # of bound keys */ +#define NFILEN 80 /* # of bytes, file name */ +#define NBUFN 16 /* # of bytes, buffer name */ +#define NLINE 256 /* # of bytes, input line */ +#define NSTRING 128 /* # of bytes, string buffers */ +#define NKBDM 256 /* # of strokes, keyboard macro */ +#define NPAT 128 /* # of bytes, pattern */ +#define HUGE 1000 /* Huge number */ +#define NLOCKS 100 /* max # of file locks active */ +#define NCOLORS 8 /* number of supported colors */ +#define KBLOCK 250 /* sizeof kill buffer chunks */ +#define NBLOCK 16 /* line block chunk size */ +#define NVSIZE 10 /* max #chars in a var name */ -#define CONTROL 0x0100 /* Control flag, or'ed in */ -#define META 0x0200 /* Meta flag, or'ed in */ -#define CTLX 0x0400 /* ^X flag, or'ed in */ -#define SPEC 0x0800 /* special key (function keys) */ +#define CONTROL 0x0100 /* Control flag, or'ed in */ +#define META 0x0200 /* Meta flag, or'ed in */ +#define CTLX 0x0400 /* ^X flag, or'ed in */ +#define SPEC 0x0800 /* special key (function keys) */ #if PKCODE #define MAXNLINE 10000000 /* max lines from one file */ @@ -270,14 +270,14 @@ #undef TRUE #endif -#define FALSE 0 /* False, no, bad, etc. */ -#define TRUE 1 /* True, yes, good, etc. */ -#define ABORT 2 /* Death, ^G, abort, etc. */ -#define FAILED 3 /* not-quite fatal false return */ +#define FALSE 0 /* False, no, bad, etc. */ +#define TRUE 1 /* True, yes, good, etc. */ +#define ABORT 2 /* Death, ^G, abort, etc. */ +#define FAILED 3 /* not-quite fatal false return */ -#define STOP 0 /* keyboard macro not in use */ -#define PLAY 1 /* playing */ -#define RECORD 2 /* recording */ +#define STOP 0 /* keyboard macro not in use */ +#define PLAY 1 /* playing */ +#define RECORD 2 /* recording */ /* Directive definitions */ @@ -298,23 +298,23 @@ * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for * the scan routines. */ -#define PTBEG 0 /* Leave the point at the beginning on search */ -#define PTEND 1 /* Leave the point at the end on search */ -#define FORWARD 0 /* forward direction */ -#define REVERSE 1 /* backwards direction */ +#define PTBEG 0 /* Leave the point at the beginning on search */ +#define PTEND 1 /* Leave the point at the end on search */ +#define FORWARD 0 /* forward direction */ +#define REVERSE 1 /* backwards direction */ -#define FIOSUC 0 /* File I/O, success. */ -#define FIOFNF 1 /* File I/O, file not found. */ -#define FIOEOF 2 /* File I/O, end of file. */ -#define FIOERR 3 /* File I/O, error. */ -#define FIOMEM 4 /* File I/O, out of memory */ -#define FIOFUN 5 /* File I/O, eod of file/bad line*/ +#define FIOSUC 0 /* File I/O, success. */ +#define FIOFNF 1 /* File I/O, file not found. */ +#define FIOEOF 2 /* File I/O, end of file. */ +#define FIOERR 3 /* File I/O, error. */ +#define FIOMEM 4 /* File I/O, out of memory */ +#define FIOFUN 5 /* File I/O, eod of file/bad line */ -#define CFCPCN 0x0001 /* Last command was C-P, C-N */ -#define CFKILL 0x0002 /* Last command was a kill */ +#define CFCPCN 0x0001 /* Last command was C-P, C-N */ +#define CFKILL 0x0002 /* Last command was a kill */ -#define BELL 0x07 /* a bell character */ -#define TAB 0x09 /* a tab character */ +#define BELL 0x07 /* a bell character */ +#define TAB 0x09 /* a tab character */ #if V7 | USG | BSD #define PATHCHR ':' @@ -326,17 +326,17 @@ /* Macro argument token types */ -#define TKNUL 0 /* end-of-string */ -#define TKARG 1 /* interactive argument */ -#define TKBUF 2 /* buffer argument */ -#define TKVAR 3 /* user variables */ -#define TKENV 4 /* environment variables */ -#define TKFUN 5 /* function.... */ -#define TKDIR 6 /* directive */ -#define TKLBL 7 /* line label */ -#define TKLIT 8 /* numeric literal */ -#define TKSTR 9 /* quoted string literal */ -#define TKCMD 10 /* command name */ +#define TKNUL 0 /* end-of-string */ +#define TKARG 1 /* interactive argument */ +#define TKBUF 2 /* buffer argument */ +#define TKVAR 3 /* user variables */ +#define TKENV 4 /* environment variables */ +#define TKFUN 5 /* function.... */ +#define TKDIR 6 /* directive */ +#define TKLBL 7 /* line label */ +#define TKLIT 8 /* numeric literal */ +#define TKSTR 9 /* quoted string literal */ +#define TKCMD 10 /* command name */ /* Internal defined functions */ @@ -428,34 +428,34 @@ * the full blown redisplay is just too expensive to run for every input * character. */ -typedef struct WINDOW { - struct WINDOW *w_wndp; /* Next window */ - struct BUFFER *w_bufp; /* Buffer displayed in window */ - struct LINE *w_linep; /* Top line in the window */ - struct LINE *w_dotp; /* Line containing "." */ - short w_doto; /* Byte offset for "." */ - struct LINE *w_markp; /* Line containing "mark" */ - short w_marko; /* Byte offset for "mark" */ - char w_toprow; /* Origin 0 top row of window */ - char w_ntrows; /* # of rows of text in window */ - char w_force; /* If NZ, forcing row. */ - char w_flag; /* Flags. */ +typedef struct WINDOW { + struct WINDOW *w_wndp; /* Next window */ + struct BUFFER *w_bufp; /* Buffer displayed in window */ + struct LINE *w_linep; /* Top line in the window */ + struct LINE *w_dotp; /* Line containing "." */ + short w_doto; /* Byte offset for "." */ + struct LINE *w_markp; /* Line containing "mark" */ + short w_marko; /* Byte offset for "mark" */ + char w_toprow; /* Origin 0 top row of window */ + char w_ntrows; /* # of rows of text in window */ + char w_force; /* If NZ, forcing row. */ + char w_flag; /* Flags. */ #if COLOR - char w_fcolor; /* current forground color */ - char w_bcolor; /* current background color */ + char w_fcolor; /* current forground color */ + char w_bcolor; /* current background color */ #endif -} WINDOW; +} WINDOW; -#define WFFORCE 0x01 /* Window needs forced reframe */ -#define WFMOVE 0x02 /* Movement from line to line */ -#define WFEDIT 0x04 /* Editing within a line */ -#define WFHARD 0x08 /* Better to a full display */ -#define WFMODE 0x10 /* Update mode line. */ -#define WFCOLR 0x20 /* Needs a color change */ +#define WFFORCE 0x01 /* Window needs forced reframe */ +#define WFMOVE 0x02 /* Movement from line to line */ +#define WFEDIT 0x04 /* Editing within a line */ +#define WFHARD 0x08 /* Better to a full display */ +#define WFMODE 0x10 /* Update mode line. */ +#define WFCOLR 0x20 /* Needs a color change */ #if SCROLLCODE -#define WFKILLS 0x40 /* something was deleted */ -#define WFINS 0x80 /* something was inserted */ +#define WFKILLS 0x40 /* something was deleted */ +#define WFINS 0x80 /* something was inserted */ #endif @@ -470,50 +470,50 @@ typedef struct WINDOW { * Buffers may be "Inactive" which means the files associated with them * have not been read in yet. These get read in at "use buffer" time. */ -typedef struct BUFFER { - struct BUFFER *b_bufp; /* Link to next BUFFER */ - struct LINE *b_dotp; /* Link to "." LINE structure */ - short b_doto; /* Offset of "." in above LINE */ - struct LINE *b_markp; /* The same as the above two, */ - short b_marko; /* but for the "mark" */ - struct LINE *b_linep; /* Link to the header LINE */ - char b_active; /* window activated flag */ - char b_nwnd; /* Count of windows on buffer */ - char b_flag; /* Flags */ - int b_mode; /* editor mode of this buffer */ - char b_fname[NFILEN]; /* File name */ - char b_bname[NBUFN]; /* Buffer name */ +typedef struct BUFFER { + struct BUFFER *b_bufp; /* Link to next BUFFER */ + struct LINE *b_dotp; /* Link to "." LINE structure */ + short b_doto; /* Offset of "." in above LINE */ + struct LINE *b_markp; /* The same as the above two, */ + short b_marko; /* but for the "mark" */ + struct LINE *b_linep; /* Link to the header LINE */ + char b_active; /* window activated flag */ + char b_nwnd; /* Count of windows on buffer */ + char b_flag; /* Flags */ + int b_mode; /* editor mode of this buffer */ + char b_fname[NFILEN]; /* File name */ + char b_bname[NBUFN]; /* Buffer name */ #if CRYPT - char b_key[NPAT]; /* current encrypted key */ + char b_key[NPAT]; /* current encrypted key */ #endif -} BUFFER; +} BUFFER; -#define BFINVS 0x01 /* Internal invisable buffer */ -#define BFCHG 0x02 /* Changed since last write */ -#define BFTRUNC 0x04 /* buffer was truncated when read */ +#define BFINVS 0x01 /* Internal invisable buffer */ +#define BFCHG 0x02 /* Changed since last write */ +#define BFTRUNC 0x04 /* buffer was truncated when read */ /* mode flags */ -#define NUMMODES 9 /* # of defined modes */ +#define NUMMODES 9 /* # of defined modes */ -#define MDWRAP 0x0001 /* word wrap */ -#define MDCMOD 0x0002 /* C indentation and fence match*/ -#define MDSPELL 0x0004 /* spell error parcing */ -#define MDEXACT 0x0008 /* Exact matching for searches */ -#define MDVIEW 0x0010 /* read-only buffer */ -#define MDOVER 0x0020 /* overwrite mode */ -#define MDMAGIC 0x0040 /* regular expresions in search */ -#define MDCRYPT 0x0080 /* encrytion mode active */ -#define MDASAVE 0x0100 /* auto-save mode */ +#define MDWRAP 0x0001 /* word wrap */ +#define MDCMOD 0x0002 /* C indentation and fence match */ +#define MDSPELL 0x0004 /* spell error parcing */ +#define MDEXACT 0x0008 /* Exact matching for searches */ +#define MDVIEW 0x0010 /* read-only buffer */ +#define MDOVER 0x0020 /* overwrite mode */ +#define MDMAGIC 0x0040 /* regular expresions in search */ +#define MDCRYPT 0x0080 /* encrytion mode active */ +#define MDASAVE 0x0100 /* auto-save mode */ /* * The starting position of a region, and the size of the region in * characters, is kept in a region structure. Used by the region commands. */ -typedef struct { - struct LINE *r_linep; /* Origin LINE address. */ - short r_offset; /* Origin LINE offset. */ - long r_size; /* Length in characters. */ -} REGION; +typedef struct { + struct LINE *r_linep; /* Origin LINE address. */ + short r_offset; /* Origin LINE offset. */ + long r_size; /* Length in characters. */ +} REGION; /* * All text is kept in circularly linked lists of "LINE" structures. These @@ -523,13 +523,13 @@ typedef struct { * and the text. The end of line is not stored as a byte; it's implied. Future * additions will include update hints, and a list of marks into the line. */ -typedef struct LINE { - struct LINE *l_fp; /* Link to the next line */ - struct LINE *l_bp; /* Link to the previous line */ - short l_size; /* Allocated size */ - short l_used; /* Used size */ - char l_text[1]; /* A bunch of characters. */ -} LINE; +typedef struct LINE { + struct LINE *l_fp; /* Link to the next line */ + struct LINE *l_bp; /* Link to the previous line */ + short l_size; /* Allocated size */ + short l_used; /* Used size */ + char l_text[1]; /* A bunch of characters. */ +} LINE; #define lforw(lp) ((lp)->l_fp) #define lback(lp) ((lp)->l_bp) @@ -546,35 +546,35 @@ typedef struct LINE { * "termp->t_field" style in the future, to make it possible to run more than * one terminal type. */ -typedef struct { - short t_mrow; /* max number of rows allowable */ - short t_nrow; /* current number of rows used */ - short t_mcol; /* max Number of columns. */ - short t_ncol; /* current Number of columns. */ - short t_margin; /* min margin for extended lines*/ - short t_scrsiz; /* size of scroll region " */ - int t_pause; /* # times thru update to pause */ - int (*t_open)(); /* Open terminal at the start. */ - int (*t_close)(); /* Close terminal at end. */ - int (*t_kopen)(); /* Open keyboard */ - int (*t_kclose)(); /* close keyboard */ - int (*t_getchar)(); /* Get character from keyboard. */ - int (*t_putchar)(); /* Put character to display. */ - int (*t_flush)(); /* Flush output buffers. */ - int (*t_move)(); /* Move the cursor, origin 0. */ - int (*t_eeol)(); /* Erase to end of line. */ - int (*t_eeop)(); /* Erase to end of page. */ - int (*t_beep)(); /* Beep. */ - int (*t_rev)(); /* set reverse video state */ - int (*t_rez)(); /* change screen resolution */ +typedef struct { + short t_mrow; /* max number of rows allowable */ + short t_nrow; /* current number of rows used */ + short t_mcol; /* max Number of columns. */ + short t_ncol; /* current Number of columns. */ + short t_margin; /* min margin for extended lines */ + short t_scrsiz; /* size of scroll region " */ + int t_pause; /* # times thru update to pause */ + int (*t_open) (); /* Open terminal at the start. */ + int (*t_close) (); /* Close terminal at end. */ + int (*t_kopen) (); /* Open keyboard */ + int (*t_kclose) (); /* close keyboard */ + int (*t_getchar) (); /* Get character from keyboard. */ + int (*t_putchar) (); /* Put character to display. */ + int (*t_flush) (); /* Flush output buffers. */ + int (*t_move) (); /* Move the cursor, origin 0. */ + int (*t_eeol) (); /* Erase to end of line. */ + int (*t_eeop) (); /* Erase to end of page. */ + int (*t_beep) (); /* Beep. */ + int (*t_rev) (); /* set reverse video state */ + int (*t_rez) (); /* change screen resolution */ #if COLOR - int (*t_setfor)(); /* set forground color */ - int (*t_setback)(); /* set background color */ + int (*t_setfor) (); /* set forground color */ + int (*t_setback) (); /* set background color */ #endif -#if SCROLLCODE - int (*t_scroll)(); /* scroll a region of the screen */ +#if SCROLLCODE + int (*t_scroll) (); /* scroll a region of the screen */ #endif -} TERM; +} TERM; /* TEMPORARY macros for terminal I/O (to be placed in a machine dependant place later) */ @@ -599,17 +599,17 @@ typedef struct { /* structure for the table of initial key bindings */ -typedef struct { - short k_code; /* Key code */ - int (*k_fp)(); /* Routine to handle it */ -} KEYTAB; +typedef struct { + short k_code; /* Key code */ + int (*k_fp) (); /* Routine to handle it */ +} KEYTAB; /* structure for the name binding table */ typedef struct { char *n_name; /* name of function key */ - int (*n_func)(); /* function name is bound to */ -} NBIND; + int (*n_func) (); /* function name is bound to */ +} NBIND; /* The editor holds deleted text chunks in the KILL buffer. The kill buffer is logically a stream of ascii characters, however @@ -618,7 +618,7 @@ typedef struct { was taken up by the keycode structure) */ -typedef struct KILL { +typedef struct KILL { struct KILL *d_next; /* link to next chunk, NULL if last */ char d_chunk[KBLOCK]; /* deleted text */ } KILL; @@ -630,8 +630,8 @@ typedef struct KILL { */ typedef struct VDESC { - int v_type; /* type of variable */ - int v_num; /* ordinal pointer to variable in list */ + int v_type; /* type of variable */ + int v_num; /* ordinal pointer to variable in list */ } VDESC; /* The !WHILE directive in the execution language needs to @@ -642,7 +642,7 @@ typedef struct VDESC { typedef struct WHBLOCK { LINE *w_begin; /* ptr to !while statement */ - LINE *w_end; /* ptr to the !endwhile statement*/ + LINE *w_end; /* ptr to the !endwhile statement */ int w_type; /* block type */ struct WHBLOCK *w_next; /* next while */ } WHBLOCK; @@ -678,30 +678,30 @@ typedef struct WHBLOCK { * Defines for the metacharacters in the regular expression * search routines. */ -#define MCNIL 0 /* Like the '\0' for strings.*/ -#define LITCHAR 1 /* Literal character, or string.*/ +#define MCNIL 0 /* Like the '\0' for strings. */ +#define LITCHAR 1 /* Literal character, or string. */ #define ANY 2 #define CCL 3 #define NCCL 4 #define BOL 5 #define EOL 6 #define DITTO 7 -#define CLOSURE 256 /* An or-able value.*/ +#define CLOSURE 256 /* An or-able value. */ #define MASKCL CLOSURE - 1 -#define MC_ANY '.' /* 'Any' character (except newline).*/ -#define MC_CCL '[' /* Character class.*/ -#define MC_NCCL '^' /* Negate character class.*/ -#define MC_RCCL '-' /* Range in character class.*/ -#define MC_ECCL ']' /* End of character class.*/ -#define MC_BOL '^' /* Beginning of line.*/ -#define MC_EOL '$' /* End of line.*/ -#define MC_CLOSURE '*' /* Closure - does not extend past newline.*/ -#define MC_DITTO '&' /* Use matched string in replacement.*/ -#define MC_ESC '\\' /* Escape - suppress meta-meaning.*/ +#define MC_ANY '.' /* 'Any' character (except newline). */ +#define MC_CCL '[' /* Character class. */ +#define MC_NCCL '^' /* Negate character class. */ +#define MC_RCCL '-' /* Range in character class. */ +#define MC_ECCL ']' /* End of character class. */ +#define MC_BOL '^' /* Beginning of line. */ +#define MC_EOL '$' /* End of line. */ +#define MC_CLOSURE '*' /* Closure - does not extend past newline. */ +#define MC_DITTO '&' /* Use matched string in replacement. */ +#define MC_ESC '\\' /* Escape - suppress meta-meaning. */ -#define BIT(n) (1 << (n)) /* An integer with one bit set.*/ -#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter.*/ +#define BIT(n) (1 << (n)) /* An integer with one bit set. */ +#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */ /* HICHAR - 1 is the largest character we will deal with. * HIBYTE represents the number of bytes in the bitmap. @@ -713,19 +713,18 @@ typedef struct WHBLOCK { * the meta-character structure for MAGIC mode searching (MC), * and the meta-character structure for MAGIC mode replacment (RMC). */ -typedef char *BITMAP; +typedef char *BITMAP; -typedef struct { - short int mc_type; +typedef struct { + short int mc_type; union { - int lchar; - BITMAP cclmap; + int lchar; + BITMAP cclmap; } u; } MC; -typedef struct { - short int mc_type; - char *rstr; +typedef struct { + short int mc_type; + char *rstr; } RMC; #endif - diff --git a/eval.c b/eval.c index 496b5aa..a5793b7 100644 --- a/eval.c +++ b/eval.c @@ -11,126 +11,162 @@ #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++) + for (i = 0; i < MAXVARS; i++) uv[i].u_name[0] = 0; } -char *gtfun(fname) /* evaluate a function */ - -char *fname; /* name of function to evaluate */ +char *gtfun(fname) + /* evaluate a function */ +char *fname; /* name of function to evaluate */ { - register int fnum; /* index to function to eval */ - register int status; /* return status */ - register char *tsp; /* temporary string pointer */ - char arg1[NSTRING]; /* value of first argument */ - char arg2[NSTRING]; /* value of second argument */ - char arg3[NSTRING]; /* value of third argument */ + register int fnum; /* index to function to eval */ + register int status; /* return status */ + register char *tsp; /* temporary string pointer */ + char arg1[NSTRING]; /* value of first argument */ + char arg2[NSTRING]; /* value of second argument */ + char arg3[NSTRING]; /* value of third argument */ static char result[2 * NSTRING]; /* string result */ - char *flook(); /* look file up on path */ - char *xlat(); /* translate a char string */ + char *flook(); /* look file up on path */ + char *xlat(); /* translate a char string */ #if ENVFUNC - char *getenv(); /* get environment string */ + char *getenv(); /* get environment string */ #endif /* look the function up in the function table */ - fname[3] = 0; /* only first 3 chars significant */ - mklower(fname); /* and let it be upper or lower case */ + fname[3] = 0; /* only first 3 chars significant */ + mklower(fname); /* and let it be upper or lower case */ for (fnum = 0; fnum < NFUNCS; fnum++) if (strcmp(fname, funcs[fnum].f_name) == 0) break; /* return errorm on a bad reference */ if (fnum == NFUNCS) - return(errorm); + return (errorm); /* if needed, retrieve the first argument */ if (funcs[fnum].f_type >= MONAMIC) { if ((status = macarg(arg1)) != TRUE) - return(errorm); + return (errorm); /* if needed, retrieve the second argument */ if (funcs[fnum].f_type >= DYNAMIC) { if ((status = macarg(arg2)) != TRUE) - return(errorm); - + return (errorm); + /* if needed, retrieve the third argument */ if (funcs[fnum].f_type >= TRINAMIC) if ((status = macarg(arg3)) != TRUE) - return(errorm); + return (errorm); } } - + /* 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); - return(strcat(result, arg2)); - 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], - 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); - result[1] = 0; - return(result); - 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 UFENV: + 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, + &arg1[(strlen(arg1) - atoi(arg2))])); + 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); + result[1] = 0; + return (result); + 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 UFENV: #if ENVFUNC - tsp = getenv(arg1); - return(tsp == NULL ? "" : tsp); + tsp = getenv(arg1); + return (tsp == NULL ? "" : tsp); #else - return(""); + return (""); #endif - 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 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)); } - exit(-11); /* never should get here */ + exit(-11); /* never should get here */ } -char *gtusr(vname) /* look up a user var's value */ - -char *vname; /* name of user variable to fetch */ +char *gtusr(vname) + /* look up a user var's value */ +char *vname; /* name of user variable to fetch */ { @@ -139,18 +175,18 @@ char *vname; /* name of user variable to fetch */ /* scan the list looking for the user var name */ for (vnum = 0; vnum < MAXVARS; vnum++) { if (uv[vnum].u_name[0] == 0) - return(errorm); + return (errorm); if (strcmp(vname, uv[vnum].u_name) == 0) - return(uv[vnum].u_value); + return (uv[vnum].u_value); } /* return errorm if we run off the end */ - return(errorm); + return (errorm); } char *gtenv(vname) -char *vname; /* name of environment variable to retrieve */ +char *vname; /* name of environment variable to retrieve */ { register int vnum; /* ordinal number of var refrenced */ @@ -167,80 +203,118 @@ char *vname; /* name of environment variable to retrieve */ { extern char *getenv(); char *ename = getenv(vname); - + if (ename != NULL) - return(ename); + return (ename); else - return(errorm); - } + return (errorm); + } #else - return(errorm); + return (errorm); #endif /* 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 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; - 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 EVPENDING: + 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; + 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 EVPENDING: #if TYPEAH - return(ltos(typahead())); + return (ltos(typahead())); #else - return(falsem); + 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 EVSCROLLCOUNT: - return(itoa(scrollcount)); + 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 */ + 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 */ @@ -257,13 +331,13 @@ char *getkill() /* return some of the contents of the kill buffer */ } /* and return the constructed value */ - return(value); + return (value); } -int setvar(f, n) /* set a variable */ - -int f; /* default flag */ -int n; /* numeric arg (can overide prompted value) */ +int setvar(f, n) + /* set a variable */ +int f; /* default flag */ +int n; /* numeric arg (can overide prompted value) */ { register int status; /* status return */ @@ -272,26 +346,26 @@ int n; /* numeric arg (can overide prompted value) */ register char *ep; /* ptr to end of outline */ #endif VDESC vd; /* variable num/type */ - char var[NVSIZE+1]; /* name of variable to fetch */ + char var[NVSIZE + 1]; /* name of variable to fetch */ char value[NSTRING]; /* value to set variable to */ /* first get the variable to set.. */ if (clexec == FALSE) { status = mlreply("Variable to set: ", &var[0], NVSIZE); if (status != TRUE) - return(status); - } else { /* macro line argument */ + return (status); + } else { /* macro line argument */ /* grab token and skip it */ execstr = token(execstr, var, NVSIZE + 1); } /* check the legality and find the var */ findvar(var, &vd, NVSIZE + 1); - + /* if its not legal....bitch */ if (vd.v_type == -1) { mlwrite("%%No such variable as '%s'", var); - return(FALSE); + return (FALSE); } /* get the value for that variable */ @@ -300,7 +374,7 @@ int n; /* numeric arg (can overide prompted value) */ else { status = mlreply("Value: ", &value[0], NSTRING); if (status != TRUE) - return(status); + return (status); } /* and set the appropriate value */ @@ -309,7 +383,7 @@ int n; /* numeric arg (can overide prompted value) */ #if DEBUGM /* if $debug == TRUE, every assignment will echo a statment to that effect here. */ - + if (macbug) { strcpy(outline, "((("); @@ -331,16 +405,15 @@ 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 */ - while(ep-- > sp) + while (ep-- > sp) *(ep + 1) = *ep; /* and advance sp past the new % */ - sp += 2; + sp += 2; } /* write out the debug line */ @@ -356,56 +429,56 @@ int n; /* numeric arg (can overide prompted value) */ #endif /* and return it */ - return(status); + return (status); } -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 */ +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 */ { register int vnum; /* subscript in varable arrays */ register int vtype; /* type to return */ -fvar: vtype = -1; + fvar:vtype = -1; switch (var[0]) { - case '$': /* check for legal enviromnent var */ - for (vnum = 0; vnum < NEVARS; vnum++) - if (strcmp(&var[1], envars[vnum]) == 0) { - vtype = TKENV; - break; - } - break; - - case '%': /* check for existing legal user variable */ - for (vnum = 0; vnum < MAXVARS; vnum++) - if (strcmp(&var[1], uv[vnum].u_name) == 0) { - vtype = TKVAR; - break; - } - if (vnum < MAXVARS) + case '$': /* check for legal enviromnent var */ + for (vnum = 0; vnum < NEVARS; vnum++) + if (strcmp(&var[1], envars[vnum]) == 0) { + vtype = TKENV; break; + } + break; - /* create a new one??? */ - for (vnum = 0; vnum < MAXVARS; vnum++) - if (uv[vnum].u_name[0] == 0) { - vtype = TKVAR; - strcpy(uv[vnum].u_name, &var[1]); - break; - } + case '%': /* check for existing legal user variable */ + for (vnum = 0; vnum < MAXVARS; vnum++) + if (strcmp(&var[1], uv[vnum].u_name) == 0) { + vtype = TKVAR; + break; + } + if (vnum < MAXVARS) break; - case '&': /* indirect operator? */ - var[4] = 0; - if (strcmp(&var[1], "ind") == 0) { - /* grab token, and eval it */ - execstr = token(execstr, var, size); - strcpy(var, getval(var)); - goto fvar; + /* create a new one??? */ + for (vnum = 0; vnum < MAXVARS; vnum++) + if (uv[vnum].u_name[0] == 0) { + vtype = TKVAR; + strcpy(uv[vnum].u_name, &var[1]); + break; } + break; + + case '&': /* indirect operator? */ + var[4] = 0; + if (strcmp(&var[1], "ind") == 0) { + /* grab token, and eval it */ + execstr = token(execstr, var, size); + strcpy(var, getval(var)); + goto fvar; + } } /* return the results */ @@ -414,17 +487,17 @@ fvar: vtype = -1; return; } -int svar(var, value) /* set a variable */ - -VDESC *var; /* variable to set */ -char *value; /* value to set to */ +int svar(var, value) + /* set a variable */ +VDESC *var; /* variable to set */ +char *value; /* value to set to */ { register int vnum; /* ordinal number of var refrenced */ register int vtype; /* type of variable to set */ register int status; /* status return */ register int c; /* translated character */ - register char * sp; /* scratch string pointer */ + register char *sp; /* scratch string pointer */ /* simplify the vd structure (we are gonna look at it a lot) */ vnum = var->v_num; @@ -433,120 +506,158 @@ char *value; /* value to set to */ /* and set the appropriate value */ status = TRUE; switch (vtype) { - case TKVAR: /* set a user variable */ + case TKVAR: /* set a user variable */ if (uv[vnum].u_value != NULL) free(uv[vnum].u_value); sp = malloc(strlen(value) + 1); if (sp == NULL) - return(FALSE); + return (FALSE); strcpy(sp, value); uv[vnum].u_value = sp; break; - case TKENV: /* set an environment variable */ + case TKENV: /* set an environment variable */ status = TRUE; /* by default */ switch (vnum) { - case EVFILLCOL: fillcol = atoi(value); - break; - case EVPAGELEN: status = newsize(TRUE, atoi(value)); - break; - case EVCURCOL: status = setccol(atoi(value)); - break; - case EVCURLINE: status = gotoline(TRUE, atoi(value)); - break; - case EVRAM: break; - case EVFLICKER: flickcode = stol(value); - break; - 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); - curwp->w_flag |= WFMODE; - break; - case EVSRES: status = TTrez(value); - break; - case EVDEBUG: macbug = stol(value); - break; - case EVSTATUS: cmdstatus = stol(value); - break; - case EVPALETTE: strncpy(palstr, value, 48); - spal(palstr); - break; - case EVASAVE: gasave = atoi(value); - break; - case EVACOUNT: gacount = atoi(value); - break; - case EVLASTKEY: lastkey = atoi(value); - break; - case EVCURCHAR: ldelete(1L, FALSE); /* delete 1 char */ - c = atoi(value); - if (c == '\n') - lnewline(FALSE, 1); - else - linsert(1, c); - backchar(FALSE, 1); - break; - case EVDISCMD: discmd = stol(value); - break; - case EVVERSION: break; - case EVPROGNAME:break; - case EVSEED: seed = atoi(value); - break; - case EVDISINP: disinp = stol(value); - break; - 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); - rvstrcpy(tap, pat); + case EVFILLCOL: + fillcol = atoi(value); + break; + case EVPAGELEN: + status = newsize(TRUE, atoi(value)); + break; + case EVCURCOL: + status = setccol(atoi(value)); + break; + case EVCURLINE: + status = gotoline(TRUE, atoi(value)); + break; + case EVRAM: + break; + case EVFLICKER: + flickcode = stol(value); + break; + 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); + curwp->w_flag |= WFMODE; + break; + case EVSRES: + status = TTrez(value); + break; + case EVDEBUG: + macbug = stol(value); + break; + case EVSTATUS: + cmdstatus = stol(value); + break; + case EVPALETTE: + strncpy(palstr, value, 48); + spal(palstr); + break; + case EVASAVE: + gasave = atoi(value); + break; + case EVACOUNT: + gacount = atoi(value); + break; + case EVLASTKEY: + lastkey = atoi(value); + break; + case EVCURCHAR: + ldelete(1L, FALSE); /* delete 1 char */ + c = atoi(value); + if (c == '\n') + lnewline(FALSE, 1); + else + linsert(1, c); + backchar(FALSE, 1); + break; + case EVDISCMD: + discmd = stol(value); + break; + case EVVERSION: + break; + case EVPROGNAME: + break; + case EVSEED: + seed = atoi(value); + break; + case EVDISINP: + disinp = stol(value); + break; + 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); + rvstrcpy(tap, pat); #if MAGIC - mcclear(); + mcclear(); #endif - break; - case EVREPLACE: strcpy(rpat, value); - break; - case EVMATCH: break; - case EVKILL: break; - case EVCMODE: curbp->b_mode = atoi(value); - curwp->w_flag |= WFMODE; - break; - case EVGMODE: gmode = atoi(value); - break; - case EVTPAUSE: term.t_pause = atoi(value); - break; - case EVPENDING: break; - 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); - break; + break; + case EVREPLACE: + strcpy(rpat, value); + break; + case EVMATCH: + break; + case EVKILL: + break; + case EVCMODE: + curbp->b_mode = atoi(value); + curwp->w_flag |= WFMODE; + break; + case EVGMODE: + gmode = atoi(value); + break; + case EVTPAUSE: + term.t_pause = atoi(value); + break; + case EVPENDING: + break; + 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); + break; case EVSCROLLCOUNT: - scrollcount = atoi(value); - break; + scrollcount = atoi(value); + break; case EVSCROLL: #if SCROLLCODE - if (! stol(value)) - term.t_scroll = NULL; + if (!stol(value)) + term.t_scroll = NULL; #endif - break; + break; } break; } - return(status); + return (status); } /* atoi: ascii string to integer......This is too @@ -557,9 +668,9 @@ atoi(st) char *st; { - int result; /* resulting number */ - int sign; /* sign of resulting number */ - char c; /* current char being examined */ + int result; /* resulting number */ + int sign; /* sign of resulting number */ + char c; /* current char being examined */ result = 0; sign = 1; @@ -581,9 +692,9 @@ char *st; if (c >= '0' && c <= '9') result = result * 10 + c - '0'; else - return(0); + return (0); - return(result * sign); + return (result * sign); } /* itoa: integer to ascii string.......... This is too @@ -591,15 +702,15 @@ char *st; char *itoa(i) -int i; /* integer to translate to a string */ +int i; /* integer to translate to a string */ { - register int digit; /* current digit being used */ - register char *sp; /* pointer into result */ - register int sign; /* sign of resulting number */ - static char result[INTWIDTH+1]; /* resulting string */ + register int digit; /* current digit being used */ + register char *sp; /* pointer into result */ + register int sign; /* sign of resulting number */ + static char result[INTWIDTH + 1]; /* resulting string */ - /* record the sign...*/ + /* record the sign... */ sign = 1; if (i < 0) { sign = -1; @@ -620,12 +731,12 @@ int i; /* integer to translate to a string */ *(--sp) = '-'; /* and install the minus sign */ } - return(sp); + return (sp); } -int gettyp(token) /* find the type of a passed token */ - -char *token; /* token to analyze */ +int gettyp(token) + /* find the type of a passed token */ +char *token; /* token to analyze */ { register char c; /* first char in token */ @@ -635,133 +746,149 @@ char *token; /* token to analyze */ /* no blanks!!! */ if (c == 0) - return(TKNUL); + return (TKNUL); /* a numeric literal? */ if (c >= '0' && c <= '9') - return(TKLIT); + 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 *token; /* token to evaluate */ +char *getval(token) + /* find the value of a token */ +char *token; /* token to evaluate */ { register int status; /* error return */ register BUFFER *bp; /* temp buffer pointer */ register int blen; /* length of buffer argument */ register int distmp; /* temporary discmd flag */ - static char buf[NSTRING];/* string buffer for some returns */ + 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')); - discmd = distmp; - if (status == ABORT) - return(errorm); - return(buf); + case TKARG: /* interactive argument */ + strcpy(token, getval(&token[1])); + distmp = discmd; /* echo it always! */ + discmd = TRUE; + status = getstring(token, buf, NSTRING, ctoec('\n')); + discmd = distmp; + if (status == ABORT) + return (errorm); + return (buf); - case TKBUF: /* buffer contents fetch */ + case TKBUF: /* buffer contents fetch */ - /* grab the right buffer */ - strcpy(token, getval(&token[1])); - bp = bfind(token, FALSE, 0); - if (bp == NULL) - return(errorm); - - /* if the buffer is displayed, get the window - vars instead of the buffer vars */ - if (bp->b_nwnd > 0) { - curbp->b_dotp = curwp->w_dotp; - curbp->b_doto = curwp->w_doto; - } + /* grab the right buffer */ + strcpy(token, getval(&token[1])); + bp = bfind(token, FALSE, 0); + if (bp == NULL) + return (errorm); - /* make sure we are not at the end */ - if (bp->b_linep == bp->b_dotp) - return(errorm); - - /* grab the line as an argument */ - 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); - buf[blen] = 0; - - /* and step the buffer's line ptr ahead a line */ - bp->b_dotp = bp->b_dotp->l_fp; - bp->b_doto = 0; + /* if the buffer is displayed, get the window + vars instead of the buffer vars */ + if (bp->b_nwnd > 0) { + curbp->b_dotp = curwp->w_dotp; + curbp->b_doto = curwp->w_doto; + } - /* if displayed buffer, reset window ptr vars*/ - if (bp->b_nwnd > 0) { - curwp->w_dotp = curbp->b_dotp; - curwp->w_doto = 0; - curwp->w_flag |= WFMOVE; - } + /* make sure we are not at the end */ + if (bp->b_linep == bp->b_dotp) + return (errorm); - /* and return the spoils */ - return(buf); + /* grab the line as an argument */ + 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); + buf[blen] = 0; - 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); + /* and step the buffer's line ptr ahead a line */ + bp->b_dotp = bp->b_dotp->l_fp; + bp->b_doto = 0; + + /* if displayed buffer, reset window ptr vars */ + if (bp->b_nwnd > 0) { + curwp->w_dotp = curbp->b_dotp; + curwp->w_doto = 0; + curwp->w_flag |= WFMOVE; + } + + /* 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); } } -int stol(val) /* convert a string to a numeric logical */ - -char *val; /* value to check for stol */ +int stol(val) + /* convert a string to a numeric logical */ +char *val; /* value to check for stol */ { /* check for logical values */ if (val[0] == 'F') - return(FALSE); + return (FALSE); if (val[0] == 'T') - return(TRUE); + return (TRUE); /* check for numeric truth (!= 0) */ - return((atoi(val) != 0)); + return ((atoi(val) != 0)); } -char *ltos(val) /* numeric logical to string logical */ - -int val; /* value to translate */ +char *ltos(val) + /* numeric logical to string logical */ +int val; /* value to translate */ { if (val) - return(truem); + return (truem); else - return(falsem); + return (falsem); } -char *mkupper(str) /* make a string upper case */ - -char *str; /* string to upper case */ +char *mkupper(str) + /* make a string upper case */ +char *str; /* string to upper case */ { char *sp; @@ -772,12 +899,12 @@ char *str; /* string to upper case */ *sp += 'A' - 'a'; ++sp; } - return(str); + return (str); } -char *mklower(str) /* make a string lower case */ - -char *str; /* string to lower case */ +char *mklower(str) + /* make a string lower case */ +char *str; /* string to lower case */ { char *sp; @@ -788,33 +915,32 @@ char *str; /* string to lower case */ *sp += 'a' - 'A'; ++sp; } - return(str); + return (str); } -int abs(x) /* take the absolute value of an integer */ - +int abs(x) + /* take the absolute value of an integer */ int x; { - return(x < 0 ? -x : x); + return (x < 0 ? -x : x); } -int ernd() /* returns a random integer */ - -{ +int ernd() +{ /* returns a random integer */ seed = abs(seed * 1721 + 10007); - return(seed); + return (seed); } -int sindex(source, pattern) /* find pattern within source */ - -char *source; /* source string to search */ -char *pattern; /* string to look for */ +int sindex(source, pattern) + /* find pattern within source */ +char *source; /* source string to search */ +char *pattern; /* string to look for */ { - char *sp; /* ptr to current position to scan */ - char *csp; /* ptr to source string during comparison */ - char *cp; /* ptr to place to check for equality */ + char *sp; /* ptr to current position to scan */ + char *csp; /* ptr to source string during comparison */ + char *cp; /* ptr to place to check for equality */ /* scanning through the source string */ sp = source; @@ -831,21 +957,21 @@ char *pattern; /* string to look for */ /* was it a match? */ if (*cp == 0) - return((int)(sp - source) + 1); + return ((int) (sp - source) + 1); ++sp; } /* no match at all.. */ - return(0); + return (0); } /* Filter a string through a translation table */ char *xlat(source, lookup, trans) -char *source; /* string to filter */ -char *lookup; /* characters to translate */ -char *trans; /* resulting translated characters */ +char *source; /* string to filter */ +char *lookup; /* characters to translate */ +char *trans; /* resulting translated characters */ { register char *sp; /* pointer into source table */ @@ -870,10 +996,10 @@ char *trans; /* resulting translated characters */ /* no match, copy in the source char untranslated */ *rp++ = *sp; -xnext: ++sp; + xnext:++sp; } /* terminate and return the result */ *rp = 0; - return(result); + return (result); } diff --git a/evar.h b/evar.h index d4c0919..e0906d3 100644 --- a/evar.h +++ b/evar.h @@ -9,15 +9,15 @@ /* structure to hold user variables and their definitions */ typedef struct UVAR { - char u_name[NVSIZE + 1]; /* name of user variable */ - char *u_value; /* value (string) */ + char u_name[NVSIZE + 1]; /* name of user variable */ + char *u_value; /* value (string) */ } UVAR; /* current user variables (This structure will probably change) */ #define MAXVARS 255 -UVAR uv[MAXVARS + 1]; /* user variables */ +UVAR uv[MAXVARS + 1]; /* user variables */ /* list of recognized environment variables */ @@ -116,8 +116,8 @@ char *envars[] = { /* list of recognized user functions */ typedef struct UFUNC { - char *f_name; /* name of function */ - int f_type; /* 1 = monamic, 2 = dynamic */ + char *f_name; /* name of function */ + int f_type; /* 1 = monamic, 2 = dynamic */ } UFUNC; #define NILNAMIC 0 @@ -145,7 +145,7 @@ UFUNC funcs[] = { "sgr", DYNAMIC, /* string logical greater than */ "ind", MONAMIC, /* evaluate indirect value */ "and", DYNAMIC, /* logical and */ - "or", DYNAMIC, /* logical or */ + "or", DYNAMIC, /* logical or */ "len", MONAMIC, /* string length */ "upp", MONAMIC, /* uppercase string */ "low", MONAMIC, /* lower case string */ @@ -160,9 +160,9 @@ UFUNC funcs[] = { "bin", MONAMIC, /* loopup what function name is bound to a key */ "exi", MONAMIC, /* check if a file exists */ "fin", MONAMIC, /* look for a file on the path... */ - "ban", DYNAMIC, /* bitwise and 9-10-87 jwm */ - "bor", DYNAMIC, /* bitwise or 9-10-87 jwm */ - "bxo", DYNAMIC, /* bitwise xor 9-10-87 jwm */ + "ban", DYNAMIC, /* bitwise and 9-10-87 jwm */ + "bor", DYNAMIC, /* bitwise or 9-10-87 jwm */ + "bxo", DYNAMIC, /* bitwise xor 9-10-87 jwm */ "bno", MONAMIC, /* bitwise not */ "xla", TRINAMIC, /* XLATE character string translation */ }; diff --git a/exec.c b/exec.c index 4003462..9e13f22 100644 --- a/exec.c +++ b/exec.c @@ -15,11 +15,11 @@ namedcmd(f, n) -int f, n; /* command arguments [passed through to command executed] */ +int f, n; /* command arguments [passed through to command executed] */ { - register int (*kfunc)(); /* ptr to the requexted function to bind to */ - int (*getname())(); + register int (*kfunc) (); /* ptr to the requexted function to bind to */ + int (*getname()) (); /* prompt the user to type a named command */ mlwrite(": "); @@ -28,11 +28,11 @@ int f, n; /* command arguments [passed through to command executed] */ kfunc = getname(); if (kfunc == NULL) { mlwrite("(No such function)"); - return(FALSE); + return (FALSE); } /* and then execute the command */ - return((*kfunc)(f, n)); + return ((*kfunc) (f, n)); } /* execcmd: Execute a command line command to be typed in @@ -40,18 +40,18 @@ int f, n; /* command arguments [passed through to command executed] */ execcmd(f, n) -int f, n; /* default Flag and Numeric argument */ +int f, n; /* default Flag and Numeric argument */ { - register int status; /* status return */ - char cmdstr[NSTRING]; /* string holding command to execute */ + register int status; /* status return */ + char cmdstr[NSTRING]; /* string holding command to execute */ /* get the line wanted */ if ((status = mlreply(": ", cmdstr, NSTRING)) != TRUE) - return(status); + return (status); execlevel = 0; - return(docmd(cmdstr)); + return (docmd(cmdstr)); } /* docmd: take a passed string as a command line and translate @@ -67,21 +67,21 @@ int f, n; /* default Flag and Numeric argument */ docmd(cline) -char *cline; /* command line to execute */ +char *cline; /* command line to execute */ { register int f; /* default argument flag */ register int n; /* numeric repeat value */ - int (*fnc)(); /* function to execute */ + int (*fnc) (); /* function to execute */ int status; /* return status of function */ int oldcle; /* old contents of clexec flag */ char *oldestr; /* original exec string */ char tkn[NSTRING]; /* next token off of command line */ - int (*fncmatch())(); - + int (*fncmatch()) (); + /* if we are scanning and not executing..go back here */ if (execlevel) - return(TRUE); + return (TRUE); oldestr = execstr; /* save last ptr to string to execute */ execstr = cline; /* and set this one as current */ @@ -94,7 +94,7 @@ char *cline; /* command line to execute */ if ((status = macarg(tkn)) != TRUE) { /* and grab the first token */ execstr = oldestr; - return(status); + return (status); } /* process leadin argument */ @@ -106,25 +106,25 @@ char *cline; /* command line to execute */ /* and now get the command to execute */ if ((status = macarg(tkn)) != TRUE) { execstr = oldestr; - return(status); - } + return (status); + } } /* and match the token to see if it exists */ if ((fnc = fncmatch(tkn)) == NULL) { mlwrite("(No such Function)"); execstr = oldestr; - return(FALSE); + return (FALSE); } - + /* save the arguments and go execute the command */ - oldcle = clexec; /* save old clexec flag */ - clexec = TRUE; /* in cline execution */ - status = (*fnc)(f, n); /* call the function */ - cmdstatus = status; /* save the status */ - clexec = oldcle; /* restore clexec flag */ + oldcle = clexec; /* save old clexec flag */ + clexec = TRUE; /* in cline execution */ + status = (*fnc) (f, n); /* call the function */ + cmdstatus = status; /* save the status */ + clexec = oldcle; /* restore clexec flag */ execstr = oldestr; - return(status); + return (status); } /* token: chop a token off a string @@ -133,8 +133,8 @@ char *cline; /* command line to execute */ char *token(src, tok, size) -char *src, *tok; /* source string, destination token string */ -int size; /* maximum size of token */ +char *src, *tok; /* source string, destination token string */ +int size; /* maximum size of token */ { register int quotef; /* is the current string quoted? */ @@ -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; @@ -188,44 +199,44 @@ int size; /* maximum size of token */ if (*src) ++src; *tok = 0; - return(src); + return (src); } -macarg(tok) /* get a macro line argument */ - -char *tok; /* buffer to place argument */ +macarg(tok) + /* get a macro line argument */ +char *tok; /* buffer to place argument */ { - int savcle; /* buffer to store original clexec */ + int savcle; /* buffer to store original clexec */ int status; savcle = clexec; /* save execution mode */ clexec = TRUE; /* get the argument */ status = nextarg("", tok, NSTRING, ctoec('\n')); clexec = savcle; /* restore execution mode */ - return(status); + return (status); } /* nextarg: get the next argument */ nextarg(prompt, buffer, size, terminator) -char *prompt; /* prompt to use if we must be interactive */ -char *buffer; /* buffer to put token into */ -int size; /* size of the buffer */ -int terminator; /* terminating char to be used on interactive fetch */ +char *prompt; /* prompt to use if we must be interactive */ +char *buffer; /* buffer to put token into */ +int size; /* size of the buffer */ +int terminator; /* terminating char to be used on interactive fetch */ { /* if we are interactive, go get it! */ if (clexec == FALSE) - return(getstring(prompt, buffer, size, terminator)); + return (getstring(prompt, buffer, size, terminator)); /* grab token and advance past */ execstr = token(execstr, buffer, size); /* evaluate it */ strcpy(buffer, getval(buffer)); - return(TRUE); + return (TRUE); } /* storemac: Set up a macro buffer and flag to store all @@ -233,23 +244,23 @@ int terminator; /* terminating char to be used on interactive fetch */ storemac(f, n) -int f; /* default flag */ -int n; /* macro number to use */ +int f; /* default flag */ +int n; /* macro number to use */ { register struct BUFFER *bp; /* pointer to macro buffer */ - char bname[NBUFN]; /* name of buffer to use */ + char bname[NBUFN]; /* name of buffer to use */ /* must have a numeric argument to this function */ if (f == FALSE) { mlwrite("No macro specified"); - return(FALSE); + return (FALSE); } /* range check the macro number */ if (n < 1 || n > 40) { mlwrite("Macro number out of range"); - return(FALSE); + return (FALSE); } /* construct the macro buffer name */ @@ -260,7 +271,7 @@ int n; /* macro number to use */ /* set up the new macro buffer */ if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) { mlwrite("Can not create macro"); - return(FALSE); + return (FALSE); } /* and make sure it is empty */ @@ -269,7 +280,7 @@ int n; /* macro number to use */ /* and set the macro store pointers to it */ mstore = TRUE; bstore = bp; - return(TRUE); + return (TRUE); } #if PROC @@ -278,21 +289,22 @@ int n; /* macro number to use */ storeproc(f, n) -int f; /* default flag */ -int n; /* macro number to use */ +int f; /* default flag */ +int n; /* macro number to use */ { register struct BUFFER *bp; /* pointer to macro buffer */ - register int status; /* return status */ - char bname[NBUFN]; /* name of buffer to use */ + register int status; /* return status */ + char bname[NBUFN]; /* name of buffer to use */ /* a numeric argument means its a numbered macro */ if (f == TRUE) - return(storemac(f, n)); + return (storemac(f, n)); /* get the name of the procedure */ - if ((status = mlreply("Procedure name: ", &bname[1], NBUFN-2)) != TRUE) - return(status); + if ((status = + mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE) + return (status); /* construct the macro buffer name */ bname[0] = '*'; @@ -301,7 +313,7 @@ int n; /* macro number to use */ /* set up the new macro buffer */ if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) { mlwrite("Can not create macro"); - return(FALSE); + return (FALSE); } /* and make sure it is empty */ @@ -310,39 +322,40 @@ int n; /* macro number to use */ /* and set the macro store pointers to it */ mstore = TRUE; bstore = bp; - return(TRUE); + return (TRUE); } /* execproc: Execute a procedure */ execproc(f, n) -int f, n; /* default flag and numeric arg */ +int f, n; /* default flag and numeric arg */ { - register BUFFER *bp; /* ptr to buffer to execute */ - register int status; /* status return */ - char bufn[NBUFN+2]; /* name of buffer to execute */ + register BUFFER *bp; /* ptr to buffer to execute */ + register int status; /* status return */ + 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) - return(status); + if ((status = + mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE) + return (status); /* construct the buffer name */ bufn[0] = '*'; strcat(bufn, "*"); /* find the pointer to that buffer */ - if ((bp=bfind(bufn, FALSE, 0)) == NULL) { + if ((bp = bfind(bufn, FALSE, 0)) == NULL) { mlwrite("No such procedure"); - return(FALSE); - } + return (FALSE); + } /* and now execute it as asked */ while (n-- > 0) if ((status = dobuf(bp)) != TRUE) - return(status); - return(TRUE); + return (status); + return (TRUE); } #endif @@ -350,28 +363,28 @@ int f, n; /* default flag and numeric arg */ execbuf(f, n) -int f, n; /* default flag and numeric arg */ +int f, n; /* default flag and numeric arg */ { - register BUFFER *bp; /* ptr to buffer to execute */ - register int status; /* status return */ - char bufn[NSTRING]; /* name of buffer to execute */ + register BUFFER *bp; /* ptr to buffer to execute */ + register int status; /* status return */ + char bufn[NSTRING]; /* name of buffer to execute */ /* find out what buffer the user wants to execute */ - if ((status = mlreply("Execute buffer: ", bufn, NBUFN)) != TRUE) - return(status); + if ((status = mlreply("Execute buffer: ", bufn, NBUFN)) != TRUE) + return (status); /* find the pointer to that buffer */ - if ((bp=bfind(bufn, FALSE, 0)) == NULL) { + if ((bp = bfind(bufn, FALSE, 0)) == NULL) { mlwrite("No such buffer"); - return(FALSE); - } + return (FALSE); + } /* and now execute it as asked */ while (n-- > 0) if ((status = dobuf(bp)) != TRUE) - return(status); - return(TRUE); + return (status); + return (TRUE); } /* dobuf: execute the contents of the buffer pointed to @@ -396,10 +409,10 @@ int f, n; /* default flag and numeric arg */ dobuf(bp) -BUFFER *bp; /* buffer to execute */ +BUFFER *bp; /* buffer to execute */ { - register int status; /* status return */ + register int status; /* status return */ register LINE *lp; /* pointer to line to execute */ register LINE *hlp; /* pointer to line header */ register LINE *glp; /* line to goto */ @@ -411,7 +424,7 @@ BUFFER *bp; /* buffer to execute */ int force; /* force TRUE result? */ WINDOW *wp; /* ptr to windows to scan */ WHBLOCK *whlist; /* ptr to !WHILE list */ - WHBLOCK *scanner; /* ptr during scan */ + WHBLOCK *scanner; /* ptr during scan */ WHBLOCK *whtemp; /* temporary ptr to a WHBLOCK */ char *einit; /* initial value of eline */ char *eline; /* text of line to execute */ @@ -445,12 +458,14 @@ BUFFER *bp; /* buffer to execute */ /* if is a while directive, make a block... */ if (eline[0] == '!' && eline[1] == 'w' && eline[2] == 'h') { - whtemp = (WHBLOCK *)malloc(sizeof(WHBLOCK)); + 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); + return (FALSE); } whtemp->w_begin = lp; whtemp->w_type = BTWHILE; @@ -461,10 +476,11 @@ 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)); + whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK)); if (whtemp == NULL) goto noram; whtemp->w_begin = lp; @@ -476,8 +492,9 @@ 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'", - bp->b_bname); + mlwrite + ("%%!ENDWHILE with no preceding !WHILE in '%s'", + bp->b_bname); goto failexit; } /* move top records from the scanner list to the @@ -492,7 +509,7 @@ failexit: freewhile(scanner); } while (whlist->w_type == BTBREAK); } -nxtscan: /* on to the next line */ + nxtscan: /* on to the next line */ lp = lp->l_fp; } @@ -503,7 +520,7 @@ nxtscan: /* on to the next line */ goto failexit; } - /* let the first command inherit the flags from the last one..*/ + /* let the first command inherit the flags from the last one.. */ thisflag = lastflag; /* starting at the beginning of the buffer */ @@ -512,10 +529,10 @@ nxtscan: /* on to the next line */ while (lp != hlp) { /* allocate eline and copy macro line to it */ linlen = lp->l_used; - if ((einit = eline = malloc(linlen+1)) == NULL) { + if ((einit = eline = malloc(linlen + 1)) == NULL) { mlwrite("%%Out of Memory during macro execution"); freewhile(whlist); - return(FALSE); + return (FALSE); } strncpy(eline, lp->l_text, linlen); eline[linlen] = 0; /* make sure it ends */ @@ -532,14 +549,14 @@ nxtscan: /* on to the next line */ /* if $debug == TRUE, every line to execute gets echoed and a key needs to be pressed to continue ^G will abort the command */ - + if (macbug) { strcpy(outline, "<<<"); - + /* debug macro name */ strcat(outline, bp->b_bname); strcat(outline, ":"); - + /* debug if levels */ strcat(outline, itoa(execlevel)); strcat(outline, ":"); @@ -547,34 +564,33 @@ nxtscan: /* on to the next line */ /* and lastly the line */ strcat(outline, eline); strcat(outline, ">>>"); - + /* change all '%' to ':' so mlwrite won't expect arguments */ sp = outline; while (*sp) - if (*sp++ == '%') { - /* advance to the end */ - ep = --sp; - while (*ep++) - ; - /* null terminate the string one out */ - *(ep + 1) = 0; - /* copy backwards */ - while(ep-- > sp) - *(ep + 1) = *ep; + if (*sp++ == '%') { + /* advance to the end */ + ep = --sp; + while (*ep++); + /* null terminate the string one out */ + *(ep + 1) = 0; + /* copy backwards */ + while (ep-- > sp) + *(ep + 1) = *ep; + + /* and advance sp past the new % */ + sp += 2; + } - /* and advance sp past the new % */ - sp += 2; - } - /* write out the debug line */ mlforce(outline); update(TRUE); - + /* and get the keystroke */ if ((c = get1key()) == abortc) { mlforce("(Macro aborted)"); freewhile(whlist); - return(FALSE); + return (FALSE); } if (c == metac) @@ -589,14 +605,14 @@ nxtscan: /* on to the next line */ ++eline; for (dirnum = 0; dirnum < NUMDIRS; dirnum++) if (strncmp(eline, dname[dirnum], - strlen(dname[dirnum])) == 0) + strlen(dname[dirnum])) == 0) break; /* and bitch if it's illegal */ if (dirnum == NUMDIRS) { mlwrite("%%Unknown Directive"); freewhile(whlist); - return(FALSE); + return (FALSE); } /* service only the !ENDM macro here */ @@ -606,7 +622,7 @@ nxtscan: /* on to the next line */ goto onward; } - /* restore the original eline....*/ + /* restore the original eline.... */ --eline; } @@ -614,23 +630,24 @@ nxtscan: /* on to the next line */ if (mstore) { /* allocate the space for the line */ linlen = strlen(eline); - if ((mp=lalloc(linlen)) == NULL) { - mlwrite("Out of memory while storing macro"); + if ((mp = lalloc(linlen)) == NULL) { + mlwrite + ("Out of memory while storing macro"); return (FALSE); } - + /* copy the text into the new line */ - for (i=0; ib_linep->l_bp->l_fp = mp; + bstore->b_linep->l_bp->l_fp = mp; mp->l_bp = bstore->b_linep->l_bp; bstore->b_linep->l_bp = mp; mp->l_fp = bstore->b_linep; goto onward; } - + force = FALSE; @@ -679,13 +696,14 @@ nxtscan: /* on to the next line */ break; whtemp = whtemp->w_next; } - + if (whtemp == NULL) { - mlwrite("%%Internal While loop error"); + mlwrite + ("%%Internal While loop error"); freewhile(whlist); - return(FALSE); + return (FALSE); } - + /* reset the line pointer back.. */ lp = whtemp->w_end; goto onward; @@ -693,7 +711,7 @@ nxtscan: /* on to the next line */ case DELSE: /* ELSE directive */ if (execlevel == 1) --execlevel; - else if (execlevel == 0 ) + else if (execlevel == 0) ++execlevel; goto onward; @@ -707,13 +725,16 @@ 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, - linlen) == 0)) { + (strncmp + (&glp->l_text[1], + golabel, + linlen) == 0)) { lp = glp; goto onward; } @@ -721,10 +742,10 @@ nxtscan: /* on to the next line */ } mlwrite("%%No such label"); freewhile(whlist); - return(FALSE); + return (FALSE); } goto onward; - + case DRETURN: /* RETURN directive */ if (execlevel == 0) goto eexec; @@ -738,18 +759,20 @@ 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); + return (FALSE); } - + /* reset the line pointer back.. */ lp = whtemp->w_begin->l_bp; goto onward; @@ -763,7 +786,7 @@ nxtscan: /* on to the next line */ /* execute the statement */ status = docmd(eline); - if (force) /* force the status */ + if (force) /* force the status */ status = TRUE; /* check for a command error */ @@ -785,23 +808,23 @@ nxtscan: /* on to the next line */ free(einit); execlevel = 0; freewhile(whlist); - return(status); + return (status); } -onward: /* on to the next line */ + onward: /* on to the next line */ free(einit); lp = lp->l_fp; } -eexec: /* exit the current function */ + eexec: /* exit the current function */ execlevel = 0; freewhile(whlist); - return(TRUE); + return (TRUE); } -freewhile(wp) /* free a list of while block pointers */ - -WHBLOCK *wp; /* head of structure to free */ +freewhile(wp) + /* free a list of while block pointers */ +WHBLOCK *wp; /* head of structure to free */ { if (wp == NULL) @@ -811,17 +834,18 @@ WHBLOCK *wp; /* head of structure to free */ free(wp); } -execfile(f, n) /* execute a series of commands in a file */ - -int f, n; /* default flag and numeric arg to pass on to 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 */ { register int status; /* return status of name query */ char fname[NSTRING]; /* name of file to execute */ char *fspec; /* full file spec */ - if ((status = mlreply("File to execute: ", fname, NSTRING -1)) != TRUE) - return(status); + if ((status = + mlreply("File to execute: ", fname, NSTRING - 1)) != TRUE) + return (status); #if 1 /* look up the path for the file */ @@ -829,15 +853,15 @@ int f, n; /* default flag and numeric arg to pass on to file */ /* if it isn't around */ if (fspec == NULL) - return(FALSE); + return (FALSE); #endif /* otherwise, execute it */ while (n-- > 0) - if ((status=dofile(fspec)) != TRUE) - return(status); + if ((status = dofile(fspec)) != TRUE) + return (status); - return(TRUE); + return (TRUE); } /* dofile: yank a file into a buffer and execute it @@ -845,7 +869,7 @@ int f, n; /* default flag and numeric arg to pass on to file */ dofile(fname) -char *fname; /* file name to execute */ +char *fname; /* file name to execute */ { register BUFFER *bp; /* buffer to place file to exeute */ @@ -853,10 +877,10 @@ char *fname; /* file name to execute */ register int status; /* results of various calls */ char bname[NBUFN]; /* name of buffer */ - makename(bname, fname); /* derive the name of the buffer */ - unqname(bname); /* make sure we don't stomp things */ - if ((bp = bfind(bname, TRUE, 0)) == NULL) /* get the needed buffer */ - return(FALSE); + makename(bname, fname); /* derive the name of the buffer */ + unqname(bname); /* make sure we don't stomp things */ + if ((bp = bfind(bname, TRUE, 0)) == NULL) /* get the needed buffer */ + return (FALSE); bp->b_mode = MDVIEW; /* mark the buffer as read only */ cb = curbp; /* save the old buffer */ @@ -864,30 +888,30 @@ char *fname; /* file name to execute */ /* and try to read in the file to execute */ if ((status = readin(fname, FALSE)) != TRUE) { curbp = cb; /* restore the current buffer */ - return(status); + return (status); } /* go execute it! */ curbp = cb; /* restore the current buffer */ if ((status = dobuf(bp)) != TRUE) - return(status); + return (status); /* if not displayed, remove the now unneeded buffer and exit */ if (bp->b_nwnd == 0) zotbuf(bp); - return(TRUE); + return (TRUE); } /* cbuf: Execute the contents of a numbered buffer */ cbuf(f, n, bufnum) -int f, n; /* default flag and numeric arg */ -int bufnum; /* number of buffer to execute */ +int f, n; /* default flag and numeric arg */ +int bufnum; /* number of buffer to execute */ { - register BUFFER *bp; /* ptr to buffer to execute */ - register int status; /* status return */ + register BUFFER *bp; /* ptr to buffer to execute */ + register int status; /* status return */ static char bufname[] = "*Macro xx*"; /* make the buffer name */ @@ -895,254 +919,214 @@ int bufnum; /* number of buffer to execute */ bufname[8] = '0' + (bufnum % 10); /* find the pointer to that buffer */ - if ((bp=bfind(bufname, FALSE, 0)) == NULL) { - mlwrite("Macro not defined"); - return(FALSE); - } + if ((bp = bfind(bufname, FALSE, 0)) == NULL) { + mlwrite("Macro not defined"); + return (FALSE); + } /* and now execute it as asked */ while (n-- > 0) if ((status = dobuf(bp)) != TRUE) - return(status); - return(TRUE); + return (status); + return (TRUE); } 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); } diff --git a/file.c b/file.c index bc64ded..dff3788 100644 --- a/file.c +++ b/file.c @@ -20,14 +20,14 @@ */ fileread(f, n) { - register int s; - char fname[NFILEN]; + register int s; + char fname[NFILEN]; if (restflag) /* don't allow this command if restricted */ - return(resterr()); - if ((s=mlreply("Read file: ", fname, NFILEN)) != TRUE) - return(s); - return(readin(fname, TRUE)); + return (resterr()); + if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE) + return (s); + return (readin(fname, TRUE)); } /* @@ -39,18 +39,18 @@ fileread(f, n) */ insfile(f, n) { - register int s; + register int s; char fname[NFILEN]; if (restflag) /* don't allow this command if restricted */ - return(resterr()); - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if ((s=mlreply("Insert file: ", fname, NFILEN)) != TRUE) - return(s); - if ((s=ifile(fname)) != TRUE) - return(s); - return(reposition(TRUE, -1)); + return (resterr()); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if ((s = mlreply("Insert file: ", fname, NFILEN)) != TRUE) + return (s); + if ((s = ifile(fname)) != TRUE) + return (s); + return (reposition(TRUE, -1)); } /* @@ -64,28 +64,28 @@ insfile(f, n) */ filefind(f, n) { - char fname[NFILEN]; /* file user wishes to find */ - register int s; /* status return */ + char fname[NFILEN]; /* file user wishes to find */ + register int s; /* status return */ if (restflag) /* don't allow this command if restricted */ - return(resterr()); - if ((s=mlreply("Find file: ", fname, NFILEN)) != TRUE) - return(s); - return(getfile(fname, TRUE)); + return (resterr()); + if ((s = mlreply("Find file: ", fname, NFILEN)) != TRUE) + return (s); + return (getfile(fname, TRUE)); } -viewfile(f, n) /* visit a file in VIEW mode */ -{ - char fname[NFILEN]; /* file user wishes to find */ - register int s; /* status return */ +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 */ if (restflag) /* don't allow this command if restricted */ - return(resterr()); - if ((s=mlreply("View file: ", fname, NFILEN)) != TRUE) - return (s); + return (resterr()); + if ((s = mlreply("View file: ", fname, NFILEN)) != TRUE) + return (s); s = getfile(fname, FALSE); - if (s) { /* if we succeed, put it in view mode */ + if (s) { /* if we succeed, put it in view mode */ curwp->w_bufp->b_mode |= MDVIEW; /* scan through and update mode lines of all windows */ @@ -95,14 +95,13 @@ viewfile(f, n) /* visit a file in VIEW mode */ wp = wp->w_wndp; } } - return(s); + return (s); } #if CRYPT -resetkey() /* reset the encryption key if needed */ - -{ - register int s; /* return status */ +resetkey() +{ /* reset the encryption key if needed */ + register int s; /* return status */ /* turn off the encryption flag */ cryptflag = FALSE; @@ -112,7 +111,7 @@ resetkey() /* reset the encryption key if needed */ if (curbp->b_key[0] == 0) { s = setkey(FALSE, 0); if (s != TRUE) - return(s); + return (s); } /* let others know... */ @@ -120,72 +119,73 @@ resetkey() /* reset the encryption key if needed */ /* and set up the key to be used! */ /* de-encrypt it */ - crypt((char *)NULL, 0); + crypt((char *) NULL, 0); crypt(curbp->b_key, strlen(curbp->b_key)); /* re-encrypt it...seeding it to start */ - crypt((char *)NULL, 0); + crypt((char *) NULL, 0); crypt(curbp->b_key, strlen(curbp->b_key)); } - return(TRUE); + return (TRUE); } #endif getfile(fname, lockfl) -char fname[]; /* file name to find */ -int lockfl; /* check the file for locks? */ +char fname[]; /* file name to find */ +int lockfl; /* check the file for locks? */ { - register BUFFER *bp; - register LINE *lp; - register int i; - register int s; - char bname[NBUFN]; /* buffer name to put file */ + register BUFFER *bp; + register LINE *lp; + register int i; + register int s; + char bname[NBUFN]; /* buffer name to put file */ #if MSDOS 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) { + for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { + if ((bp->b_flag & BFINVS) == 0 + && strcmp(bp->b_fname, fname) == 0) { swbuffer(bp); - lp = curwp->w_dotp; - i = curwp->w_ntrows/2; - while (i-- && lback(lp)!=curbp->b_linep) - lp = lback(lp); - curwp->w_linep = lp; - curwp->w_flag |= WFMODE|WFHARD; + lp = curwp->w_dotp; + i = curwp->w_ntrows / 2; + while (i-- && lback(lp) != curbp->b_linep) + lp = lback(lp); + curwp->w_linep = lp; + curwp->w_flag |= WFMODE | WFHARD; cknewwindow(); mlwrite("(Old buffer)"); - return (TRUE); - } - } - makename(bname, fname); /* New buffer name. */ - while ((bp=bfind(bname, FALSE, 0)) != NULL) { + return (TRUE); + } + } + makename(bname, fname); /* New buffer name. */ + while ((bp = bfind(bname, FALSE, 0)) != NULL) { /* old buffer name conflict code */ - s = mlreply("Buffer name: ", bname, NBUFN); - if (s == ABORT) /* ^G to just quit */ - return (s); - if (s == FALSE) { /* CR to clobber it */ - makename(bname, fname); - break; - } - } - if (bp==NULL && (bp=bfind(bname, TRUE, 0))==NULL) { - mlwrite("Cannot create buffer"); - return (FALSE); - } - if (--curbp->b_nwnd == 0) { /* Undisplay. */ - curbp->b_dotp = curwp->w_dotp; - curbp->b_doto = curwp->w_doto; - curbp->b_markp = curwp->w_markp; - curbp->b_marko = curwp->w_marko; - } - curbp = bp; /* Switch to it. */ - curwp->w_bufp = bp; - curbp->b_nwnd++; - s = readin(fname, lockfl); /* Read it in. */ + s = mlreply("Buffer name: ", bname, NBUFN); + if (s == ABORT) /* ^G to just quit */ + return (s); + if (s == FALSE) { /* CR to clobber it */ + makename(bname, fname); + break; + } + } + if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) { + mlwrite("Cannot create buffer"); + return (FALSE); + } + if (--curbp->b_nwnd == 0) { /* Undisplay. */ + curbp->b_dotp = curwp->w_dotp; + curbp->b_doto = curwp->w_doto; + curbp->b_markp = curwp->w_markp; + curbp->b_marko = curwp->w_marko; + } + curbp = bp; /* Switch to it. */ + curwp->w_bufp = bp; + curbp->b_nwnd++; + s = readin(fname, lockfl); /* Read it in. */ cknewwindow(); return s; } @@ -201,19 +201,19 @@ int lockfl; /* check the file for locks? */ readin(fname, lockfl) -char fname[]; /* name of file to read */ -int lockfl; /* check for file locks? */ +char fname[]; /* name of file to read */ +int lockfl; /* check for file locks? */ { - register LINE *lp1; - register LINE *lp2; - register int i; - register WINDOW *wp; - register BUFFER *bp; - register int s; - register int nbytes; - register int nline; - int lflag; /* any lines longer than allowed? */ + register LINE *lp1; + register LINE *lp2; + register int i; + register WINDOW *wp; + register BUFFER *bp; + register int s; + register int nbytes; + register int nline; + int lflag; /* any lines longer than allowed? */ char mesg[NSTRING]; #if (FILOCK && BSD) || SVR4 @@ -226,62 +226,62 @@ int lockfl; /* check for file locks? */ goto out; } #else - return(ABORT); + return (ABORT); #endif #endif #if CRYPT s = resetkey(); if (s != TRUE) - return(s); + return (s); #endif - bp = curbp; /* Cheap. */ - if ((s=bclear(bp)) != TRUE) /* Might be old. */ - return (s); - bp->b_flag &= ~(BFINVS|BFCHG); - strcpy(bp->b_fname, fname); + bp = curbp; /* Cheap. */ + if ((s = bclear(bp)) != TRUE) /* Might be old. */ + return (s); + bp->b_flag &= ~(BFINVS | BFCHG); + strcpy(bp->b_fname, fname); /* let a user macro get hold of things...if he wants */ - execute(META|SPEC|'R', FALSE, 1); + execute(META | SPEC | 'R', FALSE, 1); /* turn off ALL keyboard translation in case we get a dos error */ TTkclose(); - if ((s=ffropen(fname)) == FIOERR) /* Hard file open. */ - goto out; + if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */ + goto out; - if (s == FIOFNF) { /* File not found. */ + if (s == FIOFNF) { /* File not found. */ mlwrite("(New file)"); - goto out; - } + goto out; + } /* read the file in */ mlwrite("(Reading file)"); - nline = 0; + nline = 0; lflag = FALSE; - while ((s=ffgetline()) == FIOSUC) { - nbytes = strlen(fline); - if ((lp1=lalloc(nbytes)) == NULL) { - s = FIOMEM; /* Keep message on the */ - break; /* display. */ - } + while ((s = ffgetline()) == FIOSUC) { + nbytes = strlen(fline); + if ((lp1 = lalloc(nbytes)) == NULL) { + s = FIOMEM; /* Keep message on the */ + break; /* display. */ + } #if PKCODE if (nline > MAXNLINE) { s = FIOMEM; break; } #endif - lp2 = lback(curbp->b_linep); - lp2->l_fp = lp1; - lp1->l_fp = curbp->b_linep; - lp1->l_bp = lp2; - curbp->b_linep->l_bp = lp1; - for (i=0; ib_linep); + lp2->l_fp = lp1; + lp1->l_fp = curbp->b_linep; + lp1->l_bp = lp2; + curbp->b_linep->l_bp = lp1; + for (i = 0; i < nbytes; ++i) + lputc(lp1, i, fline[i]); + ++nline; + } + ffclose(); /* Ignore errors. */ strcpy(mesg, "("); - if (s==FIOERR) { + if (s == FIOERR) { strcat(mesg, "I/O ERROR, "); curbp->b_flag |= BFTRUNC; } @@ -290,30 +290,30 @@ int lockfl; /* check for file locks? */ curbp->b_flag |= BFTRUNC; } sprintf(&mesg[strlen(mesg)], "Read %d line", nline); - if (nline != 1) + if (nline != 1) strcat(mesg, "s"); strcat(mesg, ")"); mlwrite(mesg); -out: - TTkopen(); /* open the keyboard again */ - for (wp=wheadp; wp!=NULL; wp=wp->w_wndp) { - if (wp->w_bufp == curbp) { - wp->w_linep = lforw(curbp->b_linep); - wp->w_dotp = lforw(curbp->b_linep); - wp->w_doto = 0; - wp->w_markp = NULL; - wp->w_marko = 0; - wp->w_flag |= WFMODE|WFHARD; - } - } - if (s == FIOERR || s == FIOFNF) /* False if error. */ - return(FALSE); + out: + TTkopen(); /* open the keyboard again */ + for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { + if (wp->w_bufp == curbp) { + wp->w_linep = lforw(curbp->b_linep); + wp->w_dotp = lforw(curbp->b_linep); + wp->w_doto = 0; + wp->w_markp = NULL; + wp->w_marko = 0; + wp->w_flag |= WFMODE | WFHARD; + } + } + if (s == FIOERR || s == FIOFNF) /* False if error. */ + return (FALSE); #if 0 if (s == ABORT) - return(ABORT); + return (ABORT); #endif - return (TRUE); + return (TRUE); } /* @@ -324,41 +324,43 @@ out: * a better place than a line of code. */ makename(bname, fname) -char bname[]; -char fname[]; +char bname[]; +char fname[]; { - register char *cp1; - register char *cp2; + register char *cp1; + register char *cp2; - cp1 = &fname[0]; - while (*cp1 != 0) - ++cp1; + cp1 = &fname[0]; + while (*cp1 != 0) + ++cp1; #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]!=']') + while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']') #endif - --cp1; + --cp1; #endif #if MSDOS - while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!='\\'&&cp1[-1]!='/') - --cp1; + while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != '\\' + && cp1[-1] != '/') + --cp1; #endif #if V7 | USG | BSD - while (cp1!=&fname[0] && cp1[-1]!='/') - --cp1; + while (cp1 != &fname[0] && cp1[-1] != '/') + --cp1; #endif - cp2 = &bname[0]; - while (cp2!=&bname[NBUFN-1] && *cp1!=0 && *cp1!=';') - *cp2++ = *cp1++; - *cp2 = 0; + cp2 = &bname[0]; + while (cp2 != &bname[NBUFN - 1] && *cp1 != 0 && *cp1 != ';') + *cp2++ = *cp1++; + *cp2 = 0; } -unqname(name) /* make sure a buffer name is unique */ - -char *name; /* name to check on */ +unqname(name) + /* make sure a buffer name is unique */ +char *name; /* name to check on */ { register char *sp; @@ -370,7 +372,7 @@ char *name; /* name to check on */ sp = name; while (*sp) ++sp; - if (sp == name || (*(sp-1) <'0' || *(sp-1) > '8')) { + if (sp == name || (*(sp - 1) < '0' || *(sp - 1) > '8')) { *sp++ = '0'; *sp = 0; } else @@ -389,25 +391,25 @@ char *name; /* name to check on */ */ filewrite(f, n) { - register WINDOW *wp; - register int s; - char fname[NFILEN]; + register WINDOW *wp; + register int s; + char fname[NFILEN]; if (restflag) /* don't allow this command if restricted */ - return(resterr()); - if ((s=mlreply("Write file: ", fname, NFILEN)) != TRUE) - return (s); - if ((s=writeout(fname)) == TRUE) { - strcpy(curbp->b_fname, fname); - curbp->b_flag &= ~BFCHG; - wp = wheadp; /* Update mode lines. */ - while (wp != NULL) { - if (wp->w_bufp == curbp) - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } - } - return (s); + return (resterr()); + if ((s = mlreply("Write file: ", fname, NFILEN)) != TRUE) + return (s); + if ((s = writeout(fname)) == TRUE) { + strcpy(curbp->b_fname, fname); + curbp->b_flag &= ~BFCHG; + wp = wheadp; /* Update mode lines. */ + while (wp != NULL) { + if (wp->w_bufp == curbp) + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } + } + return (s); } /* @@ -420,36 +422,36 @@ filewrite(f, n) */ filesave(f, n) { - register WINDOW *wp; - register int s; + register WINDOW *wp; + register int s; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if ((curbp->b_flag&BFCHG) == 0) /* Return, no changes. */ - return (TRUE); - if (curbp->b_fname[0] == 0) { /* Must have a name. */ - mlwrite("No file name"); - return (FALSE); - } + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */ + return (TRUE); + if (curbp->b_fname[0] == 0) { /* Must have a name. */ + mlwrite("No file name"); + return (FALSE); + } /* complain about truncated files */ - if ((curbp->b_flag&BFTRUNC) != 0) { + if ((curbp->b_flag & BFTRUNC) != 0) { if (mlyesno("Truncated file ... write it out") == FALSE) { mlwrite("(Aborted)"); - return(FALSE); + return (FALSE); } } - if ((s=writeout(curbp->b_fname)) == TRUE) { - curbp->b_flag &= ~BFCHG; - wp = wheadp; /* Update mode lines. */ - while (wp != NULL) { - if (wp->w_bufp == curbp) - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } - } - return (s); + if ((s = writeout(curbp->b_fname)) == TRUE) { + curbp->b_flag &= ~BFCHG; + wp = wheadp; /* Update mode lines. */ + while (wp != NULL) { + if (wp->w_bufp == curbp) + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } + } + return (s); } /* @@ -461,47 +463,47 @@ filesave(f, n) * checking of some sort. */ writeout(fn) -char *fn; +char *fn; { - register int s; - register LINE *lp; - register int nline; + register int s; + register LINE *lp; + register int nline; #if CRYPT s = resetkey(); if (s != TRUE) - return(s); + return (s); #endif /* turn off ALL keyboard translation in case we get a dos error */ TTkclose(); - if ((s=ffwopen(fn)) != FIOSUC) { /* Open writes message. */ + if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */ TTkopen(); - return (FALSE); - } - mlwrite("(Writing...)"); /* tell us were writing */ - lp = lforw(curbp->b_linep); /* First line. */ - nline = 0; /* Number of lines. */ - while (lp != curbp->b_linep) { - if ((s=ffputline(&lp->l_text[0], llength(lp))) != FIOSUC) - break; - ++nline; - lp = lforw(lp); - } - if (s == FIOSUC) { /* No write error. */ - s = ffclose(); - if (s == FIOSUC) { /* No close error. */ - if (nline == 1) + return (FALSE); + } + mlwrite("(Writing...)"); /* tell us were writing */ + lp = lforw(curbp->b_linep); /* First line. */ + nline = 0; /* Number of lines. */ + while (lp != curbp->b_linep) { + if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC) + break; + ++nline; + lp = lforw(lp); + } + if (s == FIOSUC) { /* No write error. */ + s = ffclose(); + if (s == FIOSUC) { /* No close error. */ + if (nline == 1) mlwrite("(Wrote 1 line)"); - else + else mlwrite("(Wrote %d lines)", nline); - } - } else /* Ignore close error */ - ffclose(); /* if a write error. */ + } + } else /* Ignore close error */ + ffclose(); /* if a write error. */ TTkopen(); - if (s != FIOSUC) /* Some sort of error. */ - return (FALSE); - return (TRUE); + if (s != FIOSUC) /* Some sort of error. */ + return (FALSE); + return (TRUE); } /* @@ -515,26 +517,26 @@ char *fn; */ filename(f, n) { - register WINDOW *wp; - register int s; - char fname[NFILEN]; + register WINDOW *wp; + register int s; + char fname[NFILEN]; if (restflag) /* don't allow this command if restricted */ - return(resterr()); - if ((s=mlreply("Name: ", fname, NFILEN)) == ABORT) - return (s); - if (s == FALSE) - strcpy(curbp->b_fname, ""); - else - strcpy(curbp->b_fname, fname); - wp = wheadp; /* Update mode lines. */ - while (wp != NULL) { - if (wp->w_bufp == curbp) - wp->w_flag |= WFMODE; - wp = wp->w_wndp; - } + return (resterr()); + if ((s = mlreply("Name: ", fname, NFILEN)) == ABORT) + return (s); + if (s == FALSE) + strcpy(curbp->b_fname, ""); + else + strcpy(curbp->b_fname, fname); + wp = wheadp; /* Update mode lines. */ + while (wp != NULL) { + if (wp->w_bufp == curbp) + wp->w_flag |= WFMODE; + wp = wp->w_wndp; + } curbp->b_mode &= ~MDVIEW; /* no longer read only mode */ - return (TRUE); + return (TRUE); } /* @@ -543,34 +545,34 @@ filename(f, n) * status of the read. */ ifile(fname) -char fname[]; +char fname[]; { - register LINE *lp0; - register LINE *lp1; - register LINE *lp2; - register int i; - register BUFFER *bp; - register int s; - register int nbytes; - register int nline; - int lflag; /* any lines longer than allowed? */ + register LINE *lp0; + register LINE *lp1; + register LINE *lp2; + register int i; + register BUFFER *bp; + register int s; + register int nbytes; + register int nline; + int lflag; /* any lines longer than allowed? */ char mesg[NSTRING]; - bp = curbp; /* Cheap. */ - bp->b_flag |= BFCHG; /* we have changed */ - bp->b_flag &= ~BFINVS; /* and are not temporary*/ - if ((s=ffropen(fname)) == FIOERR) /* Hard file open. */ - goto out; - if (s == FIOFNF) { /* File not found. */ + bp = curbp; /* Cheap. */ + bp->b_flag |= BFCHG; /* we have changed */ + bp->b_flag &= ~BFINVS; /* and are not temporary */ + if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */ + goto out; + if (s == FIOFNF) { /* File not found. */ mlwrite("(No such file)"); - return(FALSE); - } + return (FALSE); + } mlwrite("(Inserting file)"); #if CRYPT s = resetkey(); if (s != TRUE) - return(s); + return (s); #endif /* back up a line and save the mark here */ curwp->w_dotp = lback(curwp->w_dotp); @@ -578,14 +580,14 @@ char fname[]; curwp->w_markp = curwp->w_dotp; curwp->w_marko = 0; - nline = 0; + nline = 0; lflag = FALSE; - while ((s=ffgetline()) == FIOSUC) { - nbytes = strlen(fline); - if ((lp1=lalloc(nbytes)) == NULL) { - s = FIOMEM; /* Keep message on the */ - break; /* display. */ - } + while ((s = ffgetline()) == FIOSUC) { + nbytes = strlen(fline); + if ((lp1 = lalloc(nbytes)) == NULL) { + s = FIOMEM; /* Keep message on the */ + break; /* display. */ + } lp0 = curwp->w_dotp; /* line previous to insert */ lp2 = lp0->l_fp; /* line after insert */ @@ -597,14 +599,14 @@ char fname[]; /* and advance and write out the current line */ curwp->w_dotp = lp1; - for (i=0; iw_markp = lforw(curwp->w_markp); strcpy(mesg, "("); - if (s==FIOERR) { + if (s == FIOERR) { strcat(mesg, "I/O ERROR, "); curbp->b_flag |= BFTRUNC; } @@ -613,12 +615,12 @@ char fname[]; curbp->b_flag |= BFTRUNC; } sprintf(&mesg[strlen(mesg)], "Inserted %d line", nline); - if (nline > 1) + if (nline > 1) strcat(mesg, "s"); strcat(mesg, ")"); mlwrite(mesg); -out: + out: /* advance to the next line and mark the window for changes */ curwp->w_dotp = lforw(curwp->w_dotp); curwp->w_flag |= WFHARD | WFMODE; @@ -629,7 +631,7 @@ out: curbp->b_markp = curwp->w_markp; curbp->b_marko = curwp->w_marko; - if (s == FIOERR) /* False if error. */ - return (FALSE); - return (TRUE); + if (s == FIOERR) /* False if error. */ + return (FALSE); + return (TRUE); } diff --git a/fileio.c b/fileio.c index 55e571a..66a2e27 100644 --- a/fileio.c +++ b/fileio.c @@ -14,19 +14,19 @@ extern int nullflag; #endif -FILE *ffp; /* File pointer, all functions. */ -int eofflag; /* end-of-file flag */ +FILE *ffp; /* File pointer, all functions. */ +int eofflag; /* end-of-file flag */ /* * Open a file for reading. */ ffropen(fn) -char *fn; +char *fn; { - if ((ffp=fopen(fn, "r")) == NULL) - return (FIOFNF); + if ((ffp = fopen(fn, "r")) == NULL) + return (FIOFNF); eofflag = FALSE; - return (FIOSUC); + return (FIOSUC); } /* @@ -34,20 +34,20 @@ char *fn; * (cannot create). */ ffwopen(fn) -char *fn; +char *fn; { #if VMS - register int fd; + register int fd; - if ((fd=creat(fn, 0666, "rfm=var", "rat=cr")) < 0 - || (ffp=fdopen(fd, "w")) == NULL) { + if ((fd = creat(fn, 0666, "rfm=var", "rat=cr")) < 0 + || (ffp = fdopen(fd, "w")) == NULL) { #else - if ((ffp=fopen(fn, "w")) == NULL) { + if ((ffp = fopen(fn, "w")) == NULL) { #endif - mlwrite("Cannot open file for writing"); - return (FIOERR); - } - return (FIOSUC); + mlwrite("Cannot open file for writing"); + return (FIOERR); + } + return (FIOSUC); } /* @@ -65,16 +65,16 @@ ffclose() #if MSDOS & CTRLZ fputc(26, ffp); /* add a ^Z at the end of the file */ #endif - + #if V7 | USG | BSD | (MSDOS & (MSC | TURBO)) - if (fclose(ffp) != FALSE) { - mlwrite("Error closing file"); - return(FIOERR); - } - return(FIOSUC); + if (fclose(ffp) != FALSE) { + mlwrite("Error closing file"); + return (FIOERR); + } + return (FIOSUC); #else - fclose(ffp); - return (FIOSUC); + fclose(ffp); + return (FIOSUC); #endif } @@ -84,34 +84,34 @@ ffclose() * Check only at the newline. */ ffputline(buf, nbuf) -char buf[]; +char buf[]; { - register int i; + register int i; #if CRYPT - char c; /* character to translate */ + char c; /* character to translate */ if (cryptflag) { - for (i = 0; i < nbuf; ++i) { + for (i = 0; i < nbuf; ++i) { c = buf[i] & 0xff; crypt(&c, 1); fputc(c, ffp); } } else - for (i = 0; i < nbuf; ++i) - fputc(buf[i]&0xFF, ffp); + for (i = 0; i < nbuf; ++i) + fputc(buf[i] & 0xFF, ffp); #else - for (i = 0; i < nbuf; ++i) - fputc(buf[i]&0xFF, ffp); + for (i = 0; i < nbuf; ++i) + fputc(buf[i] & 0xFF, ffp); #endif - fputc('\n', ffp); + fputc('\n', ffp); - if (ferror(ffp)) { - mlwrite("Write I/O error"); - return (FIOERR); - } + if (ferror(ffp)) { + mlwrite("Write I/O error"); + return (FIOERR); + } - return (FIOSUC); + return (FIOSUC); } /* @@ -121,15 +121,14 @@ char buf[]; * errors too. Return status. */ ffgetline() - { - register int c; /* current character read */ - register int i; /* current index into fline */ + register int c; /* current character read */ + register int i; /* current index into fline */ register char *tmpline; /* temp storage for expanding line */ /* if we are at the end...return it */ if (eofflag) - return(FIOEOF); + return (FIOEOF); /* dump fline if it ended up too big */ if (flen > NSTRING) { @@ -140,77 +139,76 @@ ffgetline() /* if we don't have an fline, allocate one */ if (fline == NULL) if ((fline = malloc(flen = NSTRING)) == NULL) - return(FIOMEM); + return (FIOMEM); /* read the line in */ #if PKCODE if (!nullflag) { - if (fgets(fline, NSTRING, ffp) == (char *)NULL) { /* EOF ? */ - i = 0; - c = EOF; - } - else { - i = strlen(fline); - c = 0; - if (i > 0) { - c = fline[i-1]; - i--; + if (fgets(fline, NSTRING, ffp) == (char *) NULL) { /* EOF ? */ + i = 0; + c = EOF; + } else { + i = strlen(fline); + c = 0; + if (i > 0) { + c = fline[i - 1]; + i--; + } } - } - } - else { + } else { i = 0; c = fgetc(ffp); } while (c != EOF && c != '\n') { #else - i = 0; - while ((c = fgetc(ffp)) != EOF && c != '\n') { + i = 0; + while ((c = fgetc(ffp)) != EOF && c != '\n') { #endif #if PKCODE - if (c) { + if (c) { #endif - fline[i++] = c; - /* if it's longer, get more room */ - if (i >= flen) { - if ((tmpline = malloc(flen+NSTRING)) == NULL) - return(FIOMEM); - strncpy(tmpline, fline, flen); - flen += NSTRING; - free(fline); - fline = tmpline; - } + fline[i++] = c; + /* if it's longer, get more room */ + if (i >= flen) { + if ((tmpline = + malloc(flen + NSTRING)) == NULL) + return (FIOMEM); + strncpy(tmpline, fline, flen); + flen += NSTRING; + free(fline); + fline = tmpline; + } #if PKCODE - } + } c = fgetc(ffp); #endif - } + } /* test for any errors that may have occured */ - if (c == EOF) { - if (ferror(ffp)) { - mlwrite("File read error"); - return(FIOERR); - } + if (c == EOF) { + if (ferror(ffp)) { + mlwrite("File read error"); + return (FIOERR); + } - if (i != 0) + if (i != 0) eofflag = TRUE; else - return(FIOEOF); - } + return (FIOEOF); + } /* terminate and decrypt the string */ - fline[i] = 0; + fline[i] = 0; #if CRYPT if (cryptflag) crypt(fline, strlen(fline)); #endif - return(FIOSUC); + return (FIOSUC); } -int fexist(fname) /* does exist on disk? */ - -char *fname; /* file to check for existance */ +int fexist(fname) + /* does exist on disk? */ +char *fname; /* file to check for existance */ { FILE *fp; @@ -220,9 +218,9 @@ char *fname; /* file to check for existance */ /* if it fails, just return false! */ if (fp == NULL) - return(FALSE); + return (FALSE); /* otherwise, close it and report true */ fclose(fp); - return(TRUE); + return (TRUE); } diff --git a/ibmpc.c b/ibmpc.c index 37ddde9..c183e56 100644 --- a/ibmpc.c +++ b/ibmpc.c @@ -8,7 +8,7 @@ * modified by Petri Kutvonen */ -#define termdef 1 /* don't define "term" external */ +#define termdef 1 /* don't define "term" external */ #include #include "estruct.h" @@ -18,80 +18,80 @@ #if PKCODE #define NROW 50 #else -#define NROW 43 /* Max Screen size. */ +#define NROW 43 /* Max Screen size. */ #endif -#define NCOL 80 /* Edit if you want to. */ -#define MARGIN 8 /* size of minimim margin and */ -#define SCRSIZ 64 /* scroll size for extended lines */ -#define NPAUSE 200 /* # times thru update to pause */ -#define BEL 0x07 /* BEL character. */ -#define ESC 0x1B /* ESC character. */ -#define SPACE 32 /* space character */ +#define NCOL 80 /* Edit if you want to. */ +#define MARGIN 8 /* size of minimim margin and */ +#define SCRSIZ 64 /* scroll size for extended lines */ +#define NPAUSE 200 /* # times thru update to pause */ +#define BEL 0x07 /* BEL character. */ +#define ESC 0x1B /* ESC character. */ +#define SPACE 32 /* space character */ -#define SCADC 0xb8000000L /* CGA address of screen RAM */ -#define SCADM 0xb0000000L /* MONO address of screen RAM */ -#define SCADE 0xb8000000L /* EGA address of screen RAM */ +#define SCADC 0xb8000000L /* CGA address of screen RAM */ +#define SCADM 0xb0000000L /* MONO address of screen RAM */ +#define SCADE 0xb8000000L /* EGA address of screen RAM */ -#define MONOCRSR 0x0B0D /* monochrome cursor */ -#define CGACRSR 0x0607 /* CGA cursor */ -#define EGACRSR 0x0709 /* EGA cursor */ +#define MONOCRSR 0x0B0D /* monochrome cursor */ +#define CGACRSR 0x0607 /* CGA cursor */ +#define EGACRSR 0x0709 /* EGA cursor */ -#define CDCGA 0 /* color graphics card */ -#define CDMONO 1 /* monochrome text card */ -#define CDEGA 2 /* EGA color adapter */ +#define CDCGA 0 /* color graphics card */ +#define CDMONO 1 /* monochrome text card */ +#define CDEGA 2 /* EGA color adapter */ #if PKCODE #define CDVGA 3 #endif -#define CDSENSE 9 /* detect the card type */ +#define CDSENSE 9 /* detect the card type */ #if PKCODE #define NDRIVE 4 #else -#define NDRIVE 3 /* number of screen drivers */ +#define NDRIVE 3 /* number of screen drivers */ #endif -int dtype = -1; /* current display type */ -char drvname[][8] = { /* screen resolution names */ +int dtype = -1; /* current display type */ +char drvname[][8] = { /* screen resolution names */ "CGA", "MONO", "EGA" #if PKCODE - ,"VGA" + , "VGA" #endif }; -long scadd; /* address of screen ram */ -int *scptr[NROW]; /* pointer to screen lines */ -unsigned int sline[NCOL]; /* screen line image */ -int egaexist = FALSE; /* is an EGA card available? */ -extern union REGS rg; /* cpu register for use of DOS calls */ +long scadd; /* address of screen ram */ +int *scptr[NROW]; /* pointer to screen lines */ +unsigned int sline[NCOL]; /* screen line image */ +int egaexist = FALSE; /* is an EGA card available? */ +extern union REGS rg; /* cpu register for use of DOS calls */ -extern int ttopen(); /* Forward references. */ -extern int ttgetc(); -extern int ttputc(); -extern int ttflush(); -extern int ttclose(); -extern int ibmmove(); -extern int ibmeeol(); -extern int ibmeeop(); -extern int ibmbeep(); -extern int ibmopen(); -extern int ibmrev(); -extern int ibmcres(); -extern int ibmclose(); -extern int ibmputc(); -extern int ibmkopen(); -extern int ibmkclose(); +extern int ttopen(); /* Forward references. */ +extern int ttgetc(); +extern int ttputc(); +extern int ttflush(); +extern int ttclose(); +extern int ibmmove(); +extern int ibmeeol(); +extern int ibmeeop(); +extern int ibmbeep(); +extern int ibmopen(); +extern int ibmrev(); +extern int ibmcres(); +extern int ibmclose(); +extern int ibmputc(); +extern int ibmkopen(); +extern int ibmkclose(); #if COLOR -extern int ibmfcol(); -extern int ibmbcol(); -extern int ibmscroll_reg(); +extern int ibmfcol(); +extern int ibmbcol(); +extern int ibmscroll_reg(); -int cfcolor = -1; /* current forground color */ -int cbcolor = -1; /* current background color */ -int ctrans[] = /* ansi to ibm color translation table */ +int cfcolor = -1; /* current forground color */ +int cbcolor = -1; /* current background color */ +int ctrans[] = /* ansi to ibm color translation table */ #if PKCODE - {0, 4, 2, 6, 1, 5, 3, 7, 15}; +{ 0, 4, 2, 6, 1, 5, 3, 7, 15 }; #else - {0, 4, 2, 6, 1, 5, 3, 7}; +{ 0, 4, 2, 6, 1, 5, 3, 7 }; #endif #endif @@ -99,51 +99,51 @@ int ctrans[] = /* ansi to ibm color translation table */ * Standard terminal interface dispatch table. Most of the fields point into * "termio" code. */ -TERM term = { - NROW-1, - NROW-1, - NCOL, - NCOL, +TERM term = { + NROW - 1, + NROW - 1, + NCOL, + NCOL, MARGIN, SCRSIZ, NPAUSE, - ibmopen, - ibmclose, + ibmopen, + ibmclose, ibmkopen, ibmkclose, - ttgetc, + ttgetc, ibmputc, - ttflush, - ibmmove, - ibmeeol, - ibmeeop, - ibmbeep, + ttflush, + ibmmove, + ibmeeol, + ibmeeop, + ibmbeep, ibmrev, ibmcres #if COLOR - , ibmfcol, + , ibmfcol, ibmbcol #endif #if SCROLLCODE - , ibmscroll_reg + , ibmscroll_reg #endif }; #if COLOR -ibmfcol(color) /* set the current output color */ - -int color; /* color to set */ +ibmfcol(color) + /* set the current output color */ +int color; /* color to set */ { cfcolor = ctrans[color]; } -ibmbcol(color) /* set the current background color */ - -int color; /* color to set */ +ibmbcol(color) + /* set the current background color */ +int color; /* color to set */ { - cbcolor = ctrans[color]; + cbcolor = ctrans[color]; } #endif @@ -156,14 +156,13 @@ 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; - int ccol; /* current column cursor lives */ - int crow; /* row */ + int ccol; /* current column cursor lives */ + int crow; /* row */ /* find the current cursor position */ rg.h.ah = 3; /* read cursor position function code */ @@ -182,27 +181,25 @@ ibmeeol() /* erase to the end of the line */ attr = 0x0700; #endif lnptr = &sline[0]; - for (i=0; i < term.t_ncol; i++) + for (i = 0; i < term.t_ncol; i++) *lnptr++ = SPACE | attr; 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 */ - movmem(&sline[0], scptr[crow]+ccol, (term.t_ncol-ccol)*2); + movmem(&sline[0], scptr[crow] + ccol, (term.t_ncol - ccol) * 2); } -ibmputc(ch) /* put a character at the current position in the - current colors */ - +ibmputc(ch) + /* put a character at the current position in the + current colors */ int ch; { @@ -227,10 +224,11 @@ ibmeeop() rg.h.al = 0; /* # lines to scroll (clear it) */ rg.x.cx = 0; /* upper left corner of scroll */ rg.x.dx = (term.t_nrow << 8) | (term.t_ncol - 1); - /* lower right corner of scroll */ + /* 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,27 +238,27 @@ ibmeeop() int86(0x10, &rg, &rg); } -ibmrev(state) /* change reverse video state */ - -int state; /* TRUE = reverse, FALSE = normal */ +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 */ - -char *res; /* resolution to change to */ +ibmcres(res) + /* change screen resolution */ +char *res; /* resolution to change to */ { - int i; /* index */ + int i; /* index */ for (i = 0; i < NDRIVE; i++) if (strcmp(res, drvname[i]) == 0) { scinit(i); - return(TRUE); + return (TRUE); } - return(FALSE); + return (FALSE); } #if SCROLLCODE @@ -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) - 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); + else if (to > from) + for (i = howmany - 1; i >= 0; i--) + 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..... */ } @@ -297,11 +295,10 @@ ibmopen() { scinit(CDSENSE); revexist = TRUE; - ttopen(); + ttopen(); } ibmclose() - { #if COLOR ibmfcol(7); @@ -318,19 +315,17 @@ 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 */ - -int type; /* type of adapter to init for */ +scinit(type) + /* initialize the screen head pointers */ +int type; /* type of adapter to init for */ { union { @@ -345,11 +340,11 @@ int type; /* type of adapter to init for */ /* if we have nothing to do....don't do it */ if (dtype == type) - return(TRUE); + return (TRUE); /* if we try to switch to EGA and there is none, don't */ if (type == CDEGA && egaexist != TRUE) - return(FALSE); + return (FALSE); /* if we had the EGA open... close it */ if (dtype == CDEGA) @@ -361,26 +356,26 @@ int type; /* type of adapter to init for */ /* and set up the various parameters as needed */ switch (type) { - case CDMONO: /* Monochrome adapter */ - scadd = SCADM; - newsize(TRUE, 25); - break; + case CDMONO: /* Monochrome adapter */ + scadd = SCADM; + newsize(TRUE, 25); + break; - case CDCGA: /* Color graphics adapter */ - scadd = SCADC; - newsize(TRUE, 25); - break; + case CDCGA: /* Color graphics adapter */ + scadd = SCADC; + newsize(TRUE, 25); + break; - case CDEGA: /* Enhanced graphics adapter */ - scadd = SCADE; - egaopen(); - newsize(TRUE, 43); - break; - case CDVGA: /* Enhanced graphics adapter */ - scadd = SCADE; - egaopen(); - newsize(TRUE, 50); - break; + case CDEGA: /* Enhanced graphics adapter */ + scadd = SCADE; + egaopen(); + newsize(TRUE, 43); + break; + case CDVGA: /* Enhanced graphics adapter */ + scadd = SCADE; + egaopen(); + newsize(TRUE, 50); + break; } /* reset the $sres environment variable */ @@ -389,10 +384,10 @@ int type; /* type of adapter to init for */ /* initialize the screen pointer array */ for (i = 0; i < NROW; i++) { - addr.laddr = scadd + (long)(NCOL * i * 2); + addr.laddr = scadd + (long) (NCOL * i * 2); scptr[i] = addr.paddr; } - return(TRUE); + return (TRUE); } /* getboard: Determine which type of display board is attached. @@ -410,9 +405,8 @@ int type; /* type of adapter to init for */ */ int getboard() - { - int type; /* board type to return */ + int type; /* board type to return */ type = CDCGA; int86(0x11, &rg, &rg); @@ -422,14 +416,13 @@ int getboard() /* test if EGA present */ rg.x.ax = 0x1200; rg.x.bx = 0xff10; - int86(0x10,&rg, &rg); /* If EGA, bh=0-1 and bl=0-3 */ + int86(0x10, &rg, &rg); /* If EGA, bh=0-1 and bl=0-3 */ egaexist = !(rg.x.bx & 0xfefc); /* Yes, it's EGA */ - return(type); + return (type); } -egaopen() /* init the computer to work with the EGA */ - -{ +egaopen() +{ /* init the computer to work with the EGA */ /* put the beast into EGA 43 row mode */ rg.x.ax = 3; int86(16, &rg, &rg); @@ -453,19 +446,18 @@ 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*/ - -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 */ -int bacg; /* background color */ +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 */ +int bacg; /* background color */ { unsigned int attr; /* attribute byte mask to place in RAM */ @@ -475,38 +467,38 @@ 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 attr = (((bacg & 15) << 4) | (forg & 15)) << 8; #endif lnptr = &sline[0]; - for (i=0; i=0x00 && c<=0x1F) - c = CONTROL | (c+'@'); - return (c); + if (c >= 0x00 && c <= 0x1F) + c = CONTROL | (c + '@'); + return (c); } - + /* get a command name from the command line. Command completion means that pressing a will attempt to complete an unfinished command name if it is unique. */ -int (*getname())() - +int (*getname()) () { register int cpos; /* current column on screen output */ register int c; @@ -124,7 +123,7 @@ int (*getname())() register NBIND *cffp; /* current ptr to entry in name binding table */ register NBIND *lffp; /* last ptr to entry in name binding table */ char buf[NSTRING]; /* buffer to hold tentative command name */ - int (*fncmatch())(); + int (*fncmatch()) (); /* starting at the beginning of the string buffer */ cpos = 0; @@ -132,8 +131,8 @@ int (*getname())() /* if we are executing a command line get the next arg and match it */ if (clexec) { if (macarg(buf) != TRUE) - return(FALSE); - return(fncmatch(&buf[0])); + return (FALSE); + return (fncmatch(&buf[0])); } /* build a name string from the keyboard */ @@ -145,12 +144,12 @@ int (*getname())() buf[cpos] = 0; /* and match it off */ - return(fncmatch(&buf[0])); + return (fncmatch(&buf[0])); } else if (c == ectoc(abortc)) { /* Bell, abort */ ctrlg(FALSE, 0); TTflush(); - return( (int (*)()) NULL); + return ((int (*)()) NULL); } else if (c == 0x7F || c == 0x08) { /* rubout/erase */ if (cpos != 0) { @@ -175,61 +174,80 @@ int (*getname())() } else if (c == ' ' || c == 0x1b || c == 0x09) { /* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ - /* attempt a completion */ - 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) { - /* a possible match! More than one? */ - if ((ffp + 1)->n_func == NULL || - (strncmp(buf, (ffp+1)->n_name, strlen(buf)) != 0)) { - /* no...we match, print it */ - sp = ffp->n_name + cpos; - while (*sp) - TTputc(*sp++); - TTflush(); - return(ffp->n_func); - } else { + /* attempt a completion */ + 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) { + /* a possible match! More than one? */ + if ((ffp + 1)->n_func == NULL || + (strncmp + (buf, (ffp + 1)->n_name, + strlen(buf)) != 0)) { + /* no...we match, print it */ + sp = ffp->n_name + cpos; + while (*sp) + TTputc(*sp++); + TTflush(); + return (ffp->n_func); + } else { /* << << << << << << << << << << << << << << << << << */ - /* try for a partial match against the list */ + /* try for a partial match against the list */ - /* 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) - break; - ++lffp; - } + /* 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) + break; + ++lffp; + } - /* 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]; + /* 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]; - /* scan through the candidates */ - cffp = ffp + 1; - while (cffp <= lffp) { - if (cffp->n_name[cpos] != buf[cpos]) - goto onward; - ++cffp; - } + /* scan through the candidates */ + cffp = ffp + 1; + while (cffp <= + lffp) { + if (cffp-> + n_name + [cpos] + != + buf + [cpos]) + goto onward; + ++cffp; + } - /* add the character */ - TTputc(buf[cpos++]); - } + /* add the character */ + TTputc(buf + [cpos++]); + } /* << << << << << << << << << << << << << << << << << */ + } + } + ++ffp; } - } - ++ffp; - } - /* no match.....beep and onward */ - TTbeep(); -onward:; - TTflush(); + /* no match.....beep and onward */ + TTbeep(); + onward:; + TTflush(); /* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ } else { - if (cpos < NSTRING-1 && c > ' ') { + if (cpos < NSTRING - 1 && c > ' ') { buf[cpos++] = c; TTputc(c); } @@ -244,16 +262,15 @@ onward:; macro action */ int tgetc() - { - int c; /* fetched character */ + int c; /* fetched character */ /* if we are playing a keyboard macro back, */ if (kbdmode == PLAY) { /* if there is some left... */ if (kbdptr < kbdend) - return((int)*kbdptr++); + return ((int) *kbdptr++); /* at the end of last repitition? */ if (--kbdrep < 1) { @@ -266,7 +283,7 @@ int tgetc() /* reset the macro to the begining for the next rep */ kbdptr = &kbdm[0]; - return((int)*kbdptr++); + return ((int) *kbdptr++); } } @@ -289,7 +306,7 @@ int tgetc() } /* and finally give the char back */ - return(c); + return (c); } /* GET1KEY: Get one keystroke. The only prefixs legal here @@ -297,43 +314,41 @@ int tgetc() */ get1key() - { - int c; + int c; /* get a keystroke */ - c = tgetc(); + c = tgetc(); -#if MSDOS - if (c == 0) { /* Apply SPEC prefix */ - c = tgetc(); - if (c>=0x00 && c<=0x1F) /* control key? */ - c = CONTROL | (c+'@'); - return(SPEC | c); +#if MSDOS + if (c == 0) { /* Apply SPEC prefix */ + c = tgetc(); + if (c >= 0x00 && c <= 0x1F) /* control key? */ + c = CONTROL | (c + '@'); + return (SPEC | c); } #endif - if (c>=0x00 && c<=0x1F) /* C0 control -> C- */ - c = CONTROL | (c+'@'); - return (c); + if (c >= 0x00 && c <= 0x1F) /* C0 control -> C- */ + c = CONTROL | (c + '@'); + return (c); } /* GETCMD: Get a command from the keyboard. Process all applicable prefix keys */ getcmd() - { - int c; /* fetched keystroke */ + int c; /* fetched keystroke */ #if VT220 - int d; /* second character P.K. */ + int d; /* second character P.K. */ int cmask = 0; #endif /* get initial character */ c = get1key(); #if VT220 -proc_metac: + proc_metac: #endif /* process META prefix */ if (c == (CONTROL | '[')) { @@ -342,32 +357,35 @@ proc_metac: if (c == '[' || c == 'O') { /* CSI P.K. */ c = get1key(); if (c >= 'A' && c <= 'D') - return(SPEC | c | cmask); + return (SPEC | c | cmask); if (c >= 'E' && c <= 'z' && c != 'i' && c != 'c') - return(SPEC | c | cmask); + return (SPEC | c | cmask); d = get1key(); - if (d == '~') /* ESC [ n ~ P.K. */ - return(SPEC | c | cmask); - switch (c) { /* ESC [ n n ~ P.K. */ - case '1': c = d + 32; - break; - case '2': c = d + 48; - break; - case '3': c = d + 64; - break; - default: c = '?'; - break; + if (d == '~') /* ESC [ n ~ P.K. */ + return (SPEC | c | cmask); + switch (c) { /* ESC [ n n ~ P.K. */ + case '1': + c = d + 32; + break; + case '2': + c = d + 48; + break; + case '3': + c = d + 64; + break; + default: + c = '?'; + break; } - if (d != '~') /* eat tilde P.K. */ + if (d != '~') /* eat tilde P.K. */ get1key(); - if (c == 'i') { /* DO key P.K. */ + 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); + return (SPEC | c | cmask); } #endif #if VT220 @@ -376,15 +394,14 @@ proc_metac: goto proc_metac; } #endif - if (islower(c)) /* Force to upper */ - c ^= DIFCASE; - if (c>=0x00 && c<=0x1F) /* control key */ - c = CONTROL | (c+'@'); - return(META | c ); + if (islower(c)) /* Force to upper */ + c ^= DIFCASE; + if (c >= 0x00 && c <= 0x1F) /* control key */ + c = CONTROL | (c + '@'); + return (META | c); } #if PKCODE - else - if (c == metac) { + else if (c == metac) { c = get1key(); #if VT220 if (c == (CONTROL | '[')) { @@ -392,17 +409,17 @@ proc_metac: goto proc_metac; } #endif - if (islower(c)) /* Force to upper */ - c ^= DIFCASE; - if (c>=0x00 && c<=0x1F) /* control key */ - c = CONTROL | (c+'@'); - return(META | c ); + if (islower(c)) /* Force to upper */ + c ^= DIFCASE; + if (c >= 0x00 && c <= 0x1F) /* control key */ + c = CONTROL | (c + '@'); + return (META | c); } #endif #if VT220 -proc_ctlxc: + proc_ctlxc: #endif /* process CTLX prefix */ if (c == ctlxc) { @@ -413,15 +430,15 @@ proc_ctlxc: goto proc_metac; } #endif - if (c>='a' && c<='z') /* Force to upper */ - c -= 0x20; - if (c>=0x00 && c<=0x1F) /* control key */ - c = CONTROL | (c+'@'); - return(CTLX | c); + if (c >= 'a' && c <= 'z') /* Force to upper */ + c -= 0x20; + if (c >= 0x00 && c <= 0x1F) /* control key */ + c = CONTROL | (c + '@'); + return (CTLX | c); } /* otherwise, just return it */ - return(c); + return (c); } /* A more generalized prompt/reply function allowing the caller @@ -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 */ @@ -447,11 +466,11 @@ char *prompt; char *buf; int eolchar; FILE *tmpf = NULL; #endif ffile = (strcmp(prompt, "Find file: ") == 0 - || strcmp(prompt, "View file: ") == 0 - || strcmp(prompt, "Insert file: ") == 0 - || strcmp(prompt, "Write file: ") == 0 - || strcmp(prompt, "Read file: ") == 0 - || strcmp(prompt, "File to execute: ") == 0); + || strcmp(prompt, "View file: ") == 0 + || strcmp(prompt, "Insert file: ") == 0 + || strcmp(prompt, "Write file: ") == 0 + || strcmp(prompt, "Read file: ") == 0 + || strcmp(prompt, "File to execute: ") == 0); #endif cpos = 0; @@ -462,7 +481,7 @@ char *prompt; char *buf; int eolchar; for (;;) { #if COMPLC - if (! didtry) + if (!didtry) nskip = -1; didtry = 0; #endif @@ -487,9 +506,9 @@ char *prompt; char *buf; int eolchar; /* if we default the buffer, return FALSE */ if (buf[0] == 0) - return(FALSE); + return (FALSE); - return(TRUE); + return (TRUE); } /* change from command form back to character form */ @@ -499,8 +518,8 @@ char *prompt; char *buf; int eolchar; /* Abort the input? */ ctrlg(FALSE, 0); TTflush(); - return(ABORT); - } else if ((c==0x7F || c==0x08) && quotef==FALSE) { + return (ABORT); + } else if ((c == 0x7F || c == 0x08) && quotef == FALSE) { /* rubout/erase */ if (cpos != 0) { outstring("\b \b"); @@ -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 @@ -563,14 +583,14 @@ char *prompt; char *buf; int eolchar; iswild = 1; #if MSDOS if (lsav < 0 && (buf[cpos] == '\\' || - buf[cpos] == '/' || - buf[cpos] == ':' && cpos == 1)) + buf[cpos] == '/' || + buf[cpos] == ':' + && cpos == 1)) lsav = cpos; #endif } TTflush(); - if (nskip < 0) - { + if (nskip < 0) { buf[ocpos] = 0; #if UNIX if (tmpf != NULL) @@ -578,8 +598,8 @@ char *prompt; char *buf; int eolchar; strcpy(tmp, "/tmp/meXXXXXX"); strcpy(ffbuf, "echo "); strcat(ffbuf, buf); - if (! iswild) - strcat(ffbuf,"*"); + if (!iswild) + strcat(ffbuf, "*"); strcat(ffbuf, " >"); mktemp(tmp); strcat(ffbuf, tmp); @@ -589,49 +609,47 @@ char *prompt; char *buf; int eolchar; #endif #if MSDOS strcpy(sffbuf, buf); - if (! iswild) - strcat(sffbuf,"*.*"); + if (!iswild) + strcat(sffbuf, "*.*"); #endif nskip = 0; } #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 - { - strncpy(buf, sffbuf, lsav+1); - cpos = lsav+1; - fcp = ffblk.ff_name; - } + if (c == '*') + fcp = sffbuf; + else { + strncpy(buf, sffbuf, lsav + 1); + cpos = lsav + 1; + fcp = ffblk.ff_name; + } while (c != 0 && (c = *fcp++) != 0 && c != '*') #endif { - if (cpos < nbuf-1) + if (cpos < nbuf - 1) buf[cpos++] = c; } #if UNIX @@ -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("^"); @@ -668,7 +685,7 @@ char *prompt; char *buf; int eolchar; quotef = TRUE; } else { quotef = FALSE; - if (cpos < nbuf-1) { + if (cpos < nbuf - 1) { buf[cpos++] = c; if ((c < ' ') && (c != '\n')) { @@ -691,9 +708,9 @@ char *prompt; char *buf; int eolchar; } } -outstring(s) /* output a string of characters */ - -char *s; /* string to output */ +outstring(s) + /* output a string of characters */ +char *s; /* string to output */ { if (disinp) @@ -701,13 +718,12 @@ char *s; /* string to output */ TTputc(*s++); } -ostring(s) /* output a string of output characters */ - -char *s; /* string to output */ +ostring(s) + /* output a string of output characters */ +char *s; /* string to output */ { if (discmd) while (*s) TTputc(*s++); } - diff --git a/isearch.c b/isearch.c index 0f65069..eebac79 100644 --- a/isearch.c +++ b/isearch.c @@ -28,51 +28,51 @@ #if ISRCH -extern int scanner(); /* Handy search routine */ -extern int eq(); /* Compare chars, match case */ +extern int scanner(); /* Handy search routine */ +extern int eq(); /* Compare chars, match case */ /* A couple of "own" variables for re-eat */ -int (*saved_get_char)(); /* Get character routine */ -int eaten_char = -1; /* Re-eaten char */ +int (*saved_get_char) (); /* Get character routine */ +int eaten_char = -1; /* Re-eaten char */ /* A couple more "own" variables for the command string */ -int cmd_buff[CMDBUFLEN]; /* Save the command args here */ -int cmd_offset; /* Current offset into command buff */ -int cmd_reexecute = -1; /* > 0 if re-executing command */ +int cmd_buff[CMDBUFLEN]; /* Save the command args here */ +int cmd_offset; /* Current offset into command buff */ +int cmd_reexecute = -1; /* > 0 if re-executing command */ /* * Subroutine to do incremental reverse search. It actually uses the * same code as the normal incremental search, as both can go both ways. */ - + int risearch(f, n) { - LINE *curline; /* Current line on entry */ - int curoff; /* Current offset on entry */ + LINE *curline; /* Current line on entry */ + int curoff; /* Current offset on entry */ - /* remember the initial . on entry: */ + /* remember the initial . on entry: */ - curline = curwp->w_dotp; /* Save the current line pointer */ - curoff = curwp->w_doto; /* Save the current offset */ + curline = curwp->w_dotp; /* Save the current line pointer */ + curoff = curwp->w_doto; /* Save the current offset */ - /* Make sure the search doesn't match where we already are: */ + /* Make sure the search doesn't match where we already are: */ - backchar(TRUE, 1); /* Back up a character */ + backchar(TRUE, 1); /* Back up a character */ - 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 */ - update(FALSE); /* And force an update */ - mlwrite ("(search failed)"); /* Say we died */ + 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 */ + update(FALSE); /* And force an update */ + mlwrite("(search failed)"); /* Say we died */ #if PKCODE - matchlen = strlen(pat); + 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 @@ -82,27 +82,27 @@ int risearch(f, n) int fisearch(f, n) { - LINE *curline; /* Current line on entry */ - int curoff; /* Current offset on entry */ + LINE *curline; /* Current line on entry */ + int curoff; /* Current offset on entry */ - /* remember the initial . on entry: */ + /* remember the initial . on entry: */ - curline = curwp->w_dotp; /* Save the current line pointer */ - curoff = curwp->w_doto; /* Save the current offset */ + curline = curwp->w_dotp; /* Save the current line pointer */ + curoff = curwp->w_doto; /* Save the current offset */ - /* do the search */ + /* do the 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 */ - update(FALSE); /* And force an update */ - mlwrite ("(search failed)"); /* Say we died */ + 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 */ + update(FALSE); /* And force an update */ + mlwrite("(search failed)"); /* Say we died */ #if PKCODE - matchlen = strlen(pat); + 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 @@ -133,139 +133,131 @@ int fisearch(f, n) * will stall until the pattern string is edited back into something that * exists (or until the search is aborted). */ - + isearch(f, n) { - int status; /* Search status */ - int col; /* prompt column */ - register int cpos; /* character number in search string */ - register int c; /* current input character */ - register int expc; /* function expanded input char */ - char pat_save[NPAT]; /* Saved copy of the old pattern str */ - LINE *curline; /* Current line on entry */ - int curoff; /* Current offset on entry */ - int init_direction; /* The initial search direction */ + int status; /* Search status */ + int col; /* prompt column */ + register int cpos; /* character number in search string */ + register int c; /* current input character */ + register int expc; /* function expanded input char */ + char pat_save[NPAT]; /* Saved copy of the old pattern str */ + LINE *curline; /* Current line on entry */ + int curoff; /* Current offset on entry */ + int init_direction; /* The initial search direction */ - /* Initialize starting conditions */ + /* Initialize starting conditions */ - cmd_reexecute = -1; /* We're not re-executing (yet?) */ - cmd_offset = 0; /* Start at the beginning of the buff */ - cmd_buff[0] = '\0'; /* Init the command buffer */ - strncpy (pat_save, pat, NPAT); /* Save the old pattern string */ - curline = curwp->w_dotp; /* Save the current line pointer */ - curoff = curwp->w_doto; /* Save the current offset */ - init_direction = n; /* Save the initial search direction */ + cmd_reexecute = -1; /* We're not re-executing (yet?) */ + cmd_offset = 0; /* Start at the beginning of the buff */ + cmd_buff[0] = '\0'; /* Init the command buffer */ + strncpy(pat_save, pat, NPAT); /* Save the old pattern string */ + curline = curwp->w_dotp; /* Save the current line pointer */ + curoff = curwp->w_doto; /* Save the current offset */ + init_direction = n; /* Save the initial search direction */ - /* This is a good place to start a re-execution: */ + /* This is a good place to start a re-execution: */ -start_over: + start_over: - /* ask the user for the text of a pattern */ - col = promptpattern("ISearch: "); /* Prompt, remember the col */ + /* ask the user for the text of a pattern */ + col = promptpattern("ISearch: "); /* Prompt, remember the col */ - cpos = 0; /* Start afresh */ - status = TRUE; /* Assume everything's cool */ + cpos = 0; /* Start afresh */ + status = TRUE; /* Assume everything's cool */ - /* - Get the first character in the pattern. If we get an initial Control-S - or Control-R, re-use the old search string and find the first occurrence - */ + /* + Get the first character in the pattern. If we get an initial Control-S + or Control-R, re-use the old search string and find the first occurrence + */ - c = ectoc(expc = get_char()); /* Get the first character */ - 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? */ - n = -1; /* No, search in reverse */ - backchar (TRUE, 1); /* Be defensive about EOB */ - } else - n = 1; /* Yes, search forward */ - status = scanmore(pat, n); /* Do the search */ - c = ectoc(expc = get_char()); /* Get another character */ - } - - /* Top of the 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 */ - { - case IS_ABORT: /* If abort search request */ - return(FALSE); /* Quit searching again */ - - case IS_REVERSE: /* If backward search */ - case IS_FORWARD: /* If forward search */ - case IS_VMSFORW: /* of either flavor */ - if (c == IS_REVERSE) /* If reverse search */ - n = -1; /* Set the reverse direction */ - else /* Otherwise, */ - n = 1; /* go forward */ - status = scanmore(pat, n); /* Start the search again */ - c = ectoc(expc = get_char()); /* Get the next char */ - continue; /* Go continue with the search*/ - - case IS_NEWLINE: /* Carriage return */ - c = '\n'; /* Make it a new line */ - break; /* Make sure we use it */ - - case IS_QUOTE: /* Quote character */ - case IS_VMSQUOTE: /* of either variety */ - c = ectoc(expc = get_char()); /* Get the next char */ - - case IS_TAB: /* Generically allowed */ - case '\n': /* controlled characters */ - break; /* Make sure we use it */ - - case IS_BACKSP: /* If a backspace: */ - case IS_RUBOUT: /* or if a Rubout: */ - if (cmd_offset <= 1) /* Anything to delete? */ - return (TRUE); /* No, just exit */ - --cmd_offset; /* Back up over the Rubout */ - cmd_buff[--cmd_offset] = '\0'; /* Yes, delete last char */ - curwp->w_dotp = curline; /* Reset the line pointer */ - curwp->w_doto = curoff; /* and the offset */ - n = init_direction; /* Reset the search direction */ - strncpy (pat, pat_save, NPAT); /* Restore the old search str */ - cmd_reexecute = 0; /* Start the whole mess over */ - goto start_over; /* Let it take care of itself */ - - /* Presumably a quasi-normal character comes here */ - - default: /* All other chars */ - if (c < ' ') /* Is it printable? */ - { /* Nope. */ - reeat (c); /* Re-eat the char */ - return (TRUE); /* And return the last status */ - } - } /* Switch */ - - /* 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 */ - mlwrite("? Search string too long"); - return(TRUE); /* Return an error */ + c = ectoc(expc = get_char()); /* Get the first character */ + 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? */ + n = -1; /* No, search in reverse */ + backchar(TRUE, 1); /* Be defensive about EOB */ + } else + n = 1; /* Yes, search forward */ + status = scanmore(pat, n); /* Do the search */ + c = ectoc(expc = get_char()); /* Get another character */ } - pat[cpos] = 0; /* null terminate the buffer */ - col = echochar(c,col); /* Echo the character */ - 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 */ - status = scanmore(pat, n); /* or find the next match */ - c = ectoc(expc = get_char()); /* Get the next char */ - } /* for {;;} */ + + /* Top of the 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 */ + case IS_ABORT: /* If abort search request */ + return (FALSE); /* Quit searching again */ + + case IS_REVERSE: /* If backward search */ + case IS_FORWARD: /* If forward search */ + case IS_VMSFORW: /* of either flavor */ + if (c == IS_REVERSE) /* If reverse search */ + n = -1; /* Set the reverse direction */ + else /* Otherwise, */ + n = 1; /* go forward */ + status = scanmore(pat, n); /* Start the search again */ + c = ectoc(expc = get_char()); /* Get the next char */ + continue; /* Go continue with the search */ + + case IS_NEWLINE: /* Carriage return */ + c = '\n'; /* Make it a new line */ + break; /* Make sure we use it */ + + case IS_QUOTE: /* Quote character */ + case IS_VMSQUOTE: /* of either variety */ + c = ectoc(expc = get_char()); /* Get the next char */ + + case IS_TAB: /* Generically allowed */ + case '\n': /* controlled characters */ + break; /* Make sure we use it */ + + case IS_BACKSP: /* If a backspace: */ + case IS_RUBOUT: /* or if a Rubout: */ + if (cmd_offset <= 1) /* Anything to delete? */ + return (TRUE); /* No, just exit */ + --cmd_offset; /* Back up over the Rubout */ + cmd_buff[--cmd_offset] = '\0'; /* Yes, delete last char */ + curwp->w_dotp = curline; /* Reset the line pointer */ + curwp->w_doto = curoff; /* and the offset */ + n = init_direction; /* Reset the search direction */ + strncpy(pat, pat_save, NPAT); /* Restore the old search str */ + cmd_reexecute = 0; /* Start the whole mess over */ + goto start_over; /* Let it take care of itself */ + + /* Presumably a quasi-normal character comes here */ + + default: /* All other chars */ + if (c < ' ') { /* Is it printable? *//* Nope. */ + reeat(c); /* Re-eat the char */ + return (TRUE); /* And return the last status */ + } + } /* Switch */ + + /* 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 */ + mlwrite("? Search string too long"); + return (TRUE); /* Return an error */ + } + pat[cpos] = 0; /* null terminate the buffer */ + col = echochar(c, col); /* Echo the character */ + 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 */ + status = scanmore(pat, n); /* or find the next match */ + c = ectoc(expc = get_char()); /* Get the next char */ + } /* for {;;} */ } /* @@ -279,42 +271,39 @@ start_over: * scanmore or something. */ -int checknext (chr, patrn, dir) /* Check next character in search string */ -char chr; /* Next char to look for */ -char *patrn; /* The entire search string (incl chr) */ -int dir; /* Search direction */ +int checknext(chr, patrn, dir) /* Check next character in search string */ +char chr; /* Next char to look for */ +char *patrn; /* The entire search string (incl chr) */ +int dir; /* Search direction */ { - register LINE *curline; /* current line during scan */ - register int curoff; /* position within current line */ - register int buffchar; /* character at current position */ - int status; /* how well things go */ + register LINE *curline; /* current line during scan */ + register int curoff; /* position within current line */ + register int buffchar; /* character at current position */ + int status; /* how well things go */ - /* setup the local scan pointer to current "." */ + /* setup the local scan pointer to current "." */ - curline = curwp->w_dotp; /* Get the current line structure */ - curoff = curwp->w_doto; /* Get the offset within that line */ + 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 */ - { - curline = lforw(curline); /* Skip to the next line */ - if (curline == curbp->b_linep) - return (FALSE); /* Abort if at end of buffer */ - curoff = 0; /* Start at the beginning of the line */ - 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? */ - { - 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 */ - } - return (status); /* And return the status */ - } else /* Else, if reverse search: */ - return (match_pat (patrn)); /* See if we're in the right place */ + 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 */ + curoff = 0; /* Start at the beginning of the line */ + 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? */ + 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 */ + } + return (status); /* And return the status */ + } else /* Else, if reverse search: */ + return (match_pat(patrn)); /* See if we're in the right place */ } /* @@ -326,28 +315,25 @@ int dir; /* Search direction */ * forward searches and at the beginning of the matched string for reverse * searches. */ - -int scanmore(patrn, dir) /* search forward or back for a pattern */ -char *patrn; /* string to scan for */ -int dir; /* direction to search */ -{ - int sts; /* search status */ - if (dir < 0) /* reverse search? */ - { - rvstrcpy(tap, patrn); /* Put reversed string in tap */ +int scanmore(patrn, dir) /* search forward or back for a pattern */ +char *patrn; /* string to scan for */ +int dir; /* direction to search */ +{ + int sts; /* search status */ + + 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 */ + TTflush(); /* see that the feep feeps */ } - return(sts); /* else, don't even try */ + return (sts); /* else, don't even try */ } /* @@ -360,36 +346,34 @@ int dir; /* direction to search */ * be done is match the last char input. */ -int match_pat (patrn) /* See if the pattern string matches string at "." */ -char *patrn; /* String to match to buffer */ +int match_pat(patrn) /* See if the pattern string matches string at "." */ +char *patrn; /* String to match to buffer */ { - register int i; /* Generic loop index/offset */ - register int buffchar; /* character at current position */ - register LINE *curline; /* current line during scan */ - register int curoff; /* position within current line */ + register int i; /* Generic loop index/offset */ + register int buffchar; /* character at current position */ + register LINE *curline; /* current line during scan */ + register int curoff; /* position within current line */ - /* setup the local scan pointer to current "." */ + /* setup the local scan pointer to current "." */ - curline = curwp->w_dotp; /* Get the current line structure */ - curoff = curwp->w_doto; /* Get the offset within that line */ + curline = curwp->w_dotp; /* Get the current line structure */ + curoff = curwp->w_doto; /* Get the offset within that line */ - /* top of per character compare loop: */ + /* top of per character compare loop: */ - for (i = 0; i < strlen(patrn); i++) /* Loop for all characters in patrn */ - { - 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) - return (FALSE); /* Abort if at end of buffer */ - buffchar = '\n'; /* And say the next char is NL */ - } else - buffchar = lgetc(curline, curoff++); /* Get the next char */ - if (!eq(buffchar, patrn[i])) /* Is it what we're looking for? */ - return (FALSE); /* Nope, just punt it then */ - } - return (TRUE); /* Everything matched? Let's celebrate*/ + 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) + return (FALSE); /* Abort if at end of buffer */ + buffchar = '\n'; /* And say the next char is NL */ + } else + buffchar = lgetc(curline, curoff++); /* Get the next char */ + if (!eq(buffchar, patrn[i])) /* Is it what we're looking for? */ + return (FALSE); /* Nope, just punt it then */ + } + return (TRUE); /* Everything matched? Let's celebrate */ } /* Routine to prompt for I-Search string. */ @@ -397,63 +381,61 @@ char *patrn; /* String to match to buffer */ int promptpattern(prompt) char *prompt; { - char tpat[NPAT+20]; + char tpat[NPAT + 20]; - strcpy(tpat, prompt); /* copy prompt to output string */ - strcat(tpat, " ("); /* build new prompt string */ - expandp(pat, &tpat[strlen(tpat)], NPAT/2); /* add old pattern */ - strcat(tpat, "): "); + strcpy(tpat, prompt); /* copy prompt to output string */ + strcat(tpat, " ("); /* build new prompt string */ + expandp(pat, &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */ + strcat(tpat, "): "); - /* check to see if we are executing a command line */ - if (!clexec) { - mlwrite(tpat); - } - return(strlen(tpat)); + /* check to see if we are executing a command line */ + if (!clexec) { + mlwrite(tpat); + } + return (strlen(tpat)); } /* routine to echo i-search characters */ -int echochar(c,col) -int c; /* character to be echoed */ -int col; /* column to be echoed in */ +int echochar(c, col) +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*/ - { - case '\n': /* Newline */ - TTputc('<'); - TTputc('N'); - TTputc('L'); - TTputc('>'); - col += 3; - break; + movecursor(term.t_nrow, col); /* Position the cursor */ + if ((c < ' ') || (c == 0x7F)) { /* Control character? */ + switch (c) { /* Yes, dispatch special cases */ + case '\n': /* Newline */ + TTputc('<'); + TTputc('N'); + TTputc('L'); + TTputc('>'); + col += 3; + break; - case '\t': /* Tab */ - TTputc('<'); - TTputc('T'); - TTputc('A'); - TTputc('B'); - TTputc('>'); - col += 4; - break; + case '\t': /* Tab */ + TTputc('<'); + TTputc('T'); + TTputc('A'); + TTputc('B'); + TTputc('>'); + col += 4; + break; - case 0x7F: /* Rubout: */ - TTputc('^'); /* Output a funny looking */ - TTputc('?'); /* indication of Rubout */ - col++; /* Count the extra char */ - break; + case 0x7F: /* Rubout: */ + TTputc('^'); /* Output a funny looking */ + TTputc('?'); /* indication of Rubout */ + col++; /* Count the extra char */ + break; - default: /* Vanilla control char */ - TTputc('^'); /* Yes, output prefix */ - TTputc(c+0x40); /* Make it "^X" */ - col++; /* Count this char */ - } - } else - TTputc(c); /* Otherwise, output raw char */ - TTflush(); /* Flush the output */ - return(++col); /* return the new column no */ + default: /* Vanilla control char */ + TTputc('^'); /* Yes, output prefix */ + TTputc(c + 0x40); /* Make it "^X" */ + col++; /* Count this char */ + } + } else + TTputc(c); /* Otherwise, output raw char */ + TTflush(); /* Flush the output */ + return (++col); /* return the new column no */ } /* @@ -463,29 +445,28 @@ int col; /* column to be echoed in */ * next character. */ -int get_char () +int get_char() { - int c; /* A place to get a character */ + int c; /* A place to get a character */ - /* See if we're re-executing: */ + /* See if we're re-executing: */ - if (cmd_reexecute >= 0) /* Is there an offset? */ - if ((c = cmd_buff[cmd_reexecute++]) != 0) - return (c); /* Yes, return any character */ + if (cmd_reexecute >= 0) /* Is there an offset? */ + if ((c = cmd_buff[cmd_reexecute++]) != 0) + return (c); /* Yes, return any character */ - /* We're not re-executing (or aren't any more). Try for a real char */ + /* We're not re-executing (or aren't any more). Try for a real char */ - 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 ... */ - { - mlwrite ("? command too long"); /* Complain loudly and bitterly */ - return (metac); /* And force a quit */ - } - c = get1key(); /* Get the next character */ - cmd_buff[cmd_offset++] = c; /* Save the char for next time */ - cmd_buff[cmd_offset] = '\0';/* And terminate the buffer */ - return (c); /* Return the character */ + 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 ... */ + mlwrite("? command too long"); /* Complain loudly and bitterly */ + return (metac); /* And force a quit */ + } + c = get1key(); /* Get the next character */ + cmd_buff[cmd_offset++] = c; /* Save the char for next time */ + cmd_buff[cmd_offset] = '\0'; /* And terminate the buffer */ + return (c); /* Return the character */ } /* @@ -497,22 +478,22 @@ int get_char () int uneat() { - int c; + int c; - term.t_getchar = saved_get_char; /* restore the routine address */ - c = eaten_char; /* Get the re-eaten char */ - eaten_char = -1; /* Clear the old char */ - return(c); /* and return the last char */ + term.t_getchar = saved_get_char; /* restore the routine address */ + c = eaten_char; /* Get the re-eaten char */ + eaten_char = -1; /* Clear the old char */ + return (c); /* and return the last char */ } int reeat(c) -int c; +int c; { - if (eaten_char != -1) /* If we've already been here */ - return/*(NULL)*/; /* Don't do it again */ - eaten_char = c; /* Else, save the char for later */ - saved_get_char = term.t_getchar; /* Save the char get routine */ - term.t_getchar = uneat; /* Replace it with ours */ + if (eaten_char != -1) /* If we've already been here */ + return /*(NULL) */ ; /* Don't do it again */ + eaten_char = c; /* Else, save the char for later */ + saved_get_char = term.t_getchar; /* Save the char get routine */ + term.t_getchar = uneat; /* Replace it with ours */ } #else isearch() diff --git a/line.c b/line.c index 0bbbdc3..1481b2c 100644 --- a/line.c +++ b/line.c @@ -17,8 +17,8 @@ #include "estruct.h" #include "edef.h" -KILL *ykbuf; /* ptr to current kill buffer chunk being yanked */ -int ykboff; /* offset into that chunk */ +KILL *ykbuf; /* ptr to current kill buffer chunk being yanked */ +int ykboff; /* offset into that chunk */ /* * This routine allocates a block of memory large enough to hold a LINE @@ -28,17 +28,17 @@ int ykboff; /* offset into that chunk */ */ LINE *lalloc(used) -register int used; +register int used; { - register LINE *lp; - register int size; + register LINE *lp; + register int size; char *malloc(); - size = (used+NBLOCK-1) & ~(NBLOCK-1); - if (size == 0) /* Assume that an empty */ - size = NBLOCK; /* line is for type-in. */ - if ((lp = (LINE *) malloc(sizeof(LINE)+size)) == NULL) { + size = (used + NBLOCK - 1) & ~(NBLOCK - 1); + if (size == 0) /* Assume that an empty */ + size = NBLOCK; /* line is for type-in. */ + if ((lp = (LINE *) malloc(sizeof(LINE) + size)) == NULL) { mlwrite("(OUT OF MEMORY)"); return (NULL); } @@ -54,7 +54,7 @@ register int used; * conditions described in the above comments don't hold here. */ lfree(lp) -register LINE *lp; +register LINE *lp; { register BUFFER *bp; register WINDOW *wp; @@ -63,9 +63,9 @@ register LINE *lp; while (wp != NULL) { if (wp->w_linep == lp) wp->w_linep = lp->l_fp; - if (wp->w_dotp == lp) { - wp->w_dotp = lp->l_fp; - wp->w_doto = 0; + if (wp->w_dotp == lp) { + wp->w_dotp = lp->l_fp; + wp->w_doto = 0; } if (wp->w_markp == lp) { wp->w_markp = lp->l_fp; @@ -76,7 +76,7 @@ register LINE *lp; bp = bheadp; while (bp != NULL) { if (bp->b_nwnd == 0) { - if (bp->b_dotp == lp) { + if (bp->b_dotp == lp) { bp->b_dotp = lp->l_fp; bp->b_doto = 0; } @@ -100,14 +100,14 @@ register LINE *lp; * mode line needs to be updated (the "*" has to be set). */ lchange(flag) -register int flag; +register int flag; { register WINDOW *wp; - if (curbp->b_nwnd != 1) /* Ensure hard. */ + if (curbp->b_nwnd != 1) /* Ensure hard. */ flag = WFHARD; - if ((curbp->b_flag&BFCHG) == 0) { /* First change, so */ - flag |= WFMODE; /* update mode lines. */ + if ((curbp->b_flag & BFCHG) == 0) { /* First change, so */ + flag |= WFMODE; /* update mode lines. */ curbp->b_flag |= BFCHG; } wp = wheadp; @@ -118,9 +118,9 @@ register int flag; } } -insspace(f, n) /* insert spaces forward into text */ - -int f, n; /* default flag and numeric argument */ +insspace(f, n) + /* insert spaces forward into text */ +int f, n; /* default flag and numeric argument */ { linsert(n, ' '); @@ -132,14 +132,15 @@ int f, n; /* default flag and numeric argument */ */ linstr(instr) -char *instr; +char *instr; { register int status = TRUE; char tmpc; 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) { @@ -148,7 +149,7 @@ char *instr; } instr++; } - return(status); + return (status); } /* @@ -163,40 +164,40 @@ char *instr; linsert(n, c) { - register char *cp1; - register char *cp2; - register LINE *lp1; - register LINE *lp2; - register LINE *lp3; - register int doto; - register int i; + register char *cp1; + register char *cp2; + register LINE *lp1; + register LINE *lp2; + register LINE *lp3; + register int doto; + register int i; register WINDOW *wp; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ lchange(WFEDIT); - lp1 = curwp->w_dotp; /* Current line */ - if (lp1 == curbp->b_linep) { /* At the end: special */ + lp1 = curwp->w_dotp; /* Current line */ + if (lp1 == curbp->b_linep) { /* At the end: special */ if (curwp->w_doto != 0) { mlwrite("bug: linsert"); return (FALSE); } - if ((lp2=lalloc(n)) == NULL) /* Allocate new line */ + if ((lp2 = lalloc(n)) == NULL) /* Allocate new line */ return (FALSE); - lp3 = lp1->l_bp; /* Previous line */ - lp3->l_fp = lp2; /* Link in */ + lp3 = lp1->l_bp; /* Previous line */ + lp3->l_fp = lp2; /* Link in */ lp2->l_fp = lp1; lp1->l_bp = lp2; lp2->l_bp = lp3; - for (i=0; il_text[i] = c; curwp->w_dotp = lp2; curwp->w_doto = n; return (TRUE); } - doto = curwp->w_doto; /* Save for later. */ - if (lp1->l_used+n > lp1->l_size) { /* Hard: reallocate */ - if ((lp2=lalloc(lp1->l_used+n)) == NULL) + doto = curwp->w_doto; /* Save for later. */ + if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */ + if ((lp2 = lalloc(lp1->l_used + n)) == NULL) return (FALSE); cp1 = &lp1->l_text[0]; cp2 = &lp2->l_text[0]; @@ -210,23 +211,23 @@ linsert(n, c) lp1->l_fp->l_bp = lp2; lp2->l_bp = lp1->l_bp; free((char *) lp1); - } else { /* Easy: in place */ - lp2 = lp1; /* Pretend new line */ + } else { /* Easy: in place */ + lp2 = lp1; /* Pretend new line */ lp2->l_used += n; cp2 = &lp1->l_text[lp1->l_used]; - cp1 = cp2-n; + cp1 = cp2 - n; while (cp1 != &lp1->l_text[doto]) *--cp2 = *--cp1; } - for (i=0; il_text[doto+i] = c; - wp = wheadp; /* Update windows */ + for (i = 0; i < n; ++i) /* Add the characters */ + lp2->l_text[doto + i] = c; + wp = wheadp; /* Update windows */ while (wp != NULL) { if (wp->w_linep == lp1) wp->w_linep = lp2; if (wp->w_dotp == lp1) { wp->w_dotp = lp2; - if (wp==curwp || wp->w_doto>doto) + if (wp == curwp || wp->w_doto > doto) wp->w_doto += n; } if (wp->w_markp == lp1) { @@ -246,14 +247,14 @@ linsert(n, c) lowrite(c) -char c; /* character to overwrite on current position */ +char c; /* character to overwrite on current position */ { if (curwp->w_doto < curwp->w_dotp->l_used && - (lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || - ((curwp->w_doto) & tabmask) == tabmask)) - ldelete(1L, FALSE); - return(linsert(1, c)); + (lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || + ((curwp->w_doto) & tabmask) == tabmask)) + ldelete(1L, FALSE); + return (linsert(1, c)); } /* @@ -262,7 +263,7 @@ char c; /* character to overwrite on current position */ lover(ostr) -char *ostr; +char *ostr; { register int status = TRUE; @@ -270,16 +271,18 @@ 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++; } - return(status); + return (status); } /* @@ -292,25 +295,25 @@ char *ostr; */ lnewline() { - register char *cp1; - register char *cp2; - register LINE *lp1; - register LINE *lp2; - register int doto; + register char *cp1; + register char *cp2; + register LINE *lp1; + register LINE *lp2; + register int doto; register WINDOW *wp; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ #if SCROLLCODE - lchange(WFHARD|WFINS); + lchange(WFHARD | WFINS); #else lchange(WFHARD); #endif - lp1 = curwp->w_dotp; /* Get the address and */ - doto = curwp->w_doto; /* offset of "." */ - if ((lp2=lalloc(doto)) == NULL) /* New first half line */ + lp1 = curwp->w_dotp; /* Get the address and */ + doto = curwp->w_doto; /* offset of "." */ + if ((lp2 = lalloc(doto)) == NULL) /* New first half line */ return (FALSE); - cp1 = &lp1->l_text[0]; /* Shuffle text around */ + cp1 = &lp1->l_text[0]; /* Shuffle text around */ cp2 = &lp2->l_text[0]; while (cp1 != &lp1->l_text[doto]) *cp2++ = *cp1++; @@ -322,7 +325,7 @@ lnewline() lp1->l_bp = lp2; lp2->l_bp->l_fp = lp2; lp2->l_fp = lp1; - wp = wheadp; /* Windows */ + wp = wheadp; /* Windows */ while (wp != NULL) { if (wp->w_linep == lp1) wp->w_linep = lp2; @@ -351,43 +354,43 @@ lnewline() */ ldelete(n, kflag) -long n; /* # of chars to delete */ -int kflag; /* put killed text in kill buffer flag */ +long n; /* # of chars to delete */ +int kflag; /* put killed text in kill buffer flag */ { - register char *cp1; - register char *cp2; - register LINE *dotp; - register int doto; - register int chunk; + register char *cp1; + register char *cp2; + register LINE *dotp; + register int doto; + register int chunk; register WINDOW *wp; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ while (n != 0) { dotp = curwp->w_dotp; doto = curwp->w_doto; - if (dotp == curbp->b_linep) /* Hit end of buffer. */ + if (dotp == curbp->b_linep) /* Hit end of buffer. */ return (FALSE); - chunk = dotp->l_used-doto; /* Size of chunk. */ + chunk = dotp->l_used - doto; /* Size of chunk. */ if (chunk > n) chunk = n; - if (chunk == 0) { /* End of line, merge. */ + if (chunk == 0) { /* End of line, merge. */ #if SCROLLCODE - lchange(WFHARD|WFKILLS); + lchange(WFHARD | WFKILLS); #else lchange(WFHARD); #endif if (ldelnewline() == FALSE - || (kflag!=FALSE && kinsert('\n')==FALSE)) + || (kflag != FALSE && kinsert('\n') == FALSE)) return (FALSE); --n; continue; } lchange(WFEDIT); - cp1 = &dotp->l_text[doto]; /* Scrunch text. */ + cp1 = &dotp->l_text[doto]; /* Scrunch text. */ cp2 = cp1 + chunk; - if (kflag != FALSE) { /* Kill? */ + if (kflag != FALSE) { /* Kill? */ while (cp1 != cp2) { if (kinsert(*cp1) == FALSE) return (FALSE); @@ -398,14 +401,14 @@ int kflag; /* put killed text in kill buffer flag */ while (cp2 != &dotp->l_text[dotp->l_used]) *cp1++ = *cp2++; dotp->l_used -= chunk; - wp = wheadp; /* Fix windows */ + wp = wheadp; /* Fix windows */ while (wp != NULL) { - if (wp->w_dotp==dotp && wp->w_doto>=doto) { + if (wp->w_dotp == dotp && wp->w_doto >= doto) { wp->w_doto -= chunk; if (wp->w_doto < doto) wp->w_doto = doto; } - if (wp->w_markp==dotp && wp->w_marko>=doto) { + if (wp->w_markp == dotp && wp->w_marko >= doto) { wp->w_marko -= chunk; if (wp->w_marko < doto) wp->w_marko = doto; @@ -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 */ @@ -442,14 +444,14 @@ char *getctext() while (size--) *dp++ = *sp++; *dp = 0; - return(rline); + return (rline); } /* putctext: replace the current line with the passed in text */ putctext(iline) -char *iline; /* contents of new line */ +char *iline; /* contents of new line */ { register int status; @@ -457,14 +459,14 @@ char *iline; /* contents of new line */ /* delete the current line */ curwp->w_doto = 0; /* starting at the beginning of the line */ if ((status = killtext(TRUE, 1)) != TRUE) - return(status); + return (status); /* insert the new line */ if ((status = linstr(iline)) != TRUE) - return(status); + return (status); status = lnewline(); backline(TRUE, 1); - return(status); + return (status); } /* @@ -478,23 +480,23 @@ char *iline; /* contents of new line */ */ ldelnewline() { - register char *cp1; - register char *cp2; - register LINE *lp1; - register LINE *lp2; - register LINE *lp3; + register char *cp1; + register char *cp2; + register LINE *lp1; + register LINE *lp2; + register LINE *lp3; register WINDOW *wp; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ lp1 = curwp->w_dotp; lp2 = lp1->l_fp; - if (lp2 == curbp->b_linep) { /* At the buffer end. */ - if (lp1->l_used == 0) /* Blank line. */ + if (lp2 == curbp->b_linep) { /* At the buffer end. */ + if (lp1->l_used == 0) /* Blank line. */ lfree(lp1); return (TRUE); } - if (lp2->l_used <= lp1->l_size-lp1->l_used) { + if (lp2->l_used <= lp1->l_size - lp1->l_used) { cp1 = &lp1->l_text[lp1->l_used]; cp2 = &lp2->l_text[0]; while (cp2 != &lp2->l_text[lp2->l_used]) @@ -504,11 +506,11 @@ ldelnewline() if (wp->w_linep == lp2) wp->w_linep = lp1; if (wp->w_dotp == lp2) { - wp->w_dotp = lp1; + wp->w_dotp = lp1; wp->w_doto += lp1->l_used; } if (wp->w_markp == lp2) { - wp->w_markp = lp1; + wp->w_markp = lp1; wp->w_marko += lp1->l_used; } wp = wp->w_wndp; @@ -519,7 +521,7 @@ ldelnewline() free((char *) lp2); return (TRUE); } - if ((lp3=lalloc(lp1->l_used+lp2->l_used)) == NULL) + if ((lp3 = lalloc(lp1->l_used + lp2->l_used)) == NULL) return (FALSE); cp1 = &lp1->l_text[0]; cp2 = &lp3->l_text[0]; @@ -534,18 +536,18 @@ ldelnewline() lp3->l_bp = lp1->l_bp; wp = wheadp; while (wp != NULL) { - if (wp->w_linep==lp1 || wp->w_linep==lp2) + if (wp->w_linep == lp1 || wp->w_linep == lp2) wp->w_linep = lp3; if (wp->w_dotp == lp1) - wp->w_dotp = lp3; + wp->w_dotp = lp3; else if (wp->w_dotp == lp2) { - wp->w_dotp = lp3; + wp->w_dotp = lp3; wp->w_doto += lp1->l_used; } if (wp->w_markp == lp1) - wp->w_markp = lp3; + wp->w_markp = lp3; else if (wp->w_markp == lp2) { - wp->w_markp = lp3; + wp->w_markp = lp3; wp->w_marko += lp1->l_used; } wp = wp->w_wndp; @@ -562,7 +564,7 @@ ldelnewline() */ kdelete() { - KILL *kp; /* ptr to scan kill buffer chunk list */ + KILL *kp; /* ptr to scan kill buffer chunk list */ if (kbufh != NULL) { @@ -576,7 +578,7 @@ kdelete() /* and reset all the kill buffer pointers */ kbufh = kbufp = NULL; - kused = KBLOCK; + kused = KBLOCK; } } @@ -587,15 +589,15 @@ kdelete() kinsert(c) -int c; /* character to insert in the kill buffer */ +int c; /* character to insert in the kill buffer */ { - KILL *nchunk; /* ptr to newly malloced chunk */ + KILL *nchunk; /* ptr to newly malloced chunk */ /* check to see if we need a new chunk */ if (kused >= KBLOCK) { - if ((nchunk = (KILL *)malloc(sizeof(KILL))) == NULL) - return(FALSE); + if ((nchunk = (KILL *) malloc(sizeof(KILL))) == NULL) + return (FALSE); if (kbufh == NULL) /* set head ptr if first time */ kbufh = nchunk; if (kbufp != NULL) /* point the current to this new one */ @@ -607,7 +609,7 @@ int c; /* character to insert in the kill buffer */ /* and now insert the character */ kbufp->d_chunk[kused++] = c; - return(TRUE); + return (TRUE); } /* @@ -617,18 +619,18 @@ int c; /* character to insert in the kill buffer */ */ yank(f, n) { - register int c; - register int i; - register char *sp; /* pointer into string to insert */ + register int c; + register int i; + register char *sp; /* pointer into string to insert */ KILL *kp; /* pointer into kill buffer */ - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (n < 0) return (FALSE); /* make sure there is something to yank */ if (kbufh == NULL) - return(TRUE); /* not an error, just nothing */ + return (TRUE); /* not an error, just nothing */ /* for each time.... */ while (n--) { diff --git a/lock.c b/lock.c index 76d838c..5cf6d13 100644 --- a/lock.c +++ b/lock.c @@ -16,14 +16,14 @@ extern int sys_nerr; /* number of system error messages defined */ extern int errno; /* current error */ -char *lname[NLOCKS]; /* names of all locked files */ -int numlocks; /* # of current locks active */ +char *lname[NLOCKS]; /* names of all locked files */ +int numlocks; /* # of current locks active */ /* lockchk: check a file for locking and add it to the list */ lockchk(fname) -char *fname; /* file to check for a lock */ +char *fname; /* file to check for a lock */ { register int i; /* loop indexes */ @@ -32,41 +32,40 @@ char *fname; /* file to check for a lock */ /* check to see if that file is already locked here */ if (numlocks > 0) - for (i=0; i < numlocks; ++i) + for (i = 0; i < numlocks; ++i) if (strcmp(fname, lname[i]) == 0) - return(TRUE); + return (TRUE); /* if we have a full locking table, bitch and leave */ if (numlocks == NLOCKS) { mlwrite("LOCK ERROR: Lock table full"); - return(ABORT); + return (ABORT); } /* next, try to lock it */ status = lock(fname); if (status == ABORT) /* file is locked, no override */ - return(ABORT); + return (ABORT); if (status == FALSE) /* locked, overriden, dont add to table */ - return(TRUE); + return (TRUE); /* we have now locked it, add it to our table */ - lname[++numlocks - 1] = (char *)malloc(strlen(fname) + 1); + lname[++numlocks - 1] = (char *) malloc(strlen(fname) + 1); if (lname[numlocks - 1] == NULL) { /* malloc failure */ - undolock(fname); /* free the lock */ + undolock(fname); /* free the lock */ mlwrite("Cannot lock, out of memory"); --numlocks; - return(ABORT); + return (ABORT); } /* everthing is cool, add it to the table */ - strcpy(lname[numlocks-1], fname); - return(TRUE); + strcpy(lname[numlocks - 1], fname); + return (TRUE); } /* lockrel: release all the file locks so others may edit */ lockrel() - { register int i; /* loop index */ register int status; /* status of locks */ @@ -74,13 +73,13 @@ lockrel() status = TRUE; if (numlocks > 0) - for (i=0; i < numlocks; ++i) { + for (i = 0; i < numlocks; ++i) { if ((s = unlock(lname[i])) != TRUE) status = s; free(lname[i]); } numlocks = 0; - return(status); + return (status); } /* lock: Check and lock a file from access by others @@ -91,7 +90,7 @@ lockrel() lock(fname) -char *fname; /* file name to lock */ +char *fname; /* file name to lock */ { register char *locker; /* lock error message */ @@ -102,23 +101,23 @@ char *fname; /* file name to lock */ /* attempt to lock the file */ locker = dolock(fname); if (locker == NULL) /* we win */ - return(TRUE); + return (TRUE); /* file failed...abort */ if (strncmp(locker, "LOCK", 4) == 0) { lckerror(locker); - return(ABORT); + return (ABORT); } /* someone else has it....override? */ strcpy(msg, "File in use by "); strcat(msg, locker); strcat(msg, ", override?"); - status = mlyesno(msg); /* ask them */ + status = mlyesno(msg); /* ask them */ if (status == TRUE) - return(FALSE); + return (FALSE); else - return(ABORT); + return (ABORT); } /* unlock: Unlock a file @@ -127,7 +126,7 @@ char *fname; /* file name to lock */ unlock(fname) -char *fname; /* file to unlock */ +char *fname; /* file to unlock */ { register char *locker; /* undolock return string */ @@ -136,16 +135,16 @@ char *fname; /* file to unlock */ /* unclock and return */ locker = undolock(fname); if (locker == NULL) - return(TRUE); + return (TRUE); /* report the error and come back */ lckerror(locker); - return(FALSE); + return (FALSE); } -lckerror(errstr) /* report a lock error */ - -char *errstr; /* lock error string to print out */ +lckerror(errstr) + /* report a lock error */ +char *errstr; /* lock error string to print out */ { char obuf[NSTRING]; /* output buffer for error message */ @@ -160,7 +159,7 @@ char *errstr; /* lock error string to print out */ } #endif #else -lckhello() /* dummy function */ -{ +lckhello() +{ /* dummy function */ } #endif diff --git a/main.c b/main.c index c2e1871..f88daec 100644 --- a/main.c +++ b/main.c @@ -57,7 +57,7 @@ #define maindef #include "estruct.h" /* global structures and defines */ -#include "efunc.h" /* function declarations and name table */ +#include "efunc.h" /* function declarations and name table */ #include "edef.h" /* global definitions */ #include "ebind.h" /* default key bindings */ @@ -84,7 +84,7 @@ extern unsigned _stklen = 32766; #include static void emergencyexit(); #ifdef SIGWINCH - extern void sizesignal(); +extern void sizesignal(); #endif #endif @@ -93,37 +93,37 @@ emacs(argc, argv) #else main(argc, argv) #endif -int argc; /* # of arguments */ -char *argv[]; /* argument strings */ +int argc; /* # of arguments */ +char *argv[]; /* argument strings */ { - register int c; /* command character */ - register int f; /* default flag */ - register int n; /* numeric repeat count */ - register int mflag; /* negative flag on repeat */ - register BUFFER *bp; /* temp buffer pointer */ - register int firstfile; /* first file flag */ - register int carg; /* current arg to scan */ - register int startflag; /* startup executed flag */ - BUFFER *firstbp = NULL; /* ptr to first buffer in cmd line */ - int basec; /* c stripped of meta character */ - int viewflag; /* are we starting in view mode? */ - int gotoflag; /* do we need to goto a line at start? */ - int gline; /* if so, what line? */ - int searchflag; /* Do we need to search at start? */ - int saveflag; /* temp store for lastflag */ - int errflag; /* C error processing? */ - char bname[NBUFN]; /* buffer name of file to read */ + register int c; /* command character */ + register int f; /* default flag */ + register int n; /* numeric repeat count */ + register int mflag; /* negative flag on repeat */ + register BUFFER *bp; /* temp buffer pointer */ + register int firstfile; /* first file flag */ + register int carg; /* current arg to scan */ + register int startflag; /* startup executed flag */ + BUFFER *firstbp = NULL; /* ptr to first buffer in cmd line */ + int basec; /* c stripped of meta character */ + int viewflag; /* are we starting in view mode? */ + int gotoflag; /* do we need to goto a line at start? */ + int gline; /* if so, what line? */ + int searchflag; /* Do we need to search at start? */ + int saveflag; /* temp store for lastflag */ + int errflag; /* C error processing? */ + char bname[NBUFN]; /* buffer name of file to read */ #if CRYPT - int cryptflag; /* encrypting on the way in? */ - char ekey[NPAT]; /* startup encryption key */ + int cryptflag; /* encrypting on the way in? */ + char ekey[NPAT]; /* startup encryption key */ #endif char *strncpy(); - extern *pathname[]; /* startup file path/name array */ + extern *pathname[]; /* startup file path/name array */ int newc; #if PKCODE - int (*getbind())(); - int (*execfunc)(); /* ptr to function to execute */ + int (*getbind()) (); + int (*execfunc) (); /* ptr to function to execute */ #endif #if PKCODE & VMS @@ -141,8 +141,8 @@ char *argv[]; /* argument strings */ #endif /* initialize the editor */ - vtinit(); /* Display */ - edinit("main"); /* Buffers, windows */ + vtinit(); /* Display */ + edinit("main"); /* Buffers, windows */ varinit(); /* user variables */ viewflag = FALSE; /* view mode defaults off in command line */ @@ -171,51 +171,51 @@ char *argv[]; /* argument strings */ if (argv[carg][0] == '-') { switch (argv[carg][1]) { /* Process Startup macroes */ - case 'a': /* process error file */ - case 'A': - errflag = TRUE; - break; - case 'e': /* -e for Edit file */ - case 'E': - viewflag = FALSE; - break; - case 'g': /* -g for initial goto */ - case 'G': - gotoflag = TRUE; - gline = atoi(&argv[carg][2]); - break; + case 'a': /* process error file */ + case 'A': + errflag = TRUE; + break; + case 'e': /* -e for Edit file */ + case 'E': + viewflag = FALSE; + break; + case 'g': /* -g for initial goto */ + case 'G': + gotoflag = TRUE; + gline = atoi(&argv[carg][2]); + break; #if CRYPT - case 'k': /* -k for code key */ - case 'K': - cryptflag = TRUE; - strcpy(ekey, &argv[carg][2]); - break; + case 'k': /* -k for code key */ + case 'K': + cryptflag = TRUE; + strcpy(ekey, &argv[carg][2]); + break; #endif #if PKCODE - case 'n': /* -n accept null chars */ - case 'N': - nullflag = TRUE; - break; + case 'n': /* -n accept null chars */ + case 'N': + nullflag = TRUE; + break; #endif - case 'r': /* -r restrictive use */ - case 'R': - restflag = TRUE; - break; - case 's': /* -s for initial search string */ - case 'S': - searchflag = TRUE; - strncpy(pat,&argv[carg][2],NPAT); - break; - case 'v': /* -v for View File */ - case 'V': - viewflag = TRUE; - break; - default: /* unknown switch */ - /* ignore this for now */ - break; + case 'r': /* -r restrictive use */ + case 'R': + restflag = TRUE; + break; + case 's': /* -s for initial search string */ + case 'S': + searchflag = TRUE; + strncpy(pat, &argv[carg][2], NPAT); + break; + case 'v': /* -v for View File */ + case 'V': + viewflag = TRUE; + break; + default: /* unknown switch */ + /* ignore this for now */ + break; } - } else if (argv[carg][0]== '@') { + } else if (argv[carg][0] == '@') { /* Process Startup macroes */ if (startup(&argv[carg][1]) == TRUE) @@ -227,7 +227,7 @@ char *argv[]; /* argument strings */ /* Process an input file */ /* set up a buffer for this file */ - makename(bname, argv[carg]); + makename(bname, argv[carg]); unqname(bname); /* set this to inactive */ @@ -245,7 +245,7 @@ char *argv[]; /* argument strings */ #if CRYPT if (cryptflag) { bp->b_mode |= MDCRYPT; - crypt((char *)NULL, 0); + crypt((char *) NULL, 0); crypt(ekey, strlen(ekey)); strncpy(bp->b_key, ekey, NPAT); } @@ -254,7 +254,7 @@ char *argv[]; /* argument strings */ } #if UNIX - signal(SIGHUP, emergencyexit); + signal(SIGHUP, emergencyexit); signal(SIGTERM, emergencyexit); #endif @@ -270,7 +270,7 @@ char *argv[]; /* argument strings */ startup(""); startflag = TRUE; } - discmd = TRUE; /* P.K. */ + discmd = TRUE; /* P.K. */ /* if there are any files to read, read the first one! */ bp = bfind("main", FALSE, 0); @@ -280,85 +280,79 @@ char *argv[]; /* argument strings */ } else bp->b_mode |= gmode; - /* Deal with startup gotos and searches */ - if (gotoflag && searchflag) { - update(FALSE); + /* Deal with startup gotos and searches */ + if (gotoflag && searchflag) { + update(FALSE); mlwrite("(Can not search and goto at the same time!)"); - } - else if (gotoflag) { - if (gotoline(TRUE,gline) == FALSE) { - update(FALSE); + } else if (gotoflag) { + if (gotoline(TRUE, gline) == FALSE) { + update(FALSE); mlwrite("(Bogus goto argument)"); } - } else if (searchflag) { - if (forwhunt(FALSE, 0) == FALSE) - update(FALSE); - } + } else if (searchflag) { + if (forwhunt(FALSE, 0) == FALSE) + update(FALSE); + } /* setup to process commands */ - lastflag = 0; /* Fake last flags. */ + lastflag = 0; /* Fake last flags. */ -loop: + loop: #if CALLED /* if we were called as a subroutine and want to leave, do so */ if (eexitflag) - return(eexitval); + return (eexitval); #endif /* execute the "command" macro...normally null */ saveflag = lastflag; /* preserve lastflag through this */ - execute(META|SPEC|'C', FALSE, 1); + execute(META | SPEC | 'C', FALSE, 1); 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(); } #else /* Fix up the screen */ - update(FALSE); + update(FALSE); /* get the next command from the keyboard */ c = getcmd(); #endif /* if there is something on the command line, clear it */ - if (mpresf != FALSE) { - mlerase(); - update(FALSE); + if (mpresf != FALSE) { + mlerase(); + update(FALSE); #if CLRMSG - if (c == ' ') /* ITS EMACS does this */ - goto loop; + if (c == ' ') /* ITS EMACS does this */ + goto loop; #endif - } - f = FALSE; - n = 1; + } + f = FALSE; + n = 1; /* do META-# processing if needed */ - basec = c & ~META; /* strip meta char off if there */ + basec = c & ~META; /* strip meta char off if there */ if ((c & META) && ((basec >= '0' && basec <= '9') || basec == '-')) { - f = TRUE; /* there is a # arg */ - n = 0; /* start with a zero default */ - mflag = 1; /* current minus flag */ - c = basec; /* strip the META */ + f = TRUE; /* there is a # arg */ + n = 0; /* start with a zero default */ + mflag = 1; /* current minus flag */ + c = basec; /* strip the META */ while ((c >= '0' && c <= '9') || (c == '-')) { if (c == '-') { /* already hit a minus or digit? */ @@ -371,7 +365,7 @@ loop: if ((n == 0) && (mflag == -1)) /* lonely - */ mlwrite("Arg:"); else - mlwrite("Arg: %d",n * mflag); + mlwrite("Arg: %d", n * mflag); c = getcmd(); /* get the next key */ } @@ -380,54 +374,56 @@ loop: /* do ^U repeat argument processing */ - if (c == reptc) { /* ^U, start argument */ - f = TRUE; - n = 4; /* with argument of 4 */ - mflag = 0; /* that can be discarded. */ - mlwrite("Arg: 4"); - while ((c=getcmd()) >='0' && c<='9' || c==reptc || c=='-'){ - if (c == reptc) - if ((n > 0) == ((n*4) > 0)) - n = n*4; - else - n = 1; - /* - * If dash, and start of argument string, set arg. - * to -1. Otherwise, insert it. - */ - else if (c == '-') { - if (mflag) - break; - n = 0; - mflag = -1; - } - /* - * If first digit entered, replace previous argument - * with digit and set sign. Otherwise, append to arg. - */ - else { - if (!mflag) { - n = 0; - mflag = 1; - } - n = 10*n + c - '0'; - } - mlwrite("Arg: %d", (mflag >=0) ? n : (n ? -n : -1)); - } - /* - * Make arguments preceded by a minus sign negative and change - * the special argument "^U -" to an effective "^U -1". - */ - if (mflag == -1) { - if (n == 0) - n++; - n = -n; - } - } + if (c == reptc) { /* ^U, start argument */ + f = TRUE; + n = 4; /* with argument of 4 */ + mflag = 0; /* that can be discarded. */ + mlwrite("Arg: 4"); + while ((c = getcmd()) >= '0' && c <= '9' || c == reptc + || c == '-') { + if (c == reptc) + if ((n > 0) == ((n * 4) > 0)) + n = n * 4; + else + n = 1; + /* + * If dash, and start of argument string, set arg. + * to -1. Otherwise, insert it. + */ + else if (c == '-') { + if (mflag) + break; + n = 0; + mflag = -1; + } + /* + * If first digit entered, replace previous argument + * with digit and set sign. Otherwise, append to arg. + */ + else { + if (!mflag) { + n = 0; + mflag = 1; + } + n = 10 * n + c - '0'; + } + mlwrite("Arg: %d", + (mflag >= 0) ? n : (n ? -n : -1)); + } + /* + * Make arguments preceded by a minus sign negative and change + * the special argument "^U -" to an effective "^U -1". + */ + if (mflag == -1) { + if (n == 0) + n++; + n = -n; + } + } /* and execute the command */ - execute(c, f, n); - goto loop; + execute(c, f, n); + goto loop; } /* @@ -436,37 +432,37 @@ loop: * file by default, and we want the buffer name to be right. */ edinit(bname) -char bname[]; +char bname[]; { - register BUFFER *bp; - register WINDOW *wp; + register BUFFER *bp; + register WINDOW *wp; char *malloc(); - bp = bfind(bname, TRUE, 0); /* First buffer */ - blistp = bfind("*List*", TRUE, BFINVS); /* Buffer list buffer */ - wp = (WINDOW *) malloc(sizeof(WINDOW)); /* First window */ - if (bp==NULL || wp==NULL || blistp==NULL) - exit(1); - curbp = bp; /* Make this current */ - wheadp = wp; - curwp = wp; - wp->w_wndp = NULL; /* Initialize window */ - wp->w_bufp = bp; - bp->b_nwnd = 1; /* Displayed. */ - wp->w_linep = bp->b_linep; - wp->w_dotp = bp->b_linep; - wp->w_doto = 0; - wp->w_markp = NULL; - wp->w_marko = 0; - wp->w_toprow = 0; + bp = bfind(bname, TRUE, 0); /* First buffer */ + blistp = bfind("*List*", TRUE, BFINVS); /* Buffer list buffer */ + wp = (WINDOW *) malloc(sizeof(WINDOW)); /* First window */ + if (bp == NULL || wp == NULL || blistp == NULL) + exit(1); + curbp = bp; /* Make this current */ + wheadp = wp; + curwp = wp; + wp->w_wndp = NULL; /* Initialize window */ + wp->w_bufp = bp; + bp->b_nwnd = 1; /* Displayed. */ + wp->w_linep = bp->b_linep; + wp->w_dotp = bp->b_linep; + wp->w_doto = 0; + wp->w_markp = NULL; + wp->w_marko = 0; + wp->w_toprow = 0; #if COLOR /* initalize colors to global defaults */ wp->w_fcolor = gfcolor; wp->w_bcolor = gbcolor; #endif - wp->w_ntrows = term.t_nrow-1; /* "-1" for mode line. */ - wp->w_force = 0; - wp->w_flag = WFMODE|WFHARD; /* Full. */ + wp->w_ntrows = term.t_nrow - 1; /* "-1" for mode line. */ + wp->w_force = 0; + wp->w_flag = WFMODE | WFHARD; /* Full. */ } /* @@ -477,70 +473,70 @@ char bname[]; */ execute(c, f, n) { - register int status; - int (*execfunc)(); /* ptr to function to execute */ - int (*getbind())(); + register int status; + int (*execfunc) (); /* ptr to function to execute */ + int (*getbind()) (); /* if the keystroke is a bound function...do it */ execfunc = getbind(c); - if (execfunc != NULL) { + if (execfunc != NULL) { thisflag = 0; - status = (*execfunc)(f, n); + status = (*execfunc) (f, n); lastflag = thisflag; return (status); - } + } - /* - * If a space was typed, fill column is defined, the argument is non- - * negative, wrap mode is enabled, and we are now past fill column, + /* + * If a space was typed, fill column is defined, the argument is non- + * negative, wrap mode is enabled, and we are now past fill column, * and we are not read-only, perform word wrap. - */ - if (c == ' ' && (curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 && + */ + if (c == ' ' && (curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 && n >= 0 && getccol(FALSE) > fillcol && (curwp->w_bufp->b_mode & MDVIEW) == FALSE) - execute(META|SPEC|'W', FALSE, 1); + execute(META | SPEC | 'W', FALSE, 1); #if PKCODE - if ((c>=0x20 && c<=0x7E) /* Self inserting. */ + if ((c >= 0x20 && c <= 0x7E) /* Self inserting. */ #if IBMPC - || (c>=0x80 && c<=0xFE)) { + || (c >= 0x80 && c <= 0xFE)) { #else -#if VMS || BSD || USG /* 8BIT P.K. */ - || (c>=0xA0 && c<=0xFE)) { +#if VMS || BSD || USG /* 8BIT P.K. */ + || (c >= 0xA0 && c <= 0xFE)) { #else - ) { + ) { #endif #endif #else - if ((c>=0x20 && c<=0xFF)) { /* Self inserting. */ + if ((c >= 0x20 && c <= 0xFF)) { /* Self inserting. */ #endif - if (n <= 0) { /* Fenceposts. */ - lastflag = 0; - return (n<0 ? FALSE : TRUE); - } - thisflag = 0; /* For the future. */ + if (n <= 0) { /* Fenceposts. */ + lastflag = 0; + return (n < 0 ? FALSE : TRUE); + } + thisflag = 0; /* For the future. */ /* if we are in overwrite mode, not at eol, and next char is not a tab or we are at a tab stop, - delete a char forword */ + delete a char forword */ if (curwp->w_bufp->b_mode & MDOVER && curwp->w_doto < curwp->w_dotp->l_used && - (lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || - (curwp->w_doto) % 8 == 7)) - ldelete(1L, FALSE); + (lgetc(curwp->w_dotp, curwp->w_doto) != '\t' || + (curwp->w_doto) % 8 == 7)) + ldelete(1L, FALSE); /* do the appropriate insertion */ if (c == '}' && (curbp->b_mode & MDCMOD) != 0) - status = insbrace(n, c); - else if (c == '#' && (curbp->b_mode & MDCMOD) != 0) - status = inspound(); - else - status = linsert(n, c); + status = insbrace(n, c); + else if (c == '#' && (curbp->b_mode & MDCMOD) != 0) + status = inspound(); + else + status = linsert(n, c); #if CFENCE /* check for CMODE fence matching */ if ((c == '}' || c == ')' || c == ']') && - (curbp->b_mode & MDCMOD) != 0) + (curbp->b_mode & MDCMOD) != 0) fmatch(c); #endif @@ -553,13 +549,13 @@ execute(c, f, n) gacount = gasave; } - lastflag = thisflag; - return (status); - } + lastflag = thisflag; + return (status); + } TTbeep(); - mlwrite("(Key not bound)"); /* complain */ - lastflag = 0; /* Fake last flags. */ - return (FALSE); + mlwrite("(Key not bound)"); /* complain */ + lastflag = 0; /* Fake last flags. */ + return (FALSE); } /* @@ -569,38 +565,38 @@ execute(c, f, n) quickexit(f, n) { register BUFFER *bp; /* scanning pointer to buffers */ - register BUFFER *oldcb; /* original current buffer */ + register BUFFER *oldcb; /* original current buffer */ register int status; - oldcb = curbp; /* save in case we fail */ + oldcb = curbp; /* save in case we fail */ bp = bheadp; while (bp != NULL) { - if ((bp->b_flag&BFCHG) != 0 /* Changed. */ - && (bp->b_flag&BFTRUNC) == 0 /* Not truncated P.K. */ - && (bp->b_flag&BFINVS) == 0) { /* Real. */ - curbp = bp; /* make that buffer cur */ - mlwrite("(Saving %s)",bp->b_fname); + if ((bp->b_flag & BFCHG) != 0 /* Changed. */ + && (bp->b_flag & BFTRUNC) == 0 /* Not truncated P.K. */ + && (bp->b_flag & BFINVS) == 0) { /* Real. */ + curbp = bp; /* make that buffer cur */ + mlwrite("(Saving %s)", bp->b_fname); #if PKCODE #else mlwrite("\n"); #endif - if ((status = filesave(f, n)) != TRUE) { - curbp = oldcb; /* restore curbp */ - return(status); - } + if ((status = filesave(f, n)) != TRUE) { + curbp = oldcb; /* restore curbp */ + return (status); + } } - bp = bp->b_bufp; /* on to the next buffer */ + bp = bp->b_bufp; /* on to the next buffer */ } - quit(f, n); /* conditionally quit */ - return(TRUE); + quit(f, n); /* conditionally quit */ + return (TRUE); } static void emergencyexit(signr) int signr; { quickexit(FALSE, 0); - quit(TRUE, 0); + quit(TRUE, 0); } /* @@ -609,12 +605,13 @@ int signr; */ quit(f, n) { - register int s; + register int s; - if (f != FALSE /* Argument forces it. */ - || anycb() == FALSE /* All buffers clean. */ - /* User says it's OK. */ - || (s=mlyesno("Modified buffers exist. Leave anyway")) == TRUE) { + if (f != FALSE /* Argument forces it. */ + || anycb() == FALSE /* All buffers clean. */ + /* User says it's OK. */ + || (s = + mlyesno("Modified buffers exist. Leave anyway")) == TRUE) { #if (FILOCK && BSD) || SVR4 if (lockrel() != TRUE) { TTputc('\n'); @@ -624,14 +621,14 @@ quit(f, n) exit(1); } #endif - vttidy(); + vttidy(); if (f) exit(n); else - exit(GOOD); - } + exit(GOOD); + } mlwrite(""); - return(s); + return (s); } /* @@ -641,15 +638,15 @@ quit(f, n) */ ctlxlp(f, n) { - if (kbdmode != STOP) { - mlwrite("%%Macro already active"); - return(FALSE); - } - mlwrite("(Start macro)"); + if (kbdmode != STOP) { + mlwrite("%%Macro already active"); + return (FALSE); + } + mlwrite("(Start macro)"); kbdptr = &kbdm[0]; kbdend = kbdptr; - kbdmode = RECORD; - return (TRUE); + kbdmode = RECORD; + return (TRUE); } /* @@ -658,15 +655,15 @@ ctlxlp(f, n) */ ctlxrp(f, n) { - if (kbdmode == STOP) { - mlwrite("%%Macro not active"); - return(FALSE); - } - if (kbdmode == RECORD) { - mlwrite("(End macro)"); - kbdmode = STOP; + if (kbdmode == STOP) { + mlwrite("%%Macro not active"); + return (FALSE); } - return(TRUE); + if (kbdmode == RECORD) { + mlwrite("(End macro)"); + kbdmode = STOP; + } + return (TRUE); } /* @@ -676,16 +673,16 @@ ctlxrp(f, n) */ ctlxe(f, n) { - if (kbdmode != STOP) { - mlwrite("%%Macro already active"); - return(FALSE); - } - if (n <= 0) - return (TRUE); + if (kbdmode != STOP) { + mlwrite("%%Macro already active"); + return (FALSE); + } + if (n <= 0) + return (TRUE); kbdrep = n; /* remember how many times to execute */ kbdmode = PLAY; /* start us in play mode */ kbdptr = &kbdm[0]; /* at the beginning */ - return(TRUE); + return (TRUE); } /* @@ -695,46 +692,43 @@ ctlxe(f, n) */ ctrlg(f, n) { - TTbeep(); + TTbeep(); kbdmode = STOP; mlwrite("(Aborted)"); - return(ABORT); + return (ABORT); } /* tell the user that this command is illegal while we are in VIEW (read-only) mode */ rdonly() - { TTbeep(); mlwrite("(Key illegal in VIEW mode)"); - return(FALSE); + return (FALSE); } resterr() - { TTbeep(); mlwrite("(That command is RESTRICTED)"); - return(FALSE); + return (FALSE); } -nullproc() /* user function that does NOTHING */ - -{ +nullproc() +{ /* user function that does NOTHING */ } -meta() /* dummy function for binding to meta prefix */ -{ +meta() +{ /* dummy function for binding to meta prefix */ } -cex() /* dummy function for binding to control-x prefix */ -{ +cex() +{ /* dummy function for binding to control-x prefix */ } -unarg() /* dummy function for binding to universal-argument */ -{ +unarg() +{ /* dummy function for binding to universal-argument */ } /***** Compiler specific Library functions ****/ @@ -746,12 +740,12 @@ unarg() /* dummy function for binding to universal-argument */ char *strncpy(dst, src, maxlen) -char *dst; /* destination of copied string */ -char *src; /* source */ -int maxlen; /* maximum length */ +char *dst; /* destination of copied string */ +char *src; /* source */ +int maxlen; /* maximum length */ { - char *dptr; /* ptr into dst */ + char *dptr; /* ptr into dst */ dptr = dst; /* while (*src && (maxlen-- > 0)) @@ -760,11 +754,11 @@ int maxlen; /* maximum length */ *dptr++ = *src++; maxlen--; } - - *dptr = 0; /* orig */ + + *dptr = 0; /* orig */ /* if (maxlen > 0) *dptr = 0; */ - return(dst); + return (dst); } #endif @@ -781,12 +775,12 @@ int maxlen; /* maximum length */ #undef malloc #undef free -char *allocate(nbytes) /* allocate nbytes and track */ - -unsigned nbytes; /* # of bytes to allocate */ +char *allocate(nbytes) + /* allocate nbytes and track */ +unsigned nbytes; /* # of bytes to allocate */ { - char *mp; /* ptr returned from malloc */ + char *mp; /* ptr returned from malloc */ char *malloc(); mp = malloc(nbytes); @@ -797,20 +791,20 @@ unsigned nbytes; /* # of bytes to allocate */ #endif } - return(mp); + return (mp); } -release(mp) /* release malloced memory and track */ - -char *mp; /* chunk of RAM to release */ +release(mp) + /* release malloced memory and track */ +char *mp; /* chunk of RAM to release */ { - unsigned *lp; /* ptr to the long containing the block size */ + unsigned *lp; /* ptr to the long containing the block size */ if (mp) { /* update amount of ram currently malloced */ - lp = ((unsigned *)mp) - 1; - envram -= (long)*lp - 2; + lp = ((unsigned *) mp) - 1; + envram -= (long) *lp - 2; free(mp); #if RAMSHOW dspram(); @@ -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; @@ -848,7 +841,7 @@ dspram() /* display the amount of RAM currently malloced */ #if CLEAN cexit(status) -int status; /* return status of emacs */ +int status; /* return status of emacs */ { register BUFFER *bp; /* buffer list pointer */ @@ -883,7 +876,7 @@ int status; /* return status of emacs */ #if CALLED eexitflag = TRUE; /* flag a program exit */ eexitval = status; - return(status); + return (status); #else #undef exit exit(status); diff --git a/pklock.c b/pklock.c index 79bf19b..ed76c72 100644 --- a/pklock.c +++ b/pklock.c @@ -2,7 +2,7 @@ * * locking routines as modified by Petri Kutvonen */ - + #include "estruct.h" #if (FILOCK && BSD) || SVR4 @@ -26,7 +26,7 @@ int gethostname(char *name, int namelen) { - return(sysinfo(SI_HOSTNAME, name, namelen)); + return (sysinfo(SI_HOSTNAME, name, namelen)); } #endif @@ -40,18 +40,18 @@ int gethostname(char *name, int namelen) * *********************/ char *dolock(fname) - char *fname; +char *fname; { int fd, lk, n; - static char lname[MAXLOCK], locker[MAXNAME+1]; + static char lname[MAXLOCK], locker[MAXNAME + 1]; int mask; struct stat sbuf; - + strcat(strcpy(lname, fname), ".lock~"); - /* check that we are not being cheated, qname must point to */ - /* a regular file - even this code leaves a small window of */ - /* vulnerability but it is rather hard to exploit it */ + /* check that we are not being cheated, qname must point to */ + /* a regular file - even this code leaves a small window of */ + /* vulnerability but it is rather hard to exploit it */ #if defined(S_IFLNK) if (lstat(lname, &sbuf) == 0) @@ -59,17 +59,16 @@ char *dolock(fname) if (stat(lname, &sbuf) == 0) #endif #if defined(S_ISREG) - if (! S_ISREG(sbuf.st_mode)) + if (!S_ISREG(sbuf.st_mode)) #else - if (! (((sbuf.st_mode) & 070000) == 0)) /* SysV R2 */ + if (!(((sbuf.st_mode) & 070000) == 0)) /* SysV R2 */ #endif return "LOCK ERROR: not a regular file"; 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,20 +77,19 @@ 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); - strcat(locker+strlen(locker), "@"); - gethostname(locker+strlen(locker), 64); + strcat(locker + strlen(locker), "@"); + gethostname(locker + strlen(locker), 64); write(fd, locker, strlen(locker)); close(fd); return NULL; } locker[n > MAXNAME ? MAXNAME : n] = 0; return locker; -} +} /********************* @@ -102,16 +100,15 @@ char *dolock(fname) * if other error, returns "LOCK ERROR: explanation" * *********************/ - + char *undolock(fname) - char *fname; +char *fname; { int fd, lk; 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 @@ -121,5 +118,5 @@ char *undolock(fname) return "LOCK ERROR: cannot remove lock file"; } return NULL; -} +} #endif diff --git a/posix.c b/posix.c index c56d558..c5309fb 100644 --- a/posix.c +++ b/posix.c @@ -21,16 +21,16 @@ #include #include -int kbdflgs; /* saved keyboard fd flags */ -int kbdpoll; /* in O_NDELAY mode */ -int kbdqp; /* there is a char in kbdq */ -char kbdq; /* char we've already read */ +int kbdflgs; /* saved keyboard fd flags */ +int kbdpoll; /* in O_NDELAY mode */ +int kbdqp; /* there is a char in kbdq */ +char kbdq; /* char we've already read */ -struct termios otermios; /* original terminal characteristics */ -struct termios ntermios; /* charactoristics to use inside */ +struct termios otermios; /* original terminal characteristics */ +struct termios ntermios; /* charactoristics to use inside */ #define TBUFSIZ 128 -char tobuf[TBUFSIZ]; /* terminal output buffer */ +char tobuf[TBUFSIZ]; /* terminal output buffer */ /* @@ -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; @@ -71,11 +72,11 @@ ttopen() */ setbuffer(stdout, &tobuf[0], TBUFSIZ); - kbdflgs = fcntl( 0, F_GETFL, 0 ); + kbdflgs = fcntl(0, F_GETFL, 0); kbdpoll = FALSE; /* on all screens we are not sure of the initial position - of the cursor */ + of the cursor */ ttrow = 999; ttcol = 999; } @@ -136,7 +137,7 @@ ttflush() */ ttgetc() { - return(255 & fgetc(stdin)); /* 8BIT P.K. */ + return (255 & fgetc(stdin)); /* 8BIT P.K. */ } /* typahead: Check to see if any characters are already in the @@ -145,10 +146,10 @@ ttgetc() typahead() { - int x; /* holds # of pending chars */ + int x; /* holds # of pending chars */ #ifdef FIONREAD - if (ioctl(0,FIONREAD,&x) < 0) + if (ioctl(0, FIONREAD, &x) < 0) x = 0; #else x = 0; @@ -156,4 +157,4 @@ typahead() return x; } -#endif /* POSIX */ +#endif /* POSIX */ diff --git a/random.c b/random.c index cfb68fc..9131849 100644 --- a/random.c +++ b/random.c @@ -10,16 +10,16 @@ #include "estruct.h" #include "edef.h" -int tabsize; /* Tab size (0: use real tabs) */ +int tabsize; /* Tab size (0: use real tabs) */ /* * Set fill column to n. */ setfillcol(f, n) { - fillcol = n; - mlwrite("(Fill column is %d)",n); - return(TRUE); + fillcol = n; + mlwrite("(Fill column is %d)", n); + return (TRUE); } /* @@ -31,36 +31,36 @@ setfillcol(f, n) */ showcpos(f, n) { - register LINE *lp; /* current line */ - register long numchars; /* # of chars in file */ - register int numlines; /* # of lines in file */ - register long predchars; /* # chars preceding point */ - register int predlines; /* # lines preceding point */ - register int curchar; /* character under cursor */ - int ratio; - int col; - int savepos; /* temp save for current offset */ - int ecol; /* column pos/end of current line */ + register LINE *lp; /* current line */ + register long numchars; /* # of chars in file */ + register int numlines; /* # of lines in file */ + register long predchars; /* # chars preceding point */ + register int predlines; /* # lines preceding point */ + register int curchar; /* character under cursor */ + int ratio; + int col; + int savepos; /* temp save for current offset */ + int ecol; /* column pos/end of current line */ #if PKCODE struct { - int pk_clin; - int pk_tlin; - int pk_ccol; - int pk_tcol; - long pk_cchr; - long pk_tchr; - int pk_perc; - int pk_char; + int pk_clin; + int pk_tlin; + int pk_ccol; + int pk_tcol; + long pk_cchr; + long pk_tchr; + int pk_perc; + int pk_char; } pk_mlrec; #endif /* starting at the beginning of the buffer */ - lp = lforw(curbp->b_linep); + lp = lforw(curbp->b_linep); /* start counting chars and lines */ - numchars = 0; - numlines = 0; - while (lp != curbp->b_linep) { + numchars = 0; + numlines = 0; + while (lp != curbp->b_linep) { /* if we are on the current line, record it */ if (lp == curwp->w_dotp) { predlines = numlines; @@ -74,7 +74,7 @@ showcpos(f, n) ++numlines; numchars += llength(lp) + 1; lp = lforw(lp); - } + } /* if at end of file, record it */ if (curwp->w_dotp == curbp->b_linep) { @@ -92,14 +92,14 @@ showcpos(f, n) ecol = getccol(FALSE); curwp->w_doto = savepos; - ratio = 0; /* Ratio before dot. */ - if (numchars != 0) - ratio = (100L*predchars) / numchars; + ratio = 0; /* Ratio before dot. */ + if (numchars != 0) + ratio = (100L * predchars) / numchars; /* summarize and report the info */ #if PKCODE - pk_mlrec.pk_clin = predlines+1; - pk_mlrec.pk_tlin = numlines+1; + pk_mlrec.pk_clin = predlines + 1; + pk_mlrec.pk_tlin = numlines + 1; pk_mlrec.pk_ccol = col; pk_mlrec.pk_tcol = ecol; pk_mlrec.pk_cchr = predchars; @@ -110,33 +110,32 @@ showcpos(f, n) &pk_mlrec); #else mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x", - predlines+1, numlines+1, col, ecol, + predlines + 1, numlines + 1, col, ecol, predchars, numchars, ratio, curchar); #endif - return (TRUE); + return (TRUE); } -getcline() /* get the current line number */ - -{ - register LINE *lp; /* current line */ - register int numlines; /* # of lines before point */ +getcline() +{ /* get the current line number */ + register LINE *lp; /* current line */ + register int numlines; /* # of lines before point */ /* starting at the beginning of the buffer */ - lp = lforw(curbp->b_linep); + lp = lforw(curbp->b_linep); /* start counting lines */ - numlines = 0; - while (lp != curbp->b_linep) { + numlines = 0; + while (lp != curbp->b_linep) { /* if we are on the current line, record it */ if (lp == curwp->w_dotp) break; ++numlines; lp = lforw(lp); - } + } /* and return the resulting count */ - return(numlines + 1); + return (numlines + 1); } /* @@ -145,19 +144,19 @@ getcline() /* get the current line number */ getccol(bflg) int bflg; { - register int c, i, col; - col = 0; - for (i=0; iw_doto; ++i) { - c = lgetc(curwp->w_dotp, i); - if (c!=' ' && c!='\t' && bflg) - break; - if (c == '\t') - col |= tabmask; - else if (c<0x20 || c==0x7F) - ++col; - ++col; - } - return(col); + register int c, i, col; + col = 0; + for (i = 0; i < curwp->w_doto; ++i) { + c = lgetc(curwp->w_dotp, i); + if (c != ' ' && c != '\t' && bflg) + break; + if (c == '\t') + col |= tabmask; + else if (c < 0x20 || c == 0x7F) + ++col; + ++col; + } + return (col); } /* @@ -165,10 +164,10 @@ int bflg; */ setccol(pos) -int pos; /* position to set cursor */ +int pos; /* position to set cursor */ { - register int c; /* character being scanned */ + register int c; /* character being scanned */ register int i; /* index into current line */ register int col; /* current cursor column */ register int llen; /* length of line in bytes */ @@ -183,19 +182,19 @@ int pos; /* position to set cursor */ break; /* advance one character */ - c = lgetc(curwp->w_dotp, i); - if (c == '\t') - col |= tabmask; - else if (c<0x20 || c==0x7F) - ++col; - ++col; - } + c = lgetc(curwp->w_dotp, i); + if (c == '\t') + col |= tabmask; + else if (c < 0x20 || c == 0x7F) + ++col; + ++col; + } /* set us at the new position */ curwp->w_doto = i; /* and tell weather we made it */ - return(col >= pos); + return (col >= pos); } /* @@ -207,25 +206,25 @@ int pos; /* position to set cursor */ */ twiddle(f, n) { - register LINE *dotp; - register int doto; - register int cl; - register int cr; + register LINE *dotp; + register int doto; + register int cl; + register int cr; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - dotp = curwp->w_dotp; - doto = curwp->w_doto; - if (doto==llength(dotp) && --doto<0) - return (FALSE); - cr = lgetc(dotp, doto); - if (--doto < 0) - return (FALSE); - cl = lgetc(dotp, doto); - lputc(dotp, doto+0, cr); - lputc(dotp, doto+1, cl); - lchange(WFEDIT); - return (TRUE); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + dotp = curwp->w_dotp; + doto = curwp->w_doto; + if (doto == llength(dotp) && --doto < 0) + return (FALSE); + cr = lgetc(dotp, doto); + if (--doto < 0) + return (FALSE); + cl = lgetc(dotp, doto); + lputc(dotp, doto + 0, cr); + lputc(dotp, doto + 1, cl); + lchange(WFEDIT); + return (TRUE); } /* @@ -236,23 +235,23 @@ twiddle(f, n) */ quote(f, n) { - register int s; - register int c; + register int s; + register int c; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - c = tgetc(); - if (n < 0) - return (FALSE); - if (n == 0) - return (TRUE); - if (c == '\n') { - do { - s = lnewline(); - } while (s==TRUE && --n); - return (s); - } - return (linsert(n, c)); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + c = tgetc(); + if (n < 0) + return (FALSE); + if (n == 0) + return (TRUE); + if (c == '\n') { + do { + s = lnewline(); + } while (s == TRUE && --n); + return (s); + } + return (linsert(n, c)); } /* @@ -264,27 +263,27 @@ quote(f, n) */ tab(f, n) { - if (n < 0) - return (FALSE); - if (n == 0 || n > 1) { - tabsize = n; - return(TRUE); - } - if (! tabsize) - return(linsert(1, '\t')); - return(linsert(tabsize - (getccol(FALSE) % tabsize), ' ')); + if (n < 0) + return (FALSE); + if (n == 0 || n > 1) { + tabsize = n; + return (TRUE); + } + if (!tabsize) + return (linsert(1, '\t')); + return (linsert(tabsize - (getccol(FALSE) % tabsize), ' ')); } #if AEDIT -detab(f, n) /* change tabs to spaces */ - -int f,n; /* default flag and numeric repeat count */ +detab(f, n) + /* change tabs to spaces */ +int f, n; /* default flag and numeric repeat count */ { register int inc; /* increment to next line [sgn(n)] */ - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (f == FALSE) n = 1; @@ -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); } @@ -311,12 +312,12 @@ int f,n; /* default flag and numeric repeat count */ curwp->w_doto = 0; /* to the begining of the line */ thisflag &= ~CFCPCN; /* flag that this resets the goal column */ lchange(WFEDIT); /* yes, we have made at least an edit */ - return(TRUE); + return (TRUE); } -entab(f, n) /* change spaces to tabs where posible */ - -int f,n; /* default flag and numeric repeat count */ +entab(f, n) + /* change spaces to tabs where posible */ +int f, n; /* default flag and numeric repeat count */ { register int inc; /* increment to next line [sgn(n)] */ @@ -324,8 +325,8 @@ int f,n; /* default flag and numeric repeat count */ register int ccol; /* current cursor column */ register char cchar; /* current character */ - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (f == FALSE) n = 1; @@ -344,11 +345,12 @@ int f,n; /* default flag and numeric repeat count */ if (ccol - fspace < 2) fspace = -1; else { - /* there is a bug here dealing with mixed space/tabed - lines.......it will get fixed */ + /* there is a bug here dealing with mixed space/tabed + lines.......it will get fixed */ backchar(TRUE, ccol - fspace); - ldelete((long)(ccol - fspace), FALSE); - linsert(1, '\t'); + ldelete((long) (ccol - fspace), + FALSE); + linsert(1, '\t'); fspace = -1; } @@ -356,20 +358,20 @@ int f,n; /* default flag and numeric repeat count */ cchar = lgetc(curwp->w_dotp, curwp->w_doto); switch (cchar) { - case '\t': /* a tab...count em up */ - ccol = nextab(ccol); - break; + case '\t': /* a tab...count em up */ + ccol = nextab(ccol); + break; - case ' ': /* a space...compress? */ - if (fspace == -1) - fspace = ccol; - ccol++; - break; + case ' ': /* a space...compress? */ + if (fspace == -1) + fspace = ccol; + ccol++; + break; - default: /* any other char...just count */ - ccol++; - fspace = -1; - break; + default: /* any other char...just count */ + ccol++; + fspace = -1; + break; } forwchar(FALSE, 1); } @@ -381,12 +383,12 @@ int f,n; /* default flag and numeric repeat count */ curwp->w_doto = 0; /* to the begining of the line */ thisflag &= ~CFCPCN; /* flag that this resets the goal column */ lchange(WFEDIT); /* yes, we have made at least an edit */ - return(TRUE); + return (TRUE); } -trim(f, n) /* trim trailing whitespace from the point to eol */ - -int f,n; /* default flag and numeric repeat count */ +trim(f, n) + /* trim trailing whitespace from the point to eol */ +int f, n; /* default flag and numeric repeat count */ { register LINE *lp; /* current line pointer */ @@ -394,8 +396,8 @@ int f,n; /* default flag and numeric repeat count */ register int length; /* current length */ register int inc; /* increment to next line [sgn(n)] */ - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (f == FALSE) n = 1; @@ -403,15 +405,15 @@ int f,n; /* default flag and numeric repeat count */ /* loop thru trimming n lines */ inc = ((n > 0) ? 1 : -1); while (n) { - lp = curwp->w_dotp; /* find current line text */ - offset = curwp->w_doto; /* save original offset */ - length = lp->l_used; /* find current length */ + lp = curwp->w_dotp; /* find current line text */ + offset = curwp->w_doto; /* save original offset */ + length = lp->l_used; /* find current length */ /* trim the current line */ while (length > offset) { - if (lgetc(lp, length-1) != ' ' && - lgetc(lp, length-1) != '\t') - break; + if (lgetc(lp, length - 1) != ' ' && + lgetc(lp, length - 1) != '\t') + break; length--; } lp->l_used = length; @@ -422,7 +424,7 @@ int f,n; /* default flag and numeric repeat count */ } lchange(WFEDIT); thisflag &= ~CFCPCN; /* flag that this resets the goal column */ - return(TRUE); + return (TRUE); } #endif @@ -433,22 +435,22 @@ int f,n; /* default flag and numeric repeat count */ */ openline(f, n) { - register int i; - register int s; + register int i; + register int s; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if (n < 0) - return (FALSE); - if (n == 0) - return (TRUE); - i = n; /* Insert newlines. */ - do { - s = lnewline(); - } while (s==TRUE && --i); - if (s == TRUE) /* Then back up overtop */ - s = backchar(f, n); /* of them all. */ - return (s); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if (n < 0) + return (FALSE); + if (n == 0) + return (TRUE); + i = n; /* Insert newlines. */ + do { + s = lnewline(); + } while (s == TRUE && --i); + if (s == TRUE) /* Then back up overtop */ + s = backchar(f, n); /* of them all. */ + return (s); } /* @@ -457,31 +459,31 @@ openline(f, n) */ newline(f, n) { - register int s; + register int s; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (n < 0) return (FALSE); /* if we are in C mode and this is a default */ if (n == 1 && (curbp->b_mode & MDCMOD) && curwp->w_dotp != curbp->b_linep) - return(cinsert()); + return (cinsert()); - /* - * If a newline was typed, fill column is defined, the argument is non- - * negative, wrap mode is enabled, and we are now past fill column, + /* + * If a newline was typed, fill column is defined, the argument is non- + * negative, wrap mode is enabled, and we are now past fill column, * and we are not read-only, perform word wrap. - */ - if ((curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 && + */ + if ((curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 && getccol(FALSE) > fillcol && (curwp->w_bufp->b_mode & MDVIEW) == FALSE) - execute(META|SPEC|'W', FALSE, 1); + execute(META | SPEC | 'W', FALSE, 1); /* insert some lines */ while (n--) { - if ((s=lnewline()) != TRUE) + if ((s = lnewline()) != TRUE) return (s); #if SCROLLCODE curwp->w_flag |= WFINS; @@ -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? */ @@ -509,7 +510,7 @@ cinsert() /* insert a newline and indentation for C */ /* save the indent of the previous line */ i = 0; while ((i < tptr) && (cptr[i] == ' ' || cptr[i] == '\t') - && (i < NSTRING - 1)) { + && (i < NSTRING - 1)) { ichar[i] = cptr[i]; ++i; } @@ -517,7 +518,7 @@ cinsert() /* insert a newline and indentation for C */ /* put in the newline */ if (lnewline() == FALSE) - return(FALSE); + return (FALSE); /* and the saved indentation */ linstr(ichar); @@ -529,14 +530,14 @@ cinsert() /* insert a newline and indentation for C */ #if SCROLLCODE curwp->w_flag |= WFINS; #endif - return(TRUE); + return (TRUE); } #if NBRACE -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) */ +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) */ { register int ch; /* last character before input */ @@ -544,80 +545,91 @@ int c; /* brace to insert (always } for now) */ register int i, count; register int target; /* column brace should go after */ register LINE *oldlp; - register int oldoff; + register int oldoff; /* if we aren't at the beginning of the line... */ if (curwp->w_doto != 0) - /* scan to see if all space before this is white space */ + /* scan to see if all space before this is white space */ for (i = curwp->w_doto - 1; i >= 0; --i) { ch = lgetc(curwp->w_dotp, i); if (ch != ' ' && ch != '\t') - return(linsert(n, c)); + return (linsert(n, c)); } /* 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)) ch = '\n'; 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)) break; } - + if (count != 0) { /* no match */ curwp->w_dotp = oldlp; curwp->w_doto = oldoff; - return(linsert(n, c)); + return (linsert(n, c)); } - - curwp->w_doto = 0; /* debut de ligne */ + + curwp->w_doto = 0; /* debut de ligne */ /* 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 */ target = getccol(FALSE); /* c'est l'indent que l'on doit avoir */ curwp->w_dotp = oldlp; curwp->w_doto = oldoff; - + while (target != getccol(FALSE)) { if (target < getccol(FALSE)) /* on doit detruire des caracteres */ while (getccol(FALSE) > target) backdel(FALSE, 1); - else { /* on doit en inserer */ + else { /* on doit en inserer */ while (target - getccol(FALSE) >= 8) - linsert(1,'\t'); + linsert(1, '\t'); linsert(target - getccol(FALSE), ' '); } } /* and insert the required brace(s) */ - return(linsert(n, c)); + return (linsert(n, c)); } #else -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) */ +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) */ { register int ch; /* last character before input */ @@ -626,13 +638,13 @@ int c; /* brace to insert (always { for now) */ /* if we are at the beginning of the line, no go */ if (curwp->w_doto == 0) - return(linsert(n,c)); + return (linsert(n, c)); /* scan to see if all space before this is white space */ for (i = curwp->w_doto - 1; i >= 0; --i) { ch = lgetc(curwp->w_dotp, i); if (ch != ' ' && ch != '\t') - return(linsert(n, c)); + return (linsert(n, c)); } /* delete back first */ @@ -643,25 +655,24 @@ int c; /* brace to insert (always { for now) */ backdel(FALSE, 1); /* and insert the required brace(s) */ - return(linsert(n, c)); + return (linsert(n, c)); } #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; /* if we are at the beginning of the line, no go */ if (curwp->w_doto == 0) - return(linsert(1,'#')); + return (linsert(1, '#')); /* scan to see if all space before this is white space */ for (i = curwp->w_doto - 1; i >= 0; --i) { ch = lgetc(curwp->w_dotp, i); if (ch != ' ' && ch != '\t') - return(linsert(1, '#')); + return (linsert(1, '#')); } /* delete back first */ @@ -669,7 +680,7 @@ inspound() /* insert a # into the text here...we are in CMODE */ backdel(FALSE, 1); /* and insert the required pound */ - return(linsert(1, '#')); + return (linsert(1, '#')); } /* @@ -682,24 +693,24 @@ inspound() /* insert a # into the text here...we are in CMODE */ */ deblank(f, n) { - register LINE *lp1; - register LINE *lp2; - long nld; + register LINE *lp1; + register LINE *lp2; + long nld; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - lp1 = curwp->w_dotp; - while (llength(lp1)==0 && (lp2=lback(lp1))!=curbp->b_linep) - lp1 = lp2; - lp2 = lp1; - nld = 0; - while ((lp2=lforw(lp2))!=curbp->b_linep && llength(lp2)==0) - ++nld; - if (nld == 0) - return (TRUE); - curwp->w_dotp = lforw(lp1); - curwp->w_doto = 0; - return (ldelete(nld, FALSE)); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + lp1 = curwp->w_dotp; + while (llength(lp1) == 0 && (lp2 = lback(lp1)) != curbp->b_linep) + lp1 = lp2; + lp2 = lp1; + nld = 0; + while ((lp2 = lforw(lp2)) != curbp->b_linep && llength(lp2) == 0) + ++nld; + if (nld == 0) + return (TRUE); + curwp->w_dotp = lforw(lp1); + curwp->w_doto = 0; + return (ldelete(nld, FALSE)); } /* @@ -712,30 +723,30 @@ deblank(f, n) */ indent(f, n) { - register int nicol; - register int c; - register int i; + register int nicol; + register int c; + register int i; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if (n < 0) - return (FALSE); - while (n--) { - nicol = 0; - for (i=0; iw_dotp); ++i) { - c = lgetc(curwp->w_dotp, i); - if (c!=' ' && c!='\t') - break; - if (c == '\t') - nicol |= tabmask; - ++nicol; - } - if (lnewline() == FALSE - || ((i=nicol/8)!=0 && linsert(i, '\t')==FALSE) - || ((i=nicol%8)!=0 && linsert(i, ' ')==FALSE)) - return (FALSE); - } - return (TRUE); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if (n < 0) + return (FALSE); + while (n--) { + nicol = 0; + for (i = 0; i < llength(curwp->w_dotp); ++i) { + c = lgetc(curwp->w_dotp, i); + if (c != ' ' && c != '\t') + break; + if (c == '\t') + nicol |= tabmask; + ++nicol; + } + if (lnewline() == FALSE + || ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE) + || ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE)) + return (FALSE); + } + return (TRUE); } /* @@ -746,16 +757,16 @@ indent(f, n) */ forwdel(f, n) { - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if (n < 0) - return (backdel(f, -n)); - if (f != FALSE) { /* Really a kill. */ - if ((lastflag&CFKILL) == 0) - kdelete(); - thisflag |= CFKILL; - } - return (ldelete((long)n, f)); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if (n < 0) + return (backdel(f, -n)); + if (f != FALSE) { /* Really a kill. */ + if ((lastflag & CFKILL) == 0) + kdelete(); + thisflag |= CFKILL; + } + return (ldelete((long) n, f)); } /* @@ -766,20 +777,20 @@ forwdel(f, n) */ backdel(f, n) { - register int s; + register int s; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if (n < 0) - return (forwdel(f, -n)); - if (f != FALSE) { /* Really a kill. */ - if ((lastflag&CFKILL) == 0) - kdelete(); - thisflag |= CFKILL; - } - if ((s=backchar(f, n)) == TRUE) - s = ldelete((long)n, f); - return (s); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if (n < 0) + return (forwdel(f, -n)); + if (f != FALSE) { /* Really a kill. */ + if ((lastflag & CFKILL) == 0) + kdelete(); + thisflag |= CFKILL; + } + if ((s = backchar(f, n)) == TRUE) + s = ldelete((long) n, f); + return (s); } /* @@ -792,104 +803,104 @@ backdel(f, n) */ killtext(f, n) { - register LINE *nextp; - long chunk; + register LINE *nextp; + long chunk; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if ((lastflag&CFKILL) == 0) /* Clear kill buffer if */ - kdelete(); /* last wasn't a kill. */ - thisflag |= CFKILL; - if (f == FALSE) { - chunk = llength(curwp->w_dotp)-curwp->w_doto; - if (chunk == 0) - chunk = 1; - } else if (n == 0) { - chunk = curwp->w_doto; - curwp->w_doto = 0; - } else if (n > 0) { - chunk = llength(curwp->w_dotp)-curwp->w_doto+1; - nextp = lforw(curwp->w_dotp); - while (--n) { - if (nextp == curbp->b_linep) - return (FALSE); - chunk += llength(nextp)+1; - nextp = lforw(nextp); - } - } else { - mlwrite("neg kill"); - return (FALSE); - } - return(ldelete(chunk, TRUE)); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */ + kdelete(); /* last wasn't a kill. */ + thisflag |= CFKILL; + if (f == FALSE) { + chunk = llength(curwp->w_dotp) - curwp->w_doto; + if (chunk == 0) + chunk = 1; + } else if (n == 0) { + chunk = curwp->w_doto; + curwp->w_doto = 0; + } else if (n > 0) { + chunk = llength(curwp->w_dotp) - curwp->w_doto + 1; + nextp = lforw(curwp->w_dotp); + while (--n) { + if (nextp == curbp->b_linep) + return (FALSE); + chunk += llength(nextp) + 1; + nextp = lforw(nextp); + } + } else { + mlwrite("neg kill"); + return (FALSE); + } + return (ldelete(chunk, TRUE)); } -setmode(f, n) /* prompt and set an editor mode */ - -int f, n; /* default and argument */ +setmode(f, n) + /* prompt and set an editor mode */ +int f, n; /* default and argument */ { #if PKCODE - return adjustmode(TRUE, FALSE); + return adjustmode(TRUE, FALSE); #else adjustmode(TRUE, FALSE); #endif } -delmode(f, n) /* prompt and delete an editor mode */ - -int f, n; /* default and argument */ +delmode(f, n) + /* prompt and delete an editor mode */ +int f, n; /* default and argument */ { #if PKCODE - return adjustmode(FALSE, FALSE); + return adjustmode(FALSE, FALSE); #else adjustmode(FALSE, FALSE); #endif } -setgmode(f, n) /* prompt and set a global editor mode */ - -int f, n; /* default and argument */ +setgmode(f, n) + /* prompt and set a global editor mode */ +int f, n; /* default and argument */ { #if PKCODE - return adjustmode(TRUE, TRUE); + return adjustmode(TRUE, TRUE); #else adjustmode(TRUE, TRUE); #endif } -delgmode(f, n) /* prompt and delete a global editor mode */ - -int f, n; /* default and argument */ +delgmode(f, n) + /* prompt and delete a global editor mode */ +int f, n; /* default and argument */ { #if PKCODE - return adjustmode(FALSE, TRUE); + return adjustmode(FALSE, TRUE); #else adjustmode(FALSE, TRUE); #endif } -adjustmode(kind, global) /* change the editor mode status */ - -int kind; /* true = set, false = delete */ -int global; /* true = global flag, false = current buffer flag */ +adjustmode(kind, global) + /* change the editor mode status */ +int kind; /* true = set, false = delete */ +int global; /* true = global flag, false = current buffer flag */ { - register char *scan; /* scanning pointer to convert prompt */ - register int i; /* loop index */ - register int status; /* error return on input */ + register char *scan; /* scanning pointer to convert prompt */ + register int i; /* loop index */ + register int status; /* error return on input */ #if COLOR - register int uflag; /* was modename uppercase? */ + register int uflag; /* was modename uppercase? */ #endif char prompt[50]; /* string to prompt user with */ - char cbuf[NPAT]; /* buffer to recieve mode name into */ + char cbuf[NPAT]; /* buffer to recieve mode name into */ /* build the proper prompt string */ if (global) - strcpy(prompt,"Global mode to "); + strcpy(prompt, "Global mode to "); else - strcpy(prompt,"Mode to "); + strcpy(prompt, "Mode to "); if (kind == TRUE) strcat(prompt, "add: "); @@ -900,7 +911,7 @@ int global; /* true = global flag, false = current buffer flag */ status = mlreply(prompt, cbuf, NPAT - 1); if (status != TRUE) - return(status); + return (status); /* make it uppercase */ @@ -916,24 +927,21 @@ int global; /* true = global flag, false = current buffer flag */ /* test it first against the colors we know */ #if PKCODE & IBMPC - for (i=0; i<=NCOLORS; i++) { + for (i = 0; i <= NCOLORS; i++) { #else - for (i=0; iw_fcolor = i; - } - else - { + } else { if (global) gbcolor = i; #if PKCODE == 0 @@ -945,13 +953,13 @@ int global; /* true = global flag, false = current buffer flag */ curwp->w_flag |= WFCOLR; #endif mlerase(); - return(TRUE); + return (TRUE); } } /* test it against the modes we know */ - for (i=0; i < NUMMODES; i++) { + for (i = 0; i < NUMMODES; i++) { if (strcmp(cbuf, modename[i]) == 0) { /* finding a match, we process it */ if (kind == TRUE) @@ -959,21 +967,20 @@ int global; /* true = global flag, false = current buffer flag */ gmode |= (1 << i); else curbp->b_mode |= (1 << i); + else if (global) + gmode &= ~(1 << i); else - if (global) - gmode &= ~(1 << i); - else - curbp->b_mode &= ~(1 << i); + curbp->b_mode &= ~(1 << i); /* display new mode line */ if (global == 0) upmode(); mlerase(); /* erase the junk */ - return(TRUE); + return (TRUE); } } mlwrite("No such mode!"); - return(FALSE); + return (FALSE); } /* This function simply clears the message line, @@ -981,11 +988,11 @@ int global; /* true = global flag, false = current buffer flag */ clrmes(f, n) -int f, n; /* arguments ignored */ +int f, n; /* arguments ignored */ { mlforce(""); - return(TRUE); + return (TRUE); } /* This function writes a string on the message line @@ -993,17 +1000,18 @@ int f, n; /* arguments ignored */ writemsg(f, n) -int f, n; /* arguments ignored */ +int f, n; /* arguments ignored */ { register char *sp; /* pointer into buf to expand %s */ register char *np; /* ptr into nbuf */ register int status; char buf[NPAT]; /* buffer to recieve message into */ - char nbuf[NPAT*2]; /* buffer to expand string into */ + char nbuf[NPAT * 2]; /* buffer to expand string into */ - if ((status = mlreply("Message to write: ", buf, NPAT - 1)) != TRUE) - return(status); + if ((status = + mlreply("Message to write: ", buf, NPAT - 1)) != TRUE) + return (status); /* expand all '%' to "%%" so mlwrite won't expect arguments */ sp = buf; @@ -1017,7 +1025,7 @@ int f, n; /* arguments ignored */ /* write the message out */ mlforce(nbuf); - return(TRUE); + return (TRUE); } #if CFENCE @@ -1025,7 +1033,7 @@ int f, n; /* arguments ignored */ getfence(f, n) -int f, n; /* not used */ +int f, n; /* not used */ { register LINE *oldlp; /* original line pointer */ @@ -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 */ @@ -1089,14 +1117,14 @@ int f, n; /* not used */ else forwchar(FALSE, 1); curwp->w_flag |= WFMOVE; - return(TRUE); + return (TRUE); } /* restore the current position */ curwp->w_dotp = oldlp; curwp->w_doto = oldoff; TTbeep(); - return(FALSE); + return (FALSE); } #endif @@ -1105,7 +1133,7 @@ int f, n; /* not used */ fmatch(ch) -char ch; /* fence type to match against */ +char ch; /* fence type to match against */ { register LINE *oldlp; /* original line pointer */ @@ -1164,58 +1192,57 @@ char ch; /* fence type to match against */ /* restore the current position */ curwp->w_dotp = oldlp; curwp->w_doto = oldoff; - return(TRUE); + return (TRUE); } -istring(f, n) /* ask for and insert a string into the current - buffer at the current point */ - -int f, n; /* ignored arguments */ +istring(f, n) + /* ask for and insert a string into the current + buffer at the current point */ +int f, n; /* ignored arguments */ { register int status; /* status return code */ - char tstring[NPAT+1]; /* string to add */ + char tstring[NPAT + 1]; /* string to add */ /* ask for string to insert */ - status = mlreplyt("String to insert: ", tstring, NPAT, metac); + status = + mlreplyt("String to insert: ", tstring, NPAT, metac); if (status != TRUE) - return(status); + return (status); if (f == FALSE) n = 1; if (n < 0) - n = - n; + n = -n; /* insert it */ - while (n-- && (status = linstr(tstring))) - ; - return(status); + while (n-- && (status = linstr(tstring))); + return (status); } -ovstring(f, n) /* ask for and overwite a string into the current - buffer at the current point */ - -int f, n; /* ignored arguments */ +ovstring(f, n) + /* ask for and overwite a string into the current + buffer at the current point */ +int f, n; /* ignored arguments */ { register int status; /* status return code */ - char tstring[NPAT+1]; /* string to add */ + char tstring[NPAT + 1]; /* string to add */ /* ask for string to insert */ - status = mlreplyt("String to overwrite: ", tstring, NPAT, metac); + status = + mlreplyt("String to overwrite: ", tstring, NPAT, metac); if (status != TRUE) - return(status); + return (status); if (f == FALSE) n = 1; if (n < 0) - n = - n; + n = -n; /* insert it */ - while (n-- && (status = lover(tstring))) - ; - return(status); + while (n-- && (status = lover(tstring))); + return (status); } - diff --git a/region.c b/region.c index b133f0b..ab83fca 100644 --- a/region.c +++ b/region.c @@ -21,19 +21,19 @@ */ killregion(f, n) { - register int s; - REGION region; + register int s; + REGION region; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if ((s=getregion(®ion)) != TRUE) - return (s); - if ((lastflag&CFKILL) == 0) /* This is a kill type */ - kdelete(); /* command, so do magic */ - thisflag |= CFKILL; /* kill buffer stuff. */ - curwp->w_dotp = region.r_linep; - curwp->w_doto = region.r_offset; - return (ldelete(region.r_size, TRUE)); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if ((s = getregion(®ion)) != TRUE) + return (s); + if ((lastflag & CFKILL) == 0) /* This is a kill type */ + kdelete(); /* command, so do magic */ + thisflag |= CFKILL; /* kill buffer stuff. */ + curwp->w_dotp = region.r_linep; + curwp->w_doto = region.r_offset; + return (ldelete(region.r_size, TRUE)); } /* @@ -44,32 +44,32 @@ killregion(f, n) */ copyregion(f, n) { - register LINE *linep; - register int loffs; - register int s; - REGION region; + register LINE *linep; + register int loffs; + register int s; + REGION region; - if ((s=getregion(®ion)) != TRUE) - return (s); - if ((lastflag&CFKILL) == 0) /* Kill type command. */ - kdelete(); - thisflag |= CFKILL; - linep = region.r_linep; /* Current line. */ - loffs = region.r_offset; /* Current offset. */ - while (region.r_size--) { - if (loffs == llength(linep)) { /* End of line. */ - if ((s=kinsert('\n')) != TRUE) - return (s); - linep = lforw(linep); - loffs = 0; - } else { /* Middle of line. */ - if ((s=kinsert(lgetc(linep, loffs))) != TRUE) - return (s); - ++loffs; - } - } + if ((s = getregion(®ion)) != TRUE) + return (s); + if ((lastflag & CFKILL) == 0) /* Kill type command. */ + kdelete(); + thisflag |= CFKILL; + linep = region.r_linep; /* Current line. */ + loffs = region.r_offset; /* Current offset. */ + while (region.r_size--) { + if (loffs == llength(linep)) { /* End of line. */ + if ((s = kinsert('\n')) != TRUE) + return (s); + linep = lforw(linep); + loffs = 0; + } else { /* Middle of line. */ + if ((s = kinsert(lgetc(linep, loffs))) != TRUE) + return (s); + ++loffs; + } + } mlwrite("(region copied)"); - return (TRUE); + return (TRUE); } /* @@ -82,31 +82,31 @@ copyregion(f, n) */ lowerregion(f, n) { - register LINE *linep; - register int loffs; - register int c; - register int s; - REGION region; + register LINE *linep; + register int loffs; + register int c; + register int s; + REGION region; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if ((s=getregion(®ion)) != TRUE) - return (s); - lchange(WFHARD); - linep = region.r_linep; - loffs = region.r_offset; - while (region.r_size--) { - if (loffs == llength(linep)) { - linep = lforw(linep); - loffs = 0; - } else { - c = lgetc(linep, loffs); - if (c>='A' && c<='Z') - lputc(linep, loffs, c+'a'-'A'); - ++loffs; - } - } - return (TRUE); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if ((s = getregion(®ion)) != TRUE) + return (s); + lchange(WFHARD); + linep = region.r_linep; + loffs = region.r_offset; + while (region.r_size--) { + if (loffs == llength(linep)) { + linep = lforw(linep); + loffs = 0; + } else { + c = lgetc(linep, loffs); + if (c >= 'A' && c <= 'Z') + lputc(linep, loffs, c + 'a' - 'A'); + ++loffs; + } + } + return (TRUE); } /* @@ -119,31 +119,31 @@ lowerregion(f, n) */ upperregion(f, n) { - register LINE *linep; - register int loffs; - register int c; - register int s; - REGION region; + register LINE *linep; + register int loffs; + register int c; + register int s; + REGION region; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ - if ((s=getregion(®ion)) != TRUE) - return (s); - lchange(WFHARD); - linep = region.r_linep; - loffs = region.r_offset; - while (region.r_size--) { - if (loffs == llength(linep)) { - linep = lforw(linep); - loffs = 0; - } else { - c = lgetc(linep, loffs); - if (c>='a' && c<='z') - lputc(linep, loffs, c-'a'+'A'); - ++loffs; - } - } - return (TRUE); + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ + if ((s = getregion(®ion)) != TRUE) + return (s); + lchange(WFHARD); + linep = region.r_linep; + loffs = region.r_offset; + while (region.r_size--) { + if (loffs == llength(linep)) { + linep = lforw(linep); + loffs = 0; + } else { + c = lgetc(linep, loffs); + if (c >= 'a' && c <= 'z') + lputc(linep, loffs, c - 'a' + 'A'); + ++loffs; + } + } + return (TRUE); } /* @@ -160,53 +160,54 @@ upperregion(f, n) getregion(rp) register REGION *rp; { - register LINE *flp; - register LINE *blp; - long fsize; - long bsize; + register LINE *flp; + register LINE *blp; + long fsize; + long bsize; - if (curwp->w_markp == NULL) { - mlwrite("No mark set in this window"); - return (FALSE); - } - if (curwp->w_dotp == curwp->w_markp) { - 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); - } else { - rp->r_offset = curwp->w_marko; - rp->r_size = (long)(curwp->w_doto-curwp->w_marko); - } - return (TRUE); - } - blp = curwp->w_dotp; - bsize = (long)curwp->w_doto; - flp = curwp->w_dotp; - fsize = (long)(llength(flp)-curwp->w_doto+1); - while (flp!=curbp->b_linep || lback(blp)!=curbp->b_linep) { - if (flp != curbp->b_linep) { - flp = lforw(flp); - if (flp == curwp->w_markp) { - rp->r_linep = curwp->w_dotp; - rp->r_offset = curwp->w_doto; - rp->r_size = fsize+curwp->w_marko; - return (TRUE); - } - fsize += llength(flp)+1; - } - if (lback(blp) != curbp->b_linep) { - blp = lback(blp); - bsize += llength(blp)+1; - if (blp == curwp->w_markp) { - rp->r_linep = blp; - rp->r_offset = curwp->w_marko; - rp->r_size = bsize - curwp->w_marko; - return (TRUE); - } - } - } - mlwrite("Bug: lost mark"); - return (FALSE); + if (curwp->w_markp == NULL) { + mlwrite("No mark set in this window"); + return (FALSE); + } + if (curwp->w_dotp == curwp->w_markp) { + 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); + } else { + rp->r_offset = curwp->w_marko; + rp->r_size = + (long) (curwp->w_doto - curwp->w_marko); + } + return (TRUE); + } + blp = curwp->w_dotp; + bsize = (long) curwp->w_doto; + flp = curwp->w_dotp; + fsize = (long) (llength(flp) - curwp->w_doto + 1); + while (flp != curbp->b_linep || lback(blp) != curbp->b_linep) { + if (flp != curbp->b_linep) { + flp = lforw(flp); + if (flp == curwp->w_markp) { + rp->r_linep = curwp->w_dotp; + rp->r_offset = curwp->w_doto; + rp->r_size = fsize + curwp->w_marko; + return (TRUE); + } + fsize += llength(flp) + 1; + } + if (lback(blp) != curbp->b_linep) { + blp = lback(blp); + bsize += llength(blp) + 1; + if (blp == curwp->w_markp) { + rp->r_linep = blp; + rp->r_offset = curwp->w_marko; + rp->r_size = bsize - curwp->w_marko; + return (TRUE); + } + } + } + mlwrite("Bug: lost mark"); + return (FALSE); } - diff --git a/search.c b/search.c index 7ca9370..74435ba 100644 --- a/search.c +++ b/search.c @@ -61,17 +61,17 @@ #include "estruct.h" #include "edef.h" -static int readpattern(); -static int replaces(); -static int nextch(); +static int readpattern(); +static int replaces(); +static int nextch(); #if MAGIC -static int cclmake(); -static int mcstr(); -static int rmcstr(); -static int mceq(); -static void setbit(); -static int amatch(); -static int biteq(); +static int cclmake(); +static int mcstr(); +static int rmcstr(); +static int mceq(); +static void setbit(); +static int amatch(); +static int biteq(); static BITMAP clearbits(); #endif @@ -81,7 +81,7 @@ static BITMAP clearbits(); * the match string, and (perhaps) repaint the display. */ forwsearch(f, n) -int f, n; /* default flag / numeric argument */ +int f, n; /* default flag / numeric argument */ { register int status = TRUE; @@ -89,7 +89,7 @@ int f, n; /* default flag / numeric argument */ * Otherwise proceed by asking for the search string. */ if (n < 0) - return(backsearch(f, -n)); + return (backsearch(f, -n)); /* Ask the user for the text of a pattern. If the * response is TRUE (responses other than FALSE are @@ -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); @@ -115,7 +117,7 @@ int f, n; /* default flag / numeric argument */ else mlwrite("Not found"); } - return(status); + return (status); } /* @@ -125,25 +127,23 @@ int f, n; /* default flag / numeric argument */ */ forwhunt(f, n) -int f, n; /* default flag / numeric argument */ +int f, n; /* default flag / numeric argument */ { register int status = TRUE; if (n < 0) /* search backwards */ - return(backhunt(f, -n)); + return (backhunt(f, -n)); /* 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); @@ -171,7 +170,7 @@ int f, n; /* default flag / numeric argument */ else mlwrite("Not found"); - return(status); + return (status); } /* @@ -181,7 +180,7 @@ int f, n; /* default flag / numeric argument */ * (the last character that was matched). */ backsearch(f, n) -int f, n; /* default flag / numeric argument */ +int f, n; /* default flag / numeric argument */ { register int status = TRUE; @@ -189,7 +188,7 @@ int f, n; /* default flag / numeric argument */ * Otherwise proceed by asking for the search string. */ if (n < 0) - return(forwsearch(f, -n)); + return (forwsearch(f, -n)); /* Ask the user for the text of a pattern. If the * response is TRUE (responses other than FALSE are @@ -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); @@ -215,7 +217,7 @@ int f, n; /* default flag / numeric argument */ else mlwrite("Not found"); } - return(status); + return (status); } /* @@ -225,25 +227,23 @@ int f, n; /* default flag / numeric argument */ * (the last character that was matched). */ backhunt(f, n) -int f, n; /* default flag / numeric argument */ +int f, n; /* default flag / numeric argument */ { - register int status = TRUE; + register int status = TRUE; if (n < 0) - return(forwhunt(f, -n)); + return (forwhunt(f, -n)); /* 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); @@ -271,7 +270,7 @@ int f, n; /* default flag / numeric argument */ else mlwrite("Not found"); - return(status); + return (status); } #if MAGIC @@ -280,13 +279,13 @@ int f, n; /* default flag / numeric argument */ * reset the "." to be at the start or just after the match string, * and (perhaps) repaint the display. */ -int mcscanner(mcpatrn, direct, beg_or_end) -MC *mcpatrn; /* pointer into pattern */ -int direct; /* which way to go.*/ -int beg_or_end; /* put point at beginning or end of pattern.*/ +int mcscanner(mcpatrn, direct, beg_or_end) +MC *mcpatrn; /* pointer into pattern */ +int direct; /* which way to go. */ +int beg_or_end; /* put point at beginning or end of pattern. */ { - LINE *curline; /* current line during scan */ - int curoff; /* position within current line */ + LINE *curline; /* current line during scan */ + int curoff; /* position within current line */ /* If we are going in reverse, then the 'end' is actually * the beginning of the pattern. Toggle it. @@ -304,12 +303,11 @@ int beg_or_end; /* put point at beginning or end of pattern.*/ /* Setup local scan pointers to global ".". */ curline = curwp->w_dotp; - curoff = curwp->w_doto; + curoff = curwp->w_doto; /* 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,23 +316,20 @@ 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; } - curwp->w_flag |= WFMOVE; /* flag that we have moved */ + curwp->w_flag |= WFMOVE; /* flag that we have moved */ return TRUE; } @@ -343,7 +338,7 @@ int beg_or_end; /* put point at beginning or end of pattern.*/ nextch(&curline, &curoff, direct); } - return FALSE; /* We could not find a match.*/ + return FALSE; /* We could not find a match. */ } /* @@ -351,15 +346,15 @@ int beg_or_end; /* put point at beginning or end of pattern.*/ * recursive routine amatch() (for "anchored match") in * Kernighan & Plauger's "Software Tools". */ -static int amatch(mcptr, direct, pcwline, pcwoff) -register MC *mcptr; /* string to scan for */ -int direct; /* which way to go.*/ -LINE **pcwline; /* current line during scan */ -int *pcwoff; /* position within current line */ +static int amatch(mcptr, direct, pcwline, pcwoff) +register MC *mcptr; /* string to scan for */ +int direct; /* which way to go. */ +LINE **pcwline; /* current line during scan */ +int *pcwoff; /* position within current line */ { - register int c; /* character at current position */ - LINE *curline; /* current line during scan */ - int curoff; /* position within current line */ + register int c; /* character at current position */ + LINE *curline; /* current line during scan */ + int curoff; /* position within current line */ int nchars; /* Set up local scan pointers to ".", and get @@ -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 @@ -481,14 +466,14 @@ int *pcwoff; /* position within current line */ */ matchlen++; mcptr++; - } /* End of mcptr loop.*/ + } /* End of mcptr loop. */ /* A SUCCESSFULL MATCH!!! * Reset the "." pointers. */ -success: + success: *pcwline = curline; - *pcwoff = curoff; + *pcwoff = curoff; return TRUE; } @@ -499,17 +484,17 @@ success: * reset the "." to be at the start or just after the match string, * and (perhaps) repaint the display. */ -int scanner(patrn, direct, beg_or_end) -unsigned char *patrn; /* string to scan for */ -int direct; /* which way to go.*/ -int beg_or_end; /* put point at beginning or end of pattern.*/ +int scanner(patrn, direct, beg_or_end) +unsigned char *patrn; /* string to scan for */ +int direct; /* which way to go. */ +int beg_or_end; /* put point at beginning or end of pattern. */ { - register int c; /* character at current position */ + register int c; /* character at current position */ register unsigned char *patptr; /* pointer into pattern */ - LINE *curline; /* current line during scan */ - int curoff; /* position within current line */ - LINE *scanline; /* current line during scanning */ - int scanoff; /* position in scanned line */ + LINE *curline; /* current line during scan */ + int curoff; /* position within current line */ + LINE *scanline; /* current line during scanning */ + int scanoff; /* position in scanned line */ /* If we are going in reverse, then the 'end' is actually * the beginning of the pattern. Toggle it. @@ -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,42 +539,39 @@ 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; } - curwp->w_flag |= WFMOVE; /* Flag that we have moved.*/ + curwp->w_flag |= WFMOVE; /* Flag that we have moved. */ return TRUE; } -fail:; /* continue to search */ + fail:; /* continue to search */ } - return FALSE; /* We could not find a match */ + return FALSE; /* We could not find a match */ } /* * eq -- Compare two characters. The "bc" comes from the buffer, "pc" * from the pattern. If we are not in EXACT mode, fold out the case. */ -int eq(bc, pc) +int eq(bc, pc) #if PKCODE -register char bc; -register char pc; +register char bc; +register char pc; #else -register int bc; -register int pc; +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; @@ -614,17 +593,17 @@ register int pc; * to delimit the end-of-pattern to allow s in the search * string. */ -static int readpattern(prompt, apat, srch) -char *prompt; -char apat[]; -int srch; +static int readpattern(prompt, apat, srch) +char *prompt; +char apat[]; +int srch; { int status; - char tpat[NPAT+20]; + char tpat[NPAT + 20]; strcpy(tpat, prompt); /* copy prompt to output string */ strcat(tpat, " ("); /* build new prompt string */ - expandp(&apat[0], &tpat[strlen(tpat)], NPAT/2); /* add old pattern */ + expandp(&apat[0], &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */ strcat(tpat, "): "); /* Read a pattern. Either we get one, @@ -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,19 +625,16 @@ 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 - status = srch? mcstr(): rmcstr(); + } 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); + return (status); } /* @@ -668,10 +642,10 @@ int srch; */ savematch() { - register char *ptr; /* pointer to last match string */ - register int j; - LINE *curline; /* line of last match */ - int curoff; /* offset " " */ + register char *ptr; /* pointer to last match string */ + register int j; + LINE *curline; /* line of last match */ + int curoff; /* offset " " */ /* Free any existing match string, then * attempt to allocate a new one. @@ -681,8 +655,7 @@ savematch() ptr = patmatch = malloc(matchlen + 1); - if (ptr != NULL) - { + if (ptr != NULL) { curoff = matchoff; curline = matchline; @@ -697,7 +670,7 @@ savematch() * rvstrcpy -- Reverse string copy. */ rvstrcpy(rvstr, str) -register char *rvstr, *str; +register char *rvstr, *str; { register int i; @@ -713,30 +686,30 @@ register char *rvstr, *str; * sreplace -- Search and replace. */ sreplace(f, n) -int f; /* default flag */ -int n; /* # of repetitions wanted */ +int f; /* default flag */ +int n; /* # of repetitions wanted */ { - return(replaces(FALSE, f, n)); + return (replaces(FALSE, f, n)); } /* * qreplace -- search and replace with query. */ qreplace(f, n) -int f; /* default flag */ -int n; /* # of repetitions wanted */ +int f; /* default flag */ +int n; /* # of repetitions wanted */ { - return(replaces(TRUE, f, n)); + return (replaces(TRUE, f, n)); } /* * replaces -- Search for a string and replace it with another * string. Query might be enabled (according to kind). */ -static int replaces(kind, f, n) -int kind; /* Query enabled flag */ -int f; /* default flag */ -int n; /* # of repetitions wanted */ +static int replaces(kind, f, n) +int kind; /* Query enabled flag */ +int f; /* default flag */ +int n; /* # of repetitions wanted */ { register int status; /* success flag on pattern inputs */ register int rlength; /* length of replacement string */ @@ -751,25 +724,26 @@ int n; /* # of repetitions wanted */ LINE *lastline; /* position of last replace and */ int lastoff; /* offset (for 'u' query option) */ - if (curbp->b_mode & MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ /* Check for negative repetitions. */ if (f && n < 0) - return(FALSE); + return (FALSE); /* Ask the user for the text of a pattern. */ - if ((status = readpattern( - (kind == FALSE ? "Replace" : "Query replace"), &pat[0], TRUE)) - != TRUE) - return(status); + if ((status = readpattern((kind == + FALSE ? "Replace" : "Query replace"), + &pat[0], TRUE)) + != TRUE) + return (status); /* Ask for the replacement string. */ if ((status = readpattern("with", &rpat[0], FALSE)) == ABORT) - return(status); + return (status); /* Find the length of the replacement string. */ @@ -781,14 +755,13 @@ int n; /* # of repetitions wanted */ nlflag = (pat[matchlen - 1] == '\n'); nlrepl = FALSE; - if (kind) - { + if (kind) { /* Build query replace question string. */ strcpy(tpat, "Replace '"); - expandp(&pat[0], &tpat[strlen(tpat)], NPAT/3); + expandp(&pat[0], &tpat[strlen(tpat)], NPAT / 3); strcat(tpat, "' with '"); - expandp(&rpat[0], &tpat[strlen(tpat)], NPAT/3); + expandp(&rpat[0], &tpat[strlen(tpat)], NPAT / 3); strcat(tpat, "'? "); /* Initialize last replaced pointers. @@ -805,24 +778,21 @@ int n; /* # of repetitions wanted */ numsub = 0; nummatch = 0; - while ( (f == FALSE || n > nummatch) && - (nlflag == FALSE || nlrepl == FALSE) ) - { + while ((f == FALSE || n > nummatch) && + (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 */ + if (!scanner(&pat[0], FORWARD, PTBEG)) + break; /* all done */ ++nummatch; /* Increment # of matches */ @@ -832,100 +802,99 @@ int n; /* # of repetitions wanted */ /* Check for query. */ - if (kind) - { + if (kind) { /* Get the query. */ -pprompt: mlwrite(&tpat[0], &pat[0], &rpat[0]); -qprompt: - update(TRUE); /* show the proposed place to change */ - c = tgetc(); /* and input */ - mlwrite(""); /* and clear it */ + pprompt:mlwrite(&tpat[0], &pat[0], + &rpat[0]); + qprompt: + update(TRUE); /* show the proposed place to change */ + c = tgetc(); /* and input */ + mlwrite(""); /* and clear it */ /* And respond appropriately. */ - switch (c) - { + switch (c) { #if PKCODE - case 'Y': + case 'Y': #endif - case 'y': /* yes, substitute */ - case ' ': - savematch(); - break; + case 'y': /* yes, substitute */ + case ' ': + savematch(); + break; #if PKCODE - case 'N': + case 'N': #endif - case 'n': /* no, onword */ - forwchar(FALSE, 1); - continue; + case 'n': /* no, onword */ + forwchar(FALSE, 1); + continue; - case '!': /* yes/stop asking */ - kind = FALSE; - break; + case '!': /* yes/stop asking */ + kind = FALSE; + break; #if PKCODE - case 'U': + case 'U': #endif - case 'u': /* undo last and re-prompt */ + case 'u': /* undo last and re-prompt */ - /* Restore old position. + /* Restore old position. + */ + if (lastline == NULL) { + /* There is nothing to undo. */ - if (lastline == NULL) - { - /* There is nothing to undo. - */ - TTbeep(); - goto pprompt; - } - curwp->w_dotp = lastline; - curwp->w_doto = lastoff; - lastline = NULL; - lastoff = 0; - - /* Delete the new string. - */ - backchar(FALSE, rlength); -#if PKCODE - matchline = curwp->w_dotp; - matchoff = curwp->w_doto; -#endif - status = delins(rlength, patmatch, FALSE); - if (status != TRUE) - return (status); - - /* Record one less substitution, - * backup, save our place, and - * reprompt. - */ - --numsub; - backchar(FALSE, mlenold); - matchline = curwp->w_dotp; - matchoff = curwp->w_doto; - goto pprompt; - - case '.': /* abort! and return */ - /* restore old position */ - curwp->w_dotp = origline; - curwp->w_doto = origoff; - curwp->w_flag |= WFMOVE; - - case BELL: /* abort! and stay */ - mlwrite("Aborted!"); - return(FALSE); - - default: /* bitch and beep */ TTbeep(); + goto pprompt; + } + curwp->w_dotp = lastline; + curwp->w_doto = lastoff; + lastline = NULL; + lastoff = 0; - case '?': /* help me */ - mlwrite( -"(Y)es, (N)o, (!)Do rest, (U)ndo last, (^G)Abort, (.)Abort back, (?)Help: "); - goto qprompt; + /* Delete the new string. + */ + backchar(FALSE, rlength); +#if PKCODE + matchline = curwp->w_dotp; + matchoff = curwp->w_doto; +#endif + status = delins(rlength, patmatch, FALSE); + if (status != TRUE) + return (status); + + /* Record one less substitution, + * backup, save our place, and + * reprompt. + */ + --numsub; + backchar(FALSE, mlenold); + matchline = curwp->w_dotp; + matchoff = curwp->w_doto; + goto pprompt; + + case '.': /* abort! and return */ + /* restore old position */ + curwp->w_dotp = origline; + curwp->w_doto = origoff; + curwp->w_flag |= WFMOVE; + + case BELL: /* abort! and stay */ + mlwrite("Aborted!"); + return (FALSE); + + default: /* bitch and beep */ + TTbeep(); + + case '?': /* help me */ + 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; } @@ -949,7 +917,7 @@ qprompt: /* And report the results. */ mlwrite("%d substitutions", numsub); - return(TRUE); + return (TRUE); } /* @@ -958,13 +926,13 @@ qprompt: * replacement meta-array. */ delins(dlength, instr, use_meta) -int dlength; -char *instr; -int use_meta; +int dlength; +char *instr; +int use_meta; { - int status; + int status; #if MAGIC - RMC *rmcptr; + RMC *rmcptr; #endif /* Zap what we gotta, @@ -974,39 +942,37 @@ int use_meta; mlwrite("%%ERROR while deleting"); else #if MAGIC - if ((rmagical && use_meta) && - (curwp->w_bufp->b_mode & MDMAGIC) != 0) { - rmcptr = &rmcpat[0]; - while (rmcptr->mc_type != MCNIL && status == TRUE) { - if (rmcptr->mc_type == LITCHAR) - status = linstr(rmcptr->rstr); - else - status = linstr(patmatch); - rmcptr++; - } - } else + if ((rmagical && use_meta) && + (curwp->w_bufp->b_mode & MDMAGIC) != 0) { + rmcptr = &rmcpat[0]; + while (rmcptr->mc_type != MCNIL && status == TRUE) { + if (rmcptr->mc_type == LITCHAR) + status = linstr(rmcptr->rstr); + else + status = linstr(patmatch); + rmcptr++; + } + } else #endif - status = linstr(instr); + status = linstr(instr); - return(status); + return (status); } /* * expandp -- Expand control key sequences for output. */ expandp(srcstr, deststr, maxlength) -char *srcstr; /* string to expand */ -char *deststr; /* destination of expanded string */ -int maxlength; /* maximum chars in destination */ +char *srcstr; /* string to expand */ +char *deststr; /* destination of expanded string */ +int maxlength; /* maximum chars in destination */ { unsigned char c; /* current char to translate */ /* 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,29 +988,25 @@ 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); + return (FALSE); } } *deststr = '\0'; - return(TRUE); + return (TRUE); } /* @@ -1055,21 +1016,18 @@ int maxlength; /* maximum chars in destination */ * in future, a' la VMS EDT. At the moment, just return TRUE or * FALSE depending on if a boundry is hit (ouch). */ -int boundry(curline, curoff, dir) -LINE *curline; -int curoff, dir; +int boundry(curline, curoff, dir) +LINE *curline; +int curoff, dir; { - register int border; + register int border; - if (dir == FORWARD) - { + if (dir == FORWARD) { border = (curoff == llength(curline)) && - (lforw(curline) == curbp->b_linep); - } - else - { + (lforw(curline) == curbp->b_linep); + } else { border = (curoff == 0) && - (lback(curline) == curbp->b_linep); + (lback(curline) == curbp->b_linep); } return (border); } @@ -1083,37 +1041,31 @@ int curoff, dir; * look at the character. */ static int nextch(pcurline, pcuroff, dir) -LINE **pcurline; -int *pcuroff; -int dir; +LINE **pcurline; +int *pcuroff; +int dir; { - register LINE *curline; - register int curoff; - register int c; + register LINE *curline; + register int curoff; + register int c; 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 */ - } - else + c = '\n'; /* and return a */ + } 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); } @@ -1139,12 +1091,12 @@ int dir; */ static int mcstr() { - MC *mcptr, *rtpcm; - char *patptr; - int mj; - int pchr; - int status = TRUE; - int does_closure = FALSE; + MC *mcptr, *rtpcm; + char *patptr; + int mj; + int pchr; + int status = TRUE; + int does_closure = FALSE; /* If we had metacharacters in the MC array previously, * free up any bitmaps that may have been allocated. @@ -1157,68 +1109,66 @@ static int mcstr() mcptr = &mcpat[0]; patptr = &pat[0]; - while ((pchr = *patptr) && status) - { - switch (pchr) - { - case MC_CCL: - status = cclmake(&patptr, mcptr); - magical = TRUE; - does_closure = TRUE; - break; - case MC_BOL: - if (mj != 0) - goto litcase; + while ((pchr = *patptr) && status) { + switch (pchr) { + case MC_CCL: + status = cclmake(&patptr, mcptr); + magical = TRUE; + does_closure = TRUE; + break; + case MC_BOL: + if (mj != 0) + goto litcase; - mcptr->mc_type = BOL; - magical = TRUE; - does_closure = FALSE; - break; - case MC_EOL: - if (*(patptr + 1) != '\0') - goto litcase; + mcptr->mc_type = BOL; + magical = TRUE; + does_closure = FALSE; + break; + case MC_EOL: + if (*(patptr + 1) != '\0') + goto litcase; - mcptr->mc_type = EOL; - magical = TRUE; - does_closure = FALSE; - break; - case MC_ANY: - mcptr->mc_type = ANY; - magical = TRUE; - does_closure = TRUE; - break; - case MC_CLOSURE: - /* Does the closure symbol mean closure here? - * If so, back up to the previous element - * and indicate it is enclosed. - */ - if (!does_closure) - goto litcase; - mj--; - mcptr--; - mcptr->mc_type |= CLOSURE; - magical = TRUE; - does_closure = FALSE; - break; + mcptr->mc_type = EOL; + magical = TRUE; + does_closure = FALSE; + break; + case MC_ANY: + mcptr->mc_type = ANY; + magical = TRUE; + does_closure = TRUE; + break; + case MC_CLOSURE: + /* Does the closure symbol mean closure here? + * If so, back up to the previous element + * and indicate it is enclosed. + */ + if (!does_closure) + goto litcase; + mj--; + mcptr--; + mcptr->mc_type |= CLOSURE; + magical = TRUE; + does_closure = FALSE; + break; /* Note: no break between MC_ESC case and the default. */ - case MC_ESC: - if (*(patptr + 1) != '\0') - { - pchr = *++patptr; - magical = TRUE; - } - default: -litcase: mcptr->mc_type = LITCHAR; - mcptr->u.lchar = pchr; - does_closure = (pchr != '\n'); - break; - } /* End of switch.*/ + case MC_ESC: + if (*(patptr + 1) != '\0') { + pchr = *++patptr; + magical = TRUE; + } + default: + litcase:mcptr->mc_type = + LITCHAR; + mcptr->u.lchar = pchr; + does_closure = (pchr != '\n'); + break; + } /* End of switch. */ mcptr++; patptr++; mj++; - } /* End of while.*/ + } /* End of while. */ /* Close off the meta-string. */ @@ -1232,24 +1182,20 @@ 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(); } - return(status); + return (status); } /* @@ -1260,86 +1206,80 @@ litcase: mcptr->mc_type = LITCHAR; */ static int rmcstr() { - RMC *rmcptr; - char *patptr; - int status = TRUE; - int mj; + RMC *rmcptr; + char *patptr; + int status = TRUE; + int mj; patptr = &rpat[0]; rmcptr = &rmcpat[0]; mj = 0; rmagical = FALSE; - while (*patptr && status == TRUE) - { - switch (*patptr) - { - case MC_DITTO: + while (*patptr && status == TRUE) { + switch (*patptr) { + case MC_DITTO: - /* If there were non-magical characters - * in the string before reaching this - * character, plunk it in the replacement - * array before processing the current - * meta-character. - */ - if (mj != 0) - { - rmcptr->mc_type = LITCHAR; - if ((rmcptr->rstr = malloc(mj + 1)) == NULL) - { - mlwrite("%%Out of memory"); - status = FALSE; - break; - } - strncpy(rmcptr->rstr, patptr - mj, mj); - rmcptr++; - mj = 0; - } - rmcptr->mc_type = DITTO; - rmcptr++; - rmagical = TRUE; - break; - - case MC_ESC: + /* If there were non-magical characters + * in the string before reaching this + * character, plunk it in the replacement + * array before processing the current + * meta-character. + */ + if (mj != 0) { rmcptr->mc_type = LITCHAR; - - /* We malloc mj plus two here, instead - * of one, because we have to count the - * current character. - */ - if ((rmcptr->rstr = malloc(mj + 2)) == NULL) - { + if ((rmcptr->rstr = + malloc(mj + 1)) == NULL) { mlwrite("%%Out of memory"); status = FALSE; break; } - - strncpy(rmcptr->rstr, patptr - mj, mj + 1); - - /* If MC_ESC is not the last character - * in the string, find out what it is - * escaping, and overwrite the last - * character with it. - */ - if (*(patptr + 1) != '\0') - *((rmcptr->rstr) + mj) = *++patptr; - + strncpy(rmcptr->rstr, patptr - mj, mj); rmcptr++; mj = 0; - rmagical = TRUE; - break; + } + rmcptr->mc_type = DITTO; + rmcptr++; + rmagical = TRUE; + break; - default: - mj++; + case MC_ESC: + rmcptr->mc_type = LITCHAR; + + /* We malloc mj plus two here, instead + * of one, because we have to count the + * current character. + */ + if ((rmcptr->rstr = malloc(mj + 2)) == NULL) { + mlwrite("%%Out of memory"); + status = FALSE; + break; + } + + strncpy(rmcptr->rstr, patptr - mj, mj + 1); + + /* If MC_ESC is not the last character + * in the string, find out what it is + * escaping, and overwrite the last + * character with it. + */ + if (*(patptr + 1) != '\0') + *((rmcptr->rstr) + mj) = *++patptr; + + rmcptr++; + mj = 0; + rmagical = TRUE; + break; + + default: + mj++; } 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; } @@ -1355,12 +1295,11 @@ static int rmcstr() */ mcclear() { - register MC *mcptr; + register MC *mcptr; 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); @@ -1374,12 +1313,11 @@ mcclear() */ rmcclear() { - register RMC *rmcptr; + register RMC *rmcptr; rmcptr = &rmcpat[0]; - while (rmcptr->mc_type != MCNIL) - { + while (rmcptr->mc_type != MCNIL) { if (rmcptr->mc_type == LITCHAR) free(rmcptr->rstr); rmcptr++; @@ -1393,52 +1331,48 @@ rmcclear() * Software Tools, this is the function omatch(), but i felt there * were too many functions with the 'match' name already. */ -static int mceq(bc, mt) -int bc; -MC *mt; +static int mceq(bc, mt) +int bc; +MC *mt; { register int result; #if PKCODE bc = bc & 0xFF; #endif - switch (mt->mc_type & MASKCL) - { - case LITCHAR: - result = eq(bc, mt->u.lchar); - break; + switch (mt->mc_type & MASKCL) { + case LITCHAR: + result = eq(bc, mt->u.lchar); + break; - case ANY: - result = (bc != '\n'); - break; - - case CCL: - if (!(result = biteq(bc, mt->u.cclmap))) - { - if ((curwp->w_bufp->b_mode & MDEXACT) == 0 && - (isletter(bc))) - { - result = biteq(CHCASE(bc), mt->u.cclmap); - } - } - break; - - case NCCL: - result = !biteq(bc, mt->u.cclmap); + case ANY: + result = (bc != '\n'); + break; + case CCL: + if (!(result = biteq(bc, mt->u.cclmap))) { if ((curwp->w_bufp->b_mode & MDEXACT) == 0 && - (isletter(bc))) - { - result &= !biteq(CHCASE(bc), mt->u.cclmap); + (isletter(bc))) { + result = biteq(CHCASE(bc), mt->u.cclmap); } - break; + } + break; - default: - mlwrite("mceq: what is %d?", mt->mc_type); - result = FALSE; - break; + case NCCL: + result = !biteq(bc, mt->u.cclmap); - } /* End of switch.*/ + if ((curwp->w_bufp->b_mode & MDEXACT) == 0 && + (isletter(bc))) { + result &= !biteq(CHCASE(bc), mt->u.cclmap); + } + break; + + default: + mlwrite("mceq: what is %d?", mt->mc_type); + result = FALSE; + break; + + } /* End of switch. */ return (result); } @@ -1448,17 +1382,16 @@ MC *mt; * ppatptr is left pointing to the end-of-character-class character, * so that a loop may automatically increment with safety. */ -static int cclmake(ppatptr, mcptr) -char **ppatptr; -MC *mcptr; +static int cclmake(ppatptr, mcptr) +char **ppatptr; +MC *mcptr; { - BITMAP clearbits(); - BITMAP bmap; - register char *patptr; - register int pchr, ochr; + BITMAP clearbits(); + BITMAP bmap; + 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,32 +1422,29 @@ 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. */ - case MC_RCCL: - if (*(patptr + 1) == MC_ECCL) - setbit(pchr, bmap); - else - { - pchr = *++patptr; - while (++ochr <= pchr) - setbit(ochr, bmap); - } - break; + case MC_RCCL: + if (*(patptr + 1) == MC_ECCL) + setbit(pchr, bmap); + else { + pchr = *++patptr; + while (++ochr <= pchr) + setbit(ochr, bmap); + } + break; /* Note: no break between case MC_ESC and the default. */ - case MC_ESC: - pchr = *++patptr; - default: - setbit(pchr, bmap); - break; + case MC_ESC: + pchr = *++patptr; + default: + setbit(pchr, bmap); + break; } patptr++; ochr = pchr; @@ -1527,8 +1452,7 @@ MC *mcptr; *ppatptr = patptr; - if (ochr == '\0') - { + if (ochr == '\0') { mlwrite("%%Character class not ended"); free(bmap); return FALSE; @@ -1539,9 +1463,9 @@ MC *mcptr; /* * biteq -- is the character in the bitmap? */ -static int biteq(bc, cclmap) -int bc; -BITMAP cclmap; +static int biteq(bc, cclmap) +int bc; +BITMAP cclmap; { #if PKCODE bc = bc & 0xFF; @@ -1549,18 +1473,18 @@ BITMAP cclmap; if (bc >= HICHAR) return FALSE; - return( (*(cclmap + (bc >> 3)) & BIT(bc & 7))? TRUE: FALSE ); + return ((*(cclmap + (bc >> 3)) & BIT(bc & 7)) ? TRUE : FALSE); } /* * clearbits -- Allocate and zero out a CCL bitmap. */ -static BITMAP clearbits() +static BITMAP clearbits() { - char *malloc(); + char *malloc(); - BITMAP cclstart, cclmap; - register int j; + BITMAP cclstart, cclmap; + register int j; if ((cclmap = cclstart = (BITMAP) malloc(HIBYTE)) != NULL) for (j = 0; j < HIBYTE; j++) @@ -1573,8 +1497,8 @@ static BITMAP clearbits() * setbit -- Set a bit (ON only) in the bitmap. */ static void setbit(bc, cclmap) -int bc; -BITMAP cclmap; +int bc; +BITMAP cclmap; { #if PKCODE bc = bc & 0xFF; diff --git a/spawn.c b/spawn.c index c64969e..616e37b 100644 --- a/spawn.c +++ b/spawn.c @@ -9,16 +9,16 @@ #include "edef.h" #if VMS -#define EFN 0 /* Event flag. */ +#define EFN 0 /* Event flag. */ -#include /* Random headers. */ +#include /* Random headers. */ #include #include #include -extern int oldmode[3]; /* In "termio.c" */ -extern int newmode[3]; /* In "termio.c" */ -extern short iochan; /* In "termio.c" */ +extern int oldmode[3]; /* In "termio.c" */ +extern int newmode[3]; /* In "termio.c" */ +extern short iochan; /* In "termio.c" */ #endif #if V7 | USG | BSD @@ -43,50 +43,50 @@ extern void sizesignal(); spawncli(f, n) { #if V7 | USG | BSD - register char *cp; - char *getenv(); + register char *cp; + char *getenv(); #endif /* don't allow this command if restricted */ if (restflag) - return(resterr()); + return (resterr()); #if VMS - movecursor(term.t_nrow, 0); /* In last line. */ - mlputs("(Starting DCL)\r\n"); - TTflush(); /* Ignore "ttcol". */ - sgarbf = TRUE; + movecursor(term.t_nrow, 0); /* In last line. */ + mlputs("(Starting DCL)\r\n"); + TTflush(); /* Ignore "ttcol". */ + sgarbf = TRUE; sys(NULL); sleep(1); mlputs("\r\n(Returning from DCL)\r\n"); TTflush(); sleep(1); - return(TRUE); + return (TRUE); #endif #if MSDOS & (MSC | TURBO) - movecursor(term.t_nrow, 0); /* Seek to last line. */ - TTflush(); + movecursor(term.t_nrow, 0); /* Seek to last line. */ + TTflush(); TTkclose(); shellprog(""); TTkopen(); - sgarbf = TRUE; - return(TRUE); + sgarbf = TRUE; + return (TRUE); #endif #if V7 | USG | BSD - movecursor(term.t_nrow, 0); /* Seek to last line. */ - TTflush(); - TTclose(); /* stty to old settings */ - if ((cp = getenv("SHELL")) != NULL && *cp != '\0') - system(cp); - else + movecursor(term.t_nrow, 0); /* Seek to last line. */ + TTflush(); + TTclose(); /* stty to old settings */ + if ((cp = getenv("SHELL")) != NULL && *cp != '\0') + system(cp); + else #if BSD - system("exec /bin/csh"); + system("exec /bin/csh"); #else - system("exec /bin/sh"); + system("exec /bin/sh"); #endif - sgarbf = TRUE; + sgarbf = TRUE; sleep(2); - TTopen(); + TTopen(); TTkopen(); #ifdef SIGWINCH /* @@ -95,17 +95,17 @@ spawncli(f, n) * -lbt */ chg_width = term.t_ncol; - chg_height = term.t_nrow+1; + chg_height = term.t_nrow + 1; term.t_nrow = term.t_ncol = 0; #endif - return(TRUE); + return (TRUE); #endif } #if BSD | __hpux | SVR4 -bktoshell() /* suspend MicroEMACS and wait to wake up */ -{ +bktoshell() +{ /* suspend MicroEMACS and wait to wake up */ int pid; vttidy(); @@ -131,62 +131,61 @@ rtfrmshell() */ spawn(f, n) { - register int s; - char line[NLINE]; + register int s; + char line[NLINE]; /* don't allow this command if restricted */ if (restflag) - return(resterr()); + return (resterr()); #if VMS - if ((s=mlreply("!", line, NLINE)) != TRUE) - return (s); + if ((s = mlreply("!", line, NLINE)) != TRUE) + return (s); movecursor(term.t_nrow, 0); - TTflush(); - s = sys(line); /* Run the command. */ + TTflush(); + s = sys(line); /* Run the command. */ if (clexec == FALSE) { - mlputs("\r\n\n(End)"); /* Pause. */ + mlputs("\r\n\n(End)"); /* Pause. */ TTflush(); tgetc(); } - sgarbf = TRUE; - return (s); + sgarbf = TRUE; + return (s); #endif #if MSDOS - if ((s=mlreply("!", line, NLINE)) != TRUE) - return(s); + if ((s = mlreply("!", line, NLINE)) != TRUE) + return (s); movecursor(term.t_nrow, 0); TTkclose(); - shellprog(line); + shellprog(line); TTkopen(); /* if we are interactive, pause here */ if (clexec == FALSE) { - mlputs("\r\n(End)"); - tgetc(); - } - sgarbf = TRUE; - return (TRUE); + mlputs("\r\n(End)"); + tgetc(); + } + sgarbf = TRUE; + return (TRUE); #endif #if V7 | USG | BSD - if ((s=mlreply("!", line, NLINE)) != TRUE) - return (s); - TTflush(); - TTclose(); /* stty to old modes */ + if ((s = mlreply("!", line, NLINE)) != TRUE) + return (s); + TTflush(); + TTclose(); /* stty to old modes */ TTkclose(); - system(line); - fflush(stdout); /* to be sure P.K. */ - TTopen(); + system(line); + fflush(stdout); /* to be sure P.K. */ + TTopen(); if (clexec == FALSE) { - mlputs("(End)"); /* Pause. */ + mlputs("(End)"); /* Pause. */ TTflush(); - while ((s = tgetc()) != '\r' && s != ' ') - ; + while ((s = tgetc()) != '\r' && s != ' '); mlputs("\r\n"); } TTkopen(); - sgarbf = TRUE; - return (TRUE); + sgarbf = TRUE; + return (TRUE); #endif } @@ -197,58 +196,56 @@ spawn(f, n) */ execprg(f, n) - { - register int s; - char line[NLINE]; + register int s; + char line[NLINE]; /* don't allow this command if restricted */ if (restflag) - return(resterr()); + return (resterr()); #if VMS - if ((s=mlreply("!", line, NLINE)) != TRUE) - return (s); - TTflush(); - s = sys(line); /* Run the command. */ - mlputs("\r\n\n(End)"); /* Pause. */ - TTflush(); - tgetc(); - sgarbf = TRUE; - return (s); + if ((s = mlreply("!", line, NLINE)) != TRUE) + return (s); + TTflush(); + s = sys(line); /* Run the command. */ + mlputs("\r\n\n(End)"); /* Pause. */ + TTflush(); + tgetc(); + sgarbf = TRUE; + return (s); #endif #if MSDOS - if ((s=mlreply("$", line, NLINE)) != TRUE) - return(s); + if ((s = mlreply("$", line, NLINE)) != TRUE) + return (s); movecursor(term.t_nrow, 0); TTkclose(); - execprog(line); + execprog(line); TTkopen(); /* if we are interactive, pause here */ if (clexec == FALSE) { - mlputs("\r\n(End)"); - tgetc(); - } - sgarbf = TRUE; - return (TRUE); + mlputs("\r\n(End)"); + tgetc(); + } + sgarbf = TRUE; + return (TRUE); #endif #if V7 | USG | BSD - if ((s=mlreply("!", line, NLINE)) != TRUE) - return (s); - TTputc('\n'); /* Already have '\r' */ - TTflush(); - TTclose(); /* stty to old modes */ - system(line); - fflush(stdout); /* to be sure P.K. */ - TTopen(); - mlputs("(End)"); /* Pause. */ - TTflush(); - while ((s = tgetc()) != '\r' && s != ' ') - ; - sgarbf = TRUE; - return (TRUE); + if ((s = mlreply("!", line, NLINE)) != TRUE) + return (s); + TTputc('\n'); /* Already have '\r' */ + TTflush(); + TTclose(); /* stty to old modes */ + system(line); + fflush(stdout); /* to be sure P.K. */ + TTopen(); + mlputs("(End)"); /* Pause. */ + TTflush(); + while ((s = tgetc()) != '\r' && s != ' '); + sgarbf = TRUE; + return (TRUE); #endif } @@ -258,10 +255,10 @@ execprg(f, n) */ pipecmd(f, n) { - register int s; /* return status from CLI */ + register int s; /* return status from CLI */ register WINDOW *wp; /* pointer to new window */ register BUFFER *bp; /* pointer to buffer to zot */ - char line[NLINE]; /* command line send to shell */ + char line[NLINE]; /* command line send to shell */ static char bname[] = "command"; static char filnam[NSTRING] = "command"; @@ -271,36 +268,38 @@ pipecmd(f, n) char *getenv(); FILE *fp; FILE *fopen(); - int len; + int len; #endif /* don't allow this command if restricted */ if (restflag) - return(resterr()); + 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] != '/') - strcat(filnam,"\\"); - strcat(filnam,"command"); - } + if (len <= 0 || filnam[len - 1] != '\\' + && filnam[len - 1] != '/') + strcat(filnam, "\\"); + strcat(filnam, "command"); + } #endif #if VMS mlwrite("Not available under VMS"); - return(FALSE); + return (FALSE); #endif /* get the command to pipe in */ - if ((s=mlreply("@", line, NLINE)) != TRUE) - return(s); + if ((s = mlreply("@", line, NLINE)) != TRUE) + return (s); /* get rid of the command output buffer if it exists */ - if ((bp=bfind(bname, FALSE, 0)) != FALSE) { + if ((bp = bfind(bname, FALSE, 0)) != FALSE) { /* try to make sure we are off screen */ wp = wheadp; while (wp != NULL) { @@ -320,17 +319,16 @@ pipecmd(f, n) } if (zotbuf(bp) != TRUE) - return(FALSE); + return (FALSE); } - #if MSDOS - strcat(line," >>"); - strcat(line,filnam); + strcat(line, " >>"); + strcat(line, filnam); movecursor(term.t_nrow, 0); TTkclose(); - shellprog(line); + shellprog(line); TTkopen(); - sgarbf = TRUE; + sgarbf = TRUE; if ((fp = fopen(filnam, "r")) == NULL) { s = FALSE; } else { @@ -340,27 +338,27 @@ pipecmd(f, n) #endif #if V7 | USG | BSD - TTflush(); - TTclose(); /* stty to old modes */ - strcat(line,">"); - strcat(line,filnam); - system(line); - TTopen(); - TTflush(); - sgarbf = TRUE; - s = TRUE; + TTflush(); + TTclose(); /* stty to old modes */ + strcat(line, ">"); + strcat(line, filnam); + system(line); + TTopen(); + TTflush(); + sgarbf = TRUE; + s = TRUE; #endif if (s != TRUE) - return(s); + return (s); /* split the current window to make room for the command output */ if (splitwind(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); /* and read the stuff in */ if (getfile(filnam, FALSE) == FALSE) - return(FALSE); + return (FALSE); /* make this window in VIEW mode, update all mode lines */ curwp->w_bufp->b_mode |= MDVIEW; @@ -372,7 +370,7 @@ pipecmd(f, n) /* and get rid of the temporary file */ unlink(filnam); - return(TRUE); + return (TRUE); } /* @@ -380,11 +378,10 @@ pipecmd(f, n) * Bound to ^X # */ filter(f, n) - { - register int s; /* return status from CLI */ + register int s; /* return status from CLI */ register BUFFER *bp; /* pointer to buffer to zot */ - char line[NLINE]; /* command line send to shell */ + char line[NLINE]; /* command line send to shell */ char tmpnam[NFILEN]; /* place to store real file name */ static char bname1[] = "fltinp"; @@ -393,19 +390,19 @@ filter(f, n) /* don't allow this command if restricted */ if (restflag) - return(resterr()); + return (resterr()); - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ #if VMS mlwrite("Not available under VMS"); - return(FALSE); + return (FALSE); #endif /* get the filter name and its args */ - if ((s=mlreply("#", line, NLINE)) != TRUE) - return(s); + if ((s = mlreply("#", line, NLINE)) != TRUE) + return (s); /* setup the proper file names */ bp = curbp; @@ -416,48 +413,47 @@ filter(f, n) if (writeout(filnam1) != TRUE) { mlwrite("(Cannot write filter file)"); strcpy(bp->b_fname, tmpnam); - return(FALSE); + return (FALSE); } - #if MSDOS - strcat(line," fltout"); + strcat(line, " fltout"); movecursor(term.t_nrow - 1, 0); TTkclose(); - shellprog(line); + shellprog(line); TTkopen(); - sgarbf = TRUE; + sgarbf = TRUE; s = TRUE; #endif #if V7 | USG | BSD - TTputc('\n'); /* Already have '\r' */ - TTflush(); - TTclose(); /* stty to old modes */ - strcat(line," fltout"); - system(line); - TTopen(); - TTflush(); - sgarbf = TRUE; - s = TRUE; + TTputc('\n'); /* Already have '\r' */ + TTflush(); + TTclose(); /* stty to old modes */ + strcat(line, " fltout"); + system(line); + TTopen(); + TTflush(); + sgarbf = TRUE; + s = TRUE; #endif /* on failure, escape gracefully */ - if (s != TRUE || (readin(filnam2,FALSE) == FALSE)) { + if (s != TRUE || (readin(filnam2, FALSE) == FALSE)) { mlwrite("(Execution failed)"); strcpy(bp->b_fname, tmpnam); unlink(filnam1); unlink(filnam2); - return(s); + return (s); } /* reset file name */ strcpy(bp->b_fname, tmpnam); /* restore name */ - bp->b_flag |= BFCHG; /* flag it as changed */ + bp->b_flag |= BFCHG; /* flag it as changed */ /* and get rid of the temporary file */ unlink(filnam1); unlink(filnam2); - return(TRUE); + return (TRUE); } #if VMS @@ -468,36 +464,36 @@ filter(f, n) * and the way out, because DCL does not want the channel to be in raw mode. */ sys(cmd) -register char *cmd; +register char *cmd; { - struct dsc$descriptor cdsc; - struct dsc$descriptor *cdscp; - long status; - long substatus; - long iosb[2]; + struct dsc$descriptor cdsc; + struct dsc$descriptor *cdscp; + long status; + long substatus; + long iosb[2]; - status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, - oldmode, sizeof(oldmode), 0, 0, 0, 0); - if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) - return (FALSE); - cdscp = NULL; /* Assume DCL. */ - if (cmd != NULL) { /* Build descriptor. */ - cdsc.dsc$a_pointer = cmd; - cdsc.dsc$w_length = strlen(cmd); - cdsc.dsc$b_dtype = DSC$K_DTYPE_T; - cdsc.dsc$b_class = DSC$K_CLASS_S; - cdscp = &cdsc; - } - status = LIB$SPAWN(cdscp, 0, 0, 0, 0, 0, &substatus, 0, 0, 0); - if (status != SS$_NORMAL) - substatus = status; - status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, - newmode, sizeof(newmode), 0, 0, 0, 0); - if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) - return (FALSE); - if ((substatus&STS$M_SUCCESS) == 0) /* Command failed. */ - return (FALSE); - return (TRUE); + status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, + oldmode, sizeof(oldmode), 0, 0, 0, 0); + if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) + return (FALSE); + cdscp = NULL; /* Assume DCL. */ + if (cmd != NULL) { /* Build descriptor. */ + cdsc.dsc$a_pointer = cmd; + cdsc.dsc$w_length = strlen(cmd); + cdsc.dsc$b_dtype = DSC$K_DTYPE_T; + cdsc.dsc$b_class = DSC$K_CLASS_S; + cdscp = &cdsc; + } + status = LIB$SPAWN(cdscp, 0, 0, 0, 0, 0, &substatus, 0, 0, 0); + if (status != SS$_NORMAL) + substatus = status; + status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, + newmode, sizeof(newmode), 0, 0, 0, 0); + if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) + return (FALSE); + if ((substatus & STS$M_SUCCESS) == 0) /* Command failed. */ + return (FALSE); + return (TRUE); } #endif @@ -507,7 +503,7 @@ register char *cmd; shellprog(cmd) -char *cmd; /* Incoming command line to execute */ +char *cmd; /* Incoming command line to execute */ { char *shell; /* Name of system command processor */ @@ -521,11 +517,11 @@ char *cmd; /* Incoming command line to execute */ regs.h.ah = 0x37; /* get setting data */ regs.h.al = 0x00; /* get switch character */ intdos(®s, ®s); - swchar = (char)regs.h.dl; + swchar = (char) regs.h.dl; /* get name of system shell */ if ((shell = getenv("COMSPEC")) == NULL) { - return(FALSE); /* No shell located */ + return (FALSE); /* No shell located */ } /* trim leading whitespace off the command */ @@ -543,9 +539,9 @@ char *cmd; /* Incoming command line to execute */ comline[strlen(comline)] = swchar; strcat(comline, "c "); strcat(comline, cmd); - return(execprog(comline)); + return (execprog(comline)); } else - return(execprog(shell)); + return (execprog(shell)); } /* EXECPROG: A function to execute a named program @@ -554,7 +550,7 @@ char *cmd; /* Incoming command line to execute */ execprog(cmd) -char *cmd; /* Incoming command line to execute */ +char *cmd; /* Incoming command line to execute */ { char *sp; /* temporary string pointer */ @@ -581,16 +577,16 @@ char *cmd; /* Incoming command line to execute */ /* and parse out the command tail */ while (*cmd && ((*cmd == ' ') || (*cmd == '\t'))) ++cmd; - *tail = (char)(strlen(cmd)); /* record the byte length */ + *tail = (char) (strlen(cmd)); /* record the byte length */ strcpy(&tail[1], cmd); strcat(&tail[1], "\r"); /* look up the program on the path trying various extentions */ if ((sp = flook(prog, TRUE)) == NULL) if ((sp = flook(strcat(prog, ".exe"), TRUE)) == NULL) { - strcpy(&prog[strlen(prog)-4], ".com"); + strcpy(&prog[strlen(prog) - 4], ".com"); if ((sp = flook(prog, TRUE)) == NULL) - return(FALSE); + return (FALSE); } strcpy(prog, sp); @@ -599,17 +595,17 @@ char *cmd; /* Incoming command line to execute */ /* set up the EXEC parameter block */ pblock.envptr = 0; /* make the child inherit the parents env */ - pblock.fcb1 = f1; /* point to a blank FCB */ - pblock.fcb2 = f2; /* point to a blank FCB */ - pblock.cline = tail; /* parameter line pointer */ + pblock.fcb1 = f1; /* point to a blank FCB */ + pblock.fcb2 = f2; /* point to a blank FCB */ + pblock.cline = tail; /* parameter line pointer */ /* and make the call */ regs.h.ah = 0x4b; /* EXEC Load or Execute a Program */ regs.h.al = 0x00; /* load end execute function subcode */ - segreg.ds = ((unsigned long)(prog) >> 16); /* program name ptr */ - regs.x.dx = (unsigned int)(prog); - segreg.es = ((unsigned long)(&pblock) >> 16); /* set up param block ptr */ - regs.x.bx = (unsigned int)(&pblock); + segreg.ds = ((unsigned long) (prog) >> 16); /* program name ptr */ + regs.x.dx = (unsigned int) (prog); + segreg.es = ((unsigned long) (&pblock) >> 16); /* set up param block ptr */ + regs.x.bx = (unsigned int) (&pblock); #if TURBO | MSC intdosx(®s, ®s, &segreg); if (regs.x.cflag == 0) { @@ -623,6 +619,6 @@ char *cmd; /* Incoming command line to execute */ rval = -_doserrno; /* failed child call */ #endif #endif - return((rval < 0) ? FALSE : TRUE); + return ((rval < 0) ? FALSE : TRUE); } #endif diff --git a/tcap.c b/tcap.c index 38c7488..723508e 100644 --- a/tcap.c +++ b/tcap.c @@ -11,7 +11,7 @@ * -lbt */ #define USE_BROKEN_OPTIMIZATION 0 -#define termdef 1 /* don't define "term" external */ +#define termdef 1 /* don't define "term" external */ #include #include "estruct.h" @@ -25,37 +25,37 @@ #define MARGIN 8 #define SCRSIZ 64 -#define NPAUSE 10 /* # times thru update to pause */ +#define NPAUSE 10 /* # times thru update to pause */ #define BEL 0x07 #define ESC 0x1B -extern int ttopen(); -extern int ttgetc(); -extern int ttputc(); -extern int tgetnum(); -extern int ttflush(); -extern int ttclose(); -extern int tcapkopen(); -extern int tcapkclose(); -extern int tcapmove(); -extern int tcapeeol(); -extern int tcapeeop(); -extern int tcapbeep(); -extern int tcaprev(); -extern int tcapcres(); -extern int tcapopen(); +extern int ttopen(); +extern int ttgetc(); +extern int ttputc(); +extern int tgetnum(); +extern int ttflush(); +extern int ttclose(); +extern int tcapkopen(); +extern int tcapkclose(); +extern int tcapmove(); +extern int tcapeeol(); +extern int tcapeeop(); +extern int tcapbeep(); +extern int tcaprev(); +extern int tcapcres(); +extern int tcapopen(); #if PKCODE -extern int tcapclose(); +extern int tcapclose(); #endif -extern int tput(); -extern char *tgoto(); +extern int tput(); +extern char *tgoto(); #if COLOR -extern int tcapfcol(); -extern int tcapbcol(); +extern int tcapfcol(); +extern int tcapbcol(); #endif #if SCROLLCODE -extern int tcapscroll_reg(); -extern int tcapscroll_delins(); +extern int tcapscroll_reg(); +extern int tcapscroll_delins(); #endif @@ -73,155 +73,150 @@ char *CS, *DL, *AL, *SF, *SR; #endif TERM term = { - 0, /* these four values are set dynamically at open time */ + 0, /* these four values are set dynamically at open time */ 0, 0, 0, MARGIN, SCRSIZ, NPAUSE, - tcapopen, + tcapopen, #if PKCODE tcapclose, #else - ttclose, + ttclose, #endif - tcapkopen, - tcapkclose, - ttgetc, - ttputc, - ttflush, - tcapmove, - tcapeeol, - tcapeeop, - tcapbeep, - tcaprev, - tcapcres + tcapkopen, + tcapkclose, + ttgetc, + ttputc, + ttflush, + tcapmove, + tcapeeol, + tcapeeop, + tcapbeep, + tcaprev, + tcapcres #if COLOR - , tcapfcol, + , tcapfcol, tcapbcol #endif -#if SCROLLCODE - , NULL /* set dynamically at open time */ +#if SCROLLCODE + , NULL /* set dynamically at open time */ #endif }; tcapopen() - { - char *getenv(); - char *t, *p, *tgetstr(); - char tcbuf[1024]; - char *tv_stype; - char err_str[72]; - int int_col, int_row; + char *getenv(); + char *t, *p, *tgetstr(); + char tcbuf[1024]; + char *tv_stype; + char err_str[72]; + 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) - { - puts("Environment variable TERM not defined!"); - exit(1); - } + 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); - puts(err_str); - exit(1); - } + if ((tgetent(tcbuf, tv_stype)) != 1) { + sprintf(err_str, "Unknown terminal type %s!", + tv_stype); + puts(err_str); + exit(1); + } - /* Get screen size from system, or else from termcap. */ - getscreensize(&int_col, &int_row); - term.t_nrow = int_row-1; - term.t_ncol = int_col; - - if ((term.t_nrow <= 0) && (term.t_nrow=(short)tgetnum("li")-1) == -1){ - puts("termcap entry incomplete (lines)"); - exit(1); - } + /* Get screen size from system, or else from termcap. */ + getscreensize(&int_col, &int_row); + term.t_nrow = int_row - 1; + term.t_ncol = int_col; - if ((term.t_ncol <= 0) && (term.t_ncol=(short)tgetnum("co")) == -1){ - puts("Termcap entry incomplete (columns)"); - exit(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) { + puts("Termcap entry incomplete (columns)"); + exit(1); + } #ifdef SIGWINCH - term.t_mrow = MAXROW; - term.t_mcol = MAXCOL; + term.t_mrow = MAXROW; + term.t_mcol = MAXCOL; #else - term.t_mrow = term.t_nrow > MAXROW ? MAXROW : term.t_nrow; - term.t_mcol = term.t_ncol > MAXCOL ? MAXCOL : term.t_ncol; + term.t_mrow = term.t_nrow > MAXROW ? MAXROW : term.t_nrow; + term.t_mcol = term.t_ncol > MAXCOL ? MAXCOL : term.t_ncol; #endif - p = tcapbuf; - t = tgetstr("pc", &p); - if(t) - PC = *t; - else - PC = 0; + p = tcapbuf; + t = tgetstr("pc", &p); + if (t) + PC = *t; + else + PC = 0; - CL = tgetstr("cl", &p); - CM = tgetstr("cm", &p); - CE = tgetstr("ce", &p); - UP = tgetstr("up", &p); - SE = tgetstr("se", &p); - SO = tgetstr("so", &p); - if (SO != NULL) - revexist = TRUE; + CL = tgetstr("cl", &p); + CM = tgetstr("cm", &p); + CE = tgetstr("ce", &p); + UP = tgetstr("up", &p); + SE = tgetstr("se", &p); + SO = tgetstr("so", &p); + if (SO != NULL) + revexist = TRUE; #if PKCODE - if (tgetnum("sg") > 0) { /* can reverse be used? P.K. */ - revexist = FALSE; - SE = NULL; - SO = NULL; - } - TI = tgetstr("ti", &p); /* terminal init and exit */ - TE = tgetstr("te", &p); + if (tgetnum("sg") > 0) { /* can reverse be used? P.K. */ + revexist = FALSE; + SE = NULL; + SO = NULL; + } + TI = tgetstr("ti", &p); /* terminal init and exit */ + TE = tgetstr("te", &p); #endif - if(CL == NULL || CM == NULL || UP == NULL) - { - puts("Incomplete termcap entry\n"); - exit(1); - } + if (CL == NULL || CM == NULL || UP == NULL) { + puts("Incomplete termcap entry\n"); + exit(1); + } - if (CE == NULL) /* will we be able to use clear to EOL? */ - eolexist = FALSE; -#if SCROLLCODE - CS = tgetstr("cs", &p); - SF = tgetstr("sf", &p); - SR = tgetstr("sr", &p); - DL = tgetstr("dl", &p); - AL = tgetstr("al", &p); - - if (CS && SR) { - if (SF == NULL) /* assume '\n' scrolls forward */ - SF = "\n"; - term.t_scroll = tcapscroll_reg; - } else if (DL && AL) { - term.t_scroll = tcapscroll_delins; - } else { - term.t_scroll = NULL; - } + if (CE == NULL) /* will we be able to use clear to EOL? */ + eolexist = FALSE; +#if SCROLLCODE + CS = tgetstr("cs", &p); + SF = tgetstr("sf", &p); + SR = tgetstr("sr", &p); + DL = tgetstr("dl", &p); + AL = tgetstr("al", &p); + + if (CS && SR) { + if (SF == NULL) /* assume '\n' scrolls forward */ + SF = "\n"; + term.t_scroll = tcapscroll_reg; + } else if (DL && AL) { + term.t_scroll = tcapscroll_delins; + } else { + term.t_scroll = NULL; + } #endif - - if (p >= &tcapbuf[TCAPSLEN]) - { - puts("Terminal description too big!\n"); - exit(1); - } + + if (p >= &tcapbuf[TCAPSLEN]) { + puts("Terminal description too big!\n"); + exit(1); + } #if PKCODE && USE_BROKEN_OPTIMIZATION - term_init_ok = 1; + term_init_ok = 1; } #endif - ttopen(); + ttopen(); } #if PKCODE tcapclose() - { putpad(tgoto(CM, 0, term.t_nrow)); putpad(TE); @@ -231,7 +226,6 @@ tcapclose() #endif tcapkopen() - { #if PKCODE putpad(TI); @@ -241,111 +235,109 @@ tcapkopen() } tcapkclose() - { } tcapmove(row, col) register int row, col; { - putpad(tgoto(CM, col, row)); + putpad(tgoto(CM, col, row)); } tcapeeol() { - putpad(CE); + putpad(CE); } tcapeeop() { - putpad(CL); + putpad(CL); } -tcaprev(state) /* change reverse video status */ - -int state; /* FALSE = normal video, TRUE = reverse video */ +tcaprev(state) + /* change reverse video status */ +int state; /* FALSE = normal video, TRUE = reverse video */ { static int revstate = FALSE; if (state) { if (SO != NULL) putpad(SO); - } else - if (SE != NULL) - putpad(SE); + } else if (SE != NULL) + putpad(SE); } -tcapcres() /* change screen resolution */ - -{ - return(TRUE); +tcapcres() +{ /* change screen resolution */ + return (TRUE); } -#if SCROLLCODE - +#if SCROLLCODE + /* move howmanylines lines starting at from to to */ -tcapscroll_reg(from,to,howmanylines) -{ - int i; - if (to == from) return; - if (to < from) { - tcapscrollregion(to, from + howmanylines - 1); - tcapmove(from + howmanylines - 1,0); - for (i = from - to; i > 0; i--) - putpad(SF); - } else { /* from < to */ - tcapscrollregion(from, to + howmanylines - 1); - tcapmove(from,0); - for (i = to - from; i > 0; i--) - putpad(SR); - } +tcapscroll_reg(from, to, howmanylines) +{ + int i; + if (to == from) + return; + if (to < from) { + tcapscrollregion(to, from + howmanylines - 1); + tcapmove(from + howmanylines - 1, 0); + for (i = from - to; i > 0; i--) + putpad(SF); + } else { /* from < to */ + tcapscrollregion(from, to + howmanylines - 1); + tcapmove(from, 0); + for (i = to - from; i > 0; i--) + putpad(SR); + } tcapscrollregion(0, term.t_nrow); } - + /* move howmanylines lines starting at from to to */ -tcapscroll_delins(from,to,howmanylines) +tcapscroll_delins(from, to, howmanylines) { - int i; - if (to == from) return; - if (to < from) { - tcapmove(to,0); - for (i = from - to; i > 0; i--) - putpad(DL); - tcapmove(to+howmanylines,0); - for (i = from - to; i > 0; i--) - putpad(AL); - } else { - tcapmove(from+howmanylines,0); - for (i = to - from; i > 0; i--) - putpad(DL); - tcapmove(from,0); - for (i = to - from; i > 0; i--) - putpad(AL); - } + int i; + if (to == from) + return; + if (to < from) { + tcapmove(to, 0); + for (i = from - to; i > 0; i--) + putpad(DL); + tcapmove(to + howmanylines, 0); + for (i = from - to; i > 0; i--) + putpad(AL); + } else { + tcapmove(from + howmanylines, 0); + for (i = to - from; i > 0; i--) + putpad(DL); + tcapmove(from, 0); + for (i = to - from; i > 0; i--) + putpad(AL); + } } - + /* cs is set up just like cm, so we use tgoto... */ -tcapscrollregion(top,bot) +tcapscrollregion(top, bot) { ttputc(PC); - putpad(tgoto(CS, bot, top)); + putpad(tgoto(CS, bot, top)); } - + #endif -spal(dummy) /* change palette string */ - -{ - /* Does nothing here */ +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 @@ -355,26 +347,26 @@ tcapbeep() } putpad(str) -char *str; +char *str; { tputs(str, 1, ttputc); } putnpad(str, n) -char *str; +char *str; { tputs(str, n, ttputc); } #if FNLABEL -fnclabel(f, n) /* label a function key */ - -int f,n; /* default flag, numeric argument [unused] */ +fnclabel(f, n) + /* label a function key */ +int f, n; /* default flag, numeric argument [unused] */ { /* on machines with no function keys...don't bother */ - return(TRUE); + return (TRUE); } #endif #else diff --git a/termio.c b/termio.c index 86abf75..fb58672 100644 --- a/termio.c +++ b/termio.c @@ -9,7 +9,7 @@ */ #ifndef POSIX - + #include #include "estruct.h" #include "edef.h" @@ -22,35 +22,35 @@ #include #include -#define NIBUF 128 /* Input buffer size */ -#define NOBUF 1024 /* MM says bug buffers win! */ -#define EFN 0 /* Event flag */ +#define NIBUF 128 /* Input buffer size */ +#define NOBUF 1024 /* MM says bug buffers win! */ +#define EFN 0 /* Event flag */ -char obuf[NOBUF]; /* Output buffer */ -int nobuf; /* # of bytes in above */ -char ibuf[NIBUF]; /* Input buffer */ -int nibuf; /* # of bytes in above */ -int ibufi; /* Read index */ -int oldmode[3]; /* Old TTY mode bits */ -int newmode[3]; /* New TTY mode bits */ -short iochan; /* TTY I/O channel */ +char obuf[NOBUF]; /* Output buffer */ +int nobuf; /* # of bytes in above */ +char ibuf[NIBUF]; /* Input buffer */ +int nibuf; /* # of bytes in above */ +int ibufi; /* Read index */ +int oldmode[3]; /* Old TTY mode bits */ +int newmode[3]; /* New TTY mode bits */ +short iochan; /* TTY I/O channel */ #endif #if MSDOS & (MSC | TURBO) -union REGS rg; /* cpu register for use of DOS calls */ -int nxtchar = -1; /* character held from type ahead */ +union REGS rg; /* cpu register for use of DOS calls */ +int nxtchar = -1; /* character held from type ahead */ #endif #if USG /* System V */ #include #include #include -int kbdflgs; /* saved keyboard fd flags */ -int kbdpoll; /* in O_NDELAY mode */ -int kbdqp; /* there is a char in kbdq */ -char kbdq; /* char we've already read */ -struct termio otermio; /* original terminal characteristics */ -struct termio ntermio; /* charactoristics to use inside */ +int kbdflgs; /* saved keyboard fd flags */ +int kbdpoll; /* in O_NDELAY mode */ +int kbdqp; /* there is a char in kbdq */ +char kbdq; /* char we've already read */ +struct termio otermio; /* original terminal characteristics */ +struct termio ntermio; /* charactoristics to use inside */ #if XONXOFF #define XXMASK 0016000 #endif @@ -59,34 +59,37 @@ struct termio ntermio; /* charactoristics to use inside */ #if V7 | BSD #include /* for stty/gtty functions */ #include -struct sgttyb ostate; /* saved tty state */ -struct sgttyb nstate; /* values for editor mode */ -struct tchars otchars; /* Saved terminal special character set */ +struct sgttyb ostate; /* saved tty state */ +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 }; +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 }; +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 }; +struct ltchars oltchars; /* Saved terminal local special character set */ +struct ltchars nltchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + /* A lot of nothing */ #endif #if BSD #include /* to get at the typeahead */ -extern int rtfrmshell(); /* return from suspended shell */ +extern int rtfrmshell(); /* return from suspended shell */ #define TBUFSIZ 128 char tobuf[TBUFSIZ]; /* terminal output buffer */ #endif #endif #if __hpux | SVR4 -extern int rtfrmshell(); /* return from suspended shell */ +extern int rtfrmshell(); /* return from suspended shell */ #define TBUFSIZ 128 -char tobuf[TBUFSIZ]; /* terminal output buffer */ +char tobuf[TBUFSIZ]; /* terminal output buffer */ #endif /* @@ -97,51 +100,51 @@ char tobuf[TBUFSIZ]; /* terminal output buffer */ ttopen() { #if VMS - struct dsc$descriptor idsc; - struct dsc$descriptor odsc; - char oname[40]; - int iosb[2]; - int status; + struct dsc$descriptor idsc; + struct dsc$descriptor odsc; + char oname[40]; + int iosb[2]; + int status; - odsc.dsc$a_pointer = "TT"; - odsc.dsc$w_length = strlen(odsc.dsc$a_pointer); - odsc.dsc$b_dtype = DSC$K_DTYPE_T; - odsc.dsc$b_class = DSC$K_CLASS_S; - idsc.dsc$b_dtype = DSC$K_DTYPE_T; - idsc.dsc$b_class = DSC$K_CLASS_S; - do { - idsc.dsc$a_pointer = odsc.dsc$a_pointer; - idsc.dsc$w_length = odsc.dsc$w_length; - odsc.dsc$a_pointer = &oname[0]; - odsc.dsc$w_length = sizeof(oname); - status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc); - if (status!=SS$_NORMAL && status!=SS$_NOTRAN) - exit(status); - if (oname[0] == 0x1B) { - odsc.dsc$a_pointer += 4; - odsc.dsc$w_length -= 4; - } - } while (status == SS$_NORMAL); - status = SYS$ASSIGN(&odsc, &iochan, 0, 0); - if (status != SS$_NORMAL) - exit(status); - status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0, - oldmode, sizeof(oldmode), 0, 0, 0, 0); - if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) - exit(status); - newmode[0] = oldmode[0]; - newmode[1] = oldmode[1] | TT$M_NOECHO; + odsc.dsc$a_pointer = "TT"; + odsc.dsc$w_length = strlen(odsc.dsc$a_pointer); + odsc.dsc$b_dtype = DSC$K_DTYPE_T; + odsc.dsc$b_class = DSC$K_CLASS_S; + idsc.dsc$b_dtype = DSC$K_DTYPE_T; + idsc.dsc$b_class = DSC$K_CLASS_S; + do { + idsc.dsc$a_pointer = odsc.dsc$a_pointer; + idsc.dsc$w_length = odsc.dsc$w_length; + odsc.dsc$a_pointer = &oname[0]; + odsc.dsc$w_length = sizeof(oname); + status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc); + if (status != SS$_NORMAL && status != SS$_NOTRAN) + exit(status); + if (oname[0] == 0x1B) { + odsc.dsc$a_pointer += 4; + odsc.dsc$w_length -= 4; + } + } while (status == SS$_NORMAL); + status = SYS$ASSIGN(&odsc, &iochan, 0, 0); + if (status != SS$_NORMAL) + exit(status); + status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0, + oldmode, sizeof(oldmode), 0, 0, 0, 0); + if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) + exit(status); + newmode[0] = oldmode[0]; + newmode[1] = oldmode[1] | TT$M_NOECHO; #if XONXOFF #else - newmode[1] &= ~(TT$M_TTSYNC|TT$M_HOSTSYNC); + newmode[1] &= ~(TT$M_TTSYNC | TT$M_HOSTSYNC); #endif - newmode[2] = oldmode[2] | TT2$M_PASTHRU; - status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, - newmode, sizeof(newmode), 0, 0, 0, 0); - if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) - exit(status); - term.t_nrow = (newmode[1]>>24) - 1; - term.t_ncol = newmode[0]>>16; + newmode[2] = oldmode[2] | TT2$M_PASTHRU; + status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, + newmode, sizeof(newmode), 0, 0, 0, 0); + if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) + exit(status); + term.t_nrow = (newmode[1] >> 24) - 1; + term.t_ncol = newmode[0] >> 16; #endif @@ -155,7 +158,7 @@ ttopen() #if USG ioctl(0, TCGETA, &otermio); /* save old settings */ - ntermio.c_iflag = 0; /* setup new settings */ + ntermio.c_iflag = 0; /* setup new settings */ #if XONXOFF ntermio.c_iflag = otermio.c_iflag & XXMASK; /* save XON/XOFF P.K. */ #endif @@ -170,46 +173,46 @@ ttopen() #else ioctl(0, TCSETA, &ntermio); /* and activate them */ #endif - kbdflgs = fcntl( 0, F_GETFL, 0 ); + kbdflgs = fcntl(0, F_GETFL, 0); kbdpoll = FALSE; #endif #if V7 | BSD - gtty(0, &ostate); /* save old state */ - gtty(0, &nstate); /* get base of new state */ + gtty(0, &ostate); /* save old state */ + gtty(0, &nstate); /* get base of new state */ #if XONXOFF - nstate.sg_flags |= (CBREAK|TANDEM); + nstate.sg_flags |= (CBREAK | TANDEM); #else - nstate.sg_flags |= RAW; + nstate.sg_flags |= RAW; #endif - nstate.sg_flags &= ~(ECHO|CRMOD); /* no echo for now... */ - stty(0, &nstate); /* set mode */ - ioctl(0, TIOCGETC, &otchars); /* Save old characters */ - ioctl(0, TIOCSETC, &ntchars); /* Place new character into K */ + nstate.sg_flags &= ~(ECHO | CRMOD); /* no echo for now... */ + stty(0, &nstate); /* set mode */ + ioctl(0, TIOCGETC, &otchars); /* Save old characters */ + ioctl(0, TIOCSETC, &ntchars); /* Place new character into K */ #if BSD & PKCODE - ioctl(0, TIOCGLTC, &oltchars); /* Save old local characters */ - ioctl(0, TIOCSLTC, &nltchars); /* New local characters */ + ioctl(0, TIOCGLTC, &oltchars); /* Save old local characters */ + ioctl(0, TIOCSLTC, &nltchars); /* New local characters */ #endif #if BSD /* provide a smaller terminal output buffer so that the type ahead detection works better (more often) */ setbuffer(stdout, &tobuf[0], TBUFSIZ); - signal(SIGTSTP,SIG_DFL); /* set signals so that we can */ - signal(SIGCONT,rtfrmshell); /* suspend & restart emacs */ + signal(SIGTSTP, SIG_DFL); /* set signals so that we can */ + signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */ #endif #endif #if __hpux | SVR4 - /* provide a smaller terminal output buffer so that - the type ahead detection works better (more often) */ - setvbuf(stdout, &tobuf[0], _IOFBF, TBUFSIZ); - signal(SIGTSTP,SIG_DFL); /* set signals so that we can */ - signal(SIGCONT,rtfrmshell); /* suspend & restart emacs */ - TTflush(); -#endif /* __hpux */ + /* provide a smaller terminal output buffer so that + the type ahead detection works better (more often) */ + setvbuf(stdout, &tobuf[0], _IOFBF, TBUFSIZ); + signal(SIGTSTP, SIG_DFL); /* set signals so that we can */ + signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */ + TTflush(); +#endif /* __hpux */ /* on all screens we are not sure of the initial position - of the cursor */ + of the cursor */ ttrow = 999; ttcol = 999; } @@ -222,17 +225,17 @@ ttopen() ttclose() { #if VMS - int status; - int iosb[1]; + int status; + int iosb[1]; - ttflush(); - status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, - oldmode, sizeof(oldmode), 0, 0, 0, 0); - if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL) - exit(status); - status = SYS$DASSGN(iochan); - if (status != SS$_NORMAL) - exit(status); + ttflush(); + status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0, + oldmode, sizeof(oldmode), 0, 0, 0, 0); + if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL) + exit(status); + status = SYS$DASSGN(iochan); + if (status != SS$_NORMAL) + exit(status); #endif #if MSDOS & (TURBO | (PKCODE & MSC)) /* restore the CONTROL-break interupt */ @@ -252,7 +255,7 @@ ttclose() #endif #if V7 | BSD - stty(0, &ostate); + stty(0, &ostate); ioctl(0, TIOCSETC, &otchars); /* Place old character into K */ #if BSD & PKCODE ioctl(0, TIOCSLTC, &oltchars); /* Place old local character into K */ @@ -269,9 +272,9 @@ ttclose() ttputc(c) { #if VMS - if (nobuf >= NOBUF) - ttflush(); - obuf[nobuf++] = c; + if (nobuf >= NOBUF) + ttflush(); + obuf[nobuf++] = c; #endif #if MSDOS & ~IBMPC @@ -279,7 +282,7 @@ ttputc(c) #endif #if V7 | USG | BSD - fputc(c, stdout); + fputc(c, stdout); #endif } @@ -290,18 +293,19 @@ ttputc(c) ttflush() { #if VMS - int status; - int iosb[2]; + int status; + int iosb[2]; - status = SS$_NORMAL; - if (nobuf != 0) { - 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; - nobuf = 0; - } - return (status); + status = SS$_NORMAL; + if (nobuf != 0) { + 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; + nobuf = 0; + } + return (status); #endif #if MSDOS @@ -318,15 +322,15 @@ ttflush() * jph, 8-Oct-1993 */ -#include +#include - int status; + int status; - status = fflush(stdout); + status = fflush(stdout); - if (status != 0 && errno != EAGAIN) { - exit(errno); - } + if (status != 0 && errno != EAGAIN) { + exit(errno); + } #endif } @@ -338,69 +342,68 @@ ttflush() ttgetc() { #if VMS - int status; - int iosb[2]; - int term[2]; + int status; + int iosb[2]; + int term[2]; - while (ibufi >= nibuf) { - ibufi = 0; - term[0] = 0; - term[1] = 0; - status = SYS$QIOW(EFN, iochan, IO$_READLBLK|IO$M_TIMED, - iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0); - if (status != SS$_NORMAL) - exit(status); - status = iosb[0] & 0xFFFF; - if (status!=SS$_NORMAL && status!=SS$_TIMEOUT && - status!=SS$_DATAOVERUN) - exit(status); - 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); - if (status != SS$_NORMAL - || (status = (iosb[0]&0xFFFF)) != SS$_NORMAL) + while (ibufi >= nibuf) { + ibufi = 0; + term[0] = 0; + term[1] = 0; + status = SYS$QIOW(EFN, iochan, IO$_READLBLK | IO$M_TIMED, + iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0); + if (status != SS$_NORMAL) + exit(status); + status = iosb[0] & 0xFFFF; + if (status != SS$_NORMAL && status != SS$_TIMEOUT && + status != SS$_DATAOVERUN) + exit(status); + 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); + if (status != SS$_NORMAL + || (status = (iosb[0] & 0xFFFF)) != SS$_NORMAL) if (status != SS$_DATAOVERUN) exit(status); - nibuf = (iosb[0]>>16) + (iosb[1]>>16); - } - } - return (ibuf[ibufi++] & 0xFF); /* Allow multinational */ + nibuf = (iosb[0] >> 16) + (iosb[1] >> 16); + } + } + return (ibuf[ibufi++] & 0xFF); /* Allow multinational */ #endif #if MSDOS & (MSC | TURBO) - int c; /* character read */ + int c; /* character read */ /* if a char already is ready, return it */ if (nxtchar >= 0) { c = nxtchar; nxtchar = -1; - return(c); + return (c); } /* call the dos to get a char */ rg.h.ah = 7; /* dos Direct Console Input call */ intdos(&rg, &rg); c = rg.h.al; /* grab the char */ - return(c & 255); + return (c & 255); #endif #if V7 | BSD - return(255 & fgetc(stdin)); /* 8BIT P.K. */ + return (255 & fgetc(stdin)); /* 8BIT P.K. */ #endif #if USG - if( kbdqp ) + if (kbdqp) kbdqp = FALSE; - else - { - if( kbdpoll && fcntl( 0, F_SETFL, kbdflgs ) < 0 ) + 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 ); + return (kbdq & 255); #endif } @@ -410,42 +413,40 @@ ttgetc() */ typahead() - { #if MSDOS & (MSC | TURBO) if (kbhit() != 0) - return(TRUE); + return (TRUE); else - return(FALSE); + return (FALSE); #endif #if BSD - int x; /* holds # of pending chars */ + int x; /* holds # of pending chars */ - return((ioctl(0,FIONREAD,&x) < 0) ? 0 : x); + return ((ioctl(0, FIONREAD, &x) < 0) ? 0 : x); #endif #if PKCODE & VMS - return(ibufi < nibuf); + return (ibufi < nibuf); #endif #if USG - if( !kbdqp ) - { - if( !kbdpoll && fcntl( 0, F_SETFL, kbdflgs | O_NDELAY ) < 0 ) - return(FALSE); + if (!kbdqp) { + if (!kbdpoll && fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0) + return (FALSE); #if PKCODE kbdpoll = 1; #endif - kbdqp = (1 == read( 0, &kbdq, 1 )); + kbdqp = (1 == read(0, &kbdq, 1)); } - return ( kbdqp ); + return (kbdqp); #endif #if !UNIX & !VMS & !MSDOS - return(FALSE); + return (FALSE); #endif } #endif -#endif /* not POSIX */ +#endif /* not POSIX */ diff --git a/vmsvt.c b/vmsvt.c index 82c5a98..78210c0 100644 --- a/vmsvt.c +++ b/vmsvt.c @@ -9,17 +9,17 @@ * modified by Petri Kutvonen */ -#include /* Standard I/O package */ -#include "estruct.h" /* Emacs' structures */ -#include "edef.h" /* Emacs' definitions */ +#include /* Standard I/O package */ +#include "estruct.h" /* Emacs' structures */ +#include "edef.h" /* Emacs' definitions */ #if VMSVT -#include /* Descriptor definitions */ +#include /* Descriptor definitions */ /* These would normally come from iodef.h and ttdef.h */ -#define IO$_SENSEMODE 0x27 /* Sense mode of terminal */ -#define TT$_UNKNOWN 0x00 /* Unknown terminal */ +#define IO$_SENSEMODE 0x27 /* Sense mode of terminal */ +#define TT$_UNKNOWN 0x00 /* Unknown terminal */ #define TT$_VT100 96 /** Forward references **/ @@ -34,8 +34,8 @@ int vmsfcol(), vmsbcol(); #endif /** SMG stuff **/ -static char * begin_reverse, * end_reverse, * erase_to_end_line; -static char * erase_whole_display; +static char *begin_reverse, *end_reverse, *erase_to_end_line; +static char *erase_whole_display; static int termtype; #define SMG$K_BEGIN_REVERSE 0x1bf @@ -46,7 +46,7 @@ static int termtype; #if SCROLLCODE -#define SMG$K_SCROLL_FORWARD 561 /* from sys$library:smgtrmptr.h */ +#define SMG$K_SCROLL_FORWARD 561 /* from sys$library:smgtrmptr.h */ #define SMG$K_SCROLL_REVERSE 562 #define SMG$K_SET_SCROLL_REGION 572 @@ -55,37 +55,39 @@ static char *scroll_forward, *scroll_reverse; #endif /* Dispatch table. All hard fields just point into the terminal I/O code. */ -TERM term = { +TERM term = { #if PKCODE MAXROW, #else - 24 - 1, /* Max number of rows allowable */ + 24 - 1, /* Max number of rows allowable */ #endif - /* Filled in */ - 1, /* Current number of rows used */ - MAXCOL, /* Max 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 */ - vmsopen, /* Open terminal at the start */ - ttclose, /* Close terminal at end */ - vmskopen, /* Open keyboard */ - vmskclose, /* Close keyboard */ - ttgetc, /* Get character from keyboard */ - ttputc, /* Put character to display */ - ttflush, /* Flush output buffers */ - vmsmove, /* Move cursor, origin 0 */ - vmseeol, /* Erase to end of line */ - vmseeop, /* Erase to end of page */ - vmsbeep, /* Beep */ - vmsrev, /* Set reverse video state */ - vmscres /* Change screen resolution */ + /* Filled in */ -1, + /* Current number of rows used */ + MAXCOL, /* Max 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 */ + vmsopen, /* Open terminal at the start */ + ttclose, /* Close terminal at end */ + vmskopen, /* Open keyboard */ + vmskclose, /* Close keyboard */ + ttgetc, /* Get character from keyboard */ + ttputc, /* Put character to display */ + ttflush, /* Flush output buffers */ + vmsmove, /* Move cursor, origin 0 */ + vmseeol, /* Erase to end of line */ + vmseeop, /* Erase to end of page */ + vmsbeep, /* Beep */ + vmsrev, /* Set reverse video state */ + vmscres /* Change screen resolution */ #if COLOR - , vmsfcol, /* Set forground color */ - vmsbcol /* Set background color */ + , vmsfcol, /* Set forground color */ + vmsbcol /* Set background color */ #endif #if SCROLLCODE - , NULL + , NULL #endif }; @@ -95,7 +97,7 @@ TERM term = { * Nothing returned ***/ ttputs(string) -char * string; /* String to write */ +char *string; /* String to write */ { if (string) while (*string != '\0') @@ -109,16 +111,16 @@ char * string; /* String to write */ * Nothing returned ***/ vmsmove(row, col) -int row; /* Row position */ -int col; /* Column position */ +int row; /* Row position */ +int col; /* Column position */ { char buffer[32]; int ret_length; static int request_code = SMG$K_SET_CURSOR_ABS; static int max_buffer_length = sizeof(buffer); static int arg_list[3] = { 2 }; - register char * cp; - + register char *cp; + register int i; /* Set the arguments into the arg_list array @@ -127,21 +129,22 @@ int col; /* Column position */ arg_list[1] = row + 1; arg_list[2] = col + 1; - if ((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 */ - arg_list) /* Argument list array */ + if ((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 */ + arg_list) - /* We'll know soon enough if this doesn't work */ - & 1) == 0) { - ttputs("OOPS"); - return; - } + /* Argument list array */ + /* We'll know soon enough if this doesn't work */ + &1) == 0) { + ttputs("OOPS"); + return; + } - /* Send out resulting sequence */ + /* Send out resulting sequence */ i = ret_length; cp = buffer; while (i-- > 0) @@ -150,35 +153,36 @@ int col; /* Column position */ #if SCROLLCODE -vmsscroll_reg(from,to,howmany) +vmsscroll_reg(from, to, howmany) { - int i; - if (to == from) return; - if (to < from) { - vmsscrollregion(to, from + howmany - 1); - vmsmove(from + howmany - 1,0); - for (i = from - to; i > 0; i--) - ttputs(scroll_forward); - } else { /* from < to */ - vmsscrollregion(from, to + howmany - 1); - vmsmove(from,0); - for (i = to - from; i > 0; i--) - ttputs(scroll_reverse); - } - vmsscrollregion(-1, -1); + int i; + if (to == from) + return; + if (to < from) { + vmsscrollregion(to, from + howmany - 1); + vmsmove(from + howmany - 1, 0); + for (i = from - to; i > 0; i--) + ttputs(scroll_forward); + } else { /* from < to */ + vmsscrollregion(from, to + howmany - 1); + vmsmove(from, 0); + for (i = to - from; i > 0; i--) + ttputs(scroll_reverse); + } + vmsscrollregion(-1, -1); } vmsscrollregion(top, bot) -int top; /* Top position */ -int bot; /* Bottom position */ +int top; /* Top position */ +int bot; /* Bottom position */ { char buffer[32]; int ret_length; static int request_code = SMG$K_SET_SCROLL_REGION; static int max_buffer_length = sizeof(buffer); static int arg_list[3] = { 2 }; - register char * cp; - + register char *cp; + register int i; /* Set the arguments into the arg_list array @@ -187,22 +191,23 @@ int bot; /* Bottom position */ arg_list[1] = top + 1; arg_list[2] = bot + 1; - if ((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 */ - arg_list) /* Argument list array */ + if ((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 */ + arg_list) - /* We'll know soon enough if this doesn't work */ - & 1) == 0) { - ttputs("OOPS"); - return; - } + /* Argument list array */ + /* We'll know soon enough if this doesn't work */ + &1) == 0) { + ttputs("OOPS"); + return; + } ttputc(0); - /* Send out resulting sequence */ + /* Send out resulting sequence */ i = ret_length; cp = buffer; while (i-- > 0) @@ -216,11 +221,11 @@ int bot; /* Bottom position */ * Nothing returned ***/ vmsrev(status) -int status; /* TRUE if setting reverse */ +int status; /* TRUE if setting reverse */ { if (status) ttputs(begin_reverse); - else + else ttputs(end_reverse); } @@ -232,7 +237,7 @@ int status; /* TRUE if setting reverse */ vmscres() { /* But it could. For vt100/vt200s, one could switch from - 80 and 132 columns modes */ + 80 and 132 columns modes */ } @@ -294,56 +299,56 @@ vmsbeep() * * Returns: Escape sequence * NULL No escape sequence available - ***/ -char * vmsgetstr(request_code) -int request_code; /* Request code */ + ***/ +char *vmsgetstr(request_code) +int request_code; /* Request code */ { - register char * result; + register char *result; static char seq_storage[1024]; - static char * buffer = seq_storage; + static char *buffer = seq_storage; static int arg_list[2] = { 1, 1 }; int max_buffer_length, ret_length; /* Precompute buffer length */ - + max_buffer_length = (seq_storage + sizeof(seq_storage)) - buffer; /* Get terminal commands sequence from master table */ - if ((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 */ - arg_list) /* Argument list array */ + if ((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 */ + arg_list) - /* If this doesn't work, try again with no arguments */ - - & 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 */ + /* Argument list array */ + /* If this doesn't work, try again with no arguments */ + &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) - /* Return NULL pointer if capability is not available */ - & 1) == 0) - return NULL; + /* Capability data buffer */ + /* Return NULL pointer if capability is not available */ + &1) == 0) + return NULL; /* Check for empty result */ if (ret_length == 0) return NULL; - + /* Save current position so we can return it to caller */ result = buffer; /* NIL terminate the sequence for return */ - + buffer[ret_length] = 0; /* Advance buffer */ @@ -356,19 +361,19 @@ int request_code; /* Request code */ /** I/O information block definitions **/ -struct iosb { /* I/O status block */ - short i_cond; /* Condition value */ - short i_xfer; /* Transfer count */ - long i_info; /* Device information */ +struct iosb { /* I/O status block */ + short i_cond; /* Condition value */ + short i_xfer; /* Transfer count */ + long i_info; /* Device information */ }; -struct termchar { /* Terminal characteristics */ - char t_class; /* Terminal class */ - char t_type; /* Terminal type */ - short t_width; /* Terminal width in characters */ - long t_mandl; /* Terminal's mode and length */ - long t_extend; /* Extended terminal characteristics */ +struct termchar { /* Terminal characteristics */ + char t_class; /* Terminal class */ + char t_type; /* Terminal type */ + short t_width; /* Terminal width in characters */ + long t_mandl; /* Terminal's mode and length */ + long t_extend; /* Extended terminal characteristics */ }; -static struct termchar tc; /* Terminal characteristics */ +static struct termchar tc; /* Terminal characteristics */ /*** * vmsgtty - Get terminal type from system control block @@ -385,18 +390,18 @@ vmsgtty() /* Assign input to a channel */ status = sys$assign(&devnam, &fd, 0, 0); if ((status & 1) == 0) - exit (status); + exit(status); /* Get terminal characteristics */ - status = sys$qiow( /* Queue and wait */ - 0, /* Wait on event flag zero */ - fd, /* Channel to input terminal */ - IO$_SENSEMODE, /* Get current characteristic */ - &iostatus, /* Status after operation */ - 0, 0, /* No AST service */ - &tc, /* Terminal characteristics buf */ - sizeof(tc), /* Size of the buffer */ - 0, 0, 0, 0); /* P3-P6 unused */ + status = sys$qiow( /* Queue and wait */ + 0, /* Wait on event flag zero */ + fd, /* Channel to input terminal */ + IO$_SENSEMODE, /* Get current characteristic */ + &iostatus, /* Status after operation */ + 0, 0, /* No AST service */ + &tc, /* Terminal characteristics buf */ + sizeof(tc), /* Size of the buffer */ + 0, 0, 0, 0); /* P3-P6 unused */ /* De-assign the input device */ if ((sys$dassgn(fd) & 1) == 0) @@ -421,16 +426,17 @@ 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); } - /* Access the system terminal definition table for the */ - /* information of the terminal type returned by IO$_SENSEMODE */ + /* Access the system terminal definition table for the */ + /* information of the terminal type returned by IO$_SENSEMODE */ if ((smg$init_term_table_by_type(&tc.t_type, &termtype) & 1) == 0) return -1; - + /* Set sizes */ term.t_nrow = ((unsigned int) tc.t_mandl >> 24) - 1; term.t_ncol = tc.t_width; @@ -446,8 +452,8 @@ vmsopen() #if SCROLLCODE scroll_forward = vmsgetstr(SMG$K_SCROLL_FORWARD); scroll_reverse = vmsgetstr(SMG$K_SCROLL_REVERSE); - if (tc.t_type < TT$_VT100 || scroll_reverse == NULL || - scroll_forward == NULL) + if (tc.t_type < TT$_VT100 || scroll_reverse == NULL || + scroll_forward == NULL) term.t_scroll = NULL; else term.t_scroll = vmsscroll_reg; @@ -487,11 +493,11 @@ vmskclose() * Nothing returned ***/ #if FNLABEL -fnclabel(f, n) /* label a function key */ -int f,n; /* default flag, numeric argument [unused] */ +fnclabel(f, n) /* label a function key */ +int f, n; /* default flag, numeric argument [unused] */ { /* on machines with no function keys...don't bother */ - return(TRUE); + return (TRUE); } #endif diff --git a/vt52.c b/vt52.c index dbff430..1b35e85 100644 --- a/vt52.c +++ b/vt52.c @@ -11,7 +11,7 @@ * modified by Petri Kutvonen */ -#define termdef 1 /* don't define "term" external */ +#define termdef 1 /* don't define "term" external */ #include #include "estruct.h" @@ -19,33 +19,33 @@ #if VT52 -#define NROW 24 /* Screen size. */ -#define NCOL 80 /* Edit if you want to. */ -#define MARGIN 8 /* size of minimim margin and */ -#define SCRSIZ 64 /* scroll size for extended lines */ -#define NPAUSE 100 /* # times thru update to pause */ -#define BIAS 0x20 /* Origin 0 coordinate bias. */ -#define ESC 0x1B /* ESC character. */ -#define BEL 0x07 /* ascii bell character */ +#define NROW 24 /* Screen size. */ +#define NCOL 80 /* Edit if you want to. */ +#define MARGIN 8 /* size of minimim margin and */ +#define SCRSIZ 64 /* scroll size for extended lines */ +#define NPAUSE 100 /* # times thru update to pause */ +#define BIAS 0x20 /* Origin 0 coordinate bias. */ +#define ESC 0x1B /* ESC character. */ +#define BEL 0x07 /* ascii bell character */ -extern int ttopen(); /* Forward references. */ -extern int ttgetc(); -extern int ttputc(); -extern int ttflush(); -extern int ttclose(); -extern int vt52move(); -extern int vt52eeol(); -extern int vt52eeop(); -extern int vt52beep(); -extern int vt52open(); -extern int vt52rev(); -extern int vt52cres(); -extern int vt52kopen(); -extern int vt52kclose(); +extern int ttopen(); /* Forward references. */ +extern int ttgetc(); +extern int ttputc(); +extern int ttflush(); +extern int ttclose(); +extern int vt52move(); +extern int vt52eeol(); +extern int vt52eeop(); +extern int vt52beep(); +extern int vt52open(); +extern int vt52rev(); +extern int vt52cres(); +extern int vt52kopen(); +extern int vt52kclose(); #if COLOR -extern int vt52fcol(); -extern int vt52bcol(); +extern int vt52fcol(); +extern int vt52bcol(); #endif /* @@ -53,137 +53,132 @@ extern int vt52bcol(); * hard fields just point into the * terminal I/O code. */ -TERM term = { - NROW-1, - NROW-1, - NCOL, - NCOL, +TERM term = { + NROW - 1, + NROW - 1, + NCOL, + NCOL, MARGIN, SCRSIZ, NPAUSE, - &vt52open, - &ttclose, + &vt52open, + &ttclose, &vt52kopen, &vt52kclose, - &ttgetc, - &ttputc, - &ttflush, - &vt52move, - &vt52eeol, - &vt52eeop, - &vt52beep, - &vt52rev, - &vt52cres + &ttgetc, + &ttputc, + &ttflush, + &vt52move, + &vt52eeol, + &vt52eeop, + &vt52beep, + &vt52rev, + &vt52cres #if COLOR - , &vt52fcol, + , &vt52fcol, &vt52bcol #endif #if SCROLLCODE - , NULL + , NULL #endif }; vt52move(row, col) { - ttputc(ESC); - ttputc('Y'); - ttputc(row+BIAS); - ttputc(col+BIAS); + ttputc(ESC); + ttputc('Y'); + ttputc(row + BIAS); + ttputc(col + BIAS); } vt52eeol() { - ttputc(ESC); - ttputc('K'); + ttputc(ESC); + ttputc('K'); } vt52eeop() { - ttputc(ESC); - ttputc('J'); + ttputc(ESC); + ttputc('J'); } -vt52rev(status) /* set the reverse video state */ - -int status; /* TRUE = reverse video, FALSE = normal video */ +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) */ - -{ - return(TRUE); +vt52cres() +{ /* change screen resolution - (not here though) */ + return (TRUE); } -spal() /* change palette string */ - -{ - /* Does nothing here */ +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 vt52beep() { #ifdef BEL - ttputc(BEL); - ttflush(); + ttputc(BEL); + ttflush(); #endif } vt52open() { #if V7 | BSD - register char *cp; - char *getenv(); + register char *cp; + char *getenv(); - if ((cp = getenv("TERM")) == NULL) { - puts("Shell variable TERM not defined!"); - exit(1); - } - if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) { - puts("Terminal type not 'vt52'or 'z19' !"); - exit(1); - } + if ((cp = getenv("TERM")) == NULL) { + puts("Shell variable TERM not defined!"); + exit(1); + } + if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) { + puts("Terminal type not 'vt52'or 'z19' !"); + exit(1); + } #endif - ttopen(); + ttopen(); } vt52kopen() - { } vt52kclose() - { } #if FNLABEL -fnclabel(f, n) /* label a function key */ - -int f,n; /* default flag, numeric argument [unused] */ +fnclabel(f, n) + /* label a function key */ +int f, n; /* default flag, numeric argument [unused] */ { /* on machines with no function keys...don't bother */ - return(TRUE); + return (TRUE); } #endif #else vt52hello() - { } diff --git a/window.c b/window.c index 8500f12..e425948 100644 --- a/window.c +++ b/window.c @@ -16,30 +16,29 @@ * redisplay code does). With no argument it defaults to 0. Bound to M-!. */ reposition(f, n) - { - if (f == FALSE) /* default to 0 to center screen */ - n = 0; - curwp->w_force = n; - curwp->w_flag |= WFFORCE; - return (TRUE); - } +{ + if (f == FALSE) /* default to 0 to center screen */ + n = 0; + curwp->w_force = n; + curwp->w_flag |= WFFORCE; + return (TRUE); +} /* * Refresh the screen. With no argument, it just does the refresh. With an * argument it recenters "." in the current window. Bound to "C-L". */ refresh(f, n) - { - if (f == FALSE) - sgarbf = TRUE; - else - { - curwp->w_force = 0; /* Center dot. */ - curwp->w_flag |= WFFORCE; - } +{ + if (f == FALSE) + sgarbf = TRUE; + else { + curwp->w_force = 0; /* Center dot. */ + curwp->w_flag |= WFFORCE; + } - return (TRUE); - } + return (TRUE); +} /* * The command make the next window (next => down the screen) the current @@ -51,11 +50,11 @@ refresh(f, n) */ nextwind(f, n) -int f, n; /* default flag and numeric argument */ +int f, n; /* default flag and numeric argument */ { register WINDOW *wp; - register int nwindows; /* total number of windows */ + register int nwindows; /* total number of windows */ if (f) { @@ -68,7 +67,7 @@ int f, n; /* default flag and numeric argument */ } /* if the argument is negative, it is the nth window - from the bottom of the screen */ + from the bottom of the screen */ if (n < 0) n = nwindows + n + 1; @@ -79,11 +78,10 @@ int f, n; /* default flag and numeric argument */ wp = wp->w_wndp; } else { mlwrite("Window number out of range"); - return(FALSE); + return (FALSE); } - } else - if ((wp = curwp->w_wndp) == NULL) - wp = wheadp; + } else if ((wp = curwp->w_wndp) == NULL) + wp = wheadp; curwp = wp; curbp = wp->w_bufp; cknewwindow(); @@ -103,7 +101,7 @@ prevwind(f, n) /* if we have an argument, we mean the nth window from the bottom */ if (f) - return(nextwind(f, -n)); + return (nextwind(f, -n)); wp1 = wheadp; wp2 = curwp; @@ -116,7 +114,7 @@ prevwind(f, n) curwp = wp1; curbp = wp1->w_bufp; - cknewwindow(); + cknewwindow(); upmode(); return (TRUE); } @@ -144,47 +142,43 @@ int n; * "C-X C-P". */ mvupwind(f, n) - int n; +int n; - { - register LINE *lp; - register int i; +{ + register LINE *lp; + register int i; - lp = curwp->w_linep; + lp = curwp->w_linep; - if (n < 0) - { - while (n++ && lp!=curbp->b_linep) - lp = lforw(lp); - } - else - { - while (n-- && lback(lp)!=curbp->b_linep) - lp = lback(lp); - } + if (n < 0) { + while (n++ && lp != curbp->b_linep) + lp = lforw(lp); + } else { + while (n-- && lback(lp) != curbp->b_linep) + lp = lback(lp); + } - curwp->w_linep = lp; - curwp->w_flag |= WFHARD; /* Mode line is OK. */ + curwp->w_linep = lp; + curwp->w_flag |= WFHARD; /* Mode line is OK. */ - for (i = 0; i < curwp->w_ntrows; ++i) - { - if (lp == curwp->w_dotp) - return (TRUE); - if (lp == curbp->b_linep) - break; - lp = lforw(lp); - } + for (i = 0; i < curwp->w_ntrows; ++i) { + if (lp == curwp->w_dotp) + return (TRUE); + if (lp == curbp->b_linep) + break; + lp = lforw(lp); + } - lp = curwp->w_linep; - i = curwp->w_ntrows/2; + lp = curwp->w_linep; + i = curwp->w_ntrows / 2; - while (i-- && lp != curbp->b_linep) - lp = lforw(lp); + while (i-- && lp != curbp->b_linep) + lp = lforw(lp); - curwp->w_dotp = lp; - curwp->w_doto = 0; - return (TRUE); - } + curwp->w_dotp = lp; + curwp->w_doto = 0; + return (TRUE); +} /* * This command makes the current window the only window on the screen. Bound @@ -195,43 +189,43 @@ mvupwind(f, n) */ onlywind(f, n) { - register WINDOW *wp; - register LINE *lp; - register int i; + register WINDOW *wp; + register LINE *lp; + register int i; - while (wheadp != curwp) { - wp = wheadp; - wheadp = wp->w_wndp; - if (--wp->w_bufp->b_nwnd == 0) { - wp->w_bufp->b_dotp = wp->w_dotp; - wp->w_bufp->b_doto = wp->w_doto; - wp->w_bufp->b_markp = wp->w_markp; - wp->w_bufp->b_marko = wp->w_marko; - } - free((char *) wp); - } - while (curwp->w_wndp != NULL) { - wp = curwp->w_wndp; - curwp->w_wndp = wp->w_wndp; - if (--wp->w_bufp->b_nwnd == 0) { - wp->w_bufp->b_dotp = wp->w_dotp; - wp->w_bufp->b_doto = wp->w_doto; - wp->w_bufp->b_markp = wp->w_markp; - wp->w_bufp->b_marko = wp->w_marko; - } - free((char *) wp); - } - lp = curwp->w_linep; - i = curwp->w_toprow; - while (i!=0 && lback(lp)!=curbp->b_linep) { - --i; - lp = lback(lp); - } - curwp->w_toprow = 0; - curwp->w_ntrows = term.t_nrow-1; - curwp->w_linep = lp; - curwp->w_flag |= WFMODE|WFHARD; - return (TRUE); + while (wheadp != curwp) { + wp = wheadp; + wheadp = wp->w_wndp; + if (--wp->w_bufp->b_nwnd == 0) { + wp->w_bufp->b_dotp = wp->w_dotp; + wp->w_bufp->b_doto = wp->w_doto; + wp->w_bufp->b_markp = wp->w_markp; + wp->w_bufp->b_marko = wp->w_marko; + } + free((char *) wp); + } + while (curwp->w_wndp != NULL) { + wp = curwp->w_wndp; + curwp->w_wndp = wp->w_wndp; + if (--wp->w_bufp->b_nwnd == 0) { + wp->w_bufp->b_dotp = wp->w_dotp; + wp->w_bufp->b_doto = wp->w_doto; + wp->w_bufp->b_markp = wp->w_markp; + wp->w_bufp->b_marko = wp->w_marko; + } + free((char *) wp); + } + lp = curwp->w_linep; + i = curwp->w_toprow; + while (i != 0 && lback(lp) != curbp->b_linep) { + --i; + lp = lback(lp); + } + curwp->w_toprow = 0; + curwp->w_ntrows = term.t_nrow - 1; + curwp->w_linep = lp; + curwp->w_flag |= WFMODE | WFHARD; + return (TRUE); } /* @@ -239,9 +233,9 @@ onlywind(f, n) * or, if it is the top window, the window below. Bound to C-X 0. */ -delwind(f,n) +delwind(f, n) -int f, n; /* arguments are ignored for this command */ +int f, n; /* arguments are ignored for this command */ { register WINDOW *wp; /* window to recieve deleted space */ @@ -251,7 +245,7 @@ int f, n; /* arguments are ignored for this command */ /* if there is only one window, don't delete it */ if (wheadp->w_wndp == NULL) { mlwrite("Can not delete this window"); - return(FALSE); + return (FALSE); } /* find window before curwp in linked list */ @@ -275,7 +269,7 @@ int f, n; /* arguments are ignored for this command */ wp = wp->w_wndp; } if (wp == NULL) - return(FALSE); + return (FALSE); wp->w_toprow = 0; wp->w_ntrows += target; } else { @@ -287,7 +281,7 @@ int f, n; /* arguments are ignored for this command */ wp = wp->w_wndp; } if (wp == NULL) - return(FALSE); + return (FALSE); wp->w_ntrows += 1 + curwp->w_ntrows; } @@ -302,13 +296,13 @@ int f, n; /* arguments are ignored for this command */ wheadp = curwp->w_wndp; else lwp->w_wndp = curwp->w_wndp; - free((char *)curwp); + free((char *) curwp); curwp = wp; wp->w_flag |= WFHARD; curbp = wp->w_bufp; - cknewwindow(); + cknewwindow(); upmode(); - return(TRUE); + return (TRUE); } /* @@ -322,82 +316,82 @@ for the new window. Bound to "C-X 2". */ splitwind(f, n) -int f, n; /* default flag and numeric argument */ +int f, n; /* default flag and numeric argument */ { - register WINDOW *wp; - register LINE *lp; - register int ntru; - register int ntrl; - register int ntrd; - register WINDOW *wp1; - register WINDOW *wp2; + register WINDOW *wp; + register LINE *lp; + register int ntru; + register int ntrl; + register int ntrd; + register WINDOW *wp1; + register WINDOW *wp2; char *malloc(); - if (curwp->w_ntrows < 3) { - mlwrite("Cannot split a %d line window", curwp->w_ntrows); - return (FALSE); - } - if ((wp = (WINDOW *) malloc(sizeof(WINDOW))) == NULL) { - mlwrite("(OUT OF MEMORY)"); - return (FALSE); - } - ++curbp->b_nwnd; /* Displayed twice. */ - wp->w_bufp = curbp; - wp->w_dotp = curwp->w_dotp; - wp->w_doto = curwp->w_doto; - wp->w_markp = curwp->w_markp; - wp->w_marko = curwp->w_marko; - wp->w_flag = 0; - wp->w_force = 0; + if (curwp->w_ntrows < 3) { + mlwrite("Cannot split a %d line window", curwp->w_ntrows); + return (FALSE); + } + if ((wp = (WINDOW *) malloc(sizeof(WINDOW))) == NULL) { + mlwrite("(OUT OF MEMORY)"); + return (FALSE); + } + ++curbp->b_nwnd; /* Displayed twice. */ + wp->w_bufp = curbp; + wp->w_dotp = curwp->w_dotp; + wp->w_doto = curwp->w_doto; + wp->w_markp = curwp->w_markp; + wp->w_marko = curwp->w_marko; + wp->w_flag = 0; + wp->w_force = 0; #if COLOR /* set the colors of the new window */ wp->w_fcolor = gfcolor; wp->w_bcolor = gbcolor; #endif - ntru = (curwp->w_ntrows-1) / 2; /* Upper size */ - ntrl = (curwp->w_ntrows-1) - ntru; /* Lower size */ - lp = curwp->w_linep; - ntrd = 0; - while (lp != curwp->w_dotp) { - ++ntrd; - lp = lforw(lp); - } - lp = curwp->w_linep; - if (((f == FALSE) && (ntrd <= ntru)) || ((f == TRUE) && (n == 1))) { - /* Old is upper window. */ - if (ntrd == ntru) /* Hit mode line. */ - lp = lforw(lp); - curwp->w_ntrows = ntru; - wp->w_wndp = curwp->w_wndp; - curwp->w_wndp = wp; - wp->w_toprow = curwp->w_toprow+ntru+1; - wp->w_ntrows = ntrl; - } else { /* Old is lower window */ - wp1 = NULL; - wp2 = wheadp; - while (wp2 != curwp) { - wp1 = wp2; - wp2 = wp2->w_wndp; - } - if (wp1 == NULL) - wheadp = wp; - else - wp1->w_wndp = wp; - wp->w_wndp = curwp; - wp->w_toprow = curwp->w_toprow; - wp->w_ntrows = ntru; - ++ntru; /* Mode line. */ - curwp->w_toprow += ntru; - curwp->w_ntrows = ntrl; - while (ntru--) - lp = lforw(lp); - } - curwp->w_linep = lp; /* Adjust the top lines */ - wp->w_linep = lp; /* if necessary. */ - curwp->w_flag |= WFMODE|WFHARD; - wp->w_flag |= WFMODE|WFHARD; - return (TRUE); + ntru = (curwp->w_ntrows - 1) / 2; /* Upper size */ + ntrl = (curwp->w_ntrows - 1) - ntru; /* Lower size */ + lp = curwp->w_linep; + ntrd = 0; + while (lp != curwp->w_dotp) { + ++ntrd; + lp = lforw(lp); + } + lp = curwp->w_linep; + if (((f == FALSE) && (ntrd <= ntru)) || ((f == TRUE) && (n == 1))) { + /* Old is upper window. */ + if (ntrd == ntru) /* Hit mode line. */ + lp = lforw(lp); + curwp->w_ntrows = ntru; + wp->w_wndp = curwp->w_wndp; + curwp->w_wndp = wp; + wp->w_toprow = curwp->w_toprow + ntru + 1; + wp->w_ntrows = ntrl; + } else { /* Old is lower window */ + wp1 = NULL; + wp2 = wheadp; + while (wp2 != curwp) { + wp1 = wp2; + wp2 = wp2->w_wndp; + } + if (wp1 == NULL) + wheadp = wp; + else + wp1->w_wndp = wp; + wp->w_wndp = curwp; + wp->w_toprow = curwp->w_toprow; + wp->w_ntrows = ntru; + ++ntru; /* Mode line. */ + curwp->w_toprow += ntru; + curwp->w_ntrows = ntrl; + while (ntru--) + lp = lforw(lp); + } + curwp->w_linep = lp; /* Adjust the top lines */ + wp->w_linep = lp; /* if necessary. */ + curwp->w_flag |= WFMODE | WFHARD; + wp->w_flag |= WFMODE | WFHARD; + return (TRUE); } /* @@ -408,48 +402,48 @@ int f, n; /* default flag and numeric argument */ */ enlargewind(f, n) { - register WINDOW *adjwp; - register LINE *lp; - register int i; + register WINDOW *adjwp; + register LINE *lp; + register int i; - if (n < 0) - return (shrinkwind(f, -n)); - if (wheadp->w_wndp == NULL) { - mlwrite("Only one window"); - return (FALSE); - } - if ((adjwp=curwp->w_wndp) == NULL) { - adjwp = wheadp; - while (adjwp->w_wndp != curwp) - adjwp = adjwp->w_wndp; - } - if (adjwp->w_ntrows <= n) { - mlwrite("Impossible change"); - return (FALSE); - } - if (curwp->w_wndp == adjwp) { /* Shrink below. */ - lp = adjwp->w_linep; - for (i=0; iw_bufp->b_linep; ++i) - lp = lforw(lp); - adjwp->w_linep = lp; - adjwp->w_toprow += n; - } else { /* Shrink above. */ - lp = curwp->w_linep; - for (i=0; ib_linep; ++i) - lp = lback(lp); - curwp->w_linep = lp; - curwp->w_toprow -= n; - } - curwp->w_ntrows += n; - adjwp->w_ntrows -= n; + if (n < 0) + return (shrinkwind(f, -n)); + if (wheadp->w_wndp == NULL) { + mlwrite("Only one window"); + return (FALSE); + } + if ((adjwp = curwp->w_wndp) == NULL) { + adjwp = wheadp; + while (adjwp->w_wndp != curwp) + adjwp = adjwp->w_wndp; + } + if (adjwp->w_ntrows <= n) { + mlwrite("Impossible change"); + return (FALSE); + } + if (curwp->w_wndp == adjwp) { /* Shrink below. */ + lp = adjwp->w_linep; + for (i = 0; i < n && lp != adjwp->w_bufp->b_linep; ++i) + lp = lforw(lp); + adjwp->w_linep = lp; + adjwp->w_toprow += n; + } else { /* Shrink above. */ + lp = curwp->w_linep; + for (i = 0; i < n && lback(lp) != curbp->b_linep; ++i) + lp = lback(lp); + curwp->w_linep = lp; + curwp->w_toprow -= n; + } + curwp->w_ntrows += n; + adjwp->w_ntrows -= n; #if SCROLLCODE - curwp->w_flag |= WFMODE|WFHARD|WFINS; - adjwp->w_flag |= WFMODE|WFHARD|WFKILLS; + curwp->w_flag |= WFMODE | WFHARD | WFINS; + adjwp->w_flag |= WFMODE | WFHARD | WFKILLS; #else - curwp->w_flag |= WFMODE|WFHARD; - adjwp->w_flag |= WFMODE|WFHARD; + curwp->w_flag |= WFMODE | WFHARD; + adjwp->w_flag |= WFMODE | WFHARD; #endif - return (TRUE); + return (TRUE); } /* @@ -459,71 +453,72 @@ enlargewind(f, n) */ shrinkwind(f, n) { - register WINDOW *adjwp; - register LINE *lp; - register int i; + register WINDOW *adjwp; + register LINE *lp; + register int i; - if (n < 0) - return (enlargewind(f, -n)); - if (wheadp->w_wndp == NULL) { - mlwrite("Only one window"); - return (FALSE); - } - if ((adjwp=curwp->w_wndp) == NULL) { - adjwp = wheadp; - while (adjwp->w_wndp != curwp) - adjwp = adjwp->w_wndp; - } - if (curwp->w_ntrows <= n) { - mlwrite("Impossible change"); - return (FALSE); - } - if (curwp->w_wndp == adjwp) { /* Grow below. */ - lp = adjwp->w_linep; - for (i=0; iw_bufp->b_linep; ++i) - lp = lback(lp); - adjwp->w_linep = lp; - adjwp->w_toprow -= n; - } else { /* Grow above. */ - lp = curwp->w_linep; - for (i=0; ib_linep; ++i) - lp = lforw(lp); - curwp->w_linep = lp; - curwp->w_toprow += n; - } - curwp->w_ntrows -= n; - adjwp->w_ntrows += n; + if (n < 0) + return (enlargewind(f, -n)); + if (wheadp->w_wndp == NULL) { + mlwrite("Only one window"); + return (FALSE); + } + if ((adjwp = curwp->w_wndp) == NULL) { + adjwp = wheadp; + while (adjwp->w_wndp != curwp) + adjwp = adjwp->w_wndp; + } + if (curwp->w_ntrows <= n) { + mlwrite("Impossible change"); + return (FALSE); + } + if (curwp->w_wndp == adjwp) { /* Grow below. */ + lp = adjwp->w_linep; + for (i = 0; i < n && lback(lp) != adjwp->w_bufp->b_linep; + ++i) + lp = lback(lp); + adjwp->w_linep = lp; + adjwp->w_toprow -= n; + } else { /* Grow above. */ + lp = curwp->w_linep; + for (i = 0; i < n && lp != curbp->b_linep; ++i) + lp = lforw(lp); + curwp->w_linep = lp; + curwp->w_toprow += n; + } + curwp->w_ntrows -= n; + adjwp->w_ntrows += n; #if SCROLLCODE - curwp->w_flag |= WFMODE|WFHARD|WFKILLS; - adjwp->w_flag |= WFMODE|WFHARD|WFINS; + curwp->w_flag |= WFMODE | WFHARD | WFKILLS; + adjwp->w_flag |= WFMODE | WFHARD | WFINS; #else - curwp->w_flag |= WFMODE|WFHARD; - adjwp->w_flag |= WFMODE|WFHARD; + curwp->w_flag |= WFMODE | WFHARD; + adjwp->w_flag |= WFMODE | WFHARD; #endif - return (TRUE); + return (TRUE); } /* Resize the current window to the requested size */ resize(f, n) -int f, n; /* default flag and numeric argument */ +int f, n; /* default flag and numeric argument */ { - int clines; /* current # of lines in window */ - + int clines; /* current # of lines in window */ + /* must have a non-default argument, else ignore call */ if (f == FALSE) - return(TRUE); + return (TRUE); /* find out what to do */ clines = curwp->w_ntrows; /* already the right size? */ if (clines == n) - return(TRUE); + return (TRUE); - return(enlargewind(TRUE, n - clines)); + return (enlargewind(TRUE, n - clines)); } /* @@ -531,46 +526,41 @@ 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; + register WINDOW *wp; - if (wheadp->w_wndp == NULL /* Only 1 window */ - && splitwind(FALSE, 0) == FALSE) /* and it won't split */ - return (NULL); - wp = wheadp; /* Find window to use */ - while (wp!=NULL && wp==curwp) - wp = wp->w_wndp; - return (wp); + if (wheadp->w_wndp == NULL /* Only 1 window */ + && splitwind(FALSE, 0) == FALSE) /* and it won't split */ + return (NULL); + wp = wheadp; /* Find window to use */ + while (wp != NULL && wp == curwp) + wp = wp->w_wndp; + 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); + return (TRUE); } -restwnd(f, n) /* restore the saved screen */ - -{ +restwnd(f, n) +{ /* restore the saved screen */ register WINDOW *wp; /* find the window */ @@ -586,19 +576,19 @@ restwnd(f, n) /* restore the saved screen */ } mlwrite("(No such window exists)"); - return(FALSE); + return (FALSE); } -newsize(f, n) /* resize the screen, re-writing the screen */ - -int f; /* default flag */ -int n; /* numeric argument */ +newsize(f, n) + /* resize the screen, re-writing the screen */ +int f; /* default flag */ +int n; /* numeric argument */ { - WINDOW *wp; /* current window being examined */ - WINDOW *nextwp; /* next window to scan */ - WINDOW *lastwp; /* last window scanned */ - int lastline; /* screen line of last line of current window */ + WINDOW *wp; /* current window being examined */ + WINDOW *nextwp; /* next window to scan */ + WINDOW *lastwp; /* last window scanned */ + int lastline; /* screen line of last line of current window */ /* if the command defaults, assume the largest */ if (f == FALSE) @@ -607,11 +597,11 @@ int n; /* numeric argument */ /* make sure it's in range */ if (n < 3 || n > term.t_mrow + 1) { mlwrite("%%Screen size out of range"); - return(FALSE); + return (FALSE); } if (term.t_nrow == n - 1) - return(TRUE); + return (TRUE); else if (term.t_nrow < n - 1) { /* go to the last window */ @@ -621,7 +611,7 @@ int n; /* numeric argument */ /* and enlarge it as needed */ wp->w_ntrows = n - wp->w_toprow - 2; - wp->w_flag |= WFHARD|WFMODE; + wp->w_flag |= WFHARD | WFMODE; } else { @@ -632,7 +622,7 @@ int n; /* numeric argument */ while (nextwp != NULL) { wp = nextwp; nextwp = wp->w_wndp; - + /* get rid of it if it is too low */ if (wp->w_toprow > n - 2) { @@ -643,24 +633,25 @@ int n; /* numeric argument */ wp->w_bufp->b_markp = wp->w_markp; wp->w_bufp->b_marko = wp->w_marko; } - + /* update curwp and lastwp if needed */ if (wp == curwp) curwp = wheadp; - curbp = curwp->w_bufp; + curbp = curwp->w_bufp; if (lastwp != NULL) lastwp->w_wndp = NULL; /* free the structure */ - free((char *)wp); + free((char *) wp); wp = NULL; } else { /* 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_flag |= WFHARD|WFMODE; + wp->w_ntrows = + n - wp->w_toprow - 2; + wp->w_flag |= WFHARD | WFMODE; } } @@ -671,13 +662,13 @@ int n; /* numeric argument */ /* screen is garbage */ term.t_nrow = n - 1; sgarbf = TRUE; - return(TRUE); + return (TRUE); } -newwidth(f, n) /* resize the screen, re-writing the screen */ - -int f; /* default flag */ -int n; /* numeric argument */ +newwidth(f, n) + /* resize the screen, re-writing the screen */ +int f; /* default flag */ +int n; /* numeric argument */ { register WINDOW *wp; @@ -689,7 +680,7 @@ int n; /* numeric argument */ /* make sure it's in range */ if (n < 10 || n > term.t_mcol) { mlwrite("%%Screen width out of range"); - return(FALSE); + return (FALSE); } /* otherwise, just re-width it (no big deal) */ @@ -705,12 +696,11 @@ int n; /* numeric argument */ } sgarbf = TRUE; - return(TRUE); + return (TRUE); } -int getwpos() /* get screen offset of current line in current window */ - -{ +int getwpos() +{ /* get screen offset of current line in current window */ register int sline; /* screen line from top of window */ register LINE *lp; /* scannile line pointer */ @@ -723,11 +713,10 @@ int getwpos() /* get screen offset of current line in current window */ } /* and return the value */ - return(sline); + return (sline); } cknewwindow() { - execute(META|SPEC|'X', FALSE, 1); + execute(META | SPEC | 'X', FALSE, 1); } - diff --git a/word.c b/word.c index e87f6cf..85548d4 100644 --- a/word.c +++ b/word.c @@ -20,46 +20,46 @@ */ wrapword(f, n) -int f; /* default flag */ -int n; /* numeric argument */ - +int f; /* default flag */ +int n; /* numeric argument */ + { register int cnt; /* size of word wrapped to next line */ register int c; /* charector temporary */ /* backup from the 1 char */ if (!backchar(0, 1)) - return(FALSE); + return (FALSE); /* back up until we aren't in a word, make sure there is a break in the line */ cnt = 0; while (((c = lgetc(curwp->w_dotp, curwp->w_doto)) != ' ') - && (c != '\t')) { + && (c != '\t')) { cnt++; if (!backchar(0, 1)) - return(FALSE); + return (FALSE); /* if we make it to the beginning, start a new line */ if (curwp->w_doto == 0) { gotoeol(FALSE, 0); - return(lnewline()); + return (lnewline()); } } /* delete the forward white space */ if (!forwdel(0, 1)) - return(FALSE); + return (FALSE); /* put in a end of line */ if (!lnewline()) - return(FALSE); + return (FALSE); /* and past the first word */ while (cnt-- > 0) { if (forwchar(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); } - return(TRUE); + return (TRUE); } /* @@ -105,7 +105,7 @@ forwword(f, n) return (FALSE); } } - return(TRUE); + return (TRUE); } /* @@ -115,10 +115,10 @@ forwword(f, n) */ upperword(f, n) { - register int c; + register int c; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (n < 0) return (FALSE); while (n--) { @@ -131,9 +131,9 @@ upperword(f, n) #if PKCODE if (islower(c)) { #else - if (c>='a' && c<='z') { + if (c >= 'a' && c <= 'z') { #endif - c -= 'a'-'A'; + c -= 'a' - 'A'; lputc(curwp->w_dotp, curwp->w_doto, c); lchange(WFHARD); } @@ -151,10 +151,10 @@ upperword(f, n) */ lowerword(f, n) { - register int c; + register int c; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (n < 0) return (FALSE); while (n--) { @@ -167,9 +167,9 @@ lowerword(f, n) #if PKCODE if (isupper(c)) { #else - if (c>='A' && c<='Z') { + if (c >= 'A' && c <= 'Z') { #endif - c += 'a'-'A'; + c += 'a' - 'A'; lputc(curwp->w_dotp, curwp->w_doto, c); lchange(WFHARD); } @@ -188,10 +188,10 @@ lowerword(f, n) */ capword(f, n) { - register int c; + register int c; - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (n < 0) return (FALSE); while (n--) { @@ -204,9 +204,9 @@ capword(f, n) #if PKCODE if (islower(c)) { #else - if (c>='a' && c<='z') { + if (c >= 'a' && c <= 'z') { #endif - c -= 'a'-'A'; + c -= 'a' - 'A'; lputc(curwp->w_dotp, curwp->w_doto, c); lchange(WFHARD); } @@ -217,10 +217,11 @@ capword(f, n) #if PKCODE if (isupper(c)) { #else - if (c>='A' && c<='Z') { + if (c >= 'A' && c <= 'Z') { #endif - c += 'a'-'A'; - lputc(curwp->w_dotp, curwp->w_doto, c); + c += 'a' - 'A'; + lputc(curwp->w_dotp, curwp->w_doto, + c); lchange(WFHARD); } if (forwchar(FALSE, 1) == FALSE) @@ -239,21 +240,21 @@ capword(f, n) */ delfword(f, n) { - register LINE *dotp; /* original cursor line */ - register int doto; /* and row */ + register LINE *dotp; /* original cursor line */ + register int doto; /* and row */ register int c; /* temp char */ long size; /* # of chars to delete */ /* don't allow this command if we are in read only mode */ - if (curbp->b_mode&MDVIEW) - return(rdonly()); + if (curbp->b_mode & MDVIEW) + return (rdonly()); /* ignore the command if there is a negative argument */ if (n < 0) return (FALSE); /* Clear the kill buffer if last command wasn't a kill */ - if ((lastflag&CFKILL) == 0) + if ((lastflag & CFKILL) == 0) kdelete(); thisflag |= CFKILL; /* this command is a kill */ @@ -267,7 +268,7 @@ delfword(f, n) /* get us into a word.... */ while (inword() == FALSE) { if (forwchar(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); ++size; } @@ -275,43 +276,43 @@ delfword(f, n) /* skip one word, no whitespace! */ while (inword() == TRUE) { if (forwchar(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); ++size; } } else { /* skip n words.... */ while (n--) { - + /* if we are at EOL; skip to the beginning of the next */ while (curwp->w_doto == llength(curwp->w_dotp)) { if (forwchar(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); ++size; } - + /* move forward till we are at the end of the word */ while (inword() == TRUE) { if (forwchar(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); ++size; } - + /* if there are more words, skip the interword stuff */ if (n != 0) while (inword() == FALSE) { if (forwchar(FALSE, 1) == FALSE) - return(FALSE); + return (FALSE); ++size; } } - + /* skip whitespace and newlines */ while ((curwp->w_doto == llength(curwp->w_dotp)) || - ((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ') || - (c == '\t')) { - if (forwchar(FALSE, 1) == FALSE) - break; - ++size; + ((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ') + || (c == '\t')) { + if (forwchar(FALSE, 1) == FALSE) + break; + ++size; } } @@ -331,15 +332,15 @@ delbword(f, n) long size; /* don't allow this command if we are in read only mode */ - if (curbp->b_mode&MDVIEW) - return(rdonly()); + if (curbp->b_mode & MDVIEW) + return (rdonly()); /* ignore the command if there is a nonpositive argument */ if (n <= 0) return (FALSE); /* Clear the kill buffer if last command wasn't a kill */ - if ((lastflag&CFKILL) == 0) + if ((lastflag & CFKILL) == 0) kdelete(); thisflag |= CFKILL; /* this command is a kill */ @@ -360,7 +361,7 @@ delbword(f, n) } if (forwchar(FALSE, 1) == FALSE) return (FALSE); -bckdel: return (ldelete(size, TRUE)); + bckdel:return (ldelete(size, TRUE)); } /* @@ -369,7 +370,7 @@ bckdel: return (ldelete(size, TRUE)); */ inword() { - register int c; + register int c; if (curwp->w_doto == llength(curwp->w_dotp)) return (FALSE); @@ -377,39 +378,39 @@ inword() #if PKCODE if (isletter(c)) #else - if (c>='a' && c<='z') + if (c >= 'a' && c <= 'z') return (TRUE); - if (c>='A' && c<='Z') + if (c >= 'A' && c <= 'Z') #endif return (TRUE); - if (c>='0' && c<='9') + if (c >= '0' && c <= '9') return (TRUE); return (FALSE); } #if WORDPRO -fillpara(f, n) /* Fill the current paragraph according to the current - fill column */ - -int f, n; /* deFault flag and Numeric argument */ +fillpara(f, n) + /* Fill the current paragraph according to the current + fill column */ +int f, n; /* deFault flag and Numeric argument */ { - register int c; /* current char durring scan */ - register int wordlen; /* length of current word */ - register int clength; /* position on line during fill */ - register int i; /* index during word copy */ - register int newlength; /* tentative new line length */ - register int eopflag; /* Are we at the End-Of-Paragraph? */ - register int firstflag; /* first word? (needs no space) */ - register LINE *eopline; /* pointer to line just past EOP */ - register int dotflag; /* was the last char a period? */ - char wbuf[NSTRING]; /* buffer for current word */ + register int c; /* current char durring scan */ + register int wordlen; /* length of current word */ + register int clength; /* position on line during fill */ + register int i; /* index during word copy */ + register int newlength; /* tentative new line length */ + register int eopflag; /* Are we at the End-Of-Paragraph? */ + register int firstflag; /* first word? (needs no space) */ + register LINE *eopline; /* pointer to line just past EOP */ + register int dotflag; /* was the last char a period? */ + char wbuf[NSTRING]; /* buffer for current word */ - if (curbp->b_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (fillcol == 0) { /* no fill column set */ mlwrite("No fill column set"); - return(FALSE); + return (FALSE); } #if PKCODE justflag = FALSE; @@ -446,7 +447,7 @@ int f, n; /* deFault flag and Numeric argument */ /* if not a separator, just add it in */ if (c != ' ' && c != '\t') { - dotflag = (c == '.'); /* was it a dot */ + dotflag = (c == '.'); /* was it a dot */ if (wordlen < NSTRING - 1) wbuf[wordlen++] = c; } else if (wordlen) { @@ -456,7 +457,7 @@ int f, n; /* deFault flag and Numeric argument */ if (newlength <= fillcol) { /* add word to current line */ if (!firstflag) { - linsert(1, ' '); /* the space */ + linsert(1, ' '); /* the space */ ++clength; } firstflag = FALSE; @@ -467,7 +468,7 @@ int f, n; /* deFault flag and Numeric argument */ } /* and add the word in in either case */ - for (i=0; ib_mode&MDVIEW) /* don't allow this command if */ - return(rdonly()); /* we are in read only mode */ + if (curbp->b_mode & MDVIEW) /* don't allow this command if */ + return (rdonly()); /* we are in read only mode */ if (fillcol == 0) { /* no fill column set */ mlwrite("No fill column set"); - return(FALSE); + return (FALSE); } justflag = TRUE; leftmarg = curwp->w_doto; - if (leftmarg+10 > fillcol) { + if (leftmarg + 10 > fillcol) { leftmarg = 0; mlwrite("Column too narrow"); - return(FALSE); - } + return (FALSE); + } /* record the pointer to the line just past the EOP */ gotoeop(FALSE, 1); @@ -558,20 +559,20 @@ int f, n; /* deFault flag and Numeric argument */ if (newlength <= fillcol) { /* add word to current line */ if (!firstflag) { - linsert(1, ' '); /* the space */ + linsert(1, ' '); /* the space */ ++clength; } firstflag = FALSE; } else { /* start a new line */ lnewline(); - for (i=0; iw_doto = llength(curwp->w_dotp); justflag = FALSE; - return(TRUE); + return (TRUE); } #endif -killpara(f, n) /* delete n paragraphs starting with the current one */ - -int f; /* default flag */ -int n; /* # of paras to delete */ +killpara(f, n) + /* delete n paragraphs starting with the current one */ +int f; /* default flag */ +int n; /* # of paras to delete */ { register int status; /* returned status of functions */ @@ -612,15 +613,15 @@ int n; /* # of paras to delete */ /* go to the beginning of the paragraph */ gotobop(FALSE, 1); curwp->w_doto = 0; /* force us to the beginning of line */ - + /* and delete it */ if ((status = killregion(FALSE, 1)) != TRUE) - return(status); + return (status); /* and clean up the 2 extra lines */ ldelete(2L, TRUE); } - return(TRUE); + return (TRUE); } @@ -630,7 +631,7 @@ int n; /* # of paras to delete */ wordcount(f, n) -int f, n; /* ignored numeric arguments */ +int f, n; /* ignored numeric arguments */ { register LINE *lp; /* current line to scan */ @@ -648,16 +649,16 @@ int f, n; /* ignored numeric arguments */ #if PKCODE struct { - long pk_1; - long pk_2; - int pk_3; - int pk_4; + long pk_1; + long pk_2; + int pk_3; + int pk_4; } pk_mlrec; #endif /* make sure we have a region to count */ if ((status = getregion(®ion)) != TRUE) - return(status); + return (status); lp = region.r_linep; offset = region.r_offset; size = region.r_size; @@ -683,12 +684,12 @@ int f, n; /* ignored numeric arguments */ /* and tabulate it */ wordflag = ( #if PKCODE - (isletter(ch)) || + (isletter(ch)) || #else - (ch >= 'a' && ch <= 'z') || - (ch >= 'A' && ch <= 'Z') || + (ch >= 'a' && ch <= 'z') || + (ch >= 'A' && ch <= 'Z') || #endif - (ch >= '0' && ch <= '9')); + (ch >= '0' && ch <= '9')); if (wordflag == TRUE && lastword == FALSE) ++nwords; lastword = wordflag; @@ -697,7 +698,7 @@ int f, n; /* ignored numeric arguments */ /* and report on the info */ if (nwords > 0L) - avgch = (int)((100L * nchars) / nwords); + avgch = (int) ((100L * nchars) / nwords); else avgch = 0; @@ -706,12 +707,12 @@ int f, n; /* ignored numeric arguments */ pk_mlrec.pk_2 = nchars; pk_mlrec.pk_3 = nlines + 1; pk_mlrec.pk_4 = avgch; - mlwrite("%*Words %D Chars %D Lines %d Avg chars/word %f", + mlwrite("%*Words %D Chars %D Lines %d Avg chars/word %f", &pk_mlrec); #else mlwrite("Words %D Chars %D Lines %d Avg chars/word %f", nwords, nchars, nlines + 1, avgch); #endif - return(TRUE); + return (TRUE); } #endif