tech-userlevel archive

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

Re: RFC - add snscanf(3) to stdio



On Sat, 30 Aug 2008, Darren Reed wrote:
> Thus I'd like to introduce the following:
> int snscanf(const char *str, const size_t buflen, const char *format, ...);
> int vsnscanf(const char *str, const size_t buflen, const char *format,  
> va_list ap);

That looks sensible to me.

> Is there a need for fsnscanf()? I'm not convinced but could be...

I assume you mean [v]fnscanf, which would read from an open file instead
of a memory buffer.

Is there a need?  Well, it's easy to imagine that the "f" versions of
these functions would be useful in parsing values from files with fixed
length fields.

Is it a good idea?  Well, all the existing scanf-like functions appear
in all possible combinations of {read from stdin, read from an arbitrary
file, read from a memory buffer}.  I would suggest that, for symmetry,
any new scan-like functions should also follow that pattern.  So there
would be six new functions [v]{|f|s}nscanf to match the six existing
functions [v]{|f|s}scanf.

On the other hand, implementation of the [v][f]nscanf functions could be
delayed until somebody is motivated to implement them, so their absence
needn't prevent adding the [v]snscanf functions.

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index