[libvirt] [RFC PATCH] build: avoid %zu in translated strings

Daniel P. Berrange berrange at redhat.com
Wed Aug 18 14:35:47 UTC 2010


On Wed, Aug 18, 2010 at 07:41:16AM -0600, Eric Blake wrote:
> On 08/18/2010 03:04 AM, Daniel P. Berrange wrote:
> > 
> > I find the PRI* stuff rather fugly. Can't we just use %llu and
> > cast to (unsigned long long)
> 
> Unfortunately, %llu is equally non-portable to mingw.  And yes, we also
> have some %llu encoded into translated strings, which would also need help.
> 
> > 
> > The question of printf-posix license doesn't appear relevant since
> > remoteError & friends all use asprintf() which is LGPLv2+ already.
> 
> We use the 'vasprintf' module, which is indeed LGPLv2+, but it does not
> guarantee the existence of %llu nor %zu -- it only guarantees that you
> have the [v]asprintf wrappers around your current system's
> (non-)compliant printf family, so it inherits the same bugs regarding
> unsupported specifiers.  We would have to use the vasprintf-posix module
> to get %zu, but that module is LGPLv3+.

I don't think this is correct. The 'vasprintf' module was added in
GNULIB in 87b04f998fd3e668027074b5b5d37205d3cdfec3. This commit
includes a full re-implementation of format parsing that appears
independent of the host system printf() impl.

$ git show 87b04f998fd3e668027074b5b5d37205d3cdfec3 | diffstat | grep lib
 lib/ChangeLog      |   13 
 lib/asnprintf.c    |   38 ++
 lib/asprintf.c     |   38 ++
 lib/printf-args.c  |  119 ++++++++
 lib/printf-args.h  |  134 +++++++++
 lib/printf-parse.c |  477 ++++++++++++++++++++++++++++++++
 lib/printf-parse.h |   72 ++++
 lib/vasnprintf.c   |  767 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/vasnprintf.h   |   61 ++++
 lib/vasprintf.c    |   38 ++
 lib/vasprintf.h    |   64 ++++

These printf-args/parse files appear to handle long long int & %llu
combinations correctly. Since mingw32 lacks any vasprintf() at all, 
we will be using this gnulib replacement. The vasprintf-posix seems
to only be used where vasprintf() exists but is broken, thus not on
mingw32

I find it strange that vasprintf is a more liberal license than the
vasprintf-posix, since the former is where all the really cool
code is - the latter just seems to be a few m4 macros that anyone
could reimplement with ease.

Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list