minor cosmetic bug

Damien Miller djm at mindrot.org
Sun Jul 2 19:16:48 EST 2000


On 1 Jul 2000, James H. Cloos Jr. wrote:

> The progress metre in scp(1) breaks when the tty is too wide.
> 
> This patch is the effortless fix:

Here is a slightly more general one, which shouldn't break on any
line size:

Index: scp.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/scp.c,v
retrieving revision 1.32
diff -u -r1.32 scp.c
--- scp.c	2000/06/20 01:39:44	1.32
+++ scp.c	2000/07/02 08:58:49
@@ -56,6 +56,14 @@
 /* For progressmeter() -- number of seconds before xfer considered "stalled" */
 #define STALLTIME	5
 
+/* Progress meter bar */
+#define BAR \
+	"************************************************************"\
+	"************************************************************"\
+	"************************************************************"\
+	"************************************************************"
+#define MAX_BARLENGTH (sizeof(BAR) - 1)
+
 /* Visual statistics about files as they are transferred. */
 void progressmeter(int);
 
@@ -1170,13 +1178,11 @@
 	snprintf(buf, sizeof(buf), "\r%-20.20s %3d%% ", curfile, ratio);
 
 	barlength = getttywidth() - 51;
+	barlength = (barlength <= MAX_BARLENGTH)?barlength:MAX_BARLENGTH;
 	if (barlength > 0) {
 		i = barlength * ratio / 100;
 		snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
-			 "|%.*s%*s|", i,
-			 "*****************************************************************************"
-			 "*****************************************************************************",
-			 barlength - i, "");
+			 "|%.*s%*s|", i, BAR, barlength - i, "");
 	}
 	i = 0;
 	abbrevsize = cursize;


-- 
| "Bombay is 250ms from New York in the new world order" - Alan Cox
| Damien Miller - http://www.mindrot.org/
| Email: djm at mindrot.org (home) -or- djm at ibs.com.au (work)








More information about the openssh-unix-dev mailing list