[parted-devel] avoid printf, when easy to do
Jim Meyering
jim at meyering.net
Wed Feb 14 08:37:14 CET 2007
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.
> 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.
However, if you'd rather skip the suggested change altogether,
go right ahead. As I said, it's not a big deal.
More information about the parted-devel
mailing list