public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links
@ 2022-09-18 22:16 Alex Colomar
  2022-09-18 22:36 ` Alex Colomar
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Alex Colomar @ 2022-09-18 22:16 UTC (permalink / raw)
  To: linux-man, libc-alpha; +Cc: Alex Colomar, Walter Harms

Reported-by: Walter Harms <wharms@bfs.de>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
---

Hello all,

I wrote this manual page after on an old discussion with Walter,
which I postponed too much.  I had a long time ago written some
using register_printf_specifier(3), and I remember having a lot of
trouble using, since there's few documentation about it, if at
all.  I had to guess much of it.

I wrote this manual page with a full example of using it (I'm
sorry I have never used the other two, so I have no examples for
them).  But maybe this one, which is quite complete about the
function it uses, will make it easier to understand the related
APIs.  If someone comes up with an example for the rest, I'd like
to consider it (although I fear the EXAMPLES are taking too much
space, but it may be worth it...).

And it seems I also need some help with my own example, since I
discovered there's some sort of undefined behavior in it (just run
it several times and see; some work, but some do show weird stuff
for the cases where with modifiers that make the number wider than
unsigned int).  If you find the undefined behavior, please show
me.  I'll continue debugging, anyway.

Well, please review this page, and comment anything you don't like.

Thank you very much in advance,

Alex

 man3/register_printf_modifier.3  |   1 +
 man3/register_printf_speficier.3 | 439 +++++++++++++++++++++++++++++++
 man3/register_printf_type.3      |   1 +
 3 files changed, 441 insertions(+)
 create mode 100644 man3/register_printf_modifier.3
 create mode 100644 man3/register_printf_speficier.3
 create mode 100644 man3/register_printf_type.3

diff --git a/man3/register_printf_modifier.3 b/man3/register_printf_modifier.3
new file mode 100644
index 000000000..296a92dd3
--- /dev/null
+++ b/man3/register_printf_modifier.3
@@ -0,0 +1 @@
+.so man3/register_printf_specifier.3
diff --git a/man3/register_printf_speficier.3 b/man3/register_printf_speficier.3
new file mode 100644
index 000000000..8911e293f
--- /dev/null
+++ b/man3/register_printf_speficier.3
@@ -0,0 +1,439 @@
+.\" Copyright (C) 2022 Alejandro Colomar <alx.manpages@gmail.com>
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.TH register_printf_specifier 3 2022-09-18 "Linux man-pages (unreleased)"
+.SH NAME
+register_printf_specifier,
+register_printf_modifier,
+register_printf_type
+\- define custom behavior for printf-like functions
+.SH LIBRARY
+Standard C library
+.RI ( libc ", " \-lc )
+.SH SYNOPSIS
+.nf
+.B #include <printf.h>
+.PP
+.BI "typedef int printf_function(FILE *" stream ,
+.BI "                            const struct printf_info *" info ,
+.BI "                            const void *const *" args );
+.BI "typedef int printf_arginfo_size_function(const struct printf_info *" info ,
+.BI "                            size_t " n ", int *" argtypes ", int *" size );
+.BI "typedef void printf_va_arg_function(void *" mem ", va_list *" ap );
+.PP
+.BI "int register_printf_specifier(int " spec ", printf_function " func ,
+.BI "                            printf_arginfo_size_function " arginfo );
+.BI "int register_printf_modifier(const wchar_t *" str );
+.BI "int register_printf_type(printf_va_arg_function " fct );
+.fi
+.SH DESCRIPTION
+These functions serve to extend and/or modify the behavior of the
+.BR printf (3)
+family of functions.
+.SS register_printf_specifier()
+This function registers a custom conversion specifier for the
+.BR printf (3)
+family of functions.
+.PP
+.I spec
+is a character,
+which will be used as a conversion specifier in the format string.
+.PP
+.I func
+is a callback function that will be
+executed by the
+.BR printf (3)
+family of functions
+to format the input arguments into the output
+.I stream
+(transparently including the case of an output string).
+.PP
+.I arginfo
+is a callback function that will be executed by the
+.BR printf (3)
+family of functions
+to know how many arguments should be parsed for the custom specifier
+and also their types.
+.SS register_printf_modifier()
+TODO
+.SS register_printf_type()
+TODO
+.SH RETURN VALUE
+.BR \%register_printf_specifier (),
+.BR \%register_printf_modifier (),
+and
+.BR \%register_printf_type ()
+return zero on success, or \-1 on error.
+.SS Callbacks
+The callback of type
+.I printf_function
+should return the number of characters written,
+or \-1 on error.
+.PP
+The callback of type
+.I \%printf_arginfo_size_function
+should return the number of arguments to be parsed by this specifier.
+It also passes information about the type of those arguments
+to the caller through
+.IR argtypes .
+On error, it should return \-1.
+.SH ERRORS
+TODO
+.SH VERSIONS
+.BR \%register_printf_function (3)
+is an older function similar to
+.BR \%register_printf_specifier,
+and is now deprecated.
+That function can't handle user-defined types.
+.PP
+.BR \%register_printf_specifier ()
+superseeds
+.BR \%register_printf_function (3).
+.SH STANDARDS
+These nonstandard functions are present in glibc.
+.SH EXAMPLES
+The following example program registers the 'b' and 'B' specifiers
+to print integers in binary format,
+mirroring rules for other unsigned conversion specifiers like 'x' and 'u'.
+This can be used to print in binary prior to C23.
+.PP
+.\" SRC BEGIN (register_printf_specifier.c)
+.EX
+/* This code is in the public domain */
+
+#include <err.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include <printf.h>
+
+#define GROUP_SEP  '_'
+
+struct Printf_Pad {
+    char ch;
+    int len;
+};
+
+static int printf_b_init(void);
+static int b_printf(FILE *stream, const struct printf_info *info,
+                    const void *const args[]);
+static int b_arginf_sz(const struct printf_info *info,
+                    size_t n, int argtypes[n], int *size);
+
+static uintmax_t b_value(const struct printf_info *info,
+                    const void *arg);
+static size_t b_bin_repr(char bin[UINTMAX_WIDTH],
+                    const struct printf_info *info, const void *arg);
+static size_t b_bin_len(const struct printf_info *info, ptrdiff_t min_len);
+static size_t b_pad_len(const struct printf_info *info, ptrdiff_t bin_len);
+static ssize_t b_print_prefix(FILE *stream, const struct printf_info *info);
+static ssize_t b_pad_zeros(FILE *stream, const struct printf_info *info,
+                    size_t min_len);
+static ssize_t b_print_number(FILE *stream, const struct printf_info *info,
+                    const char bin[UINTMAX_WIDTH],
+                    size_t min_len, size_t bin_len);
+static char pad_ch(const struct printf_info *info);
+static ssize_t pad_spaces(FILE *stream, size_t pad_len);
+
+int
+main(void)
+{
+    if (printf_b_init() == \-1)
+        err(EXIT_FAILURE, "printf_b_init");
+
+    printf("....----....----....----....----\en");
+    printf("%llb;\en", 0x5Ellu);
+    printf("%lB;\en", 0x5Elu);
+    printf("%b;\en", 0x5Eu);
+    printf("%hB;\en", 0x5Eu);
+    printf("%hhb;\en", 0x5Eu);
+    printf("%jb;\en", (uintmax_t)0x5E);
+    printf("%zb;\en", (size_t)0x5E);
+    printf("....----....----....----....----\en");
+    printf("%#b;\en", 0x5Eu);
+    printf("%#B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%10b;\en", 0x5Eu);
+    printf("%010b;\en", 0x5Eu);
+    printf("%.10b;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%\-10B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%'B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");   
+    printf("....----....----....----....----\en");
+    printf("%#16.12b;\en", 0xAB);
+    printf("%\-#'20.12b;\en", 0xAB);
+    printf("%#'020B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#020B;\en", 0xAB);
+    printf("%'020B;\en", 0xAB);
+    printf("%020B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#021B;\en", 0xAB);
+    printf("%'021B;\en", 0xAB);
+    printf("%021B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#022B;\en", 0xAB);
+    printf("%'022B;\en", 0xAB);
+    printf("%022B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#023B;\en", 0xAB);
+    printf("%'023B;\en", 0xAB);
+    printf("%023B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%\-#'19.11b;\en", 0xAB);
+    printf("%#'019B;\en", 0xAB);
+    printf("%#019B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%'019B;\en", 0xAB);
+    printf("%019B;\en", 0xAB);
+    printf("%#016b;\en", 0xAB);
+    printf("....----....----....----....----\en");
+
+    return 0;
+}
+
+static int
+printf_b_init(void)
+{
+    if (register_printf_specifier('b', b_printf, b_arginf_sz))
+        return -1;
+    if (register_printf_specifier('B', b_printf, b_arginf_sz))
+        return -1;
+    return 0;
+}
+
+static int
+b_printf(FILE *stream, const struct printf_info *info,
+         const void *const args[])
+{
+    char               bin[UINTMAX_WIDTH];
+    size_t             min_len, bin_len;
+    ssize_t            len, tmp;
+    struct Printf_Pad  pad = {0};
+
+    len = 0;
+
+    min_len = b_bin_repr(bin, info, args[0]);
+    bin_len = b_bin_len(info, min_len);
+
+    pad.ch = pad_ch(info);
+    if (pad.ch == ' ')
+        pad.len = b_pad_len(info, bin_len);
+
+    /* Padding with ' ' (right aligned) */
+    if ((pad.ch == ' ') && !info->left) {
+        tmp = pad_spaces(stream, pad.len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* "0b"/"0B" prefix */
+    if (info->alt) {
+        tmp = b_print_prefix(stream, info);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* Padding with '0' */
+    if (pad.ch == '0') {
+        tmp = b_pad_zeros(stream, info, min_len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* Print number (including leading 0s to fill precision) */
+    tmp = b_print_number(stream, info, bin, min_len, bin_len);
+    if (tmp == EOF)
+        return EOF;
+    len += tmp;
+
+    /* Padding with ' ' (left aligned) */
+    if (info\->left) {
+        tmp = pad_spaces(stream, pad.len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    return len;
+}
+
+static int
+b_arginf_sz([[maybe_unused]] const struct printf_info *info,
+            size_t n, int argtypes[n], [[maybe_unused]] int *size)
+{
+    if (n < 1)
+        return -1;
+
+    argtypes[0] = PA_INT;
+
+    return 1;
+}
+
+static uintmax_t
+b_value(const struct printf_info *info, const void *arg)
+{
+    if (info\->is_long_double)
+        return *(const unsigned long long *)arg;
+    if (info\->is_long)
+        return *(const unsigned long *)arg;
+
+    /* 'h' and 'hh' are both promoted to int */
+    return *(const unsigned int *)arg;
+}
+
+static size_t
+b_bin_repr(char bin[UINTMAX_WIDTH],
+           const struct printf_info *info, const void *arg)
+{
+    size_t     min_len;
+    uintmax_t  val;
+
+    val = b_value(info, arg);
+
+    bin[0] = '0';
+    for (min_len = 0; val; min_len++) {
+        bin[min_len] = '0' + (val % 2);
+        val >>= 1;
+    }
+
+    return MAX(min_len, 1);
+}
+
+static size_t
+b_bin_len(const struct printf_info *info, ptrdiff_t min_len)
+{
+    return MAX(info\->prec, min_len);
+}
+
+static size_t
+b_pad_len(const struct printf_info *info, ptrdiff_t bin_len)
+{
+    ptrdiff_t  pad_len;
+
+    pad_len = info\->width \- bin_len;
+    if (info\->alt)
+        pad_len \-= 2;
+    if (info\->group)
+        pad_len \-= (bin_len \- 1) / 4;
+
+    return MAX(pad_len, 0);
+}
+
+static ssize_t
+b_print_prefix(FILE *stream, const struct printf_info *info)
+{
+    ssize_t len;
+
+    len = 0;
+    if (fputc('0', stream) == EOF)
+        return EOF;
+    len++;
+    if (fputc(info\->spec, stream) == EOF)
+        return EOF;
+    len++;
+
+    return len;
+}
+
+static ssize_t
+b_pad_zeros(FILE *stream, const struct printf_info *info,
+            size_t min_len)
+{
+    size_t   tmp;
+    ssize_t  len;
+
+    len = 0;
+    tmp = info\->width \- (info\->alt * 2);
+    if (info\->group)
+        tmp \-= tmp / 5 \- !(tmp % 5);
+    for (size_t i = tmp \- 1; i + 1 < min_len; i\-\-) {
+        if (fputc('0', stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4))
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+
+static ssize_t
+b_print_number(FILE *stream, const struct printf_info *info,
+               const char bin[UINTMAX_WIDTH],
+               size_t min_len, size_t bin_len)
+{
+    ssize_t  len;
+
+    len = 0;
+
+    /* Print leading zeros to fill precision */
+    for (size_t i = bin_len \- 1; i < bin_len; i\-\-) {
+        if (fputc('0', stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4))
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    /* Print number */
+    for (size_t i = min_len \- 1; i < min_len; i\-\-) {
+        if (fputc(bin[i], stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4) || !i)
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+
+static char
+pad_ch(const struct printf_info *info)
+{
+    if ((info\->prec != \-1) || (info\->pad == ' ') || info\->left)
+        return ' ';
+    return '0';
+}
+
+static ssize_t
+pad_spaces(FILE *stream, size_t pad_len)
+{
+    ssize_t  len;
+
+    len = 0;
+    for (size_t i = pad_len; i < pad_len; i\-\-) {
+        if (fputc(' ', stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+.EE
+.\" SRC END
+.SH SEE ALSO
+TODO
diff --git a/man3/register_printf_type.3 b/man3/register_printf_type.3
new file mode 100644
index 000000000..296a92dd3
--- /dev/null
+++ b/man3/register_printf_type.3
@@ -0,0 +1 @@
+.so man3/register_printf_specifier.3
-- 
2.37.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links
  2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
@ 2022-09-18 22:36 ` Alex Colomar
  2022-09-18 22:38   ` Alex Colomar
  2022-09-18 23:09 ` [RFC v2] " Alex Colomar
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Alex Colomar @ 2022-09-18 22:36 UTC (permalink / raw)
  To: linux-man, libc-alpha; +Cc: Walter Harms


