Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2001 14:02:58 -0800 (PST)
From:      Bill Fenner <fenner@research.att.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/32988: libfetch debugging includes vt100-ish escape sequences
Message-ID:  <200112182202.fBIM2wt17372@stash.attlabs.att.com>

next in thread | raw e-mail | index | archive | help

>Number:         32988
>Category:       bin
>Synopsis:       libfetch debugging includes vt100-ish escape sequences
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 18 14:10:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Bill Fenner
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
AT&T Labs - Research
>Environment:
System: FreeBSD stash.attlabs.att.com 5.0-CURRENT FreeBSD 5.0-CURRENT #56: Thu Dec 13 13:30:23 PST 2001 root@stash.attlabs.att.com:/usr/obj/usr/src/sys/STASHNOV6 i386


	
>Description:
	

I'm happy to see libfetch's new debugging output - unfortunately, it
uses escape sequences that may not be supported by the current
terminal, or desired in a log file.

>How-To-Repeat:
	

"fetch -vv ftp://ftp.freebsd.org/pub/FreeBSD/nosuchfile > /tmp/log 2>&1";
examine /tmp/log for escape characters.

>Fix:

	
If you really want to have the debugging stand out, perhaps
using termcap's so/se sequences is appropriate; however, stripping
them completely suffices for me:


cvs diff: Diffing .
Index: common.c
===================================================================
RCS file: /home/ncvs/src/lib/libfetch/common.c,v
retrieving revision 1.22
diff -u -r1.22 common.c
--- common.c	19 Oct 2001 10:08:05 -0000	1.22
+++ common.c	18 Dec 2001 21:52:44 -0000
@@ -208,7 +208,7 @@
     struct addrinfo hints, *res, *res0;
     int sd, err;
 
-    DEBUG(fprintf(stderr, "\033[1m---> %s:%d\033[m\n", host, port));
+    DEBUG(fprintf(stderr, "---> %s:%d\n", host, port));
 
     if (verbose)
 	_fetch_info("looking up %s", host);
@@ -324,7 +324,7 @@
 	}
     } while (c != '\n');
     
-    DEBUG(fprintf(stderr, "\033[1m<<< %.*s\033[m", (int)*len, *buf));
+    DEBUG(fprintf(stderr, "<<< %.*s", (int)*len, *buf));
     return 0;
 }
 
@@ -348,7 +348,7 @@
     wlen = writev(fd, iov, 2);
     if (wlen < 0 || (size_t)wlen != len)
 	return -1;
-    DEBUG(fprintf(stderr, "\033[1m>>> %s\n\033[m", str));
+    DEBUG(fprintf(stderr, ">>> %s\n", str));
     return 0;
 }
 
Index: fetch.c
===================================================================
RCS file: /home/ncvs/src/lib/libfetch/fetch.c,v
retrieving revision 1.31
diff -u -r1.31 fetch.c
--- fetch.c	9 Dec 2001 15:05:19 -0000	1.31
+++ fetch.c	18 Dec 2001 21:52:44 -0000
@@ -403,12 +403,12 @@
     }
     
     DEBUG(fprintf(stderr,
-		  "scheme:   [\033[1m%s\033[m]\n"
-		  "user:     [\033[1m%s\033[m]\n"
-		  "password: [\033[1m%s\033[m]\n"
-		  "host:     [\033[1m%s\033[m]\n"
-		  "port:     [\033[1m%d\033[m]\n"
-		  "document: [\033[1m%s\033[m]\n",
+		  "scheme:   [%s]\n"
+		  "user:     [%s]\n"
+		  "password: [%s]\n"
+		  "host:     [%s]\n"
+		  "port:     [%d]\n"
+		  "document: [%s]\n",
 		  u->scheme, u->user, u->pwd,
 		  u->host, u->port, u->doc));
     
Index: ftp.c
===================================================================
RCS file: /home/ncvs/src/lib/libfetch/ftp.c,v
retrieving revision 1.72
diff -u -r1.72 ftp.c
--- ftp.c	4 Dec 2001 01:09:19 -0000	1.72
+++ ftp.c	18 Dec 2001 21:52:44 -0000
@@ -267,7 +267,7 @@
     }
     if (us->size == 0)
 	us->size = -1;
