BSD and USG "printf" and capital letters in hex numbers

Guy Harris guy at rlgvax.UUCP
Sat Aug 20 10:53:47 AEST 1983


A while ago, somebody complained that there was no way to get "printf" to put
out capital letters for hex numbers (they were producing output to be sent
to a PROM burner which only accepted capital letters).  They mentioned that
USG UNIX supported "%X" to do exactly this.

Guess what?

If you change the entry in the table in the 4.?BSD "doprnt.s" for the "X"
format from "hex" to "capital", you will end up with a "_doprnt" (hence,
"*printf") which supports (from what I can tell) *all* of the USG printf
features (%#[ox...], %2.2d as equivalent to %0d, etc..  (Try diffing the
"doprnt.s" from 4.?BSD, the doprnt.C (sic) from System III, and the doprnt.s
from System V.)

I can just see AT&T's new advertising slogan for UNIX:

"UNIX* - always a treasure hunt!"

*UNIX is a Trademark of Bell Laboratories.

(Yes, this one *might* be Berkeley's fault, but if that "doprnt.s" came from
32V it's Bell's fault.  I think the recent discussion of the "-depth" option
indicates that the game "Know your UNIX" is still a treasure hunt.  By the
way, until somebody mentioned "find -inum" I didn't know that option existed;
I looked in my 4.1BSD manual and, sure enough, it was there.  Then I looked
at the V7 and System III "find.c" and, sure enough, it was there...  Anybody
who knows of undocumented features that either 1) have been around long enough
that they're probably undocumented just because somebody forgot about them or
2) that get documented in later releases - i.e., they're not unsupported
features which shouldn't be used because they'll go away - should probably
make them known.  How many of us have used "#if defined(...)", even though
it wasn't officially documented until System V (along with the infamous
__FILE__ and __LINE__)?)

	Guy Harris
	{seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list