[-- Attachment #1.1: Type: text/plain, Size: 1883 bytes --]

On 9/19/22 00:16, Alex Colomar wrote:
> And it seems I also need some help with my own example, since I
> discovered there's some sort of undefined behavior in it (just run
> it several times and see; some work, but some do show weird stuff
> for the cases where with modifiers that make the number wider than
> unsigned int).  If you find the undefined behavior, please show
> me.  I'll continue debugging, anyway.
> 


This is the UB I'm experiencing:

alx@dell7760:~/tmp$ ./a.out | head
....----....----....----....----
0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
00000001011110;
00000001011110;
00000001011110;
0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
....----....----....----....----
0b00000001011110;
alx@dell7760:~/tmp$ ./a.out | head
....----....----....----....----
00000001011110;
00000001011110;
00000001011110;
00000001011110;
00000001011110;
00000001011110;
00000001011110;
....----....----....----....----
0b00000001011110;


The first run is wrong, and the second one is correct.  The relevant 
printf(3) lines are:


            printf("....----....----....----....----\n");
            printf("%llb;\n", 0x5Ellu);
            printf("%lB;\n", 0x5Elu);
            printf("%b;\n", 0x5Eu);
            printf("%hB;\n", 0x5Eu);
            printf("%hhb;\n", 0x5Eu);
            printf("%jb;\n", (uintmax_t)0x5E);
            printf("%zb;\n", (size_t)0x5E);
            printf("....----....----....----....----\n");
            printf("%#b;\n", 0x5Eu);


Cheers,

Alex


-- 
<http://www.alejandro-colomar.es/>


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links
  2022-09-18 22:36 ` Alex Colomar
@ 2022-09-18 22:38   ` Alex Colomar
  0 siblings, 0 replies; 11+ messages in thread
