Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!ut-sally!husc6!rutgers!labrea!decwrl!spar!hunt
From: hunt@spar.SPAR.SLB.COM (Neil Hunt)
Newsgroups: comp.lang.c
Subject: Re: printf's %D, %O, and %X
Message-ID: <44@spar.SPAR.SLB.COM>
Date: Mon, 27-Jul-87 13:02:30 EDT
Article-I.D.: spar.44
Posted: Mon Jul 27 13:02:30 1987
Date-Received: Tue, 28-Jul-87 04:59:41 EDT
References: <1667@xanth.UUCP> <24183@sun.uucp>
Reply-To: hunt@spar.UUCP (Neil Hunt)
Organization: Schlumberger Palo Alto Research - CASLAB
Lines: 28

>> For a long time now I've been under the impression that using "%D"," %O", and
>> "%X" in a printf() conversion spec is equivalent to using "%ld", "%lo", and
>> "%lx".  However when I looked at the documentation for printf (4.3 BSD) I
>> discovered that capitalizing "%d, "%o", and "%x" are not mentioned at all.
>> 
>> Do anyone know if printf() used to handle "%D", etc. as outlined above?
>
>You should use %l[dox] rather than %[DOX], both because the former is
>supported by more C implementations than the latter and because the
>former is the form that's blessed by the current ANSI C draft
>standard (and likely to be the form blessed by the final standard).
>Furthermore, in some cases %D can screw you up; if a %D in a format
>string is followed by another %, all hell breaks loose if you check
>the file into SCCS, since that sequence is expanded to the current
>date when the file is gotten.  (This fouled up a couple of utilities
>in 4.2BSD.)

Notice that in [fs]scanf there is a similar problem, and here the
capitalising convention is still used (in Sun 3.2, at least):

  The conversion chanacters d, u, o, and x may be capitalized
  or preceded by l or h to indicate that a pointer to long or
  to short rather than to int is in the argument list.  Simi-
  larly, the conversion characters e, f, and g may be preceded
  by l to indicate that a pointer to  double  rather  than  to
  float is in the argument list.

Neil/.