diff options
author | ache <ache@FreeBSD.org> | 1994-11-02 07:34:01 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-11-02 07:34:01 +0000 |
commit | 3ee3d198c2039d0be6fbbe443ed9e333113cb2d7 (patch) | |
tree | 7ea783dedf1c4ad90a8114638ce8880edd1059fe /sbin | |
parent | d39ebc09c347363e8272c223abe7221c5e4f7972 (diff) | |
download | FreeBSD-src-3ee3d198c2039d0be6fbbe443ed9e333113cb2d7.zip FreeBSD-src-3ee3d198c2039d0be6fbbe443ed9e333113cb2d7.tar.gz |
Restore things broken by phk, please use patches on 'cvs update'
instead of whole files!
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/sysinstall/utils.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c index 32f00ef..c5a1bd5 100644 --- a/sbin/sysinstall/utils.c +++ b/sbin/sysinstall/utils.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: utils.c,v 1.15 1994/11/01 10:10:43 phk Exp $ + * $Id: utils.c,v 1.16 1994/11/02 06:19:53 jkh Exp $ * */ @@ -31,6 +31,42 @@ #include "sysinstall.h" void +strip_trailing_newlines(char *p) +{ + int len = strlen(p); + while (len > 0 && p[len-1] == '\n') + p[--len] = '\0'; +} + +int strwidth(char *p) +{ + int i = 0, len; + char *start, *s; + + for (start = s = p; (s = strchr(s, '\n')) != NULL; start = ++s) { + *s = '\0'; + len = strlen(start); + *s = '\n'; + if (len > i) + i = len; + } + len = strlen(start); + if (len > i) + i = len; + return i; +} + +int strheight(char *p) +{ + int i = 1; + char *s; + + for (s = p; (s = strchr(s, '\n')) != NULL; s++) + i++; + return i; +} + +void Debug(char *fmt, ...) { char *p; @@ -54,10 +90,11 @@ TellEm(char *fmt, ...) va_start(ap,fmt); vsnprintf(p, 2048, fmt, ap); va_end(ap); + strip_trailing_newlines(p); write(debug_fd,"Progress <",10); write(debug_fd,p,strlen(p)); write(debug_fd,">\n\r",3); - dialog_msgbox("Progress", p, 3, 75, 0); + dialog_msgbox("Progress", p, strheight(p)+2, strwidth(p)+4, 0); free(p); } @@ -70,10 +107,11 @@ Fatal(char *fmt, ...) va_start(ap,fmt); vsnprintf(p, 2048, fmt, ap); va_end(ap); + strip_trailing_newlines(p); if (dialog_active) - dialog_msgbox("Fatal", p, 12, 75, 1); + dialog_msgbox("Fatal", p, strheight(p)+4, strwidth(p)+4, 1); else - fprintf(stderr, "Fatal -- %s", p); + fprintf(stderr, "Fatal -- %s\n", p); free(p); ExitSysinstall(); } |