From: Alex Colomar @ 2022-09-18 22:38 UTC (permalink / raw)
  To: linux-man, libc-alpha; +Cc: Walter Harms


[-- Attachment #1.1: Type: text/plain, Size: 2252 bytes --]

On 9/19/22 00:36, Alex Colomar wrote:
> On 9/19/22 00:16, Alex Colomar wrote:
>> And it seems I also need some help with my own example, since I
>> discovered there's some sort of undefined behavior in it (just run
>> it several times and see; some work, but some do show weird stuff
>> for the cases where with modifiers that make the number wider than
>> unsigned int).  If you find the undefined behavior, please show
>> me.  I'll continue debugging, anyway.
>>
> 
> 
> This is the UB I'm experiencing:
> 
> alx@dell7760:~/tmp$ ./a.out | head
> ....----....----....----....----
> 0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
> 0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
> 00000001011110;
> 00000001011110;
> 00000001011110;
> 0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
> 0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
> ....----....----....----....----
> 0b00000001011110;
> alx@dell7760:~/tmp$ ./a.out | head
> ....----....----....----....----
> 00000001011110;
> 00000001011110;
> 00000001011110;
> 00000001011110;
> 00000001011110;
> 00000001011110;
> 00000001011110;
> ....----....----....----....----
> 0b00000001011110;
> 

Oh, and I have extra zeros, but that's a bug I introduced today.  Before 
that, the other one is still there. :/

> 
> The first run is wrong, and the second one is correct.  The relevant 
> printf(3) lines are:
> 
> 
>             printf("....----....----....----....----\n");
>             printf("%llb;\n", 0x5Ellu);
>             printf("%lB;\n", 0x5Elu);
>             printf("%b;\n", 0x5Eu);
>             printf("%hB;\n", 0x5Eu);
>             printf("%hhb;\n", 0x5Eu);
>             printf("%jb;\n", (uintmax_t)0x5E);
>             printf("%zb;\n", (size_t)0x5E);
>             printf("....----....----....----....----\n");
>             printf("%#b;\n", 0x5Eu);
> 
> 
> Cheers,
> 
> Alex
> 
> 

-- 
<http://www.alejandro-colomar.es/>


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC v2] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links
  2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
  2022-09-18 22:36 ` Alex Colomar
@ 2022-09-18 23:09 ` Alex Colomar
  2022-09-19  8:55   ` Alex Colomar
  2022-09-18 23:18 ` [PATCH] " G. Branden Robinson
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Alex Colomar @ 2022-09-18 23:09 UTC (permalink / raw)
  To: linux-man, libc-alpha; +Cc: Alex Colomar, Walter Harms

Suggested-by: Walter Harms <wharms@bfs.de>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
---

v2:

 - bug about padding zeros fixed.  But UB about 'l', 'll' (and 'j', 'z') not.


 man3/register_printf_modifier.3  |   1 +
 man3/register_printf_speficier.3 | 439 +++++++++++++++++++++++++++++++
 man3/register_printf_type.3      |   1 +
 3 files changed, 441 insertions(+)
 create mode 100644 man3/register_printf_modifier.3
 create mode 100644 man3/register_printf_speficier.3
 create mode 100644 man3/register_printf_type.3

