bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib and *printf


From: Bruno Haible
Subject: Re: gnulib and *printf
Date: Fri, 9 Oct 2009 00:04:56 +0200
User-agent: KMail/1.9.9

Hi Joel,

> In another case, I'm computing a column width for a table to be formatted
> to a stream. 

Note that snprintf is not suitable for this purpose, because as soon as
non-ASCII characters appear (in a UTF-8 locale for example), the number of
bytes and the number of columns for a string are different. For computing
the number of columns of a string, gnulib offers you the 'mbswidth' module.
And if your table cells have multiple lines and you want to do line breaking,
you can use the unilbrk/ulc-width-linebreaks module.

> > Maybe it would be worth an
> > uber-printf{-posix} module that pulls in all the variants, but I'm
> > probably not going to write it.
> 
> While -DGNULIB_POSIXCHECK solves the biggest problem, it still seems a 
> little silly to maintain a list of gnulib's printf-posix modules in bison.  
> Is the following patch ok?  I'm not sure how to fill out some of the 
> fields.
> 
> >From 351599f18e824e4cdc883156f080becc64ffeb41 Mon Sep 17 00:00:00 2001
> From: Joel E. Denny <address@hidden>
> Date: Thu, 8 Oct 2009 00:18:25 -0400
> Subject: [PATCH] all-printf, all-printf-posix: new modules.
> 
> * modules/all-printf: New module.
> * modules/all-printf-posix: New module.
> ---
>  ChangeLog                |    6 ++++++
>  modules/all-printf       |   25 +++++++++++++++++++++++++
>  modules/all-printf-posix |   31 +++++++++++++++++++++++++++++++
>  3 files changed, 62 insertions(+), 0 deletions(-)
>  create mode 100644 modules/all-printf
>  create mode 100644 modules/all-printf-posix
> 
> diff --git a/ChangeLog b/ChangeLog
> index dedcfc8..a953cbc 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,9 @@
> +2009-10-08  Joel E. Denny  <address@hidden>
> +
> +     all-printf, all-printf-posix: new modules.
> +     * modules/all-printf: New module.
> +     * modules/all-printf-posix: New module.
> +
>  2009-10-07  Eric Blake  <address@hidden>
>  
>       areadlinkat-with-size: new module
> diff --git a/modules/all-printf b/modules/all-printf
> new file mode 100644
> index 0000000..efc6f35
> --- /dev/null
> +++ b/modules/all-printf
> @@ -0,0 +1,25 @@
> +Description:
> +All functions in the printf family.
> +
> +Files:
> +
> +Depends-on:
> +dprintf
> +obstack-printf
> +snprintf
> +vasnprintf
> +vasprintf
> +vdprintf
> +vsnprintf
> +xprintf
> +xvasprintf

This does not look very reusable: 80% of the programs don't use obstacks, 95%
of the programs don't use 'dprintf', and 30% of the programs are LGPL and
cannot use 'xvasprintf'.

So there is considerable variance in what various gnulib users would want.
Therefore the list that you want should probably better be shown in a piece
of documentation, rather than as a module. Either in MODULES.html (generated
by MODULES.html.sh), or in the doc/ directory. Would you care to write a
patch for the documentation?

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]