Re: [AD] al_fgets

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Peter Wang wrote:
al_fgets has a major problem in the implementation  If you pass too
short of a buffer it will read in a whole line from the file but return
a partial string, discarding the rest.  We should of course stop reading
at max-1 bytes, but we need a way to tell if there is more of the line
remaining.  We could:

- do like fgets() and return the line terminator
- explicitly return whether a whole line was read

Any preferences?  I think the former is a bit irritating to work with in
practice.

If we call the function "fgets", then I think it would make most sense to keep the same semantics (return all characters and terminate with 0). A function with the same name but different behavior never is a good idea (like so many things in the A4 API were not).


It would be nice to have a version of al_fgets() that returns an
ALLEGRO_USTR.

Definitely - most likely you will want to use string operations on the result and then (when using plain C) will want to have it as USTR anyway. And we could then simply remove the current al_fgets without another replacement.

--
Elias Pschernig <elias@xxxxxxxxxx>




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/