diff --git a/man3/register_printf_modifier.3 b/man3/register_printf_modifier.3
new file mode 100644
index 000000000..296a92dd3
--- /dev/null
+++ b/man3/register_printf_modifier.3
@@ -0,0 +1 @@
+.so man3/register_printf_specifier.3
diff --git a/man3/register_printf_speficier.3 b/man3/register_printf_speficier.3
new file mode 100644
index 000000000..7e9d3e700
--- /dev/null
+++ b/man3/register_printf_speficier.3
@@ -0,0 +1,439 @@
+.\" Copyright (C) 2022 Alejandro Colomar <alx.manpages@gmail.com>
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.TH register_printf_specifier 3 2022-09-18 "Linux man-pages (unreleased)"
+.SH NAME
+register_printf_specifier,
+register_printf_modifier,
+register_printf_type
+\- define custom behavior for printf-like functions
+.SH LIBRARY
+Standard C library
+.RI ( libc ", " \-lc )
+.SH SYNOPSIS
+.nf
+.B #include <printf.h>
+.PP
+.BI "typedef int printf_function(FILE *" stream ,
+.BI "                            const struct printf_info *" info ,
+.BI "                            const void *const *" args );
+.BI "typedef int printf_arginfo_size_function(const struct printf_info *" info ,
+.BI "                            size_t " n ", int *" argtypes ", int *" size );
+.BI "typedef void printf_va_arg_function(void *" mem ", va_list *" ap );
+.PP
+.BI "int register_printf_specifier(int " spec ", printf_function " func ,
+.BI "                            printf_arginfo_size_function " arginfo );
+.BI "int register_printf_modifier(const wchar_t *" str );
+.BI "int register_printf_type(printf_va_arg_function " fct );
+.fi
+.SH DESCRIPTION
+These functions serve to extend and/or modify the behavior of the
+.BR printf (3)
+family of functions.
+.SS register_printf_specifier()
+This function registers a custom conversion specifier for the
+.BR printf (3)
+family of functions.
+.PP
+.I spec
+is a character,
+which will be used as a conversion specifier in the format string.
+.PP
+.I func
+is a callback function that will be
+executed by the
+.BR printf (3)
+family of functions
+to format the input arguments into the output
+.I stream
+(transparently including the case of an output string).
+.PP
+.I arginfo
+is a callback function that will be executed by the
+.BR printf (3)
+family of functions
+to know how many arguments should be parsed for the custom specifier
+and also their types.
+.SS register_printf_modifier()
+TODO
+.SS register_printf_type()
+TODO
+.SH RETURN VALUE
+.BR \%register_printf_specifier (),
+.BR \%register_printf_modifier (),
+and
+.BR \%register_printf_type ()
+return zero on success, or \-1 on error.
+.SS Callbacks
+The callback of type
+.I printf_function
+should return the number of characters written,
+or \-1 on error.
+.PP
+The callback of type
+.I \%printf_arginfo_size_function
+should return the number of arguments to be parsed by this specifier.
+It also passes information about the type of those arguments
+to the caller through
+.IR argtypes .
+On error, it should return \-1.
+.SH ERRORS
+TODO
+.SH VERSIONS
+.BR \%register_printf_function (3)
+is an older function similar to
+.BR \%register_printf_specifier,
+and is now deprecated.
+That function can't handle user-defined types.
+.PP
+.BR \%register_printf_specifier ()
+superseeds
+.BR \%register_printf_function (3).
+.SH STANDARDS
+These nonstandard functions are present in glibc.
+.SH EXAMPLES
+The following example program registers the 'b' and 'B' specifiers
+to print integers in binary format,
+mirroring rules for other unsigned conversion specifiers like 'x' and 'u'.
+This can be used to print in binary prior to C23.
+.PP
+.\" SRC BEGIN (register_printf_specifier.c)
+.EX
+/* This code is in the public domain */
+
+#include <err.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include <printf.h>
+
+#define GROUP_SEP  '_'
+
+struct Printf_Pad {
+    char    ch;
+    size_t  len;
+};
+
+static int printf_b_init(void);
+static int b_printf(FILE *stream, const struct printf_info *info,
+                    const void *const args[]);
+static int b_arginf_sz(const struct printf_info *info,
+                    size_t n, int argtypes[n], int *size);
+
+static uintmax_t b_value(const struct printf_info *info,
+                    const void *arg);
+static size_t b_bin_repr(char bin[UINTMAX_WIDTH],
+                    const struct printf_info *info, const void *arg);
+static size_t b_bin_len(const struct printf_info *info, ptrdiff_t min_len);
+static size_t b_pad_len(const struct printf_info *info, ptrdiff_t bin_len);
+static ssize_t b_print_prefix(FILE *stream, const struct printf_info *info);
+static ssize_t b_pad_zeros(FILE *stream, const struct printf_info *info,
+                    ptrdiff_t min_len);
+static ssize_t b_print_number(FILE *stream, const struct printf_info *info,
+                    const char bin[UINTMAX_WIDTH],
+                    size_t min_len, size_t bin_len);
+static char pad_ch(const struct printf_info *info);
+static ssize_t pad_spaces(FILE *stream, size_t pad_len);
+
+int
+main(void)
+{
+    if (printf_b_init() == \-1)
+        err(EXIT_FAILURE, "printf_b_init");
+
+    printf("....----....----....----....----\en");
+    printf("%llb;\en", 0x5Ellu);
+    printf("%lB;\en", 0x5Elu);
+    printf("%b;\en", 0x5Eu);
+    printf("%hB;\en", 0x5Eu);
+    printf("%hhb;\en", 0x5Eu);
+    printf("%jb;\en", (uintmax_t)0x5E);
+    printf("%zb;\en", (size_t)0x5E);
+    printf("....----....----....----....----\en");
+    printf("%#b;\en", 0x5Eu);
+    printf("%#B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%10b;\en", 0x5Eu);
+    printf("%010b;\en", 0x5Eu);
+    printf("%.10b;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%\-10B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%'B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");   
+    printf("....----....----....----....----\en");
+    printf("%#16.12b;\en", 0xAB);
+    printf("%\-#'20.12b;\en", 0xAB);
+    printf("%#'020B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#020B;\en", 0xAB);
+    printf("%'020B;\en", 0xAB);
+    printf("%020B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#021B;\en", 0xAB);
+    printf("%'021B;\en", 0xAB);
+    printf("%021B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#022B;\en", 0xAB);
+    printf("%'022B;\en", 0xAB);
+    printf("%022B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#023B;\en", 0xAB);
+    printf("%'023B;\en", 0xAB);
+    printf("%023B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%\-#'19.11b;\en", 0xAB);
+    printf("%#'019B;\en", 0xAB);
+    printf("%#019B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%'019B;\en", 0xAB);
+    printf("%019B;\en", 0xAB);
+    printf("%#016b;\en", 0xAB);
+    printf("....----....----....----....----\en");
+
+    return 0;
+}
+
+static int
+printf_b_init(void)
+{
+    if (register_printf_specifier('b', b_printf, b_arginf_sz))
+        return -1;
+    if (register_printf_specifier('B', b_printf, b_arginf_sz))
+        return -1;
+    return 0;
+}
+
+static int
+b_printf(FILE *stream, const struct printf_info *info,
+         const void *const args[])
+{
+    char               bin[UINTMAX_WIDTH];
+    size_t             min_len, bin_len;
+    ssize_t            len, tmp;
+    struct Printf_Pad  pad = {0};
+
+    len = 0;
+
+    min_len = b_bin_repr(bin, info, args[0]);
+    bin_len = b_bin_len(info, min_len);
+
+    pad.ch = pad_ch(info);
+    if (pad.ch == ' ')
+        pad.len = b_pad_len(info, bin_len);
+
+    /* Padding with ' ' (right aligned) */
+    if ((pad.ch == ' ') && !info->left) {
+        tmp = pad_spaces(stream, pad.len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* "0b"/"0B" prefix */
+    if (info->alt) {
+        tmp = b_print_prefix(stream, info);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* Padding with '0' */
+    if (pad.ch == '0') {
+        tmp = b_pad_zeros(stream, info, min_len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* Print number (including leading 0s to fill precision) */
+    tmp = b_print_number(stream, info, bin, min_len, bin_len);
+    if (tmp == EOF)
+        return EOF;
+    len += tmp;
+
+    /* Padding with ' ' (left aligned) */
+    if (info\->left) {
+        tmp = pad_spaces(stream, pad.len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    return len;
+}
+
+static int
+b_arginf_sz([[maybe_unused]] const struct printf_info *info,
+            size_t n, int argtypes[n], [[maybe_unused]] int *size)
+{
+    if (n < 1)
+        return -1;
+
+    argtypes[0] = PA_INT;
+
+    return 1;
+}
+
+static uintmax_t
+b_value(const struct printf_info *info, const void *arg)
+{
+    if (info\->is_long_double)
+        return *(const unsigned long long *)arg;
+    if (info\->is_long)
+        return *(const unsigned long *)arg;
+
+    /* 'h' and 'hh' are both promoted to int */
+    return *(const unsigned int *)arg;
+}
+
+static size_t
+b_bin_repr(char bin[UINTMAX_WIDTH],
+           const struct printf_info *info, const void *arg)
+{
+    size_t     min_len;
+    uintmax_t  val;
+
+    val = b_value(info, arg);
+
+    bin[0] = '0';
+    for (min_len = 0; val; min_len++) {
+        bin[min_len] = '0' + (val % 2);
+        val >>= 1;
+    }
+
+    return MAX(min_len, 1);
+}
+
+static size_t
+b_bin_len(const struct printf_info *info, ptrdiff_t min_len)
+{
+    return MAX(info\->prec, min_len);
+}
+
+static size_t
+b_pad_len(const struct printf_info *info, ptrdiff_t bin_len)
+{
+    ptrdiff_t  pad_len;
+
+    pad_len = info\->width \- bin_len;
+    if (info\->alt)
+        pad_len \-= 2;
+    if (info\->group)
+        pad_len \-= (bin_len \- 1) / 4;
+
+    return MAX(pad_len, 0);
+}
+
+static ssize_t
+b_print_prefix(FILE *stream, const struct printf_info *info)
+{
+    ssize_t len;
+
+    len = 0;
+    if (fputc('0', stream) == EOF)
+        return EOF;
+    len++;
+    if (fputc(info\->spec, stream) == EOF)
+        return EOF;
+    len++;
+
+    return len;
+}
+
+static ssize_t
+b_pad_zeros(FILE *stream, const struct printf_info *info,
+            ptrdiff_t min_len)
+{
+    ssize_t    len;
+    ptrdiff_t  tmp;
+
+    len = 0;
+    tmp = info\->width \- (info\->alt * 2);
+    if (info\->group)
+        tmp \-= tmp / 5 \- !(tmp % 5);
+    for (ptrdiff_t i = tmp \- 1; i > min_len \- 1; i\-\-) {
+        if (fputc('0', stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4))
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+
+static ssize_t
+b_print_number(FILE *stream, const struct printf_info *info,
+               const char bin[UINTMAX_WIDTH],
+               size_t min_len, size_t bin_len)
+{
+    ssize_t  len;
+
+    len = 0;
+
+    /* Print leading zeros to fill precision */
+    for (size_t i = bin_len \- 1; i > min_len \- 1; i\-\-) {
+        if (fputc('0', stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4))
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    /* Print number */
+    for (size_t i = min_len \- 1; i < min_len; i\-\-) {
+        if (fputc(bin[i], stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4) || !i)
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+
+static char
+pad_ch(const struct printf_info *info)
+{
+    if ((info\->prec != \-1) || (info\->pad == ' ') || info\->left)
+        return ' ';
+    return '0';
+}
+
+static ssize_t
+pad_spaces(FILE *stream, size_t pad_len)
+{
+    ssize_t  len;
+
+    len = 0;
+    for (size_t i = pad_len - 1; i < pad_len; i\-\-) {
+        if (fputc(' ', stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+.EE
+.\" SRC END
+.SH SEE ALSO
+TODO
diff --git a/man3/register_printf_type.3 b/man3/register_printf_type.3
new file mode 100644
index 000000000..296a92dd3
--- /dev/null
+++ b/man3/register_printf_type.3
@@ -0,0 +1 @@
+.so man3/register_printf_specifier.3
-- 
2.37.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links
  2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
  2022-09-18 22:36 ` Alex Colomar
  2022-09-18 23:09 ` [RFC v2] " Alex Colomar
@ 2022-09-18 23:18 ` G. Branden Robinson
  2022-09-18 23:25   ` Alex Colomar
  2022-09-19 16:54 ` [RFC v3] printf.3head: Document functions for customizing printf(3)-like functions Alex Colomar
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: G. Branden Robinson @ 2022-09-18 23:18 UTC (permalink / raw)
  To: Alex Colomar; +Cc: linux-man, libc-alpha, Walter Harms

[-- Attachment #1: Type: text/plain, Size: 634 bytes --]

At 2022-09-19T00:16:41+0200, Alex Colomar wrote:
> I wrote this manual page after on an old discussion with Walter,
> which I postponed too much.  I had a long time ago written some
> using register_printf_specifier(3), and I remember having a lot of
> trouble using, since there's few documentation about it, if at
> all.  I had to guess much of it.
> Well, please review this page, and comment anything you don't like.
[...]
>  man3/register_printf_speficier.3 | 439 +++++++++++++++++++++++++++++++

Well, for a start, I'd spell the new file name correctly, avoiding a
controversial git rename in the future.  ;-)

Regards,
Branden

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links
  2022-09-18 23:18 ` [PATCH] " G. Branden Robinson
@ 2022-09-18 23:25   ` Alex Colomar
  0 siblings, 0 replies; 11+ messages in thread
From: Alex Colomar @ 2022-09-18 23:25 UTC (permalink / raw)
  To: G. Branden Robinson; +Cc: linux-man, libc-alpha, Walter Harms


[-- Attachment #1.1: Type: text/plain, Size: 1303 bytes --]

Hi Branden!

On 9/19/22 01:18, G. Branden Robinson wrote:
> At 2022-09-19T00:16:41+0200, Alex Colomar wrote:
>> I wrote this manual page after on an old discussion with Walter,
>> which I postponed too much.  I had a long time ago written some
>> using register_printf_specifier(3), and I remember having a lot of
>> trouble using, since there's few documentation about it, if at
>> all.  I had to guess much of it.
>> Well, please review this page, and comment anything you don't like.
> [...]
>>   man3/register_printf_speficier.3 | 439 +++++++++++++++++++++++++++++++
> 
> Well, for a start, I'd spell the new file name correctly, avoiding a
> controversial git rename in the future.  ;-)

Yeah, that may be a good start :)

I'm still far from pushing anything like that, so expect a lot of typos. 
  How about the layout and contents of the page?  Do you like them? 
Also I considered adding documentation about the related types in the 
same page, since this is one of those where the header is really small, 
and the types don't leak out of them, so we can have a true manual page 
(even if somewhat big, since those functions are a hell to understand, 
and therefore document).

Cheers,

Alex

> 
> Regards,
> Branden

-- 
<http://www.alejandro-colomar.es/>


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC v2] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links
  2022-09-18 23:09 ` [RFC v2] " Alex Colomar
@ 2022-09-19  8:55   ` Alex Colomar
  0 siblings, 0 replies; 11+ messages in thread
From: Alex Colomar @ 2022-09-19  8:55 UTC (permalink / raw)
  To: linux-man, libc-alpha; +Cc: Walter Harms, G. Branden Robinson


[-- Attachment #1.1: Type: text/plain, Size: 539 bytes --]

On 9/19/22 01:09, Alex Colomar wrote:
> Suggested-by: Walter Harms <wharms@bfs.de>
> Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
> ---
> 
> v2:
> 
>   - bug about padding zeros fixed.  But UB about 'l', 'll' (and 'j', 'z') not.
> 
> 

I found the reason of the bug.  It seems I didn't correctly understand 
printf_arginfo_size_funtion (as I suspected).  I had to OR 
PA_FLAG_LONG[_LONG].  Now it works fine.  I'll update the page, and send 
it later.

Cheers,

Alex

-- 
<http://www.alejandro-colomar.es/>


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC v3] printf.3head: Document functions for customizing printf(3)-like functions
  2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
                   ` (2 preceding siblings ...)
  2022-09-18 23:18 ` [PATCH] " G. Branden Robinson
@ 2022-09-19 16:54 ` Alex Colomar
  2022-09-19 16:54 ` [RFC v3 2/4] register_printf_specifier.3, register_printf_modifier.3, register_printf_type.3: Add links to printf.h(3head) Alex Colomar
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Alex Colomar @ 2022-09-19 16:54 UTC (permalink / raw)
  To: linux-man
  Cc: Alex Colomar, Walter Harms, Radisson97, G. Branden Robinson, libc-alpha

Suggested-by: Walter Harms <wharms@bfs.de>
Cc: <Radisson97@gmx.de>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: <libc-alpha@sourceware.org>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
---
 man3head/printf.h.3head | 561 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 561 insertions(+)
 create mode 100644 man3head/printf.h.3head

diff --git a/man3head/printf.h.3head b/man3head/printf.h.3head
new file mode 100644
index 000000000..cd396c872
--- /dev/null
+++ b/man3head/printf.h.3head
@@ -0,0 +1,561 @@
+.\" Copyright (C) 2022 Alejandro Colomar <alx.manpages@gmail.com>
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.TH printf.h 3head 2022-09-18 "Linux man-pages (unreleased)"
+.SH NAME
+printf.h,
+\%register_printf_specifier,
+\%register_printf_modifier,
+\%register_printf_type,
+\%printf_function,
+\%printf_arginfo_size_function,
+\%printf_va_arg_function,
+\%printf_info,
+\%PA_INT,
+\%PA_CHAR,
+\%PA_WCHAR,
+\%PA_STRING,
+\%PA_WSTRING,
+\%PA_POINTER,
+\%PA_FLOAT,
+\%PA_DOUBLE,
+\%PA_LAST,
+\%PA_FLAG_LONG_LONG,
+\%PA_FLAG_LONG_DOUBLE,
+\%PA_FLAG_LONG,
+\%PA_FLAG_SHORT,
+\%PA_FLAG_PTR
+\- define custom behavior for printf-like functions
+.SH LIBRARY
+Standard C library
+.RI ( libc ", " \-lc )
+.SH SYNOPSIS
+.nf
+.B #include <printf.h>
+.PP
+.BI "int register_printf_specifier(int " spec ", printf_function " func ,
+.BI "                              printf_arginfo_size_function " arginfo );
+.BI "int register_printf_modifier(const wchar_t *" str );
+.BI "int register_printf_type(printf_va_arg_function " fct );
+.fi
+.SS Callbacks
+.nf
+.BI "typedef int printf_function(FILE *" stream ", const struct printf_info *" info ,
+.BI "                              const void *const " args []);
+.BI "typedef int printf_arginfo_size_function(const struct printf_info *" info ,
+.BI "                              size_t " n ", int " argtypes [ n "], int " size [ n ]);
+.BI "typedef void printf_va_arg_function(void *" mem ", va_list *" ap );
+.fi
+.SS Types
+.EX
+.B struct printf_info
+.B {
+.BR "    int            prec;            " "// Precision"
+.BR "    int            width;           " "// Width"
+.BR "    wchar_t        spec;            " "// Format letter"
+.BR "    unsigned int   is_long_double:1;" "// " L " or " ll " flag"
+.BR "    unsigned int   is_short:1;      " "// " h " flag"
+.BR "    unsigned int   is_long:1;       " "// " l " flag"
+.BR "    unsigned int   alt:1;           " "// " # " flag"
+.BR "    unsigned int   space:1;         " "// Space flag"
+.BR "    unsigned int   left:1;          " "// " - " flag"
+.BR "    unsigned int   showsign:1;      " "// " + " flag"
+.BR "    unsigned int   group:1;         " "// " ' " flag"
+.BR "    unsigned int   extra:1;         " "// For special use"
+.BR "    unsigned int   is_char:1;       " "// " hh " flag"
+.BR "    unsigned int   wide:1;          " "// True for wide character streams"
+.BR "    unsigned int   i18n:1;          " "// " I " flag"
+.BR "    unsigned int   is_binary128:1;  " "/* Floating-point argument is"
+.BR "                                    " "   ABI-compatible with"
+.BR "                                    " "   IEC 60559 binary128 */"
+.BR "    unsigned short user;            " "// Bits for user-installed modifiers"
+.BR "    wchar_t        pad;             " "// Padding character"
+.B };
+.EE
+.SS Constants
+.EX
+.B enum
+.BR "{              " "// C type:"
+.BR "    PA_INT,    " "// " int
+.BR "    PA_CHAR,   " "// " int ", cast to " char
+.BR "    PA_WCHAR,  " "// " wchar_t
+.BR "    PA_STRING, " "// " "const char *" ", a " '\e0' "-terminated string"
+.BR "    PA_WSTRING," "// " "const wchar_t *" ", wide character " L'\e0' "-terminated string"
+.BR "    PA_POINTER," "// " "void *"
+.BR "    PA_FLOAT,  " "// " float
+.BR "    PA_DOUBLE, " "// " double
+.BR "    PA_LAST
+.B };
+.PP
+.BR "#define PA_FLAG_LONG_LONG    " "/* ... */"
+.BR "#define PA_FLAG_LONG_DOUBLE  " "/* ... */"
+.BR "#define PA_FLAG_LONG         " "/* ... */"
+.BR "#define PA_FLAG_SHORT        " "/* ... */"
+.BR "#define PA_FLAG_PTR          " "/* ... */"
+.EE
+.SH DESCRIPTION
+These functions serve to extend and/or modify the behavior of the
+.BR printf (3)
+family of functions.
+.SS register_printf_specifier()
+This function registers a custom conversion specifier for the
+.BR printf (3)
+family of functions.
+.TP
+.I spec
+The character which will be used as a conversion specifier in the format string.
+.TP
+.I func
+Callback function that will be executed by the
+.BR printf (3)
+family of functions
+to format the input arguments into the output
+.IR stream .
+.RS
+.TP
+.I stream
+Output stream where the formatted output should be printed.
+This stream transparently represents the output,
+even in the case of functions that write to a string.
+.TP
+.I info
+Structure that holds context information,
+including the modifiers specified in the format string.
+This holds the same contents as in
+.IR arginfo .
+.TP
+.I args
+Array of pointers to the arguments to the
+.BR printf (3)\c
+-like function.
+.RE
+.TP
+.I arginfo
+Callback function that will be executed by the
+.BR printf (3)
+family of functions
+to know how many arguments should be parsed for the custom specifier
+and also their types.
+.RS
+.TP
+.I info
+Structure that holds context information,
+including the modifiers specified in the format string.
+This holds the same contents as in
+.IR func .
+.TP
+.I n
+Number of arguments remaining to be parsed.
+.TP
+.I argtypes
+This array should be set to
+define the type of each of the arguments that will be parsed.
+Each element in the array represents one of the arguments to be parsed,
+in the same order that they are passed to the
+.BR printf (3)\c
+-like function.
+Each element should be set to a base type
+.RB ( PA_ *)
+from the enum above,
+or a custom one,
+and optionally ORed with an appropriate length modifier
+.RB ( PA_FLAG_ *).
+.TP
+.I size
+For user-defined types,
+the size of the type (in bytes) should also be specified through this array.
+Otherwise, leave it unused.
+.RE
+.PP
+.I arginfo
+is called before
+.IR func ,
+and prepares some information needed to call
+.IR func .
+.SS register_printf_modifier()
+TODO
+.SS register_printf_type()
+TODO
+.SH RETURN VALUE
+.BR \%register_printf_specifier (),
+.BR \%register_printf_modifier (),
+and
+.BR \%register_printf_type ()
+return zero on success, or \-1 on error.
+.SS Callbacks
+The callback of type
+.I printf_function
+should return the number of characters written,
+or \-1 on error.
+.PP
+The callback of type
+.I \%printf_arginfo_size_function
+should return the number of arguments to be parsed by this specifier.
+It also passes information about the type of those arguments
+to the caller through
+.IR argtypes .
+On error, it should return \-1.
+.SH ERRORS
+.TP
+.B EINVAL
+The specifier was not a valid character.
+.SH VERSIONS
+.BR \%register_printf_function (3)
+is an older function similar to
+.BR \%register_printf_specifier,
+and is now deprecated.
+That function can't handle user-defined types.
+.PP
+.BR \%register_printf_specifier ()
+superseeds
+.BR \%register_printf_function (3).
+.SH STANDARDS
+These nonstandard functions are present in glibc.
+.SH EXAMPLES
+The following example program registers the 'b' and 'B' specifiers
+to print integers in binary format,
+mirroring rules for other unsigned conversion specifiers like 'x' and 'u'.
+This can be used to print in binary prior to C23.
+.PP
+.\" SRC BEGIN (register_printf_specifier.c)
+.EX
+/* This code is in the public domain */
+
+#include <err.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include <printf.h>
+
+#define GROUP_SEP  '_'
+
+struct Printf_Pad {
+    char    ch;
+    size_t  len;
+};
+
+static int b_printf(FILE *stream, const struct printf_info *info,
+                    const void *const args[]);
+static int b_arginf_sz(const struct printf_info *info,
+                    size_t n, int argtypes[n], int size[n]);
+
+static uintmax_t b_value(const struct printf_info *info,
+                    const void *arg);
+static size_t b_bin_repr(char bin[UINTMAX_WIDTH],
+                    const struct printf_info *info, const void *arg);
+static size_t b_bin_len(const struct printf_info *info,
+                    ptrdiff_t min_len);
+static size_t b_pad_len(const struct printf_info *info,
+                    ptrdiff_t bin_len);
+static ssize_t b_print_prefix(FILE *stream,
+                    const struct printf_info *info);
+static ssize_t b_pad_zeros(FILE *stream, const struct printf_info *info,
+                    ptrdiff_t min_len);
+static ssize_t b_print_number(FILE *stream,
+                    const struct printf_info *info,
+                    const char bin[UINTMAX_WIDTH],
+                    size_t min_len, size_t bin_len);
+static char pad_ch(const struct printf_info *info);
+static ssize_t pad_spaces(FILE *stream, size_t pad_len);
+
+int
+main(void)
+{
+    if (register_printf_specifier('b', b_printf, b_arginf_sz) == -1)
+        err(EXIT_FAILURE, "register_printf_specifier('b', ...)");
+    if (register_printf_specifier('B', b_printf, b_arginf_sz) == -1)
+        err(EXIT_FAILURE, "register_printf_specifier('B', ...)");
+
+    printf("....----....----....----....----\en");
+    printf("%llb;\en", 0x5Ellu);
+    printf("%lB;\en", 0x5Elu);
+    printf("%b;\en", 0x5Eu);
+    printf("%hB;\en", 0x5Eu);
+    printf("%hhb;\en", 0x5Eu);
+    printf("%jb;\en", (uintmax_t)0x5E);
+    printf("%zb;\en", (size_t)0x5E);
+    printf("....----....----....----....----\en");
+    printf("%#b;\en", 0x5Eu);
+    printf("%#B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%10b;\en", 0x5Eu);
+    printf("%010b;\en", 0x5Eu);
+    printf("%.10b;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%\-10B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");
+    printf("%'B;\en", 0x5Eu);
+    printf("....----....----....----....----\en");   
+    printf("....----....----....----....----\en");
+    printf("%#16.12b;\en", 0xAB);
+    printf("%\-#'20.12b;\en", 0xAB);
+    printf("%#'020B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#020B;\en", 0xAB);
+    printf("%'020B;\en", 0xAB);
+    printf("%020B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#021B;\en", 0xAB);
+    printf("%'021B;\en", 0xAB);
+    printf("%021B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#022B;\en", 0xAB);
+    printf("%'022B;\en", 0xAB);
+    printf("%022B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%#023B;\en", 0xAB);
+    printf("%'023B;\en", 0xAB);
+    printf("%023B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%\-#'19.11b;\en", 0xAB);
+    printf("%#'019B;\en", 0xAB);
+    printf("%#019B;\en", 0xAB);
+    printf("....----....----....----....----\en");
+    printf("%'019B;\en", 0xAB);
+    printf("%019B;\en", 0xAB);
+    printf("%#016b;\en", 0xAB);
+    printf("....----....----....----....----\en");
+
+    return 0;
+}
+
+static int
+b_printf(FILE *stream, const struct printf_info *info,
+         const void *const args[])
+{
+    char               bin[UINTMAX_WIDTH];
+    size_t             min_len, bin_len;
+    ssize_t            len, tmp;
+    struct Printf_Pad  pad = {0};
+
+    len = 0;
+
+    min_len = b_bin_repr(bin, info, args[0]);
+    bin_len = b_bin_len(info, min_len);
+
+    pad.ch = pad_ch(info);
+    if (pad.ch == ' ')
+        pad.len = b_pad_len(info, bin_len);
+
+    /* Padding with ' ' (right aligned) */
+    if ((pad.ch == ' ') && !info->left) {
+        tmp = pad_spaces(stream, pad.len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* "0b"/"0B" prefix */
+    if (info->alt) {
+        tmp = b_print_prefix(stream, info);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* Padding with '0' */
+    if (pad.ch == '0') {
+        tmp = b_pad_zeros(stream, info, min_len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    /* Print number (including leading 0s to fill precision) */
+    tmp = b_print_number(stream, info, bin, min_len, bin_len);
+    if (tmp == EOF)
+        return EOF;
+    len += tmp;
+
+    /* Padding with ' ' (left aligned) */
+    if (info\->left) {
+        tmp = pad_spaces(stream, pad.len);
+        if (tmp == EOF)
+            return EOF;
+        len += tmp;
+    }
+
+    return len;
+}
+
+static int
+b_arginf_sz(const struct printf_info *info, size_t n, int argtypes[n],
+            [[maybe_unused]] int size[n])
+{
+    if (n < 1)
+        return -1;
+
+    if (info\->is_long_double)
+        argtypes[0] = PA_INT | PA_FLAG_LONG_LONG;
+    else if (info\->is_long)
+        argtypes[0] = PA_INT | PA_FLAG_LONG;
+    else
+        argtypes[0] = PA_INT;
+
+    return 1;
+}
+
+static uintmax_t
+b_value(const struct printf_info *info, const void *arg)
+{
+    if (info\->is_long_double)
+        return *(const unsigned long long *)arg;
+    if (info\->is_long)
+        return *(const unsigned long *)arg;
+
+    /* short and char are both promoted to int */
+    return *(const unsigned int *)arg;
+}
+
+static size_t
+b_bin_repr(char bin[UINTMAX_WIDTH],
+           const struct printf_info *info, const void *arg)
+{
+    size_t     min_len;
+    uintmax_t  val;
+
+    val = b_value(info, arg);
+
+    bin[0] = '0';
+    for (min_len = 0; val; min_len++) {
+        bin[min_len] = '0' + (val % 2);
+        val >>= 1;
+    }
+
+    return MAX(min_len, 1);
+}
+
+static size_t
+b_bin_len(const struct printf_info *info, ptrdiff_t min_len)
+{
+    return MAX(info\->prec, min_len);
+}
+
+static size_t
+b_pad_len(const struct printf_info *info, ptrdiff_t bin_len)
+{
+    ptrdiff_t  pad_len;
+
+    pad_len = info\->width \- bin_len;
+    if (info\->alt)
+        pad_len \-= 2;
+    if (info\->group)
+        pad_len \-= (bin_len \- 1) / 4;
+
+    return MAX(pad_len, 0);
+}
+
+static ssize_t
+b_print_prefix(FILE *stream, const struct printf_info *info)
+{
+    ssize_t len;
+
+    len = 0;
+    if (fputc('0', stream) == EOF)
+        return EOF;
+    len++;
+    if (fputc(info\->spec, stream) == EOF)
+        return EOF;
+    len++;
+
+    return len;
+}
+
+static ssize_t
+b_pad_zeros(FILE *stream, const struct printf_info *info,
+            ptrdiff_t min_len)
+{
+    ssize_t    len;
+    ptrdiff_t  tmp;
+
+    len = 0;
+    tmp = info\->width \- (info\->alt * 2);
+    if (info\->group)
+        tmp \-= tmp / 5 \- !(tmp % 5);
+    for (ptrdiff_t i = tmp \- 1; i > min_len \- 1; i\-\-) {
+        if (fputc('0', stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4))
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+
+static ssize_t
+b_print_number(FILE *stream, const struct printf_info *info,
+               const char bin[UINTMAX_WIDTH],
+               size_t min_len, size_t bin_len)
+{
+    ssize_t  len;
+
+    len = 0;
+
+    /* Print leading zeros to fill precision */
+    for (size_t i = bin_len \- 1; i > min_len \- 1; i\-\-) {
+        if (fputc('0', stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4))
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    /* Print number */
+    for (size_t i = min_len \- 1; i < min_len; i\-\-) {
+        if (fputc(bin[i], stream) == EOF)
+            return EOF;
+        len++;
+
+        if (!info\->group || (i % 4) || !i)
+            continue;
+        if (fputc(GROUP_SEP, stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+
+static char
+pad_ch(const struct printf_info *info)
+{
+    if ((info\->prec != \-1) || (info\->pad == ' ') || info\->left)
+        return ' ';
+    return '0';
+}
+
+static ssize_t
+pad_spaces(FILE *stream, size_t pad_len)
+{
+    ssize_t  len;
+
+    len = 0;
+    for (size_t i = pad_len - 1; i < pad_len; i\-\-) {
+        if (fputc(' ', stream) == EOF)
+            return EOF;
+        len++;
+    }
+
+    return len;
+}
+.EE
+.\" SRC END
+.SH SEE ALSO
+.BR asprintf (3),
+.BR printf (3),
+.BR wprintf (3)
-- 
2.37.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC v3 2/4] register_printf_specifier.3, register_printf_modifier.3, register_printf_type.3: Add links to printf.h(3head)
  2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
                   ` (3 preceding siblings ...)
  2022-09-19 16:54 ` [RFC v3] printf.3head: Document functions for customizing printf(3)-like functions Alex Colomar
@ 2022-09-19 16:54 ` Alex Colomar
  2022-09-19 16:54 ` [RFC v3 3/4] printf_arginfo_size_function.3type, printf_function.3type, printf_info.3type, printf_va_arg_function.3type: " Alex Colomar
  2022-09-19 16:54 ` [RFC v3 4/4] PA_CHAR.3const, PA_DOUBLE.3const, PA_FLAG_LONG.3const, PA_FLAG_LONG_DOUBLE.3const, PA_FLAG_LONG_LONG.3const, PA_FLAG_PTR.3const, PA_FLAG_SHORT.3const, PA_FLOAT.3const, PA_INT.3const, PA_LAST.3const, PA_POINTER.3const, PA_STRING.3const, PA_WCHAR.3const, PA_WSTRING.3const: " Alex Colomar
  6 siblings, 0 replies; 11+ messages in thread
From: Alex Colomar @ 2022-09-19 16:54 UTC (permalink / raw)
  To: linux-man
  Cc: Alex Colomar, Walter Harms, Radisson97, G. Branden Robinson, libc-alpha

Cc: Walter Harms <wharms@bfs.de>
Cc: <Radisson97@gmx.de>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: <libc-alpha@sourceware.org>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
---
 man3/register_printf_modifier.3  | 1 +
 man3/register_printf_specifier.3 | 1 +
 man3/register_printf_type.3      | 1 +
 3 files changed, 3 insertions(+)
 create mode 100644 man3/register_printf_modifier.3
 create mode 100644 man3/register_printf_specifier.3
 create mode 100644 man3/register_printf_type.3

diff --git a/man3/register_printf_modifier.3 b/man3/register_printf_modifier.3
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3/register_printf_modifier.3
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3/register_printf_specifier.3 b/man3/register_printf_specifier.3
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3/register_printf_specifier.3
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3/register_printf_type.3 b/man3/register_printf_type.3
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3/register_printf_type.3
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
-- 
2.37.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC v3 3/4] printf_arginfo_size_function.3type, printf_function.3type, printf_info.3type, printf_va_arg_function.3type: Add links to printf.h(3head)
  2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
                   ` (4 preceding siblings ...)
  2022-09-19 16:54 ` [RFC v3 2/4] register_printf_specifier.3, register_printf_modifier.3, register_printf_type.3: Add links to printf.h(3head) Alex Colomar
@ 2022-09-19 16:54 ` Alex Colomar
  2022-09-19 16:54 ` [RFC v3 4/4] PA_CHAR.3const, PA_DOUBLE.3const, PA_FLAG_LONG.3const, PA_FLAG_LONG_DOUBLE.3const, PA_FLAG_LONG_LONG.3const, PA_FLAG_PTR.3const, PA_FLAG_SHORT.3const, PA_FLOAT.3const, PA_INT.3const, PA_LAST.3const, PA_POINTER.3const, PA_STRING.3const, PA_WCHAR.3const, PA_WSTRING.3const: " Alex Colomar
  6 siblings, 0 replies; 11+ messages in thread
From: Alex Colomar @ 2022-09-19 16:54 UTC (permalink / raw)
  To: linux-man
  Cc: Alex Colomar, Walter Harms, Radisson97, G. Branden Robinson, libc-alpha

Cc: Walter Harms <wharms@bfs.de>
Cc: <Radisson97@gmx.de>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: <libc-alpha@sourceware.org>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
---
 man3type/printf_arginfo_size_function.3type | 1 +
 man3type/printf_function.3type              | 1 +
 man3type/printf_info.3type                  | 1 +
 man3type/printf_va_arg_function.3type       | 1 +
 4 files changed, 4 insertions(+)
 create mode 100644 man3type/printf_arginfo_size_function.3type
 create mode 100644 man3type/printf_function.3type
 create mode 100644 man3type/printf_info.3type
 create mode 100644 man3type/printf_va_arg_function.3type

diff --git a/man3type/printf_arginfo_size_function.3type b/man3type/printf_arginfo_size_function.3type
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3type/printf_arginfo_size_function.3type
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3type/printf_function.3type b/man3type/printf_function.3type
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3type/printf_function.3type
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3type/printf_info.3type b/man3type/printf_info.3type
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3type/printf_info.3type
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3type/printf_va_arg_function.3type b/man3type/printf_va_arg_function.3type
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3type/printf_va_arg_function.3type
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
-- 
2.37.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC v3 4/4] PA_CHAR.3const, PA_DOUBLE.3const, PA_FLAG_LONG.3const, PA_FLAG_LONG_DOUBLE.3const, PA_FLAG_LONG_LONG.3const, PA_FLAG_PTR.3const, PA_FLAG_SHORT.3const, PA_FLOAT.3const, PA_INT.3const, PA_LAST.3const, PA_POINTER.3const, PA_STRING.3const, PA_WCHAR.3const, PA_WSTRING.3const: Add links to printf.h(3head)
  2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
                   ` (5 preceding siblings ...)
  2022-09-19 16:54 ` [RFC v3 3/4] printf_arginfo_size_function.3type, printf_function.3type, printf_info.3type, printf_va_arg_function.3type: " Alex Colomar
@ 2022-09-19 16:54 ` Alex Colomar
  6 siblings, 0 replies; 11+ messages in thread
From: Alex Colomar @ 2022-09-19 16:54 UTC (permalink / raw)
  To: linux-man
  Cc: Alex Colomar, Walter Harms, Radisson97, G. Branden Robinson, libc-alpha

Cc: Walter Harms <wharms@bfs.de>
Cc: <Radisson97@gmx.de>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: <libc-alpha@sourceware.org>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
---
 man3const/PA_CHAR.3const             | 1 +
 man3const/PA_DOUBLE.3const           | 1 +
 man3const/PA_FLAG_LONG.3const        | 1 +
 man3const/PA_FLAG_LONG_DOUBLE.3const | 1 +
 man3const/PA_FLAG_LONG_LONG.3const   | 1 +
 man3const/PA_FLAG_PTR.3const         | 1 +
 man3const/PA_FLAG_SHORT.3const       | 1 +
 man3const/PA_FLOAT.3const            | 1 +
 man3const/PA_INT.3const              | 1 +
 man3const/PA_LAST.3const             | 1 +
 man3const/PA_POINTER.3const          | 1 +
 man3const/PA_STRING.3const           | 1 +
 man3const/PA_WCHAR.3const            | 1 +
 man3const/PA_WSTRING.3const          | 1 +
 14 files changed, 14 insertions(+)
 create mode 100644 man3const/PA_CHAR.3const
 create mode 100644 man3const/PA_DOUBLE.3const
 create mode 100644 man3const/PA_FLAG_LONG.3const
 create mode 100644 man3const/PA_FLAG_LONG_DOUBLE.3const
 create mode 100644 man3const/PA_FLAG_LONG_LONG.3const
 create mode 100644 man3const/PA_FLAG_PTR.3const
 create mode 100644 man3const/PA_FLAG_SHORT.3const
 create mode 100644 man3const/PA_FLOAT.3const
 create mode 100644 man3const/PA_INT.3const
 create mode 100644 man3const/PA_LAST.3const
 create mode 100644 man3const/PA_POINTER.3const
 create mode 100644 man3const/PA_STRING.3const
 create mode 100644 man3const/PA_WCHAR.3const
 create mode 100644 man3const/PA_WSTRING.3const

diff --git a/man3const/PA_CHAR.3const b/man3const/PA_CHAR.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_CHAR.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_DOUBLE.3const b/man3const/PA_DOUBLE.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_DOUBLE.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_FLAG_LONG.3const b/man3const/PA_FLAG_LONG.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_FLAG_LONG.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_FLAG_LONG_DOUBLE.3const b/man3const/PA_FLAG_LONG_DOUBLE.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_FLAG_LONG_DOUBLE.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_FLAG_LONG_LONG.3const b/man3const/PA_FLAG_LONG_LONG.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_FLAG_LONG_LONG.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_FLAG_PTR.3const b/man3const/PA_FLAG_PTR.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_FLAG_PTR.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_FLAG_SHORT.3const b/man3const/PA_FLAG_SHORT.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_FLAG_SHORT.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_FLOAT.3const b/man3const/PA_FLOAT.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_FLOAT.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_INT.3const b/man3const/PA_INT.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_INT.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_LAST.3const b/man3const/PA_LAST.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_LAST.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_POINTER.3const b/man3const/PA_POINTER.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_POINTER.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_STRING.3const b/man3const/PA_STRING.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_STRING.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_WCHAR.3const b/man3const/PA_WCHAR.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_WCHAR.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
diff --git a/man3const/PA_WSTRING.3const b/man3const/PA_WSTRING.3const
new file mode 100644
index 000000000..ad10bad38
--- /dev/null
+++ b/man3const/PA_WSTRING.3const
@@ -0,0 +1 @@
+.so man3head/printf.h.3head
-- 
2.37.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-09-19 16:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
2022-09-18 22:36 ` Alex Colomar
2022-09-18 22:38   ` Alex Colomar
2022-09-18 23:09 ` [RFC v2] " Alex Colomar
2022-09-19  8:55   ` Alex Colomar
2022-09-18 23:18 ` [PATCH] " G. Branden Robinson
2022-09-18 23:25   ` Alex Colomar
2022-09-19 16:54 ` [RFC v3] printf.3head: Document functions for customizing printf(3)-like functions Alex Colomar
2022-09-19 16:54 ` [RFC v3 2/4] register_printf_specifier.3, register_printf_modifier.3, register_printf_type.3: Add links to printf.h(3head) Alex Colomar
2022-09-19 16:54 ` [RFC v3 3/4] printf_arginfo_size_function.3type, printf_function.3type, printf_info.3type, printf_va_arg_function.3type: " Alex Colomar
2022-09-19 16:54 ` [RFC v3 4/4] PA_CHAR.3const, PA_DOUBLE.3const, PA_FLAG_LONG.3const, PA_FLAG_LONG_DOUBLE.3const, PA_FLAG_LONG_LONG.3const, PA_FLAG_PTR.3const, PA_FLAG_SHORT.3const, PA_FLOAT.3const, PA_INT.3const, PA_LAST.3const, PA_POINTER.3const, PA_STRING.3const, PA_WCHAR.3const, PA_WSTRING.3const: " Alex Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).