bug-make
[Top][All Lists]
Advanced

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

Re: [rfc] Colorized output for GNU make?


From: Sebastian Pipping
Subject: Re: [rfc] Colorized output for GNU make?
Date: Sun, 12 Feb 2012 18:11:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120207 Thunderbird/10.0

On 02/12/2012 05:27 PM, Eli Zaretskii wrote:
>> Date: Sun, 12 Feb 2012 05:07:48 +0100
>> From: Sebastian Pipping <address@hidden>
>> CC: address@hidden, address@hidden
>>
>> So far both of these have been requirements: (1) keep the overall format
>> translatable so other languages can adjust order of elements and (2) use
>> C89 functions, only.  It seems that (1) requires function vsnprintf
>> which violates (2).
> 
> Why does (1) violate (2)?  (1) will only be possible with C libraries
> that support the n$ positional specifiers.  AFAIK, when these are
> supported, they can be used with any of the *printf functions.

The problem is nesting.  If we have

  _("%s[%u]: %s%s%s%s")
               ^^
for the final output, the actual message (third %s above) needs to be
present in linear string form already.  With constant messages that's
given, but we are dealing with

  _("%s: Entering directory `%s'\n")

too.  So that inner format needs to be written to a string buffer first
or we lose the gained abstraction.  Since we would run into buffer
overflows with sprintf/vsprintf, we rely on snprintf/vsnprintf for that
task.  Quoting from my "man 3 printf" output:

  snprintf(), vsnprintf():
    _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE \
      || _POSIX_C_SOURCE >= 200112L;
    or cc -std=c99

That's my understanding of the situation.

Best,



Sebastian



reply via email to

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