tech-userlevel archive

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

Re: RFC - add snscanf(3) to stdio



> In using sscanf() on lines retrived with fgetln(), I ran into an
> annoying bug with sscanf() - it calls strlen() on the buffer being
> passed in.

I'm not sure it's really fair to call this a bug; it just means that
sscanf()'s interface is not well suited to your application.

> This makes it unsuitable for use on text that is returned with
> fgetln() without whacking it with a gratutious \0

...which is an invalid thing to do, since you're not allowed to modify
the returned string beyond the returned size value.  (Unless you stamp
on the newline, I suppose, but the newline is not guaranteed to be
there.)

> Thus I'd like to introduce [snscanf and vsnscanf]

I like them.

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

I'm not even sure what it would mean.  The difference between fscanf
and sscanf is where the input comes from; based on the name, fsnscanf()
appears to be taking input from two places at once (and limiting the
length, but that's a separate issue).

/~\ The ASCII                           der Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index