fgetpos, fsetpos, and ANSIness in general

Ian Stewartson gis at datlog.co.uk
Fri Oct 13 17:24:04 AEST 1989


In article <OTTO.89Oct8093607 at tukki.jyu.fi> otto at tukki.jyu.fi (Otto J. Makela) writes: (edited)

>For example, I like the idea behind strftime, the date formatting routine ala
>printf.  But I dislike the interface: the more-or-less Unix tradition for such
>functions is to return a pointer to a fixed buffer. 
>
>Now, this interface could be extended for this: define that the function will
>use a internal buffer of, er, let's say 80 characters IF the buffer pointer
>given is NULL.  Function returns zero, as originally, if the buffer length is
>exceeded.  This way, you get the best of both implementation ideas.  Nothing
>like this was not done.  Why ?

One of the major problems with the world today is that we don't all speak
English as our first (and only) language and format our dates the way the
British (as opposed to any other 'english' speaking nation) do.  Indeed, some
governments and nations insist that computer software speaks their language
and date formats.  And even the British can't make up their mind.  Therefore,
when you pass a format to strftime, how do it now how big the resultant string
is going to be.  Well it doesn't, so to put the responsibility for any
problems in the right place, you have to pass a buffer and length.  I believe
the reasons for this are very similar to the reasons for using fgets
instead of gets.

Strftime was designed to implement National Language Support which it does
quite sensibly (especially when you compare it with the original nl_ascxtime
and nl_cxtime).

Regards,

Ian Stewartson
Data Logic Ltd, Queens House, Greenhill Way, Harrow, Middlesex, HA1 1YR, UK.
(Phone) +44 1 863 0383 (Telex) 888103 (Fax) +44 1 861 2010
	+44 81 863 0383 after May 1990.
(Network) gis at datlog.co.uk or ukc!datlog!gis



More information about the Comp.lang.c mailing list