X-Git-Url: https://git.cameronkatri.com/bsd-progress.git/blobdiff_plain/f03f0dba0d741e3a0242e188ee85ecb48bca3d12..6814f3fb912279eed9dad628244664ccbeba1309:/progressbar.c diff --git a/progressbar.c b/progressbar.c index 34d3cc6..d7edd27 100644 --- a/progressbar.c +++ b/progressbar.c @@ -1,7 +1,7 @@ -/* $NetBSD: progressbar.c,v 1.15 2007/04/17 05:52:03 lukem Exp $ */ +/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */ /*- - * Copyright (c) 1997-2007 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -15,13 +15,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -38,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.15 2007/04/17 05:52:03 lukem Exp $"); +__RCSID("$NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $"); #endif /* not lint */ /* @@ -93,7 +86,7 @@ updateprogressmeter(int dummy) /* * List of order of magnitude suffixes, per IEC 60027-2. */ -static const char const *suffixes[] = { +static const char * const suffixes[] = { "", /* 2^0 (byte) */ "KiB", /* 2^10 Kibibyte */ "MiB", /* 2^20 Mebibyte */ @@ -107,7 +100,7 @@ static const char const *suffixes[] = { "YiB", /* 2^80 Yobibyte */ #endif }; -#define NSUFFIXES (sizeof(suffixes) / sizeof(suffixes[0])) +#define NSUFFIXES (int)(sizeof(suffixes) / sizeof(suffixes[0])) /* * Display a transfer progress bar if progress is non-zero. @@ -180,8 +173,8 @@ progressmeter(int flag) "transfer aborted because stalled for %lu sec.\r\n", getprogname(), (unsigned long)wait.tv_sec); (void)write(fileno(ttyout), buf, len); - (void)xsignal(SIGALRM, SIG_DFL); alarmtimer(0); + (void)xsignal(SIGALRM, SIG_DFL); siglongjmp(toplevel, 1); } #endif /* !STANDALONE_PROGRESS */ @@ -198,8 +191,8 @@ progressmeter(int flag) (void)xsignal_restart(SIGALRM, updateprogressmeter, 1); alarmtimer(1); /* set alarm timer for 1 Hz */ } else if (flag == 1) { - (void)xsignal(SIGALRM, SIG_DFL); alarmtimer(0); + (void)xsignal(SIGALRM, SIG_DFL); } } #ifndef NO_PROGRESS @@ -226,7 +219,7 @@ progressmeter(int flag) * calculate the length of the `*' bar, ensuring that * the number of stars won't exceed the buffer size */ - barlength = MIN(sizeof(buf) - 1, ttywidth) - BAROVERHEAD; + barlength = MIN((int)(sizeof(buf) - 1), ttywidth) - BAROVERHEAD; if (prefix) barlength -= (int)strlen(prefix); if (barlength > 0) {