[parted-devel] avoid printf, when easy to do
Otavio Salvador
otavio at debian.org
Wed Feb 14 12:08:11 CET 2007
Jim Meyering <jim at meyering.net> writes:
> Otavio Salvador <otavio at debian.org> wrote:
>> Jim Meyering <jim at meyering.net> writes:
>> Your proposed changes looks right but I do think we should provide a
>> method to make it easier?
>
> It's a one time conversion, so making the transition "easier"
> is less important than making the resulting code readable.
> Also, with the standard functions, you won't have to publicize
> the new interface if/when you want to use the same technique
> in another .c file.
Yes. It'll need to be done once but we'll also continue to code and
then we'll use it every now and then.
By 'publicize' you need the need of #include <foo> on the file header?
Well, while it's true we can also put it together with parted.h since
it's very specific.
>> For example the following code (I hadn't test this code)?
>>
>> #v+
>> static void printp (...)
>> {
>> va_list va_args;
>>
>> va_start (va_args);
>> fputs (va_args, stdout);
>> va_end (va_args);
>> }
>> #v-
>>
>> Using it, we could then do:
>>
>> #v+
>> - printf(_("\nCommand History:\n"));
>> + printp (_("\nCommand History:\n"));
>> #v-
>
> I see your point (reducing syntax, which is good), but I'd rather not
> add a nonstandard name that some readers might think still supports
> printf-style format strings. Everyone knows what fputs does, and if you
> omit the FILE* argument, the preprocessor will gripe right away. Also,
> I prefer to avoid using va_* functions, unless there's a clear need.
We can use fprintf instead. That way we would support the printf-style
and also print directly on stdout as need.
I agree with you about the va_* but that could be workarounded if we
use a macro for it, can't it?
> However, if you'd rather skip the suggested change altogether,
> go right ahead. As I said, it's not a big deal.
No. This isn't what I want to do. I just think that while we're on it
we should also prepare the code for the future and leave it as simple
as possible to code.
--
O T A V I O S A L V A D O R
---------------------------------------------
E-mail: otavio at debian.org UIN: 5906116
GNU/Linux User: 239058 GPG ID: 49A5F855
Home Page: http://otavio.ossystems.com.br
---------------------------------------------
"Microsoft sells you Windows ... Linux gives
you the whole house."
More information about the parted-devel
mailing list