On 01/24/2013 03:24 AM, Richard W.M. Jones wrote:
On Thu, Jan 24, 2013 at 10:17:16AM +0000, Daniel P. Berrange wrote:
> On Thu, Jan 24, 2013 at 10:10:56AM +0000, Richard W.M. Jones wrote:
>> Version 3 of this patch. Because I now have to pass the 'mgr' pointer
>> around, the patch is considerably more complicated than before.
>>
>> Patch 1/2 is required so that I can use virReportSystemError when I
>> don't need to have any optional arguments, ie. the equivalent of:
>>
>> printf ("foo\n");
>
> No, that's not allowed - everything must have a format string - even
> static messages - it should instead be:
>
> printf ("%s", _("foo\n"));
>
> make syntax-check ought to have complained about this IIRC.
I don't see why. Presumably the worry is that the translator will
introduce a %-sequence into the string? That should be picked up by
one of the msg* utilities.
Whether or not it is picked up by the msg* utilities, there is also the
issue of whether xgettext will mark the string as being printf-format
when extracting the string for translation, as well as the issue that
there are existing compilers (at least the older gcc on FreeBSD) that
loudly complain (and thus break a -Werror build) if given a function
marked __attribute__((__printf__(...))) but with no % in the format
string. So just because the standard allows you to use printf with a
format string with no % doesn't mean that we like that style.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org