bin/81495: hexdump(1) format option does not allow literal '%' in output

Hirohisa Yamaguchi umq at ueo.co.jp
Thu May 26 11:20:07 GMT 2005


>Number:         81495
>Category:       bin
>Synopsis:       hexdump(1) format option does not allow literal '%' in output
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 26 11:20:01 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Hirohisa Yamaguchi
>Release:        6.0-CURRENT
>Organization:
>Environment:
>Description:
I cannot get literal '%' in hexdump(1) output with any format_string.
Though the man page mentions exceptions in fprintf-style format,
there's no explanation why '%' cannot be printed.
>How-To-Repeat:
exec hexdump(1) with format_string which contains '%%' to get literal '%' in output.
e.g.)
 $ echo foo | hexdump -e '"" /1 "%%%02x" "\n"'

I got:
 hexdump: %%: bad conversion character
>Fix:
a) If there's any historical reasons to be so, update the man page; to mention that literal '%' cannot be included in output.

or

b) fix it.
I wrote a patch, not thoroughly tested. And flag name is, perhaps, not appropriate.

--- src/usr.bin/hexdump/parse.c.orig	Thu Jul 22 22:14:42 2004
+++ src/usr.bin/hexdump/parse.c	Thu May 26 19:22:28 2005
@@ -383,6 +383,10 @@ isint2:					switch(fu->bcnt) {
 					badconv(p1);
 				}
 				break;
+			case '%':
+				/* skip over '%' */
+				pr->flags = F_ADDRESS;
+				break;
 			default:
 				p1[1] = '\0';
 				badconv(p1);

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list