diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-03-27 17:42:38 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-03-27 17:42:38 +0000 |
commit | f669fd006e528f67d3ef363fa19ed9b5024470bc (patch) | |
tree | 67037a4394021e5b9e9ff7e3c430e886c33c213c | |
parent | 87bbeef386d9841d66a33f3656cceb83128598e6 (diff) |
Fixes the the following problems (from zyrnix)
1) Mg crashes with column width of 1, rows > 2
2) Mg panics on resizing due to incomplete write
3) Mg doesn't compile with STARTUPFILE defined
deraadt@ OK
-rw-r--r-- | usr.bin/mg/display.c | 6 | ||||
-rw-r--r-- | usr.bin/mg/fileio.c | 22 | ||||
-rw-r--r-- | usr.bin/mg/ttyio.c | 20 |
3 files changed, 26 insertions, 22 deletions
diff --git a/usr.bin/mg/display.c b/usr.bin/mg/display.c index a03bd6dccf5..26cd9bb97fb 100644 --- a/usr.bin/mg/display.c +++ b/usr.bin/mg/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.12 2002/03/16 04:17:36 vincent Exp $ */ +/* $OpenBSD: display.c,v 1.13 2002/03/27 17:42:37 millert Exp $ */ /* * The functions in this file handle redisplay. The @@ -629,11 +629,15 @@ updext(int currow, int curcol) LINE *lp; /* pointer to current line */ int j; /* index into line */ + if (ncol < 2) + return; + /* * calculate what column the left bound should be * (force cursor into middle half of screen) */ lbound = curcol - (curcol % (ncol >> 1)) - (ncol >> 2); + /* * scan through the line outputing characters to the virtual screen * once we reach the left edge diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 109c33e3458..df1c027c17a 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fileio.c,v 1.26 2002/03/16 19:30:29 vincent Exp $ */ +/* $OpenBSD: fileio.c,v 1.27 2002/03/27 17:42:37 millert Exp $ */ /* * POSIX fileio.c @@ -297,8 +297,8 @@ adjustname(const char *fn) != -1;) { if (linkbuf[0] != '/') { --cp; - while (cp > fnb && *--cp != '/') { - } + while (cp > fnb && *--cp != '/') + ; ++cp; (void) strncpy(cp, linkbuf, i); cp += i; @@ -333,8 +333,8 @@ adjustname(const char *fn) default: break; } - while (*fn && (*cp++ = *fn++) != '/') { - } + while (*fn && (*cp++ = *fn++) != '/') + ; } if (cp[-1] == '/') --cp; @@ -350,8 +350,7 @@ adjustname(const char *fn) * to the startup file name. */ char * -startupfile(suffix) - char *suffix; +startupfile(char *suffix) { static char file[NFILEN]; char *home; @@ -373,7 +372,7 @@ startupfile(suffix) return file; nohome: #ifdef STARTUPFILE - if (suffix == NULL) + if (suffix == NULL) { if (snprintf(file, sizeof(file), "%s", STARTUPFILE) >= sizeof(file)) return NULL; @@ -395,9 +394,7 @@ nohome: #include "kbd.h" int -copy(frname, toname) - char *frname; - char *toname; +copy(char *frname, char *toname) { pid_t pid; int status; @@ -418,8 +415,7 @@ copy(frname, toname) * dirname needs to have enough place to store an additional '/'. */ BUFFER * -dired_(dirname) - char *dirname; +dired_(char *dirname) { BUFFER *bp; FILE *dirpipe; diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c index 01d375c3fc4..c5e1889bf99 100644 --- a/usr.bin/mg/ttyio.c +++ b/usr.bin/mg/ttyio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttyio.c,v 1.18 2002/02/21 00:02:05 deraadt Exp $ */ +/* $OpenBSD: ttyio.c,v 1.19 2002/03/27 17:42:37 millert Exp $ */ /* * POSIX terminal I/O. @@ -121,8 +121,7 @@ ttcooked() * to make things a little bit more efficient. */ int -ttputc(c) - int c; +ttputc(int c) { if (nobuf >= NOBUF) @@ -137,12 +136,18 @@ ttputc(c) void ttflush() { + ssize_t written; + + if (nobuf == 0) + return; - if (nobuf != 0) { - if (write(1, obuf, nobuf) != nobuf) + while ((written = write(fileno(stdout), obuf, nobuf)) != nobuf) { + if (written == -1) panic("ttflush write failed"); - nobuf = 0; + else + nobuf -= written; } + nobuf = 0; } /* @@ -184,8 +189,7 @@ typeahead() * panic - just exit, as quickly as we can. */ void -panic(s) - char *s; +panic(char *s) { (void) fputs("panic: ", stderr); |