At Wed, 24 Jun 2009 23:11:37 +0200, Marc Balmer <marc%msys.ch@localhost> wrote: Subject: Re: strtonum(3) from OpenBSD? > > > what I find amusing is that people come up with their own implemetation > of such a function instead of simply accept the fact that there is a > function > in OpenBSD and FreeBSD that is accepted by many good folks... Note that the _example_ function I showed has several potentially extreme use-specific limitations which I tried to document: > > FWIW, here's my super-picky, super portable (except for err.h et al), > > version of parseint() suitable for use where hard exits on error are > > desired and the output range is the full INT_MIN to INT_MAX: I.e. it is not suitable for general use, though it is perhaps a somewhat better design in several ways than the much less useful strtonum(3) you're supporting for reasons I can't quite understand. If you read my earlier mail you'd also hopefully know that deviating from any of the restrictions imposed by my parseint() example requires re-writing some or all of the main conditions and checks and parameters used by my parseint(). In other words the best function(s) for common use and inclusion in a system library is already there: strtol(3) and friends. Unfortunately as my parseint() example and the length of this discussion thread shows, strtol(3) is apparently not the easiest API to use correctly either. Still, as I said before, from my experience I can't see that at is possible to do any better with a common utility wrapper function since all the error handling and range checking is probably still easier done with local statements than it is to design a good enough API that can be used widely enough to justify inclusion in a system library. It it were possible I'm sure ANSI or IEEE would have done it instead of publishing strtol(3). -- Greg A. Woods Planix, Inc. <woods%planix.com@localhost> +1 416 218-0099 http://www.planix.com/
Attachment:
pgpkdHrIw0dQl.pgp
Description: PGP signature