-    DEBUG(fprintf(stderr, "size: [\033[1m%lld\033[m]\n", (long long)us->size));
+    DEBUG(fprintf(stderr, "size: [%lld]\n", (long long)us->size));
 
     if ((e = _ftp_cmd(cd, "MDTM %s", s)) != FTP_FILE_STATUS) {
 	_ftp_seterr(e);
@@ -301,8 +301,8 @@
 	t = time(NULL);
     us->mtime = t;
     us->atime = t;
-    DEBUG(fprintf(stderr, "last modified: [\033[1m%04d-%02d-%02d "
-		  "%02d:%02d:%02d\033[m]\n",
+    DEBUG(fprintf(stderr, "last modified: [%04d-%02d-%02d "
+		  "%02d:%02d:%02d]\n",
 		  tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
 		  tm.tm_hour, tm.tm_min, tm.tm_sec));
     return 0;
Index: http.c
===================================================================
RCS file: /home/ncvs/src/lib/libfetch/http.c,v
retrieving revision 1.47
diff -u -r1.47 http.c
--- http.c	9 Dec 2001 15:05:58 -0000	1.47
+++ http.c	18 Dec 2001 21:52:44 -0000
@@ -146,11 +146,11 @@
     if (fetchDebug) {
 	c->total += c->chunksize;
 	if (c->chunksize == 0)
-	    fprintf(stderr, "\033[1m_http_fillbuf(): "
-		    "end of last chunk\033[m\n");
+	    fprintf(stderr, "_http_fillbuf(): "
+		    "end of last chunk\n");
 	else
-	    fprintf(stderr, "\033[1m_http_fillbuf(): "
-		    "new chunk: %lu (%lu)\033[m\n",
+	    fprintf(stderr, "_http_fillbuf(): "
+		    "new chunk: %lu (%lu)\n",
 		    (unsigned long)c->chunksize, (unsigned long)c->total);
     }
 #endif
@@ -447,8 +447,8 @@
     setlocale(LC_TIME, locale);
     if (r == NULL)
 	return -1;
-    DEBUG(fprintf(stderr, "last modified: [\033[1m%04d-%02d-%02d "
-		  "%02d:%02d:%02d\033[m]\n",
+    DEBUG(fprintf(stderr, "last modified: [%04d-%02d-%02d "
+		  "%02d:%02d:%02d]\n",
 		  tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
 		  tm.tm_hour, tm.tm_min, tm.tm_sec));
     *mtime = timegm(&tm);
@@ -467,7 +467,7 @@
 	len = len * 10 + (*p - '0');
     if (*p)
 	return -1;
-    DEBUG(fprintf(stderr, "content length: [\033[1m%lld\033[m]\n",
+    DEBUG(fprintf(stderr, "content length: [%lld]\n",
 		  (long long)len));
     *length = len;
     return 0;
@@ -495,7 +495,7 @@
 	len = len * 10 + *p - '0';
     if (*p || len < last - first + 1)
 	return -1;
-    DEBUG(fprintf(stderr, "content range: [\033[1m%lld-%lld/%lld\033[m]\n",
+    DEBUG(fprintf(stderr, "content range: [%lld-%lld/%lld]\n",
 		  (long long)first, (long long)last, (long long)len));
     *offset = first;
     *length = last - first + 1;
@@ -573,8 +573,8 @@
     char *upw, *auth;
     int r;
 
-    DEBUG(fprintf(stderr, "usr: [\033[1m%s\033[m]\n", usr));
-    DEBUG(fprintf(stderr, "pwd: [\033[1m%s\033[m]\n", pwd));
+    DEBUG(fprintf(stderr, "usr: [%s]\n", usr));
+    DEBUG(fprintf(stderr, "pwd: [%s]\n", pwd));
     if (asprintf(&upw, "%s:%s", usr, pwd) == -1)
 	return -1;
     auth = _http_base64(upw);
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200112182202.fBIM2wt17372>