Subject: bin/3148: ftp hash printing conflicts with progress bar
To: None <gnats-bugs@gnats.netbsd.org>
From: Matthias Scheler <tron@lyssa.owl.de>
List: netbsd-bugs
Date: 01/27/1997 11:27:29
>Number:         3148
>Category:       bin
>Synopsis:       ftp hash printing conflicts with progress bar
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 27 02:35:01 1997
>Last-Modified:
>Originator:     Matthias Scheler
>Organization:
Matthias Scheler				http://colwyn.owl.de/~tron/
>Release:        970124
>Environment:
System: NetBSD lyssa 1.2B NetBSD 1.2B (LYSSA) #3: Sun Jan 26 02:48:28 MET 1997 tron@lyssa:/usr/src/sys/arch/i386/compile/LYSSA i386


>Description:
I tried to download a file a system running Sun-OS 5.5 with the original
FTP daemon. But although I turned on hash mark printing nothing got print
during the transfer. I had to turn off the progress bar manually to get
hash mark printing working.

>How-To-Repeat:
Connect to a FTP daemon which doesn't understand the "SIZE" command,
turn on "hash" and download a file.

>Fix:
*** src/usr.bin/ftp/ftp.c.orig	Mon Jan 20 13:22:07 1997
--- src/usr.bin/ftp/ftp.c	Mon Jan 27 11:16:57 1997
*************** sendrequest(cmd, local, remote, printnam
*** 650,656 ****
  			for (bufp = buf; c > 0; c -= d, bufp += d)
  				if ((d = write(fileno(dout), bufp, c)) <= 0)
  					break;
! 			if (hash && !progress) {
  				while (bytes >= hashbytes) {
  					(void) putchar('#');
  					hashbytes += mark;
--- 650,656 ----
  			for (bufp = buf; c > 0; c -= d, bufp += d)
  				if ((d = write(fileno(dout), bufp, c)) <= 0)
  					break;
! 			if (hash && (!progress || filesize < 0) ) {
  				while (bytes >= hashbytes) {
  					(void) putchar('#');
  					hashbytes += mark;
*************** sendrequest(cmd, local, remote, printnam
*** 659,665 ****
  			}
  			progressmeter(0);
  		}
! 		if (hash && !progress && bytes > 0) {
  			if (bytes < mark)
  				(void) putchar('#');
  			(void) putchar('\n');
--- 659,665 ----
  			}
  			progressmeter(0);
  		}
! 		if (hash && (!progress || filesize < 0) && bytes > 0) {
  			if (bytes < mark)
  				(void) putchar('#');
  			(void) putchar('\n');
*************** sendrequest(cmd, local, remote, printnam
*** 677,683 ****
  	case TYPE_A:
  		while ((c = getc(fin)) != EOF) {
  			if (c == '\n') {
! 				while (hash && !progress &&
  				    (bytes >= hashbytes)) {
  					(void) putchar('#');
  					(void) fflush(stdout);
--- 677,683 ----
  	case TYPE_A:
  		while ((c = getc(fin)) != EOF) {
  			if (c == '\n') {
! 				while (hash && (!progress || filesize < 0) &&
  				    (bytes >= hashbytes)) {
  					(void) putchar('#');
  					(void) fflush(stdout);
*************** sendrequest(cmd, local, remote, printnam
*** 698,704 ****
  #endif
  			progressmeter(0);
  		}
! 		if (hash && !progress) {
  			if (bytes < hashbytes)
  				(void) putchar('#');
  			(void) putchar('\n');
--- 698,704 ----
  #endif
  			progressmeter(0);
  		}
! 		if (hash && (!progress || filesize < 0)) {
  			if (bytes < hashbytes)
  				(void) putchar('#');
  			(void) putchar('\n');
*************** recvrequest(cmd, local, remote, lmode, p
*** 943,949 ****
  			if ((d = write(fileno(fout), buf, c)) != c)
  				break;
  			bytes += c;
! 			if (hash && !progress) {
  				while (bytes >= hashbytes) {
  					(void) putchar('#');
  					hashbytes += mark;
--- 943,949 ----
  			if ((d = write(fileno(fout), buf, c)) != c)
  				break;
  			bytes += c;
! 			if (hash && (!progress || filesize < 0)) {
  				while (bytes >= hashbytes) {
  					(void) putchar('#');
  					hashbytes += mark;
*************** recvrequest(cmd, local, remote, lmode, p
*** 952,958 ****
  			}
  			progressmeter(0);
  		}
! 		if (hash && !progress && bytes > 0) {
  			if (bytes < mark)
  				(void) putchar('#');
  			(void) putchar('\n');
--- 952,958 ----
  			}
  			progressmeter(0);
  		}
! 		if (hash && (!progress || filesize < 0) && bytes > 0) {
  			if (bytes < mark)
  				(void) putchar('#');
  			(void) putchar('\n');
*************** done:
*** 996,1002 ****
  			if (c == '\n')
  				bare_lfs++;
  			while (c == '\r') {
! 				while (hash && !progress &&
  				    (bytes >= hashbytes)) {
  					(void) putchar('#');
  					(void) fflush(stdout);
--- 996,1002 ----
  			if (c == '\n')
  				bare_lfs++;
  			while (c == '\r') {
! 				while (hash && (!progress || filesize < 0) &&
  				    (bytes >= hashbytes)) {
  					(void) putchar('#');
  					(void) fflush(stdout);
*************** break2:
*** 1026,1032 ****
  			    "mode\n", bare_lfs);
  			printf("File may not have transferred correctly.\n");
  		}
! 		if (hash && !progress) {
  			if (bytes < hashbytes)
  				(void) putchar('#');
  			(void) putchar('\n');
--- 1026,1032 ----
  			    "mode\n", bare_lfs);
  			printf("File may not have transferred correctly.\n");
  		}
! 		if (hash && (!progress || filesize < 0)) {
  			if (bytes < hashbytes)
  				(void) putchar('#');
  			(void) putchar('\n');
>Audit-Trail:
>Unformatted: