Re: [PATCH 1/3] add binary printf

From: Frederic Weisbecker
Date: Thu Feb 26 2009 - 14:05:31 EST


On Thu, Feb 26, 2009 at 07:56:35PM +0100, Ingo Molnar wrote:
>
> * Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:
>
> > Instead of calling the in/out helper from the decoder, why not
> > calling the decoder from these three functions and let them
> > take the appropriate actions for each decoded format token?
> >
> > Naive example:
> >
> > bstr_printf() {
> > while (decode_format(...))
> > if (type == number)
> > read_number_from_buf()
> > str = number(....)
> > ....
> > }
> >
> > vsnprintf {
> > while (decode_format(...))
> > if (type == number)
> > var_arg(...)
> > str = number(....)
> > ....
> > }
> >
> > vbin_printf {
> > while (decode_format(...))
> > if (type == number)
> > var_arg(...)
> > write_number_to_buffer()
> > ...
> > }
> >
> > And the standard in/out pieces can be invoked through helpers.
>
> ok, that looks rather clean too. And maybe vsnprintf() and
> bstr_printf() could be further unified?


Yes, read process can be unified between vbin_printf and vsnprintf
and write process can be unified between bstr_printf and vsnprintf,
both further than the above example.


> I guess it depends on how it all looks like in the end. Only one
> way to find out ...


Let's try, the practice will tell us more, I'm on it.

Thanks.

> Ingo

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/