Ingo Schwarze <[email protected]> writes:

>     prevent gnulib from crashing while trying to replace printf(3)
>     
>     As expected, the newer gnulib used in groff-1.24 has become even
>     more aggressive disparaging our printf(3) implementation for multiple
>     bad reasons.  Getting it to build at all has become significantly
>     harder.  Notably, the pointless quibbles about errno.h and strerror(0)
>     appear to make gnulib want to replace the entire printf(3)
>     implementation, unless i'm totally misinterpreting what is going
>     on in the build - which might be the case because both the gnulib
>     code and the ./configure code are utterly unreadable: the former
>     because of its totally excessive use of #if directives, the latter
>     because it has no indentation whatsoever that could help reading
>     it.  So i'm not completely sure this is the minimal fix, though it
>     does look like every single one of the seven tweaks is really
>     required.
>     
>     With this fix, the build progresses slightly further.
>     Now grodvi builds; it's now grops that explodes.

On OpenBSD printf is replaced by Gnulib for the following reasons [1]:

1. It does not support C23 size specifiers (w8, w16, w32, w64, wf8,
wf16, wf32, wf64).

2. It's %a directive improperly rounds. Here is a test program:

    $ cat main.c 
    #include <stdio.h>
    int
    main (void)
    {
      static char buf[100];
      sprintf (buf, "%.0a", 1.51);
      printf ("%s\n", buf);
      return 0;
    }

When run on GNU/Linux amd64:

    $ cc main.c
    $ ./a.out 
    0x2p+0

When run on OpenBSD 7.8 amd64:

    $ cc main.c
    $ ./a.out                                                                   
                                                                
    0x1p+0

3. It does not support the %b directive required by C23.

4. Upon exhausting memory, OpenBSD's printf returns 0 instead of -1
despite correctly setting errno to ENOMEM.

Collin

[1] https://www.gnu.org/software/gnulib/manual/html_node/printf.html

Reply via email to