First cut at turning things into proper modern ANSI C

Hey! Real declarations!
This commit is contained in:
Linus Torvalds 2005-09-30 16:34:11 -07:00
parent 118ee5f944
commit 9605cf8826
10 changed files with 618 additions and 470 deletions

71
basic.c
View File

@ -18,7 +18,7 @@
* beginning of the current line.
* Trivial.
*/
gotobol(f, n)
int gotobol(int f, int n)
{
curwp->w_doto = 0;
return (TRUE);
@ -30,8 +30,7 @@ gotobol(f, n)
* location. Error if you try and move out of the buffer. Set the flag if the
* line pointer for dot changes.
*/
backchar(f, n)
register int n;
int backchar(int f, int n)
{
register LINE *lp;
@ -53,7 +52,7 @@ register int n;
/*
* Move the cursor to the end of the current line. Trivial. No errors.
*/
gotoeol(f, n)
int gotoeol(int f, int n)
{
curwp->w_doto = llength(curwp->w_dotp);
return (TRUE);
@ -65,8 +64,7 @@ gotoeol(f, n)
* location, and move ".". Error if you try and move off the end of the
* buffer. Set the flag if the line pointer for dot changes.
*/
forwchar(f, n)
register int n;
int forwchar(int f, int n)
{
if (n < 0)
return (backchar(f, -n));
@ -83,10 +81,14 @@ register int n;
return (TRUE);
}
gotoline(f, n)
{ /* move to a particular line.
argument (n) must be a positive integer for
this to actually do anything */
/*
* move to a particular line.
*
* argument (n) must be a positive integer for
* this to actually do anything
*/
int gotoline(int f, int n)
{
register int status; /* status return */
char arg[NSTRING]; /* buffer to hold argument */
@ -114,7 +116,7 @@ gotoline(f, n)
* considered to be hard motion; it really isn't if the original value of dot
* is the same as the new value of dot. Normally bound to "M-<".
*/
gotobob(f, n)
int gotobob(int f, int n)
{
curwp->w_dotp = lforw(curbp->b_linep);
curwp->w_doto = 0;
@ -127,7 +129,7 @@ gotobob(f, n)
* (ZJ). The standard screen code does most of the hard parts of update.
* Bound to "M->".
*/
gotoeob(f, n)
int gotoeob(int f, int n)
{
curwp->w_dotp = curbp->b_linep;
curwp->w_doto = 0;
@ -141,7 +143,7 @@ gotoeob(f, n)
* controls how the goal column is set. Bound to "C-N". No errors are
* possible.
*/
forwline(f, n)
int forwline(int f, int n)
{
register LINE *dlp;
@ -178,7 +180,7 @@ forwline(f, n)
* alternate. Figure out the new line and call "movedot" to perform the
* motion. No errors are possible. Bound to "C-P".
*/
backline(f, n)
int backline(int f, int n)
{
register LINE *dlp;
@ -211,12 +213,14 @@ backline(f, n)
}
#if WORDPRO
gotobop(f, n)
/* go back to the beginning of the current paragraph
here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
combination to delimit the beginning of a paragraph */
int f, n; /* default Flag & Numeric argument */
/*
* go back to the beginning of the current paragraph
* here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
* combination to delimit the beginning of a paragraph
*
* int f, n; default Flag & Numeric argument
*/
int gotobop(int f, int n)
{
register int suc; /* success of last backchar */
@ -256,12 +260,14 @@ int f, n; /* default Flag & Numeric argument */
return (TRUE);
}
gotoeop(f, n)
/* go forword to the end of the current paragraph
here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
combination to delimit the beginning of a paragraph */
int f, n; /* default Flag & Numeric argument */
/*
* go forword to the end of the current paragraph
* here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
* combination to delimit the beginning of a paragraph
*
* int f, n; default Flag & Numeric argument
*/
int gotoeop(int f, int n)
{
register int suc; /* success of last backchar */
@ -312,8 +318,7 @@ int f, n; /* default Flag & Numeric argument */
* column, return the best choice for the offset. The offset is returned.
* Used by "C-N" and "C-P".
*/
getgoal(dlp)
register LINE *dlp;
int getgoal(LINE *dlp)
{
register int c;
register int col;
@ -344,8 +349,7 @@ register LINE *dlp;
* the overlap; this value is the default overlap value in ITS EMACS. Because
* this zaps the top line in the display window, we have to do a hard update.
*/
forwpage(f, n)
register int n;
int forwpage(int f, int n)
{
register LINE *lp;
@ -387,8 +391,7 @@ register int n;
* EMACS manual. Bound to "M-V". We do a hard update for exactly the same
* reason.
*/
backpage(f, n)
register int n;
int backpage(int f, int n)
{
register LINE *lp;
@ -428,7 +431,7 @@ register int n;
* Set the mark in the current window to the value of "." in the window. No
* errors are possible. Bound to "M-.".
*/
setmark(f, n)
int setmark(int f, int n)
{
curwp->w_markp = curwp->w_dotp;
curwp->w_marko = curwp->w_doto;
@ -442,7 +445,7 @@ setmark(f, n)
* that moves the mark about. The only possible error is "no mark". Bound to
* "C-X C-X".
*/
swapmark(f, n)
int swapmark(int f, int n)
{
register LINE *odotp;
register int odoto;

279
display.c
View File

@ -10,6 +10,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include "estruct.h"
#include "edef.h"
@ -52,7 +53,7 @@ int chg_width, chg_height;
* The original window has "WFCHG" set, so that it will get completely
* redrawn on the first call to "update".
*/
vtinit()
void vtinit(void)
{
register int i;
register VIDEO *vp;
@ -99,7 +100,7 @@ vtinit()
#if CLEAN
/* free up all the dynamically allocated video structures */
vtfree()
void vtfree(void)
{
int i;
for (i = 0; i < term.t_mrow; ++i) {
@ -121,7 +122,7 @@ vtfree()
* system prompt will be written in the line). Shut down the channel to the
* terminal.
*/
vttidy()
void vttidy(void)
{
mlerase();
movecursor(term.t_nrow, 0);
@ -138,23 +139,21 @@ vttidy()
* screen. There is no checking for nonsense values; this might be a good
* idea during the early stages.
*/
vtmove(row, col)
void vtmove(int row, int col)
{
vtrow = row;
vtcol = col;
}
/* Write a character to the virtual screen. The virtual row and
column are updated. If we are not yet on left edge, don't print
it yet. If the line is too long put a "$" in the last column.
This routine only puts printing characters into the virtual
terminal buffers. Only column overflow is checked.
*/
vtputc(c)
int c;
/*
* Write a character to the virtual screen. The virtual row and
* column are updated. If we are not yet on left edge, don't print
* it yet. If the line is too long put a "$" in the last column.
*
* This routine only puts printing characters into the virtual
* terminal buffers. Only column overflow is checked.
*/
void vtputc(int c)
{
register VIDEO *vp; /* ptr to line being updated */
@ -183,7 +182,7 @@ int c;
* Erase from the end of the software cursor to the end of the line on which
* the software cursor is located.
*/
vteeol()
void vteeol(void)
{
/* register VIDEO *vp; */
register char *vcp = vscreen[vtrow]->v_text;
@ -194,10 +193,12 @@ vteeol()
vcp[vtcol++] = ' ';
}
/* upscreen: user routine to force a screen update
always finishes complete update */
upscreen(f, n)
/*
* upscreen:
* user routine to force a screen update
* always finishes complete update
*/
int upscreen(int f, int n)
{
update(TRUE);
return (TRUE);
@ -213,11 +214,10 @@ int scrflags;
* and refresh the screen. Second, make sure that "currow" and "curcol" are
* correct for the current window. Third, make the virtual and physical
* screens the same.
*
* int force; force update past type ahead?
*/
update(force)
int force; /* force update past type ahead? */
int update(int force)
{
register WINDOW *wp;
@ -314,13 +314,12 @@ int force; /* force update past type ahead? */
return (TRUE);
}
/* reframe: check to see if the cursor is on in the window
and re-frame it if needed or wanted */
reframe(wp)
WINDOW *wp;
/*
* reframe:
* check to see if the cursor is on in the window
* and re-frame it if needed or wanted
*/
int reframe(WINDOW *wp)
{
register LINE *lp, *lp0;
register int i;
@ -404,12 +403,13 @@ WINDOW *wp;
return (TRUE);
}
/* updone: update the current line to the virtual screen */
updone(wp)
WINDOW *wp; /* window to update current line in */
/*
* updone:
* update the current line to the virtual screen
*
* WINDOW *wp; window to update current line in
*/
void updone(WINDOW *wp)
{
register LINE *lp; /* line to update */
register int sline; /* physical screen line to update */
@ -436,12 +436,13 @@ WINDOW *wp; /* window to update current line in */
vteeol();
}
/* updall: update all the lines in a window on the virtual screen */
updall(wp)
WINDOW *wp; /* window to update lines in */
/*
* updall:
* update all the lines in a window on the virtual screen
*
* WINDOW *wp; window to update lines in
*/
void updall(WINDOW *wp)
{
register LINE *lp; /* line to update */
register int sline; /* physical screen line to update */
@ -474,10 +475,12 @@ WINDOW *wp; /* window to update lines in */
}
/* updpos: update the position of the hardware cursor and handle extended
lines. This is the only update for simple moves. */
updpos()
/*
* updpos:
* update the position of the hardware cursor and handle extended
* lines. This is the only update for simple moves.
*/
void updpos(void)
{
register LINE *lp;
register int c;
@ -512,9 +515,11 @@ updpos()
lbound = 0;
}
/* upddex: de-extend any line that derserves it */
upddex()
/*
* upddex:
* de-extend any line that derserves it
*/
void upddex(void)
{
register WINDOW *wp;
register LINE *lp;
@ -548,10 +553,12 @@ upddex()
}
}
/* updgar: if the screen is garbage, clear the physical screen and
the virtual screen and force a full update */
updgar()
/*
* updgar:
* if the screen is garbage, clear the physical screen and
* the virtual screen and force a full update
*/
void updgar(void)
{
register char *txt;
register int i, j;
@ -581,12 +588,13 @@ updgar()
#endif
}
/* updupd: update the physical screen from the virtual screen */
updupd(force)
int force; /* forced update flag */
/*
* updupd:
* update the physical screen from the virtual screen
*
* int force; forced update flag
*/
int updupd(int force)
{
register VIDEO *vp1;
register int i;
@ -620,9 +628,11 @@ int force; /* forced update flag */
#if SCROLLCODE
/* optimize out scrolls (line breaks, and newlines) */
/* arg. chooses between looking for inserts or deletes */
int scrolls(inserts)
/*
* optimize out scrolls (line breaks, and newlines)
* arg. chooses between looking for inserts or deletes
*/
int scrolls(int inserts)
{ /* returns true if it does something */
struct VIDEO *vpv; /* virtual screen image */
struct VIDEO *vpp; /* physical screen image */
@ -758,14 +768,18 @@ int scrolls(inserts)
}
/* move the "count" lines starting at "from" to "to" */
scrscroll(from, to, count)
void scrscroll(int from, int to, int count)
{
ttrow = ttcol = -1;
(*term.t_scroll) (from, to, count);
}
texttest(vrow, prow) /* return TRUE on text match */
int vrow, prow; /* virtual, physical rows */
/*
* return TRUE on text match
*
* int vrow, prow; virtual, physical rows
*/
int texttest(int vrow, int prow)
{
struct VIDEO *vpv = vscreen[vrow]; /* virtual screen image */
struct VIDEO *vpp = pscreen[prow]; /* physical screen image */
@ -773,9 +787,10 @@ int vrow, prow; /* virtual, physical rows */
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;
/*
* return the index of the first blank of trailing whitespace
*/
int endofline(char *s, int n)
{
int i;
for (i = n - 1; i >= 0; i--)
@ -786,13 +801,14 @@ char *s;
#endif /* SCROLLCODE */
/* updext: update the extended line which the cursor is currently
on at a column greater than the terminal width. The line
will be scrolled right or left to let the user see where
the cursor is
*/
updext()
/*
* updext:
* update the extended line which the cursor is currently
* on at a column greater than the terminal width. The line
* will be scrolled right or left to let the user see where
* the cursor is
*/
void updext(void)
{
register int rcursor; /* real cursor location */
register LINE *lp; /* pointer to current line */
@ -870,12 +886,14 @@ struct VIDEO *vp2;
#else
updateline(row, vp1, vp2)
int row; /* row of screen to update */
struct VIDEO *vp1; /* virtual screen image */
struct VIDEO *vp2; /* physical screen image */
/*
* updateline()
*
* int row; row of screen to update
* struct VIDEO *vp1; virtual screen image
* struct VIDEO *vp2; physical screen image
*/
int updateline(int row, struct VIDEO *vp1, struct VIDEO *vp2)
{
#if RAINBOW
/* UPDATELINE specific code for the DEC rainbow 100 micro */
@ -1035,8 +1053,7 @@ struct VIDEO *vp2; /* physical screen image */
* change the modeline format by hacking at this routine. Called by "update"
* any time there is a dirty window.
*/
modeline(wp)
WINDOW *wp;
void modeline(WINDOW *wp)
{
register char *cp;
register int c;
@ -1225,7 +1242,7 @@ WINDOW *wp;
}
}
upmode()
void upmode(void)
{ /* update all the mode lines */
register WINDOW *wp;
@ -1241,7 +1258,7 @@ upmode()
* and column "col". The row and column arguments are origin 0. Optimize out
* random calls. Update "ttrow" and "ttcol".
*/
movecursor(row, col)
void movecursor(int row, int col)
{
if (row != ttrow || col != ttcol) {
ttrow = row;
@ -1255,7 +1272,7 @@ movecursor(row, col)
* is not considered to be part of the virtual screen. It always works
* immediately; the terminal buffer is flushed via a call to the flusher.
*/
mlerase()
void mlerase(void)
{
int i;
@ -1284,16 +1301,14 @@ mlerase()
* position. A small class of printf like format items is handled. Assumes the
* stack grows down; this assumption is made by the "++" in the argument scan
* loop. Set the "message line" flag TRUE.
*
* char *fmt; format string for output
* char *arg; pointer to first argument to print
*/
mlwrite(fmt, arg)
char *fmt; /* format string for output */
char *arg; /* pointer to first argument to print */
void mlwrite(const char *fmt, ...)
{
register int c; /* current char in format string */
register char *ap; /* ptr to current data field */
va_list ap;
/* if we are not currently echoing on the command line, abort this */
if (discmd == FALSE) {
@ -1313,7 +1328,7 @@ char *arg; /* pointer to first argument to print */
}
movecursor(term.t_nrow, 0);
ap = (char *) &arg;
va_start(ap, fmt);
while ((c = *fmt++) != 0) {
if (c != '%') {
TTputc(c);
@ -1321,39 +1336,28 @@ char *arg; /* pointer to first argument to print */
} else {
c = *fmt++;
switch (c) {
#if PKCODE
case '*':
ap = *(char **) ap;
break;
#endif
case 'd':
mlputi(*(int *) ap, 10);
ap += sizeof(int);
mlputi(va_arg(ap, int), 10);
break;
case 'o':
mlputi(*(int *) ap, 8);
ap += sizeof(int);
mlputi(va_arg(ap, int), 8);
break;
case 'x':
mlputi(*(int *) ap, 16);
ap += sizeof(int);
mlputi(va_arg(ap, int), 16);
break;
case 'D':
mlputli(*(long *) ap, 10);
ap += sizeof(long);
mlputli(va_arg(ap, long), 10);
break;
case 's':
mlputs(*(char **) ap);
ap += sizeof(char *);
mlputs(va_arg(ap, char *));
break;
case 'f':
mlputf(*(int *) ap);
ap += sizeof(int);
mlputf(va_arg(ap, int));
break;
default:
@ -1362,6 +1366,7 @@ char *arg; /* pointer to first argument to print */
}
}
}
va_end(ap);
/* if we can, erase to the end of screen */
if (eolexist == TRUE)
@ -1370,15 +1375,14 @@ char *arg; /* pointer to first argument to print */
mpresf = TRUE;
}
/* Force a string out to the message line regardless of the
current $discmd setting. This is needed when $debug is TRUE
and for the write-message and clear-message-line commands
*/
mlforce(s)
char *s; /* string to force out */
/*
* Force a string out to the message line regardless of the
* current $discmd setting. This is needed when $debug is TRUE
* and for the write-message and clear-message-line commands
*
* char *s; string to force out
*/
void mlforce(char *s)
{
register int oldcmd; /* original command display flag */
@ -1393,8 +1397,7 @@ char *s; /* string to force out */
* the characters in the string all have width "1"; if this is not the case
* things will get screwed up a little.
*/
mlputs(s)
char *s;
void mlputs(char *s)
{
register int c;
@ -1408,7 +1411,7 @@ char *s;
* Write out an integer, in the specified radix. Update the physical cursor
* position.
*/
mlputi(i, r)
void mlputi(int i, int r)
{
register int q;
static char hexdigits[] = "0123456789ABCDEF";
@ -1430,8 +1433,7 @@ mlputi(i, r)
/*
* do the same except as a long integer.
*/
mlputli(l, r)
long l;
void mlputli(long l, int r)
{
register long q;
@ -1450,13 +1452,11 @@ long l;
}
/*
* write out a scaled integer with two decimal places
* write out a scaled integer with two decimal places
*
* int s; scaled integer to output
*/
mlputf(s)
int s; /* scaled integer to output */
void mlputf(int s)
{
int i; /* integer portion of number */
int f; /* fractional portion of number */
@ -1475,9 +1475,7 @@ int s; /* scaled integer to output */
#if RAINBOW
putline(row, col, buf)
int row, col;
char buf[];
void putline(int row, int col, char *buf)
{
int n;
@ -1492,8 +1490,7 @@ char buf[];
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)
int *widthp, *heightp;
void getscreensize(int *widthp, int *heightp)
{
#ifdef TIOCGWINSZ
struct winsize size;
@ -1510,8 +1507,7 @@ int *widthp, *heightp;
}
#ifdef SIGWINCH
void sizesignal(signr)
int signr;
void sizesignal(int signr)
{
int w, h;
extern int errno;
@ -1526,14 +1522,13 @@ int signr;
errno = old_errno;
}
newscreensize(h, w)
int h, w;
int newscreensize(int h, int w)
{
/* do the change later */
if (displaying) {
chg_width = w;
chg_height = h;
return;
return FALSE;
}
chg_width = chg_height = 0;
if (h - 1 < term.t_mrow)

164
edef.h
View File

@ -13,6 +13,8 @@
#include <stdlib.h>
#include <string.h>
struct VIDEO;
char *flook();
char *getctext();
char *getfname();
@ -320,3 +322,165 @@ extern char outline[]; /* global string to hold debug line text */
#ifndef termdef
extern TERM term; /* Terminal information. */
#endif
/* word.c */
extern int wrapword(int f, int n);
extern int backword(int f, int n);
extern int forwword(int f, int n);
extern int upperword(int f, int n);
extern int lowerword(int f, int n);
extern int capword(int f, int n);
extern int delfword(int f, int n);
extern int delbword(int f, int n);
extern int inword(void);
extern int fillpara(int f, int n);
extern int justpara(int f, int n);
extern int killpara(int f, int n);
extern int wordcount(int f, int n);
/* line.c */
extern int lfree(LINE *lp);
extern int lchange(int flag);
extern int insspace(int f, int n);
extern int linstr(char *instr);
extern int linsert(int n, int c);
extern int lowrite(int c);
extern int lover(char *ostr);
extern int lnewline(void);
extern int ldelete(long n, int kflag);
extern char *getctext(void);
extern int putctext(char *iline);
extern int ldelnewline(void);
extern int kdelete(void);
extern int kinsert(int c);
extern int yank(int f, int n);
/* window.c */
extern int reposition(int f, int n);
extern int refresh(int f, int n);
extern int nextwind(int f, int n);
extern int prevwind(int f, int n);
extern int mvdnwind(int f, int n);
extern int mvupwind(int f, int n);
extern int onlywind(int f, int n);
extern int delwind(int f, int n);
extern int splitwind(int f, int n);
extern int enlargewind(int f, int n);
extern int shrinkwind(int f, int n);
extern int resize(int f, int n);
extern int scrnextup(int f, int n);
extern int scrnextdw(int f, int n);
extern int savewnd(int f, int n);
extern int restwnd(int f, int n);
extern int newsize(int f, int n);
extern int newwidth(int f, int n);
extern int getwpos(void);
extern int cknewwindow(void);
/* basic.c */
extern int gotobol(int f, int n);
extern int backchar(int f, int n);
extern int gotoeol(int f, int n);
extern int forwchar(int f, int n);
extern int gotoline(int f, int n);
extern int gotobob(int f, int n);
extern int gotoeob(int f, int n);
extern int forwline(int f, int n);
extern int backline(int f, int n);
extern int gotobop(int f, int n);
extern int gotoeop(int f, int n);
extern int getgoal(LINE *dlp);
extern int forwpage(int f, int n);
extern int backpage(int f, int n);
extern int setmark(int f, int n);
extern int swapmark(int f, int n);
/* random.c */
extern int tabsize; /* Tab size (0: use real tabs) */;
extern int setfillcol(int f, int n);
extern int showcpos(int f, int n);
extern int getcline(void);
extern int getccol(int bflg);
extern int setccol(int pos);
extern int twiddle(int f, int n);
extern int quote(int f, int n);
extern int tab(int f, int n);
extern int detab(int f, int n);
extern int entab(int f, int n);
extern int trim(int f, int n);
extern int openline(int f, int n);
extern int newline(int f, int n);
extern int cinsert(void);
extern int insbrace(int n, int c);
extern int insbrace(int n, int c);
extern int inspound(void);
extern int deblank(int f, int n);
extern int indent(int f, int n);
extern int forwdel(int f, int n);
extern int backdel(int f, int n);
extern int killtext(int f, int n);
extern int setmode(int f, int n);
extern int delmode(int f, int n);
extern int setgmode(int f, int n);
extern int delgmode(int f, int n);
extern int adjustmode(int kind, int global);
extern int clrmes(int f, int n);
extern int writemsg(int f, int n);
extern int getfence(int f, int n);
extern int fmatch(int ch);
extern int istring(int f, int n);
extern int ovstring(int f, int n);
/* main.c */
extern int edinit(char *bname);
extern int execute(int c, int f, int n);
extern int quickexit(int f, int n);
extern int quit(int f, int n);
extern int ctlxlp(int f, int n);
extern int ctlxrp(int f, int n);
extern int ctlxe(int f, int n);
extern int ctrlg(int f, int n);
extern int rdonly(void);
extern int resterr(void);
extern int nullproc(int f, int n);
extern int meta(int f, int n);
extern int cex(int f, int n);
extern int unarg(int f, int n);
extern int cexit(int status);
/* display.c */
extern void vtinit(void);
extern void vtfree(void);
extern void vttidy(void);
extern void vtmove(int row, int col);
extern void vtputc(int c);
extern void vteeol(void);
extern int upscreen(int f, int n);
extern int update(int force);
extern int reframe(WINDOW *wp);
extern void updone(WINDOW *wp);
extern void updall(WINDOW *wp);
extern void updpos(void);
extern void upddex(void);
extern void updgar(void);
extern int updupd(int force);
extern int scrolls(int inserts);
extern void scrscroll(int from, int to, int count);
extern int texttest(int vrow, int prow);
extern int endofline(char *s, int n);
extern void updext(void);
extern int updateline(int row, struct VIDEO *vp1, struct VIDEO *vp2);
extern void modeline(WINDOW *wp);
extern void upmode(void);
extern void movecursor(int row, int col);
extern void mlerase(void);
extern void mlwrite(const char *fmt, ...);
extern void mlforce(char *s);
extern void mlputs(char *s);
extern void mlputi(int i, int r);
extern void mlputli(long l, int r);
extern void mlputf(int s);
extern void putline(int row, int col, char *buf);
extern void getscreensize(int *widthp, int *heightp);
extern void sizesignal(int signr);
extern int newscreensize(int h, int w);

2
eval.c
View File

@ -573,7 +573,7 @@ char *value; /* value to set to */
ldelete(1L, FALSE); /* delete 1 char */
c = atoi(value);
if (c == '\n')
lnewline(FALSE, 1);
lnewline();
else
linsert(1, c);
backchar(FALSE, 1);

87
line.c
View File

@ -26,10 +26,7 @@ int ykboff; /* offset into that chunk */
* a pointer to the new block, or NULL if there isn't any memory left. Print a
* message in the message line if no space.
*/
LINE *lalloc(used)
register int used;
LINE *lalloc(int used)
{
register LINE *lp;
register int size;
@ -52,8 +49,7 @@ register int used;
* might be in. Release the memory. The buffers are updated too; the magic
* conditions described in the above comments don't hold here.
*/
lfree(lp)
register LINE *lp;
int lfree(LINE *lp)
{
register BUFFER *bp;
register WINDOW *wp;
@ -98,8 +94,7 @@ register LINE *lp;
* displayed in more than 1 window we change EDIT t HARD. Set MODE if the
* mode line needs to be updated (the "*" has to be set).
*/
lchange(flag)
register int flag;
int lchange(int flag)
{
register WINDOW *wp;
@ -117,10 +112,12 @@ register int flag;
}
}
insspace(f, n)
/* insert spaces forward into text */
int f, n; /* default flag and numeric argument */
/*
* insert spaces forward into text
*
* int f, n; default flag and numeric argument
*/
int insspace(int f, int n)
{
linsert(n, ' ');
backchar(f, n);
@ -130,8 +127,7 @@ int f, n; /* default flag and numeric argument */
* linstr -- Insert a string at the current point
*/
linstr(instr)
char *instr;
int linstr(char *instr)
{
register int status = TRUE;
char tmpc;
@ -161,7 +157,7 @@ char *instr;
* well, and FALSE on errors.
*/
linsert(n, c)
int linsert(int n, int c)
{
register char *cp1;
register char *cp2;
@ -242,12 +238,9 @@ linsert(n, c)
/*
* Overwrite a character into the current line at the current position
*
* int c; character to overwrite on current position
*/
lowrite(c)
char c; /* character to overwrite on current position */
int lowrite(int c)
{
if (curwp->w_doto < curwp->w_dotp->l_used &&
(lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
@ -259,11 +252,7 @@ char c; /* character to overwrite on current position */
/*
* lover -- Overwrite a string at the current point
*/
lover(ostr)
char *ostr;
int lover(char *ostr)
{
register int status = TRUE;
char tmpc;
@ -292,7 +281,7 @@ char *ostr;
* update of dot and mark is a bit easier then in the above case, because the
* split forces more updating.
*/
lnewline()
int lnewline(void)
{
register char *cp1;
register char *cp2;
@ -350,12 +339,11 @@ lnewline()
* with end of lines, etc. It returns TRUE if all of the characters were
* deleted, and FALSE if they were not (because dot ran into the end of the
* buffer. The "kflag" is TRUE if the text should be put in the kill buffer.
*
* long n; # of chars to delete
* int kflag; put killed text in kill buffer flag
*/
ldelete(n, kflag)
long n; /* # of chars to delete */
int kflag; /* put killed text in kill buffer flag */
int ldelete(long n, int kflag)
{
register char *cp1;
register char *cp2;
@ -419,11 +407,11 @@ int kflag; /* put killed text in kill buffer flag */
return (TRUE);
}
/* getctext: grab and return a string with the text of
the current line
*/
char *getctext()
/*
* getctext: grab and return a string with the text of
* the current line
*/
char *getctext(void)
{
register LINE *lp; /* line to copy */
register int size; /* length of line to return */
@ -446,12 +434,13 @@ char *getctext()
return (rline);
}
/* putctext: replace the current line with the passed in text */
putctext(iline)
char *iline; /* contents of new line */
/*
* putctext:
* replace the current line with the passed in text
*
* char *iline; contents of new line
*/
int putctext(char *iline)
{
register int status;
@ -477,7 +466,7 @@ char *iline; /* contents of new line */
* about in memory. Return FALSE on error and TRUE if all looks ok. Called by
* "ldelete" only.
*/
ldelnewline()
int ldelnewline(void)
{
register char *cp1;
register char *cp2;
@ -561,7 +550,7 @@ ldelnewline()
* new kill context is being created. The kill buffer array is released, just
* in case the buffer has grown to immense size. No errors.
*/
kdelete()
int kdelete(void)
{
KILL *kp; /* ptr to scan kill buffer chunk list */
@ -584,12 +573,10 @@ kdelete()
/*
* Insert a character to the kill buffer, allocating new chunks as needed.
* Return TRUE if all is well, and FALSE on errors.
*
* int c; character to insert in the kill buffer
*/
kinsert(c)
int c; /* character to insert in the kill buffer */
int kinsert(int c)
{
KILL *nchunk; /* ptr to newly malloced chunk */
@ -616,7 +603,7 @@ int c; /* character to insert in the kill buffer */
* is done by the standard insert routines. All you do is run the loop, and
* check for errors. Bound to "C-Y".
*/
yank(f, n)
int yank(int f, int n)
{
register int c;
register int i;

55
main.c
View File

@ -89,13 +89,10 @@ extern void sizesignal();
#endif
#if CALLED
emacs(argc, argv)
int emacs(int argc, char **argv)
#else
main(argc, argv)
int main(int argc, char **argv)
#endif
int argc; /* # of arguments */
char *argv[]; /* argument strings */
{
register int c; /* command character */
register int f; /* default flag */
@ -430,8 +427,7 @@ char *argv[]; /* argument strings */
* as an argument, because the main routine may have been told to read in a
* file by default, and we want the buffer name to be right.
*/
edinit(bname)
char bname[];
int edinit(char *bname)
{
register BUFFER *bp;
register WINDOW *wp;
@ -469,7 +465,7 @@ char bname[];
* and arranges to move it to the "lastflag", so that the next command can
* look at it. Return the status of command.
*/
execute(c, f, n)
int execute(int c, int f, int n)
{
register int status;
int (*execfunc) (); /* ptr to function to execute */
@ -560,7 +556,7 @@ execute(c, f, n)
* Fancy quit command, as implemented by Norm. If the any buffer has
* changed do a write on that buffer and exit emacs, otherwise simply exit.
*/
quickexit(f, n)
int quickexit(int f, int n)
{
register BUFFER *bp; /* scanning pointer to buffers */
register BUFFER *oldcb; /* original current buffer */
@ -590,8 +586,7 @@ quickexit(f, n)
return (TRUE);
}
static void emergencyexit(signr)
int signr;
static void emergencyexit(int signr)
{
quickexit(FALSE, 0);
quit(TRUE, 0);
@ -601,7 +596,7 @@ int signr;
* Quit command. If an argument, always quit. Otherwise confirm if a buffer
* has been changed and not written out. Normally bound to "C-X C-C".
*/
quit(f, n)
int quit(int f, int n)
{
register int s;
@ -634,7 +629,7 @@ quit(f, n)
* Error if not at the top level in keyboard processing. Set up variables and
* return.
*/
ctlxlp(f, n)
int ctlxlp(int f, int n)
{
if (kbdmode != STOP) {
mlwrite("%%Macro already active");
@ -651,7 +646,7 @@ ctlxlp(f, n)
* End keyboard macro. Check for the same limit conditions as the above
* routine. Set up the variables and return to the caller.
*/
ctlxrp(f, n)
int ctlxrp(int f, int n)
{
if (kbdmode == STOP) {
mlwrite("%%Macro not active");
@ -669,7 +664,7 @@ ctlxrp(f, n)
* The command argument is the number of times to loop. Quit as soon as a
* command gets an error. Return TRUE if all ok, else FALSE.
*/
ctlxe(f, n)
int ctlxe(int f, int n)
{
if (kbdmode != STOP) {
mlwrite("%%Macro already active");
@ -688,7 +683,7 @@ ctlxe(f, n)
* Beep the beeper. Kill off any keyboard macro, etc., that is in progress.
* Sometimes called as a routine, to do general aborting of stuff.
*/
ctrlg(f, n)
int ctrlg(int f, int n)
{
TTbeep();
kbdmode = STOP;
@ -696,36 +691,37 @@ ctrlg(f, n)
return (ABORT);
}
/* tell the user that this command is illegal while we are in
VIEW (read-only) mode */
rdonly()
/*
* tell the user that this command is illegal while we are in
* VIEW (read-only) mode
*/
int rdonly(void)
{
TTbeep();
mlwrite("(Key illegal in VIEW mode)");
return (FALSE);
}
resterr()
int resterr(void)
{
TTbeep();
mlwrite("(That command is RESTRICTED)");
return (FALSE);
}
nullproc()
int nullproc(int f, int n)
{ /* user function that does NOTHING */
}
meta()
int meta(int f, int n)
{ /* dummy function for binding to meta prefix */
}
cex()
int cex(int f, int n)
{ /* dummy function for binding to control-x prefix */
}
unarg()
int unarg(int f, int n)
{ /* dummy function for binding to universal-argument */
}
@ -808,10 +804,13 @@ dspram()
*/
#if CLEAN
cexit(status)
int status; /* return status of emacs */
/*
* cexit()
*
* int status; return status of emacs
*/
int cexit(int status)
{
register BUFFER *bp; /* buffer list pointer */
register WINDOW *wp; /* window list pointer */

238
random.c
View File

@ -15,7 +15,7 @@ int tabsize; /* Tab size (0: use real tabs) */
/*
* Set fill column to n.
*/
setfillcol(f, n)
int setfillcol(int f, int n)
{
fillcol = n;
mlwrite("(Fill column is %d)", n);
@ -29,7 +29,7 @@ setfillcol(f, n)
* column, but the column that would be used on an infinite width display.
* Normally this is bound to "C-X =".
*/
showcpos(f, n)
int showcpos(int f, int n)
{
register LINE *lp; /* current line */
register long numchars; /* # of chars in file */
@ -97,26 +97,13 @@ showcpos(f, n)
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_ccol = col;
pk_mlrec.pk_tcol = ecol;
pk_mlrec.pk_cchr = predchars;
pk_mlrec.pk_tchr = numchars;
pk_mlrec.pk_perc = ratio;
pk_mlrec.pk_char = curchar;
mlwrite("%*Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x",
&pk_mlrec);
#else
mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x",
predlines + 1, numlines + 1, col, ecol,
predchars, numchars, ratio, curchar);
#endif
return (TRUE);
}
getcline()
int getcline(void)
{ /* get the current line number */
register LINE *lp; /* current line */
register int numlines; /* # of lines before point */
@ -141,8 +128,7 @@ getcline()
/*
* Return current column. Stop at first non-blank given TRUE argument.
*/
getccol(bflg)
int bflg;
int getccol(int bflg)
{
register int c, i, col;
col = 0;
@ -161,11 +147,10 @@ int bflg;
/*
* Set current column.
*
* int pos; position to set cursor
*/
setccol(pos)
int pos; /* position to set cursor */
int setccol(int pos)
{
register int c; /* character being scanned */
register int i; /* index into current line */
@ -204,7 +189,7 @@ int pos; /* position to set cursor */
* work. This fixes up a very common typo with a single stroke. Normally bound
* to "C-T". This always works within a line, so "WFEDIT" is good enough.
*/
twiddle(f, n)
int twiddle(int f, int n)
{
register LINE *dotp;
register int doto;
@ -233,7 +218,7 @@ twiddle(f, n)
* its line splitting meaning. The character is always read, even if it is
* inserted 0 times, for regularity. Bound to "C-Q"
*/
quote(f, n)
int quote(int f, int n)
{
register int s;
register int c;
@ -261,7 +246,7 @@ quote(f, n)
* done in this slightly funny way because the tab (in ASCII) has been turned
* into "C-I" (in 10 bit code) already. Bound to "C-I".
*/
tab(f, n)
int tab(int f, int n)
{
if (n < 0)
return (FALSE);
@ -275,10 +260,12 @@ tab(f, n)
}
#if AEDIT
detab(f, n)
/* change tabs to spaces */
int f, n; /* default flag and numeric repeat count */
/*
* change tabs to spaces
*
* int f, n; default flag and numeric repeat count
*/
int detab(int f, int n)
{
register int inc; /* increment to next line [sgn(n)] */
@ -315,10 +302,12 @@ int f, n; /* default flag and numeric repeat count */
return (TRUE);
}
entab(f, n)
/* change spaces to tabs where posible */
int f, n; /* default flag and numeric repeat count */
/*
* change spaces to tabs where posible
*
* int f, n; default flag and numeric repeat count
*/
int entab(int f, int n)
{
register int inc; /* increment to next line [sgn(n)] */
register int fspace; /* pointer to first space if in a run */
@ -386,10 +375,12 @@ int f, n; /* default flag and numeric repeat count */
return (TRUE);
}
trim(f, n)
/* trim trailing whitespace from the point to eol */
int f, n; /* default flag and numeric repeat count */
/*
* trim trailing whitespace from the point to eol
*
* int f, n; default flag and numeric repeat count
*/
int trim(int f, int n)
{
register LINE *lp; /* current line pointer */
register int offset; /* original line offset position */
@ -433,7 +424,7 @@ int f, n; /* default flag and numeric repeat count */
* and then back up over them. Everything is done by the subcommand
* procerssors. They even handle the looping. Normally this is bound to "C-O".
*/
openline(f, n)
int openline(int f, int n)
{
register int i;
register int s;
@ -457,7 +448,7 @@ openline(f, n)
* Insert a newline. Bound to "C-M". If we are in CMODE, do automatic
* indentation as specified.
*/
newline(f, n)
int newline(int f, int n)
{
register int s;
@ -492,7 +483,7 @@ newline(f, n)
return (TRUE);
}
cinsert()
int cinsert(void)
{ /* insert a newline and indentation for C */
register char *cptr; /* string pointer into text to copy */
register int tptr; /* index to scan into line */
@ -534,11 +525,13 @@ cinsert()
}
#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) */
/*
* insert a brace into the text here...we are in CMODE
*
* int n; repeat count
* int c; brace to insert (always } for now)
*/
int insbrace(int n, int c)
{
register int ch; /* last character before input */
register int oc; /* caractere oppose a c */
@ -625,12 +618,16 @@ int c; /* brace to insert (always } for now) */
/* and insert the required brace(s) */
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) */
#else
/*
* insert a brace into the text here...we are in CMODE
*
* int n; repeat count
* int c; brace to insert (always { for now)
*/
int insbrace(int n, int c)
{
register int ch; /* last character before input */
register int i;
@ -659,7 +656,7 @@ int c; /* brace to insert (always { for now) */
}
#endif
inspound()
int inspound(void)
{ /* insert a # into the text here...we are in CMODE */
register int ch; /* last character before input */
register int i;
@ -691,7 +688,7 @@ inspound()
* the line. Normally this command is bound to "C-X C-O". Any argument is
* ignored.
*/
deblank(f, n)
int deblank(int f, int n)
{
register LINE *lp1;
register LINE *lp2;
@ -721,7 +718,7 @@ deblank(f, n)
* of tabs and spaces. Return TRUE if all ok. Return FALSE if one of the
* subcomands failed. Normally bound to "C-J".
*/
indent(f, n)
int indent(int f, int n)
{
register int nicol;
register int c;
@ -755,7 +752,7 @@ indent(f, n)
* If any argument is present, it kills rather than deletes, to prevent loss
* of text if typed with a big argument. Normally bound to "C-D".
*/
forwdel(f, n)
int forwdel(int f, int n)
{
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
return (rdonly()); /* we are in read only mode */
@ -775,7 +772,7 @@ forwdel(f, n)
* forward, this actually does a kill if presented with an argument. Bound to
* both "RUBOUT" and "C-H".
*/
backdel(f, n)
int backdel(int f, int n)
{
register int s;
@ -801,7 +798,7 @@ backdel(f, n)
* number of newlines. If called with a negative argument it kills backwards
* that number of newlines. Normally bound to "C-K".
*/
killtext(f, n)
int killtext(int f, int n)
{
register LINE *nextp;
long chunk;
@ -834,10 +831,12 @@ killtext(f, n)
return (ldelete(chunk, TRUE));
}
setmode(f, n)
/* prompt and set an editor mode */
int f, n; /* default and argument */
/*
* prompt and set an editor mode
*
* int f, n; default and argument
*/
int setmode(int f, int n)
{
#if PKCODE
return adjustmode(TRUE, FALSE);
@ -846,10 +845,12 @@ int f, n; /* default and argument */
#endif
}
delmode(f, n)
/* prompt and delete an editor mode */
int f, n; /* default and argument */
/*
* prompt and delete an editor mode
*
* int f, n; default and argument
*/
int delmode(int f, int n)
{
#if PKCODE
return adjustmode(FALSE, FALSE);
@ -858,10 +859,12 @@ int f, n; /* default and argument */
#endif
}
setgmode(f, n)
/* prompt and set a global editor mode */
int f, n; /* default and argument */
/*
* prompt and set a global editor mode
*
* int f, n; default and argument
*/
int setgmode(int f, int n)
{
#if PKCODE
return adjustmode(TRUE, TRUE);
@ -870,10 +873,12 @@ int f, n; /* default and argument */
#endif
}
delgmode(f, n)
/* prompt and delete a global editor mode */
int f, n; /* default and argument */
/*
* prompt and delete a global editor mode
*
* int f, n; default and argument
*/
int delgmode(int f, int n)
{
#if PKCODE
return adjustmode(FALSE, TRUE);
@ -882,10 +887,13 @@ int f, n; /* default and argument */
#endif
}
adjustmode(kind, global)
/* change the editor mode status */
int kind; /* true = set, false = delete */
int global; /* true = global flag, false = current buffer flag */
/*
* change the editor mode status
*
* int kind; true = set, false = delete
* int global; true = global flag, false = current buffer flag
*/
int adjustmode(int kind, int global)
{
register char *scan; /* scanning pointer to convert prompt */
register int i; /* loop index */
@ -983,25 +991,25 @@ int global; /* true = global flag, false = current buffer flag */
return (FALSE);
}
/* This function simply clears the message line,
mainly for macro usage */
clrmes(f, n)
int f, n; /* arguments ignored */
/*
* This function simply clears the message line,
* mainly for macro usage
*
* int f, n; arguments ignored
*/
int clrmes(int f, int n)
{
mlforce("");
return (TRUE);
}
/* This function writes a string on the message line
mainly for macro usage */
writemsg(f, n)
int f, n; /* arguments ignored */
/*
* This function writes a string on the message line
* mainly for macro usage
*
* int f, n; arguments ignored
*/
int writemsg(int f, int n)
{
register char *sp; /* pointer into buf to expand %s */
register char *np; /* ptr into nbuf */
@ -1029,12 +1037,12 @@ int f, n; /* arguments ignored */
}
#if CFENCE
/* the cursor is moved to a matching fence */
getfence(f, n)
int f, n; /* not used */
/*
* the cursor is moved to a matching fence
*
* int f, n; not used
*/
int getfence(int f, int n)
{
register LINE *oldlp; /* original line pointer */
register int oldoff; /* and offset */
@ -1128,13 +1136,13 @@ int f, n; /* not used */
}
#endif
/* Close fences are matched against their partners, and if
on screen the cursor briefly lights there */
fmatch(ch)
char ch; /* fence type to match against */
/*
* Close fences are matched against their partners, and if
* on screen the cursor briefly lights there
*
* char ch; fence type to match against
*/
int fmatch(int ch)
{
register LINE *oldlp; /* original line pointer */
register int oldoff; /* and offset */
@ -1195,11 +1203,13 @@ char ch; /* fence type to match against */
return (TRUE);
}
istring(f, n)
/* ask for and insert a string into the current
buffer at the current point */
int f, n; /* ignored arguments */
/*
* ask for and insert a string into the current
* buffer at the current point
*
* int f, n; ignored arguments
*/
int istring(int f, int n)
{
register int status; /* status return code */
char tstring[NPAT + 1]; /* string to add */
@ -1221,11 +1231,13 @@ int f, n; /* ignored arguments */
return (status);
}
ovstring(f, n)
/* ask for and overwite a string into the current
buffer at the current point */
int f, n; /* ignored arguments */
/*
* ask for and overwite a string into the current
* buffer at the current point
*
* int f, n; ignored arguments
*/
int ovstring(int f, int n)
{
register int status; /* status return code */
char tstring[NPAT + 1]; /* string to add */

View File

@ -23,7 +23,6 @@ extern short iochan; /* In "termio.c" */
#if V7 | USG | BSD
#include <signal.h>
extern int vttidy();
#ifdef SIGWINCH
extern int chg_width, chg_height;
extern void sizesignal();

105
window.c
View File

@ -15,7 +15,7 @@
* bottom. If it is 0 the window is centered (this is what the standard
* redisplay code does). With no argument it defaults to 0. Bound to M-!.
*/
reposition(f, n)
int reposition(int f, int n)
{
if (f == FALSE) /* default to 0 to center screen */
n = 0;
@ -28,7 +28,7 @@ reposition(f, n)
* 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)
int refresh(int f, int n)
{
if (f == FALSE)
sgarbf = TRUE;
@ -47,11 +47,10 @@ refresh(f, n)
*
* with an argument this command finds the <n>th window from the top
*
* int f, n; default flag and numeric argument
*
*/
nextwind(f, n)
int f, n; /* default flag and numeric argument */
int nextwind(int f, int n)
{
register WINDOW *wp;
register int nwindows; /* total number of windows */
@ -94,7 +93,7 @@ int f, n; /* default flag and numeric argument */
* current window. There arn't any errors, although the command does not do a
* lot if there is 1 window.
*/
prevwind(f, n)
int prevwind(int f, int n)
{
register WINDOW *wp1;
register WINDOW *wp2;
@ -126,10 +125,7 @@ prevwind(f, n)
* a new dot. We share the code by having "move down" just be an interface to
* "move up". Magic. Bound to "C-X C-N".
*/
mvdnwind(f, n)
int n;
int mvdnwind(int f, int n)
{
return (mvupwind(f, -n));
}
@ -141,9 +137,7 @@ int n;
* (this command does not really move "."; it moves the frame). Bound to
* "C-X C-P".
*/
mvupwind(f, n)
int n;
int mvupwind(int f, int n)
{
register LINE *lp;
register int i;
@ -187,7 +181,7 @@ int n;
* the buffer structures right if the distruction of a window makes a buffer
* become undisplayed.
*/
onlywind(f, n)
int onlywind(int f, int n)
{
register WINDOW *wp;
register LINE *lp;
@ -231,12 +225,10 @@ onlywind(f, n)
/*
* Delete the current window, placing its space in the window above,
* or, if it is the top window, the window below. Bound to C-X 0.
*
* int f, n; arguments are ignored for this command
*/
delwind(f, n)
int f, n; /* arguments are ignored for this command */
int delwind(int f, int n)
{
register WINDOW *wp; /* window to recieve deleted space */
register WINDOW *lwp; /* ptr window before curwp */
@ -306,18 +298,15 @@ int f, n; /* arguments are ignored for this command */
}
/*
Split the current window. A window smaller than 3 lines cannot be
split. An argument of 1 forces the cursor into the upper window, an
argument of two forces the cursor to the lower window. The only other
error that is possible is a "malloc" failure allocating the structure
for the new window. Bound to "C-X 2".
* Split the current window. A window smaller than 3 lines cannot be
* split. An argument of 1 forces the cursor into the upper window, an
* argument of two forces the cursor to the lower window. The only
* other error that is possible is a "malloc" failure allocating the
* structure for the new window. Bound to "C-X 2".
*
* int f, n; default flag and numeric argument
*/
splitwind(f, n)
int f, n; /* default flag and numeric argument */
int splitwind(int f, int n)
{
register WINDOW *wp;
register LINE *lp;
@ -399,7 +388,7 @@ int f, n; /* default flag and numeric argument */
* all the hard work. You don't just set "force reframe" because dot would
* move. Bound to "C-X Z".
*/
enlargewind(f, n)
int enlargewind(int f, int n)
{
register WINDOW *adjwp;
register LINE *lp;
@ -450,7 +439,7 @@ enlargewind(f, n)
* window descriptions. Ask the redisplay to do all the hard work. Bound to
* "C-X C-Z".
*/
shrinkwind(f, n)
int shrinkwind(int f, int n)
{
register WINDOW *adjwp;
register LINE *lp;
@ -497,12 +486,12 @@ shrinkwind(f, n)
return (TRUE);
}
/* Resize the current window to the requested size */
resize(f, n)
int f, n; /* default flag and numeric argument */
/*
* Resize the current window to the requested size
*
* int f, n; default flag and numeric argument
*/
int resize(int f, int n)
{
int clines; /* current # of lines in window */
@ -525,7 +514,7 @@ int f, n; /* default flag and numeric argument */
* Pick the uppermost window that isn't the current window. An LRU algorithm
* might be better. Return a pointer, or NULL on error.
*/
WINDOW *wpopup()
WINDOW *wpopup(void)
{
register WINDOW *wp;
@ -538,27 +527,27 @@ WINDOW *wpopup()
return (wp);
}
scrnextup(f, n)
int scrnextup(int f, int n)
{ /* scroll the next window up (back) a page */
nextwind(FALSE, 1);
backpage(f, n);
prevwind(FALSE, 1);
}
scrnextdw(f, n)
int scrnextdw(int f, int n)
{ /* scroll the next window down (forward) a page */
nextwind(FALSE, 1);
forwpage(f, n);
prevwind(FALSE, 1);
}
savewnd(f, n)
int savewnd(int f, int n)
{ /* save ptr to current window */
swindow = curwp;
return (TRUE);
}
restwnd(f, n)
int restwnd(int f, int n)
{ /* restore the saved screen */
register WINDOW *wp;
@ -578,11 +567,13 @@ restwnd(f, n)
return (FALSE);
}
newsize(f, n)
/* resize the screen, re-writing the screen */
int f; /* default flag */
int n; /* numeric argument */
/*
* resize the screen, re-writing the screen
*
* int f; default flag
* int n; numeric argument
*/
int newsize(int f, int n)
{
WINDOW *wp; /* current window being examined */
WINDOW *nextwp; /* next window to scan */
@ -664,11 +655,13 @@ int n; /* numeric argument */
return (TRUE);
}
newwidth(f, n)
/* resize the screen, re-writing the screen */
int f; /* default flag */
int n; /* numeric argument */
/*
* resize the screen, re-writing the screen
*
* int f; default flag
* int n; numeric argument
*/
int newwidth(int f, int n)
{
register WINDOW *wp;
@ -698,7 +691,7 @@ int n; /* numeric argument */
return (TRUE);
}
int getwpos()
int getwpos(void)
{ /* get screen offset of current line in current window */
register int sline; /* screen line from top of window */
register LINE *lp; /* scannile line pointer */
@ -715,7 +708,7 @@ int getwpos()
return (sline);
}
cknewwindow()
int cknewwindow(void)
{
execute(META | SPEC | 'X', FALSE, 1);
}

86
word.c
View File

@ -17,12 +17,12 @@
* a new line. Otherwise, break the line at the word-break, eat it, and jump
* back to the end of the word.
* Returns TRUE on success, FALSE on errors.
*
* int f; default flag
* int n; numeric argument
*
*/
wrapword(f, n)
int f; /* default flag */
int n; /* numeric argument */
int wrapword(int f, int n)
{
register int cnt; /* size of word wrapped to next line */
register int c; /* charector temporary */
@ -67,7 +67,7 @@ int n; /* numeric argument */
* performed by the "backchar" and "forwchar" routines. Error if you try to
* move beyond the buffers.
*/
backword(f, n)
int backword(int f, int n)
{
if (n < 0)
return (forwword(f, -n));
@ -90,7 +90,7 @@ backword(f, n)
* Move the cursor forward by the specified number of words. All of the motion
* is done by "forwchar". Error if you try and move beyond the buffer's end.
*/
forwword(f, n)
int forwword(int f, int n)
{
if (n < 0)
return (backword(f, -n));
@ -113,7 +113,7 @@ forwword(f, n)
* convert any characters to upper case. Error if you try and move beyond the
* end of the buffer. Bound to "M-U".
*/
upperword(f, n)
int upperword(int f, int n)
{
register int c;
@ -149,7 +149,7 @@ upperword(f, n)
* convert characters to lower case. Error if you try and move over the end of
* the buffer. Bound to "M-L".
*/
lowerword(f, n)
int lowerword(int f, int n)
{
register int c;
@ -186,7 +186,7 @@ lowerword(f, n)
* characters to lower case. Error if you try and move past the end of the
* buffer. Bound to "M-C".
*/
capword(f, n)
int capword(int f, int n)
{
register int c;
@ -238,7 +238,7 @@ capword(f, n)
* command for the right number of characters. With a zero argument, just
* kill one word and no whitespace. Bound to "M-D".
*/
delfword(f, n)
int delfword(int f, int n)
{
register LINE *dotp; /* original cursor line */
register int doto; /* and row */
@ -327,7 +327,7 @@ delfword(f, n)
* counting the characters. When dot is finally moved to its resting place,
* fire off the kill command. Bound to "M-Rubout" and to "M-Backspace".
*/
delbword(f, n)
int delbword(int f, int n)
{
long size;
@ -368,7 +368,7 @@ delbword(f, n)
* Return TRUE if the character at dot is a character that is considered to be
* part of a word. The word character list is hard coded. Should be setable.
*/
inword()
int inword(void)
{
register int c;
@ -389,11 +389,13 @@ inword()
}
#if WORDPRO
fillpara(f, n)
/* Fill the current paragraph according to the current
fill column */
int f, n; /* deFault flag and Numeric argument */
/*
* Fill the current paragraph according to the current
* fill column
*
* f and n - deFault flag and Numeric argument
*/
int fillpara(int f, int n)
{
register int c; /* current char durring scan */
register int wordlen; /* length of current word */
@ -485,11 +487,12 @@ int f, n; /* deFault flag and Numeric argument */
}
#if PKCODE
justpara(f, n)
/* Fill the current paragraph according to the current
fill column and cursor position */
int f, n; /* deFault flag and Numeric argument */
/* Fill the current paragraph according to the current
* fill column and cursor position
*
* int f, n; deFault flag and Numeric argument
*/
int justpara(int f, int n)
{
register int c; /* current char durring scan */
register int wordlen; /* length of current word */
@ -593,11 +596,13 @@ int f, n; /* deFault flag and Numeric argument */
}
#endif
killpara(f, n)
/* delete n paragraphs starting with the current one */
int f; /* default flag */
int n; /* # of paras to delete */
/*
* delete n paragraphs starting with the current one
*
* int f default flag
* int n # of paras to delete
*/
int killpara(int f, int n)
{
register int status; /* returned status of functions */
@ -625,14 +630,14 @@ int n; /* # of paras to delete */
}
/* wordcount: count the # of words in the marked region,
along with average word sizes, # of chars, etc,
and report on them. */
wordcount(f, n)
int f, n; /* ignored numeric arguments */
/*
* wordcount: count the # of words in the marked region,
* along with average word sizes, # of chars, etc,
* and report on them.
*
* int f, n; ignored numeric arguments
*/
int wordcount(int f, int n)
{
register LINE *lp; /* current line to scan */
register int offset; /* current char to scan */
@ -702,17 +707,8 @@ int f, n; /* ignored numeric arguments */
else
avgch = 0;
#if PKCODE
pk_mlrec.pk_1 = nwords;
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",
&pk_mlrec);
#else
mlwrite("Words %D Chars %D Lines %d Avg chars/word %f",
nwords, nchars, nlines + 1, avgch);
#endif
return (TRUE);
}
#endif