* merge in OpenBSD
* rename cd34.iso to cdrom8.iso XXX gzip/compress on ramdisk in MirOS should still XXX be able to compress and not only decompress XXX files. must be revisited
This commit is contained in:
21
vi.c
21
vi.c
@ -1,5 +1,5 @@
|
||||
/* $MirBSD: vi.c,v 1.2 2003/04/12 14:32:14 tg Exp $ */
|
||||
/* $OpenBSD: vi.c,v 1.11 2003/03/13 09:03:07 deraadt Exp $ */
|
||||
/* $MirBSD: vi.c,v 1.3 2003/12/23 13:41:51 tg Exp $ */
|
||||
/* $OpenBSD: vi.c,v 1.12 2003/10/16 22:08:48 millert Exp $ */
|
||||
|
||||
/*
|
||||
* vi command editing
|
||||
@ -239,7 +239,7 @@ x_vi(buf, len)
|
||||
|
||||
x_putc('\r'); x_putc('\n'); x_flush();
|
||||
|
||||
if (c == -1)
|
||||
if (c == -1 || len <= es->linelen)
|
||||
return -1;
|
||||
|
||||
if (es->cbuf != buf)
|
||||
@ -463,15 +463,22 @@ vi_hook(ch)
|
||||
else {
|
||||
locpat[srchlen++] = ch;
|
||||
if ((ch & 0x80) && Flag(FVISHOW8)) {
|
||||
if (es->linelen + 2 > es->cbufsize)
|
||||
vi_error();
|
||||
es->cbuf[es->linelen++] = 'M';
|
||||
es->cbuf[es->linelen++] = '-';
|
||||
ch &= 0x7f;
|
||||
}
|
||||
if (ch < ' ' || ch == 0x7f) {
|
||||
if (es->linelen + 2 > es->cbufsize)
|
||||
vi_error();
|
||||
es->cbuf[es->linelen++] = '^';
|
||||
es->cbuf[es->linelen++] = ch ^ '@';
|
||||
} else
|
||||
} else {
|
||||
if (es->linelen >= es->cbufsize)
|
||||
vi_error();
|
||||
es->cbuf[es->linelen++] = ch;
|
||||
}
|
||||
es->cursor = es->linelen;
|
||||
refresh(0);
|
||||
}
|
||||
@ -694,7 +701,7 @@ vi_insert(ch)
|
||||
/* End nonstandard vi commands } */
|
||||
|
||||
default:
|
||||
if (es->linelen == es->cbufsize - 1)
|
||||
if (es->linelen >= es->cbufsize - 1)
|
||||
return -1;
|
||||
ibuf[inslen++] = ch;
|
||||
if (insert == INSERT) {
|
||||
@ -1406,8 +1413,8 @@ save_edstate(old)
|
||||
|
||||
new = (struct edstate *)alloc(sizeof(struct edstate), APERM);
|
||||
new->cbuf = alloc(old->cbufsize, APERM);
|
||||
memcpy(new->cbuf, old->cbuf, old->linelen);
|
||||
new->cbufsize = old->cbufsize;
|
||||
strlcpy(new->cbuf, old->cbuf, new->cbufsize);
|
||||
new->linelen = old->linelen;
|
||||
new->cursor = old->cursor;
|
||||
new->winleft = old->winleft;
|
||||
@ -1418,7 +1425,7 @@ static void
|
||||
restore_edstate(new, old)
|
||||
struct edstate *old, *new;
|
||||
{
|
||||
strncpy(new->cbuf, old->cbuf, old->linelen);
|
||||
memcpy(new->cbuf, old->cbuf, old->linelen);
|
||||
new->linelen = old->linelen;
|
||||
new->cursor = old->cursor;
|
||||
new->winleft = old->winleft;
|
||||
|
Reference in New Issue
Block a user