On Sun, Dec 10, 2017 at 03:29:51PM +0100, Theo Buehler wrote:
> The printf(3) manual says that DOU are deprecated but are supposed to
> behave the same way as ld, lo and lu.

I forgot to say that I found this while looking into the code coverage
report by Sergey Bronnikov and found that these format strings aren't
covered by our tests.

One small comment below.

> However:
> $ jot -w '%ld' 5 -2
> -2
> -1
> 0
> 1
> 2
> $ jot -w '%D' 5 -2
> 4294967294
> 4294967295
> 0
> 1
> 2
> $ jot -w '%ld' 4 4294967294 
> 4294967294
> 4294967295
> 4294967296
> 4294967297
> $ jot -w '%D' 4 4294967294
> jot: range error in conversion: 4294967294.000000
> 
> Similarly for %O and %U.
> 
> This makes %{D,O,U} synonymous with %l{d,o,u}:
> 
> Index: usr.bin/jot/jot.c
> ===================================================================
> RCS file: /var/cvs/src/usr.bin/jot/jot.c,v
> retrieving revision 1.36
> diff -u -p -r1.36 jot.c
> --- usr.bin/jot/jot.c 2 Sep 2016 14:23:09 -0000       1.36
> +++ usr.bin/jot/jot.c 10 Dec 2017 14:26:47 -0000
> @@ -420,12 +420,16 @@ getformat(void)
>                       intdata = true;
>                       break;
>               case 'D':
> +                     /* %lD is undefined */
>                       if (!longdata) {
> +                             longdata = true; /* %D behaves as %ld */
>                               intdata = true;
>                               break;
>                       }
>               case 'O': case 'U':
> +                     /* %lO and %lU are undefined */
>                       if (!longdata) {
> +                             longdata = true; /* %O, %U behave as %ld, %lu */

I'll change %ld into %lo in this comment before committing.

>                               intdata = nosign = true;
>                               break;
>                       }
> 

Reply via email to