diff options
author | Vincent Labrecque <vincent@cvs.openbsd.org> | 2002-03-11 13:02:57 +0000 |
---|---|---|
committer | Vincent Labrecque <vincent@cvs.openbsd.org> | 2002-03-11 13:02:57 +0000 |
commit | 195cf29954aced38f2c3260a00e78b6c543347d7 (patch) | |
tree | 24960afa1083d432e589842ec187e8c39819c7ba /usr.bin | |
parent | 3acf70e568831a61d560c056d28ea06bf89c72df (diff) |
* Move to ANSI function definitions.
* Add a whole lot of consts where I thought it made sense
no ok, but no objections either...
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/basic.c | 59 | ||||
-rw-r--r-- | usr.bin/mg/buffer.c | 49 | ||||
-rw-r--r-- | usr.bin/mg/cinfo.c | 9 | ||||
-rw-r--r-- | usr.bin/mg/def.h | 20 | ||||
-rw-r--r-- | usr.bin/mg/dir.c | 10 | ||||
-rw-r--r-- | usr.bin/mg/dired.c | 34 | ||||
-rw-r--r-- | usr.bin/mg/display.c | 63 | ||||
-rw-r--r-- | usr.bin/mg/echo.c | 48 | ||||
-rw-r--r-- | usr.bin/mg/extend.c | 76 | ||||
-rw-r--r-- | usr.bin/mg/file.c | 11 | ||||
-rw-r--r-- | usr.bin/mg/fileio.c | 30 | ||||
-rw-r--r-- | usr.bin/mg/funmap.c | 14 | ||||
-rw-r--r-- | usr.bin/mg/funmap.h | 10 | ||||
-rw-r--r-- | usr.bin/mg/help.c | 4 | ||||
-rw-r--r-- | usr.bin/mg/kbd.h | 18 | ||||
-rw-r--r-- | usr.bin/mg/keymap.c | 10 |
16 files changed, 169 insertions, 296 deletions
diff --git a/usr.bin/mg/basic.c b/usr.bin/mg/basic.c index 5040fa1403f..b463dc74835 100644 --- a/usr.bin/mg/basic.c +++ b/usr.bin/mg/basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: basic.c,v 1.11 2002/03/10 13:22:56 ho Exp $ */ +/* $OpenBSD: basic.c,v 1.12 2002/03/11 13:02:56 vincent Exp $ */ /* * Basic cursor motion commands. @@ -18,8 +18,7 @@ void setgoal(void); */ /* ARGSUSED */ int -gotobol(f, n) - int f, n; +gotobol(int f, int n) { curwp->w_doto = 0; return (TRUE); @@ -33,8 +32,7 @@ gotobol(f, n) */ /* ARGSUSED */ int -backchar(f, n) - int n; +backchar(int f, int n) { LINE *lp; @@ -61,8 +59,7 @@ backchar(f, n) */ /* ARGSUSED */ int -gotoeol(f, n) - int f, n; +gotoeol(int f, int n) { curwp->w_doto = llength(curwp->w_dotp); return (TRUE); @@ -76,8 +73,7 @@ gotoeol(f, n) */ /* ARGSUSED */ int -forwchar(f, n) - int f, n; +forwchar(int f, int n) { if (n < 0) @@ -105,8 +101,7 @@ forwchar(f, n) * but almost always the case. */ int -gotobob(f, n) - int f, n; +gotobob(int f, int n) { (void) setmark(f, n); @@ -122,8 +117,7 @@ gotobob(f, n) * almost always the case. */ int -gotoeob(f, n) - int f, n; +gotoeob(int f, int n) { (void) setmark(f, n); @@ -142,8 +136,7 @@ gotoeob(f, n) */ /* ARGSUSED */ int -forwline(f, n) - int f, n; +forwline(int f, int n) { LINE *dlp; @@ -189,8 +182,7 @@ forwline(f, n) */ /* ARGSUSED */ int -backline(f, n) - int f, n; +backline(int f, int n) { LINE *dlp; @@ -214,7 +206,7 @@ backline(f, n) * the edge of the screen; it's more like display then show position. */ void -setgoal() +setgoal(void) { curgoal = getcolpos() - 1; /* Get the position. */ @@ -229,8 +221,7 @@ setgoal() * when a vertical motion is made into the line. */ int -getgoal(dlp) - LINE *dlp; +getgoal(LINE *dlp) { int c; int col; @@ -269,8 +260,7 @@ getgoal(dlp) */ /* ARGSUSED */ int -forwpage(f, n) - int f, n; +forwpage(int f, int n) { LINE *lp; @@ -308,8 +298,7 @@ forwpage(f, n) */ /* ARGSUSED */ int -backpage(f, n) - int f, n; +backpage(int f, int n) { LINE *lp; @@ -342,10 +331,8 @@ backpage(f, n) * are used to scroll the display up (or down) one line at a time. */ int -forw1page(f, n) - int f, n; +forw1page(int f, int n) { - if (!(f & FFARG)) { n = 1; f = FFUNIV; @@ -355,10 +342,8 @@ forw1page(f, n) } int -back1page(f, n) - int f, n; +back1page(int f, int n) { - if (!(f & FFARG)) { n = 1; f = FFUNIV; @@ -372,8 +357,7 @@ back1page(f, n) * nextwind, forwpage and restore window pointers. */ int -pagenext(f, n) - int f, n; +pagenext(int f, int n) { MGWIN *wp; @@ -393,7 +377,7 @@ pagenext(f, n) * Internal set mark routine, used by other functions (daveb). */ void -isetmark() +isetmark(void) { curwp->w_markp = curwp->w_dotp; @@ -407,8 +391,7 @@ isetmark() */ /* ARGSUSED */ int -setmark(f, n) - int f, n; +setmark(int f, int n) { isetmark(); @@ -425,8 +408,7 @@ setmark(f, n) */ /* ARGSUSED */ int -swapmark(f, n) - int f, n; +swapmark(int f, int n) { LINE *odotp; int odoto; @@ -454,8 +436,7 @@ swapmark(f, n) */ /* ARGSUSED */ int -gotoline(f, n) - int f, n; +gotoline(int f, int n) { LINE *clp; int s; diff --git a/usr.bin/mg/buffer.c b/usr.bin/mg/buffer.c index 8efa928b964..b4023b9e792 100644 --- a/usr.bin/mg/buffer.c +++ b/usr.bin/mg/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.25 2002/03/05 20:31:10 vincent Exp $ */ +/* $OpenBSD: buffer.c,v 1.26 2002/03/11 13:02:56 vincent Exp $ */ /* * Buffer handling. @@ -18,8 +18,7 @@ static BUFFER *makelist(void); */ /* ARGSUSED */ int -usebuffer(f, n) - int f, n; +usebuffer(int f, int n) { BUFFER *bp; int s; @@ -50,8 +49,7 @@ usebuffer(f, n) */ /* ARGSUSED */ int -poptobuffer(f, n) - int f, n; +poptobuffer(int f, int n) { BUFFER *bp; MGWIN *wp; @@ -90,8 +88,7 @@ poptobuffer(f, n) */ /* ARGSUSED */ int -killbuffer(f, n) - int f, n; +killbuffer(int f, int n) { BUFFER *bp; BUFFER *bp1; @@ -165,7 +162,7 @@ killbuffer(f, n) rec = next; } - free(bp->b_bname); /* Release name block */ + free((char *)bp->b_bname); /* Release name block */ free(bp); /* Release buffer block */ return TRUE; } @@ -175,8 +172,7 @@ killbuffer(f, n) */ /* ARGSUSED */ int -savebuffers(f, n) - int f, n; +savebuffers(int f, int n) { if (anycb(f) == ABORT) return ABORT; @@ -212,8 +208,7 @@ static struct KEYMAPE (1 + IMAPEXT) listbufmap = { */ /* ARGSUSED */ int -listbuffers(f, n) - int f, n; +listbuffers(int f, int n) { static int initialized = 0; BUFFER *bp; @@ -224,7 +219,6 @@ listbuffers(f, n) initialized = 1; } - if ((bp = makelist()) == NULL || (wp = popbuf(bp)) == NULL) return FALSE; wp->w_dotp = bp->b_dotp;/* fix up if window already on screen */ @@ -243,7 +237,7 @@ listbuffers(f, n) * is an error (if there is no memory). */ static BUFFER * -makelist() +makelist(void) { int w = ncol / 2; BUFFER *bp, *blp; @@ -382,8 +376,7 @@ addlinef(BUFFER *bp, char *fmt, ...) * no changed buffers. */ int -anycb(f) - int f; +anycb(int f) { BUFFER *bp; int s = FALSE, save = FALSE; @@ -418,9 +411,7 @@ anycb(f) * block for the buffer. */ BUFFER * -bfind(bname, cflag) - char *bname; - int cflag; +bfind(const char *bname, int cflag) { BUFFER *bp; LINE *lp; @@ -445,7 +436,7 @@ bfind(bname, cflag) return NULL; } if ((lp = lalloc(0)) == NULL) { - free(bp->b_bname); + free((char *) bp->b_bname); free((char *) bp); return NULL; } @@ -483,8 +474,7 @@ bfind(bname, cflag) * looks good. */ int -bclear(bp) - BUFFER *bp; +bclear(BUFFER *bp) { LINE *lp; int s; @@ -507,10 +497,7 @@ bclear(bp) * action on redisplay. */ int -showbuffer(bp, wp, flags) - BUFFER *bp; - MGWIN *wp; - int flags; +showbuffer(BUFFER *bp, MGWIN *wp, int flags) { BUFFER *obp; MGWIN *owp; @@ -555,8 +542,7 @@ showbuffer(bp, wp, flags) * Returns a status. */ MGWIN * -popbuf(bp) - BUFFER *bp; +popbuf(BUFFER *bp) { MGWIN *wp; @@ -579,7 +565,7 @@ popbuf(bp) */ /* ARGSUSED */ int -bufferinsert(f, n) +bufferinsert(int f, int n) { BUFFER *bp; LINE *clp; @@ -638,7 +624,7 @@ bufferinsert(f, n) */ /* ARGSUSED */ int -notmodified(f, n) +notmodified(int f, int n) { MGWIN *wp; @@ -659,8 +645,7 @@ notmodified(f, n) * help functions. */ int -popbuftop(bp) - BUFFER *bp; +popbuftop(BUFFER *bp) { MGWIN *wp; diff --git a/usr.bin/mg/cinfo.c b/usr.bin/mg/cinfo.c index cbf530a1ed1..f77958040df 100644 --- a/usr.bin/mg/cinfo.c +++ b/usr.bin/mg/cinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cinfo.c,v 1.7 2002/02/14 02:50:10 vincent Exp $ */ +/* $OpenBSD: cinfo.c,v 1.8 2002/03/11 13:02:56 vincent Exp $ */ /* * Character class tables. @@ -90,12 +90,9 @@ const char cinfo[256] = { * '\0'. */ char * -keyname(cp, len, k) - char *cp; - size_t len; - int k; +keyname(char *cp, size_t len, int k) { - char *np; + const char *np; if (k < 0) k = CHARMASK(k);/* sign extended char */ diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h index 3f8f8895680..2d585d2df43 100644 --- a/usr.bin/mg/def.h +++ b/usr.bin/mg/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.35 2002/02/26 00:45:45 vincent Exp $ */ +/* $OpenBSD: def.h,v 1.36 2002/03/11 13:02:56 vincent Exp $ */ #include <sys/queue.h> @@ -156,7 +156,7 @@ typedef struct LIST { struct BUFFER *x_bp; /* l_bp is used by LINE */ struct LIST *l_nxt; } l_p; - char *l_name; + const char *l_name; } LIST; /* @@ -363,7 +363,7 @@ int delwind(int, int); MGWIN *wpopup(void); /* buffer.c */ -BUFFER *bfind(char *, int); +BUFFER *bfind(const char *, int); int poptobuffer(int, int); int killbuffer(int, int); int savebuffers(int, int); @@ -387,8 +387,8 @@ void update(void); /* echo.c X */ void eerase(void); -int eyorn(char *); -int eyesno(char *); +int eyorn(const char *); +int eyesno(const char *); void ewprintf(const char *fmt, ...); int ereply(const char *, char *, int, ...); int eread(const char *, char *, int, int, ...); @@ -396,13 +396,13 @@ int getxtra(LIST *, LIST *, int, int); void free_file_list(LIST *); /* fileio.c */ -int ffropen(char *, BUFFER *); -int ffwopen(char *, BUFFER *); +int ffropen(const char *, BUFFER *); +int ffwopen(const char *, BUFFER *); int ffclose(BUFFER *); int ffputbuf(BUFFER *); int ffgetline(char *, int, int *); -int fbackupfile(char *); -char *adjustname(char *); +int fbackupfile(const char *); +char *adjustname(const char *); char *startupfile(char *); int copy(char *, char *); BUFFER *dired_(char *); @@ -480,7 +480,7 @@ int extend(int, int); int evalexpr(int, int); int evalbuffer(int, int); int evalfile(int, int); -int load(char *); +int load(const char *); int excline(char *); /* help.c X */ diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c index 737f6e438ad..85778d3ad42 100644 --- a/usr.bin/mg/dir.c +++ b/usr.bin/mg/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.7 2002/02/13 03:03:49 vincent Exp $ */ +/* $OpenBSD: dir.c,v 1.8 2002/03/11 13:02:56 vincent Exp $ */ /* * Name: MG 2a @@ -17,9 +17,8 @@ static char cwd[NFILEN]; * Initialize anything the directory management routines need */ void -dirinit() +dirinit(void) { - if (!(wdir = getcwd(cwd, sizeof(cwd)))) panic("Can't get current directory!"); } @@ -29,8 +28,7 @@ dirinit() */ /* ARGSUSED */ int -changedir(f, n) - int f, n; +changedir(int f, int n) { int s; char bufc[NPAT]; @@ -55,7 +53,7 @@ changedir(f, n) */ /* ARGSUSED */ int -showcwdir(f, n) +showcwdir(int f, int n) { ewprintf("Current directory: %s", wdir); diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c index 95978351781..cbcfbc5e5e4 100644 --- a/usr.bin/mg/dired.c +++ b/usr.bin/mg/dired.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dired.c,v 1.9 2002/02/15 01:04:59 vincent Exp $ */ +/* $OpenBSD: dired.c,v 1.10 2002/03/11 13:02:56 vincent Exp $ */ /* dired module for mg 2a */ /* by Robert A. Larson */ @@ -23,8 +23,7 @@ static struct KEYMAPE (1 + IMAPEXT) diredmap = { /* ARGSUSED */ int -dired(f, n) - int f, n; +dired(int f, int n) { static int inited = 0; char dirname[NFILEN]; @@ -49,8 +48,7 @@ dired(f, n) /* ARGSUSED */ int -d_otherwindow(f, n) - int f, n; +d_otherwindow(int f, int n) { char dirname[NFILEN]; BUFFER *bp; @@ -70,10 +68,8 @@ d_otherwindow(f, n) /* ARGSUSED */ int -d_del(f, n) - int f, n; +d_del(int f, int n) { - if (n < 0) return FALSE; while (n--) { @@ -89,8 +85,7 @@ d_del(f, n) /* ARGSUSED */ int -d_undel(f, n) - int f, n; +d_undel(int f, int n) { if (n < 0) return d_undelbak(f, -n); @@ -107,10 +102,8 @@ d_undel(f, n) /* ARGSUSED */ int -d_undelbak(f, n) - int f, n; +d_undelbak(int f, int n) { - if (n < 0) return d_undel(f, -n); while (n--) { @@ -126,8 +119,7 @@ d_undelbak(f, n) /* ARGSUSED */ int -d_findfile(f, n) - int f, n; +d_findfile(int f, int n) { BUFFER *bp; int s; @@ -147,8 +139,7 @@ d_findfile(f, n) /* ARGSUSED */ int -d_ffotherwindow(f, n) - int f, n; +d_ffotherwindow(int f, int n) { char fname[NFILEN]; int s; @@ -170,8 +161,7 @@ d_ffotherwindow(f, n) /* ARGSUSED */ int -d_expunge(f, n) - int f, n; +d_expunge(int f, int n) { LINE *lp, *nlp; char fname[NFILEN]; @@ -206,8 +196,7 @@ d_expunge(f, n) /* ARGSUSED */ int -d_copy(f, n) - int f, n; +d_copy(int f, int n) { char frname[NFILEN], toname[NFILEN]; int stat; @@ -224,8 +213,7 @@ d_copy(f, n) /* ARGSUSED */ int -d_rename(f, n) - int f, n; +d_rename(int f, int n) { char frname[NFILEN], toname[NFILEN]; int stat; diff --git a/usr.bin/mg/display.c b/usr.bin/mg/display.c index b6ea970acad..d970c34a90f 100644 --- a/usr.bin/mg/display.c +++ b/usr.bin/mg/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.10 2002/02/16 21:27:49 millert Exp $ */ +/* $OpenBSD: display.c,v 1.11 2002/03/11 13:02:56 vincent Exp $ */ /* * The functions in this file handle redisplay. The @@ -68,7 +68,7 @@ typedef struct { void vtmove(int, int); void vtputc(int); void vtpute(int); -int vtputs(char *); +int vtputs(const char *); void vteeol(void); void updext(int, int); void modeline(MGWIN *); @@ -221,7 +221,7 @@ vtresize(int force, int newrow, int newcol) * on the first call to redisplay. */ void -vtinit() +vtinit(void) { int i; @@ -246,7 +246,7 @@ vtinit() * close the terminal channel. */ void -vttidy() +vttidy(void) { ttcolor(CTEXT); @@ -266,8 +266,7 @@ vttidy() * more efficient. No checking for errors. */ void -vtmove(row, col) - int row, col; +vtmove(int row, int col) { vtrow = row; vtcol = col; @@ -286,8 +285,7 @@ vtmove(row, col) * Three guesses how we found this. */ void -vtputc(c) - int c; +vtputc(int c) { VIDEO *vp; @@ -317,8 +315,7 @@ vtputc(c) * margin. */ void -vtpute(c) - int c; +vtpute(int c) { VIDEO *vp; @@ -351,7 +348,7 @@ vtpute(c) * hardware erase to end of line command should be used to display this. */ void -vteeol() +vteeol(void) { VIDEO *vp; @@ -370,7 +367,7 @@ vteeol() * virtual and physical screens the same. */ void -update() +update(void) { LINE *lp; MGWIN *wp; @@ -610,9 +607,7 @@ update() * display has done an update. */ void -ucopy(vvp, pvp) - VIDEO *vvp; - VIDEO *pvp; +ucopy(VIDEO *vvp, VIDEO *pvp) { vvp->v_flag &= ~VFCHG; /* Changes done. */ @@ -629,8 +624,7 @@ ucopy(vvp, pvp) * left to let the user see where the cursor is */ void -updext(currow, curcol) - int currow, curcol; +updext(int currow, int curcol) { LINE *lp; /* pointer to current line */ int j; /* index into line */ @@ -662,14 +656,8 @@ updext(currow, curcol) * reverse video works on most terminals. */ void -uline(row, vvp, pvp) - int row; - VIDEO *vvp; - VIDEO *pvp; +uline(int row, VIDEO *vvp, VIDEO *pvp) { -#ifdef MEMMAP - putline(row + 1, 1, &vvp->v_text[0]); -#else char *cp1; char *cp2; char *cp3; @@ -677,6 +665,10 @@ uline(row, vvp, pvp) char *cp5; int nbflag; +#ifdef MEMMAP + putline(row + 1, 1, &vvp->v_text[0]); +#else + if (vvp->v_color != pvp->v_color) { /* Wrong color, do a */ ttmove(row, 0); /* full redraw. */ #ifdef STANDOUT_GLITCH @@ -759,8 +751,7 @@ uline(row, vvp, pvp) * characters may never be seen. */ void -modeline(wp) - MGWIN *wp; +modeline(MGWIN *wp) { int n; BUFFER *bp; @@ -791,7 +782,7 @@ modeline(wp) } vtputc('('); ++n; - for (mode = 0;;) { + for (mode = 0; ; ) { n += vtputs(bp->b_modes[mode]->p_name); if (++mode > bp->b_nmodes) break; @@ -809,10 +800,9 @@ modeline(wp) * output a string to the mode line, report how long it was. */ int -vtputs(s) - char *s; +vtputs(const char *s) { - int n = 0; + int n = 0; while (*s != '\0') { vtputc(*s++); @@ -831,8 +821,7 @@ vtputs(s) * just about any machine. */ void -hash(vp) - VIDEO *vp; +hash(VIDEO *vp) { int i; int n; @@ -881,9 +870,7 @@ hash(vp) * bit better; but it looks ugly. */ void -setscores(offs, size) - int offs; - int size; +setscores(int offs, int size) { SCORE *sp; SCORE *sp1; @@ -970,11 +957,7 @@ setscores(offs, size) * intensive then the code that builds the score matrix! */ void -traceback(offs, size, i, j) - int offs; - int size; - int i; - int j; +traceback(int offs, int size, int i, int j) { int itrace; int jtrace; diff --git a/usr.bin/mg/echo.c b/usr.bin/mg/echo.c index 21380e7babe..793b3603f20 100644 --- a/usr.bin/mg/echo.c +++ b/usr.bin/mg/echo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: echo.c,v 1.20 2002/02/16 21:27:49 millert Exp $ */ +/* $OpenBSD: echo.c,v 1.21 2002/03/11 13:02:56 vincent Exp $ */ /* * Echo line reading and writing. @@ -23,7 +23,7 @@ static int complt_list(int, int, char *, int); static void eformat(const char *, va_list); static void eputi(int, int); static void eputl(long, int); -static void eputs(char *); +static void eputs(const char *); static void eputc(char); static LIST *copy_list(LIST *); @@ -33,7 +33,7 @@ int epresf = FALSE; /* stuff in echo line flag */ * Erase the echo line. */ void -eerase() +eerase(void) { ttcolor(CTEXT); ttmove(nrow - 1, 0); @@ -49,8 +49,7 @@ eerase() * required. */ int -eyorn(sp) - char *sp; +eyorn(const char *sp) { int s; @@ -77,8 +76,7 @@ eyorn(sp) * "yes" or "no" and the trainling newline. */ int -eyesno(sp) - char *sp; +eyesno(const char *sp) { int s; char buf[64]; @@ -307,9 +305,7 @@ done: * do completion on a list of objects. */ static int -complt(flags, c, buf, cpos) - int flags, c, cpos; - char *buf; +complt(int flags, int c, char *buf, int cpos) { LIST *lh, *lh2; LIST *wholelist = NULL; @@ -403,11 +399,7 @@ complt(flags, c, buf, cpos) * do completion on a list of objects, listing instead of completing */ static int -complt_list(flags, c, buf, cpos) - int flags; - int c; - char *buf; - int cpos; +complt_list(int flags, int c, char *buf, int cpos) { LIST *lh, *lh2, *lh3; LIST *wholelist = NULL; @@ -418,7 +410,7 @@ complt_list(flags, c, buf, cpos) int oldcol = ttcol; int oldhue = tthue; char *linebuf; - char *cp; + const char *cp; lh = NULL; @@ -562,10 +554,7 @@ complt_list(flags, c, buf, cpos) * this is normal. */ int -getxtra(lp1, lp2, cpos, wflag) - LIST *lp1, *lp2; - int cpos; - int wflag; +getxtra(LIST *lp1, LIST *lp2, int cpos, int wflag) { int i; @@ -679,8 +668,7 @@ eformat(const char *fp, va_list ap) * Put integer, in radix "r". */ static void -eputi(i, r) - int i, r; +eputi(int i, int r) { int q; @@ -697,9 +685,7 @@ eputi(i, r) * Put long, in radix "r". */ static void -eputl(l, r) - long l; - int r; +eputl(long l, int r) { long q; @@ -716,8 +702,7 @@ eputl(l, r) * Put string. */ static void -eputs(s) - char *s; +eputs(const char *s) { int c; @@ -730,8 +715,7 @@ eputs(s) * too long. */ static void -eputc(c) - char c; +eputc(char c) { if (ttcol + 2 < ncol) { if (ISCTRL(c)) { @@ -744,8 +728,7 @@ eputc(c) } void -free_file_list(lp) - LIST *lp; +free_file_list(LIST *lp) { LIST *next; @@ -757,8 +740,7 @@ free_file_list(lp) } static LIST * -copy_list(lp) - LIST *lp; +copy_list(LIST *lp) { LIST *current, *last; diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c index 3c509c77fac..45af82af5d7 100644 --- a/usr.bin/mg/extend.c +++ b/usr.bin/mg/extend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: extend.c,v 1.22 2002/03/10 13:22:56 ho Exp $ */ +/* $OpenBSD: extend.c,v 1.23 2002/03/11 13:02:56 vincent Exp $ */ /* * Extended (M-X) commands, rebinding, and startup file processing. @@ -24,18 +24,17 @@ static int remap(KEYMAP *, int, PF, KEYMAP *); static KEYMAP *realocmap(KEYMAP *); static void fixmap(KEYMAP *, KEYMAP *, KEYMAP *); -static int dobind(KEYMAP *, char *, int); +static int dobind(KEYMAP *, const char *, int); static char *skipwhite(char *); static char *parsetoken(char *); -static int bindkey(KEYMAP **, char *, KCHAR *, int); +static int bindkey(KEYMAP **, const char *, KCHAR *, int); /* * Insert a string, mainly for use from macros (created by selfinsert) */ /* ARGSUSED */ int -insert(f, n) - int f, n; +insert(int f, int n) { char *cp; char buf[128]; @@ -84,12 +83,12 @@ insert(f, n) * the keymap in a usable state. */ static int -remap(curmap, c, funct, pref_map) - KEYMAP *curmap; /* pointer to the map being changed */ - int c; /* character being changed */ - PF funct; /* function being changed to */ - KEYMAP *pref_map; /* if funct==NULL, map to bind to or +remap(KEYMAP *curmap, /* pointer to the map being changed */ + int c, /* character being changed */ + PF funct, /* function being changed to */ + KEYMAP *pref_map /* if funct==NULL, map to bind to or NULL for new */ + ) { int i, n1, n2, nold; KEYMAP *mp; @@ -260,8 +259,7 @@ remap(curmap, c, funct, pref_map) * Reallocate a keymap, used above. */ static KEYMAP * -realocmap(curmap) - KEYMAP *curmap; +realocmap(KEYMAP *curmap) { MAPS *mps; KEYMAP *mp; @@ -296,10 +294,7 @@ realocmap(curmap) * Fix references to a reallocated keymap (recursive). */ static void -fixmap(curmap, mp, mt) - KEYMAP *mt; - KEYMAP *curmap; - KEYMAP *mp; +fixmap(KEYMAP *curmap, KEYMAP *mp, KEYMAP *mt) { int i; @@ -318,10 +313,7 @@ fixmap(curmap, mp, mt) * then call remap to do the work. */ static int -dobind(curmap, p, unbind) - KEYMAP *curmap; - char *p; - int unbind; +dobind(KEYMAP *curmap, const char *p, int unbind) { KEYMAP *pref_map = NULL; PF funct; @@ -390,11 +382,7 @@ dobind(curmap, p, unbind) */ #ifdef BINDKEY static int -bindkey(mapp, fname, keys, kcount) - KEYMAP **mapp; - char *fname; - KCHAR *keys; - int kcount; +bindkey(KEYMAP **mapp, const char *fname, KCHAR *keys, int kcount) { KEYMAP *curmap = *mapp; KEYMAP *pref_map = NULL; @@ -428,10 +416,7 @@ bindkey(mapp, fname, keys, kcount) * Wrapper for bindkey() that converts escapes. */ int -dobindkey(map, func, str) - KEYMAP *map; - char *func; - char *str; +dobindkey(KEYMAP *map, const char *func, const char *str) { int i; @@ -472,8 +457,7 @@ dobindkey(map, func, str) */ /* ARGSUSED */ int -bindtokey(f, n) - int f, n; +bindtokey(int f, int n) { return dobind(fundamental_map, "Global set key: ", FALSE); } @@ -483,8 +467,7 @@ bindtokey(f, n) */ /* ARGSUSED */ int -localbind(f, n) - int f, n; +localbind(int f, int n) { return dobind(curbp->b_modes[curbp->b_nmodes]->p_map, "Local set key: ", FALSE); @@ -515,8 +498,7 @@ define_key(int f, int n) } int -unbindtokey(f, n) - int f, n; +unbindtokey(int f, int n) { return dobind(fundamental_map, "Global unset key: ", TRUE); } @@ -536,8 +518,7 @@ localunbind(f, n) * error if there is anything wrong. */ int -extend(f, n) - int f, n; +extend(int f, int n) { PF funct; int s; @@ -586,8 +567,7 @@ extend(f, n) */ /* ARGSUSED */ int -evalexpr(f, n) - int f, n; +evalexpr(int f, int n) { int s; char exbuf[128]; @@ -603,8 +583,7 @@ evalexpr(f, n) */ /* ARGSUSED */ int -evalbuffer(f, n) - int f, n; +evalbuffer(int f, int n) { LINE *lp; BUFFER *bp = curbp; @@ -630,8 +609,7 @@ evalbuffer(f, n) */ /* ARGSUSED */ int -evalfile(f, n) - int f, n; +evalfile(int f, int n) { int s; char fname[NFILEN]; @@ -645,8 +623,7 @@ evalfile(f, n) * load - go load the file name we got passed. */ int -load(fname) - char *fname; +load(const char *fname) { int s = TRUE; int nbytes = 0; @@ -680,8 +657,7 @@ load(fname) * have to fit in type char. */ int -excline(line) - char *line; +excline(char *line) { PF fp; LINE *lp, *np; @@ -932,8 +908,7 @@ cleanup: * a pair of utility functions for the above */ static char * -skipwhite(s) - char *s; +skipwhite(char *s) { while (*s == ' ' || *s == '\t' || *s == ')' || *s == '(') s++; @@ -943,8 +918,7 @@ skipwhite(s) } static char * -parsetoken(s) - char *s; +parsetoken(char *s) { if (*s != '"') { while (*s && *s != ' ' && *s != '\t' && *s != ')' && *s != '(') diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index f83ba3d34d0..18c91da6a9d 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.14 2002/02/19 12:58:42 vincent Exp $ */ +/* $OpenBSD: file.c,v 1.15 2002/03/11 13:02:56 vincent Exp $ */ /* * File commands. @@ -13,8 +13,7 @@ */ /* ARGSUSED */ int -fileinsert(f, n) - int f, n; +fileinsert(int f, int n) { int s; char fname[NFILEN]; @@ -34,8 +33,7 @@ fileinsert(f, n) */ /* ARGSUSED */ int -filevisit(f, n) - int f, n; +filevisit(int f, int n) { BUFFER *bp; int s; @@ -62,8 +60,7 @@ filevisit(f, n) */ /* ARGSUSED */ int -poptofile(f, n) - int f, n; +poptofile(int f, int n) { BUFFER *bp; MGWIN *wp; diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 66847e06086..99c449575e5 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fileio.c,v 1.24 2002/02/22 00:18:37 deraadt Exp $ */ +/* $OpenBSD: fileio.c,v 1.25 2002/03/11 13:02:56 vincent Exp $ */ /* * POSIX fileio.c @@ -18,9 +18,7 @@ static FILE *ffp; * Open a file for reading. */ int -ffropen(fn, bp) - char *fn; - BUFFER *bp; +ffropen(const char *fn, BUFFER *bp) { struct stat statbuf; @@ -41,9 +39,7 @@ ffropen(fn, bp) * FALSE on error (cannot create). */ int -ffwopen(fn, bp) - char *fn; - BUFFER *bp; +ffwopen(const char *fn, BUFFER *bp) { int fd; mode_t mode = DEFFILEMODE; @@ -84,8 +80,7 @@ ffwopen(fn, bp) */ /* ARGSUSED */ int -ffclose(bp) - BUFFER *bp; +ffclose(BUFFER *bp) { (void) fclose(ffp); @@ -100,8 +95,7 @@ ffclose(bp) * end of buffer. */ int -ffputbuf(bp) - BUFFER *bp; +ffputbuf(BUFFER *bp) { char *cp; char *cpend; @@ -137,10 +131,7 @@ ffputbuf(bp) * of data without the normally implied \n. */ int -ffgetline(buf, nbuf, nbytes) - char *buf; - int nbuf; - int *nbytes; +ffgetline(char *buf, int nbuf, int *nbytes) { int c, i; @@ -168,8 +159,7 @@ ffgetline(buf, nbuf, nbytes) * a problem when using mg with things like crontab and vipw. */ int -fbackupfile(fn) - char *fn; +fbackupfile(const char *fn) { struct stat sb; int from, to, serrno; @@ -238,8 +228,7 @@ extern char *wdir; #endif char * -adjustname(fn) - char *fn; +adjustname(const char *fn) { char *cp; static char fnb[NFILEN]; @@ -511,8 +500,7 @@ struct filelist { */ LIST * -make_file_list(buf) - char *buf; +make_file_list(char *buf) { char *dir, *file, *cp; int len, preflen; diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c index 1b3d7bb98d4..5c6c634998a 100644 --- a/usr.bin/mg/funmap.c +++ b/usr.bin/mg/funmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: funmap.c,v 1.5 2002/02/20 22:30:54 vincent Exp $ */ +/* $OpenBSD: funmap.c,v 1.6 2002/03/11 13:02:56 vincent Exp $ */ /* * Copyright (c) 2001 Artur Grabowski <art@openbsd.org>. All rights reserved. * @@ -32,8 +32,8 @@ */ struct funmap { - PF fn_funct; - char *fn_name; + PF fn_funct; + const char *fn_name; struct funmap *fn_next; }; @@ -239,7 +239,7 @@ funmap_init(void) } int -funmap_add(PF fun, char *fname) +funmap_add(PF fun, const char *fname) { struct funmap *fn; @@ -258,7 +258,7 @@ funmap_add(PF fun, char *fname) * Translate from function name to function pointer. */ PF -name_function(char *fname) +name_function(const char *fname) { struct funmap *fn; @@ -269,7 +269,7 @@ name_function(char *fname) return NULL; } -char * +const char * function_name(PF fun) { struct funmap *fn; @@ -285,7 +285,7 @@ function_name(PF fun) * list possible function name completions. */ LIST * -complete_function_list(char *fname, int c) +complete_function_list(const char *fname, int c) { struct funmap *fn; LIST *head, *el; diff --git a/usr.bin/mg/funmap.h b/usr.bin/mg/funmap.h index 22f6d67d542..ee35e27fa5d 100644 --- a/usr.bin/mg/funmap.h +++ b/usr.bin/mg/funmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: funmap.h,v 1.2 2001/05/24 13:00:45 art Exp $ */ +/* $OpenBSD: funmap.h,v 1.3 2002/03/11 13:02:56 vincent Exp $ */ /* * Copyright (c) 2001 Artur Grabowski <art@openbsd.org>. All rights reserved. * @@ -24,7 +24,7 @@ */ void funmap_init(void); -PF name_function(char *); -char *function_name(PF); -LIST *complete_function_list(char *, int); -int funmap_add(PF, char *); +PF name_function(const char *); +const char *function_name(PF); +LIST *complete_function_list(const char *, int); +int funmap_add(PF, const char *); diff --git a/usr.bin/mg/help.c b/usr.bin/mg/help.c index c5432fbfa63..65428d32f37 100644 --- a/usr.bin/mg/help.c +++ b/usr.bin/mg/help.c @@ -1,4 +1,4 @@ -/* $OpenBSD: help.c,v 1.15 2001/11/25 07:34:17 deraadt Exp $ */ +/* $OpenBSD: help.c,v 1.16 2002/03/11 13:02:56 vincent Exp $ */ /* * Help functions for Mg 2 @@ -83,7 +83,7 @@ nextmode: found: if (funct == rescan || funct == selfinsert) ewprintf("%k is not bound to any function"); - else if ((pep = function_name(funct)) != NULL) + else if ((pep = (char *)function_name(funct)) != NULL) ewprintf("%k runs the command %s", pep); else ewprintf("%k is bound to an unnamed function"); diff --git a/usr.bin/mg/kbd.h b/usr.bin/mg/kbd.h index 92ec0708784..0090258da34 100644 --- a/usr.bin/mg/kbd.h +++ b/usr.bin/mg/kbd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kbd.h,v 1.13 2002/02/16 21:27:49 millert Exp $ */ +/* $OpenBSD: kbd.h,v 1.14 2002/03/11 13:02:56 vincent Exp $ */ /* * kbd.h: type definitions for symbol.c and kbd.c for mg experimental @@ -37,7 +37,7 @@ typedef struct keymap_s KEYMAPE(1) KEYMAP; typedef struct MAPS_S { KEYMAP *p_map; - char *p_name; + const char *p_name; struct MAPS_S *p_next; } MAPS; @@ -45,13 +45,13 @@ extern MAPS *maps; extern MAPS fundamental_mode; #define fundamental_map (fundamental_mode.p_map) -int dobindkey(KEYMAP *, char *, char *); -KEYMAP *name_map(char *); -MAPS *name_mode(char *); -PF doscan(KEYMAP *, int, KEYMAP **); -char *map_name(KEYMAP *); -void maps_init(void); -int maps_add(KEYMAP *, char *); +int dobindkey(KEYMAP *, const char *, const char *); +KEYMAP *name_map(const char *); +MAPS *name_mode(const char *); +PF doscan(KEYMAP *, int, KEYMAP **); +const char *map_name(KEYMAP *); +void maps_init(void); +int maps_add(KEYMAP *, const char *); extern MAP_ELEMENT *ele; extern MAPS *defb_modes[]; diff --git a/usr.bin/mg/keymap.c b/usr.bin/mg/keymap.c index 5dcb0f5c0f9..b0258571c60 100644 --- a/usr.bin/mg/keymap.c +++ b/usr.bin/mg/keymap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keymap.c,v 1.18 2002/03/01 19:05:40 deraadt Exp $ */ +/* $OpenBSD: keymap.c,v 1.19 2002/03/11 13:02:56 vincent Exp $ */ /* * Keyboard maps. This is character set dependent. The terminal specific @@ -593,7 +593,7 @@ maps_init(void) } int -maps_add(KEYMAP *map, char *name) +maps_add(KEYMAP *map, const char *name) { MAPS *mp; @@ -608,7 +608,7 @@ maps_add(KEYMAP *map, char *name) return TRUE; } -char * +const char * map_name(KEYMAP *map) { MAPS *mp; @@ -620,7 +620,7 @@ map_name(KEYMAP *map) } MAPS * -name_mode(char *name) +name_mode(const char *name) { MAPS *mp; @@ -631,7 +631,7 @@ name_mode(char *name) } KEYMAP * -name_map(char *name) +name_map(const char *name) { MAPS *mp; return (mp = name_mode(name)) == NULL ? NULL : mp->p_map; |