summaryrefslogtreecommitdiff
path: root/bin/ksh/vi.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-12-20 11:34:27 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-12-20 11:34:27 +0000
commite445c3ad8a040ce5aa9ffd47e72de71f7cd3dd16 (patch)
treef321abeceffdba61fb97e64b666e8793cf6e1d4e /bin/ksh/vi.c
parentc6e78b160bb0e446bb146be6b8b66890b48e5b31 (diff)
Ansification plus some minor knf. No binary change on i386 and
sparc64, binary change in lex.o on macppc due to introduction of dopprompt() prototype. ok millert@
Diffstat (limited to 'bin/ksh/vi.c')
-rw-r--r--bin/ksh/vi.c209
1 files changed, 77 insertions, 132 deletions
diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c
index 9b25a2e6d68..d79f27eff66 100644
--- a/bin/ksh/vi.c
+++ b/bin/ksh/vi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.c,v 1.16 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: vi.c,v 1.17 2004/12/20 11:34:26 otto Exp $ */
/*
* vi command editing
@@ -27,45 +27,45 @@ struct edstate {
};
-static int vi_hook(int ch);
-static void vi_reset(char *buf, size_t len);
-static int nextstate(int ch);
-static int vi_insert(int ch);
-static int vi_cmd(int argcnt, const char *cmd);
-static int domove(int argcnt, const char *cmd, int sub);
-static int redo_insert(int count);
-static void yank_range(int a, int b);
-static int bracktype(int ch);
+static int vi_hook(int);
+static void vi_reset(char *, size_t);
+static int nextstate(int);
+static int vi_insert(int);
+static int vi_cmd(int, const char *);
+static int domove(int, const char *, int);
+static int redo_insert(int);
+static void yank_range(int, int);
+static int bracktype(int);
static void save_cbuf(void);
static void restore_cbuf(void);
-static void edit_reset(char *buf, size_t len);
-static int putbuf(const char *buf, int len, int repl);
-static void del_range(int a, int b);
-static int findch(int ch, int cnt, int forw, int incl);
-static int forwword(int argcnt);
-static int backword(int argcnt);
-static int endword(int argcnt);
-static int Forwword(int argcnt);
-static int Backword(int argcnt);
-static int Endword(int argcnt);
-static int grabhist(int save, int n);
-static int grabsearch(int save, int start, int fwd, char *pat);
-static void redraw_line(int newline);
-static void refresh(int leftside);
+static void edit_reset(char *, size_t);
+static int putbuf(const char *, int, int);
+static void del_range(int, int);
+static int findch(int, int, int, int);
+static int forwword(int);
+static int backword(int);
+static int endword(int);
+static int Forwword(int);
+static int Backword(int);
+static int Endword(int);
+static int grabhist(int, int);
+static int grabsearch(int, int, int, char *);
+static void redraw_line(int);
+static void refresh(int);
static int outofwin(void);
static void rewindow(void);
-static int newcol(int ch, int col);
-static void display(char *wb1, char *wb2, int leftside);
-static void ed_mov_opt(int col, char *wb);
-static int expand_word(int command);
-static int complete_word(int command, int count);
-static int print_expansions(struct edstate *e, int command);
-static int char_len(int c);
-static void x_vi_zotc(int c);
-static void vi_pprompt(int full);
+static int newcol(int, int);
+static void display(char *, char *, int);
+static void ed_mov_opt(int, char *);
+static int expand_word(int);
+static int complete_word(int, int);
+static int print_expansions(struct edstate *, int);
+static int char_len(int);
+static void x_vi_zotc(int);
+static void vi_pprompt(int);
static void vi_error(void);
static void vi_macro_reset(void);
-static int x_vi_putbuf(const char *s, size_t len);
+static int x_vi_putbuf(const char *, size_t);
#define C_ 0x1 /* a valid command that isn't a M_, E_, U_ */
#define M_ 0x2 /* movement command (h, l, etc.) */
@@ -188,9 +188,7 @@ enum expand_mode { NONE, EXPAND, COMPLETE, PRINT };
static enum expand_mode expanded = NONE;/* last input was expanded */
int
-x_vi(buf, len)
- char *buf;
- size_t len;
+x_vi(char *buf, size_t len)
{
int c;
@@ -250,8 +248,7 @@ x_vi(buf, len)
}
static int
-vi_hook(ch)
- int ch;
+vi_hook(int ch)
{
static char curcmd[MAXVICMD];
static char locpat[SRCHLEN];
@@ -524,9 +521,7 @@ vi_hook(ch)
}
static void
-vi_reset(buf, len)
- char *buf;
- size_t len;
+vi_reset(char *buf, size_t len)
{
state = VNORMAL;
ohnum = hnum = hlast = histnum(-1) + 1;
@@ -540,8 +535,7 @@ vi_reset(buf, len)
}
static int
-nextstate(ch)
- int ch;
+nextstate(int ch)
{
if (is_extend(ch))
return VEXTCMD;
@@ -560,8 +554,7 @@ nextstate(ch)
}
static int
-vi_insert(ch)
- int ch;
+vi_insert(int ch)
{
int tcursor;
@@ -689,9 +682,7 @@ vi_insert(ch)
}
static int
-vi_cmd(argcnt, cmd)
- int argcnt;
- const char *cmd;
+vi_cmd(int argcnt, const char *cmd)
{
int ncursor;
int cur, c1, c2, c3 = 0;
@@ -1142,10 +1133,7 @@ vi_cmd(argcnt, cmd)
}
static int
-domove(argcnt, cmd, sub)
- int argcnt;
- const char *cmd;
- int sub;
+domove(int argcnt, const char *cmd, int sub)
{
int bcount, i = 0, t;
int ncursor = 0;
@@ -1292,8 +1280,7 @@ domove(argcnt, cmd, sub)
}
static int
-redo_insert(count)
- int count;
+redo_insert(int count)
{
while (count-- > 0)
if (putbuf(ibuf, inslen, insert==REPLACE) != 0)
@@ -1305,8 +1292,7 @@ redo_insert(count)
}
static void
-yank_range(a, b)
- int a, b;
+yank_range(int a, int b)
{
yanklen = b - a;
if (yanklen != 0)
@@ -1314,8 +1300,7 @@ yank_range(a, b)
}
static int
-bracktype(ch)
- int ch;
+bracktype(int ch)
{
switch (ch) {
@@ -1360,7 +1345,7 @@ static char holdbuf[CMDLEN]; /* place to hold last edit buffer */
static int holdlen; /* length of holdbuf */
static void
-save_cbuf()
+save_cbuf(void)
{
memmove(holdbuf, es->cbuf, es->linelen);
holdlen = es->linelen;
@@ -1368,7 +1353,7 @@ save_cbuf()
}
static void
-restore_cbuf()
+restore_cbuf(void)
{
es->cursor = 0;
es->linelen = holdlen;
@@ -1377,8 +1362,7 @@ restore_cbuf()
/* return a new edstate */
static struct edstate *
-save_edstate(old)
- struct edstate *old;
+save_edstate(struct edstate *old)
{
struct edstate *new;
@@ -1393,8 +1377,7 @@ save_edstate(old)
}
static void
-restore_edstate(new, old)
- struct edstate *old, *new;
+restore_edstate(struct edstate *new, struct edstate *old)
{
memcpy(new->cbuf, old->cbuf, old->linelen);
new->linelen = old->linelen;
@@ -1404,8 +1387,7 @@ restore_edstate(new, old)
}
static void
-free_edstate(old)
- struct edstate *old;
+free_edstate(struct edstate *old)
{
afree(old->cbuf, APERM);
afree((char *)old, APERM);
@@ -1414,9 +1396,7 @@ free_edstate(old)
static void
-edit_reset(buf, len)
- char *buf;
- size_t len;
+edit_reset(char *buf, size_t len)
{
const char *p;
@@ -1456,18 +1436,13 @@ edit_reset(buf, len)
* this is used for calling x_escape() in complete_word()
*/
static int
-x_vi_putbuf(s, len)
- const char *s;
- size_t len;
+x_vi_putbuf(const char *s, size_t len)
{
return putbuf(s, len, 0);
}
static int
-putbuf(buf, len, repl)
- const char *buf;
- int len;
- int repl;
+putbuf(const char *buf, int len, int repl)
{
if (len == 0)
return 0;
@@ -1489,8 +1464,7 @@ putbuf(buf, len, repl)
}
static void
-del_range(a, b)
- int a, b;
+del_range(int a, int b)
{
if (es->linelen != b)
memmove(&es->cbuf[a], &es->cbuf[b], es->linelen - b);
@@ -1498,11 +1472,7 @@ del_range(a, b)
}
static int
-findch(ch, cnt, forw, incl)
- int ch;
- int cnt;
- int forw;
- int incl;
+findch(int ch, int cnt, int forw, int incl)
{
int ncursor;
@@ -1530,8 +1500,7 @@ findch(ch, cnt, forw, incl)
}
static int
-forwword(argcnt)
- int argcnt;
+forwword(int argcnt)
{
int ncursor;
@@ -1553,8 +1522,7 @@ forwword(argcnt)
}
static int
-backword(argcnt)
- int argcnt;
+backword(int argcnt)
{
int ncursor;
@@ -1579,8 +1547,7 @@ backword(argcnt)
}
static int
-endword(argcnt)
- int argcnt;
+endword(int argcnt)
{
int ncursor;
@@ -1606,8 +1573,7 @@ endword(argcnt)
}
static int
-Forwword(argcnt)
- int argcnt;
+Forwword(int argcnt)
{
int ncursor;
@@ -1622,8 +1588,7 @@ Forwword(argcnt)
}
static int
-Backword(argcnt)
- int argcnt;
+Backword(int argcnt)
{
int ncursor;
@@ -1639,8 +1604,7 @@ Backword(argcnt)
}
static int
-Endword(argcnt)
- int argcnt;
+Endword(int argcnt)
{
int ncursor;
@@ -1660,9 +1624,7 @@ Endword(argcnt)
}
static int
-grabhist(save, n)
- int save;
- int n;
+grabhist(int save, int n)
{
char *hptr;
@@ -1689,9 +1651,7 @@ grabhist(save, n)
}
static int
-grabsearch(save, start, fwd, pat)
- int save, start, fwd;
- char *pat;
+grabsearch(int save, int start, int fwd, char *pat)
{
char *hptr;
int hist;
@@ -1725,8 +1685,7 @@ grabsearch(save, start, fwd, pat)
}
static void
-redraw_line(newline)
- int newline;
+redraw_line(int newline)
{
(void) memset(wbuf[win], ' ', wbuf_len);
if (newline) {
@@ -1739,8 +1698,7 @@ redraw_line(newline)
}
static void
-refresh(leftside)
- int leftside;
+refresh(int leftside)
{
if (leftside < 0)
leftside = lastref;
@@ -1753,7 +1711,7 @@ refresh(leftside)
}
static int
-outofwin()
+outofwin(void)
{
int cur, col;
@@ -1769,7 +1727,7 @@ outofwin()
}
static void
-rewindow()
+rewindow(void)
{
int tcur, tcol;
int holdcur1, holdcol1;
@@ -1793,8 +1751,7 @@ rewindow()
}
static int
-newcol(ch, col)
- int ch, col;
+newcol(int ch, int col)
{
if (ch == '\t')
return (col | 7) + 1;
@@ -1802,9 +1759,7 @@ newcol(ch, col)
}
static void
-display(wb1, wb2, leftside)
- char *wb1, *wb2;
- int leftside;
+display(char *wb1, char *wb2, int leftside)
{
unsigned char ch;
char *twb1, *twb2, mc;
@@ -1897,9 +1852,7 @@ display(wb1, wb2, leftside)
}
static void
-ed_mov_opt(col, wb)
- int col;
- char *wb;
+ed_mov_opt(int col, char *wb)
{
if (col < cur_col) {
if (col + 1 < cur_col - col) {
@@ -1923,8 +1876,7 @@ ed_mov_opt(col, wb)
/* replace word with all expansions (ie, expand word*) */
static int
-expand_word(command)
- int command;
+expand_word(int command)
{
static struct edstate *buf;
int rval = 0;
@@ -1978,9 +1930,7 @@ expand_word(command)
}
static int
-complete_word(command, count)
- int command;
- int count;
+complete_word(int command, int count)
{
static struct edstate *buf;
int rval = 0;
@@ -2087,9 +2037,7 @@ complete_word(command, count)
}
static int
-print_expansions(e, command)
- struct edstate *e;
- int command;
+print_expansions(struct edstate *e, int command)
{
int nwords;
int start, end;
@@ -2111,8 +2059,7 @@ print_expansions(e, command)
/* How long is char when displayed (not counting tabs) */
static int
-char_len(c)
- int c;
+char_len(int c)
{
int len = 1;
@@ -2127,8 +2074,7 @@ char_len(c)
/* Similar to x_zotc(emacs.c), but no tab weirdness */
static void
-x_vi_zotc(c)
- int c;
+x_vi_zotc(int c)
{
if (Flag(FVISHOW8) && (c & 0x80)) {
x_puts("M-");
@@ -2142,14 +2088,13 @@ x_vi_zotc(c)
}
static void
-vi_pprompt(full)
- int full;
+vi_pprompt(int full)
{
pprompt(prompt + (full ? 0 : prompt_skip), prompt_trunc);
}
static void
-vi_error()
+vi_error(void)
{
/* Beem out of any macros as soon as an error occurs */
vi_macro_reset();
@@ -2158,7 +2103,7 @@ vi_error()
}
static void
-vi_macro_reset()
+vi_macro_reset(void)
{
if (macro.p) {
afree(macro.buf, APERM);