bin/86485: [PATCH] hexdump(1): hexdump -s speedup on /dev

Toby Peterson toby at apple.com
Sun Jun 22 02:30:04 UTC 2008


The following reply was made to PR bin/86485; it has been noted by GNATS.

From: Toby Peterson <toby at apple.com>
To: Garrett Cooper <yanefbsd at gmail.com>
Cc: bug-followup at FreeBSD.org
Subject: Re: bin/86485: [PATCH] hexdump(1): hexdump -s speedup on /dev
Date: Sat, 21 Jun 2008 19:05:21 -0700

 --Apple-Mail-7--430079199
 Content-Type: text/plain;
 	charset=US-ASCII;
 	format=flowed;
 	delsp=yes
 Content-Transfer-Encoding: 7bit
 
 On Jun 21, 2008, at 1:47 PM, Garrett Cooper wrote:
 
 > Hi,
 > Could you please resubmit the patch (link is broken)?
 > Thanks,
 > -Garrett
 
 
 That webserver is long defunct, but the attached patch should resolve  
 the issue.
 
 - Toby
 
 --Apple-Mail-7--430079199
 Content-Disposition: attachment;
 	filename=hexdump-fseeko.diff
 Content-Type: application/octet-stream;
 	x-unix-mode=0644;
 	name="hexdump-fseeko.diff"
 Content-Transfer-Encoding: 7bit
 
 ? hexdump
 ? hexdump.1.gz
 ? od.1.gz
 Index: Makefile
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/hexdump/Makefile,v
 retrieving revision 1.9
 diff -u -r1.9 Makefile
 --- Makefile	22 Jul 2004 13:14:42 -0000	1.9
 +++ Makefile	22 Jun 2008 02:01:24 -0000
 @@ -7,6 +7,6 @@
  MLINKS=	hexdump.1 hd.1
  LINKS=	${BINDIR}/hexdump ${BINDIR}/od
  LINKS+=	${BINDIR}/hexdump ${BINDIR}/hd
 -WARNS?=	6
 +WARNS?=	1
  
  .include <bsd.prog.mk>
 Index: display.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/hexdump/display.c,v
 retrieving revision 1.22
 diff -u -r1.22 display.c
 --- display.c	4 Aug 2004 02:47:32 -0000	1.22
 +++ display.c	22 Jun 2008 02:01:24 -0000
 @@ -44,6 +44,7 @@
  
  #include <ctype.h>
  #include <err.h>
 +#include <errno.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
 @@ -384,12 +385,13 @@
  			return;
  		}
  	}
 -	if (S_ISREG(sb.st_mode)) {
 -		if (fseeko(stdin, skip, SEEK_SET))
 -			err(1, "%s", fname);
 +	/* try to seek first; fall back on ESPIPE */
 +	if (fseeko(stdin, skip, SEEK_SET) == 0) {
  		address += skip;
  		skip = 0;
  	} else {
 +		if (errno != ESPIPE)
 +			err(1, "%s", fname);
  		for (cnt = 0; cnt < skip; ++cnt)
  			if (getchar() == EOF)
  				break;
 
 --Apple-Mail-7--430079199
 Content-Type: text/plain;
 	charset=US-ASCII;
 	format=flowed
 Content-Transfer-Encoding: 7bit
 
 
 
 --Apple-Mail-7--430079199--


More information about the freebsd-bugs mailing list