<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] warning cleared



* On 2005.09.22, in <20050922075205.GU10503@xxxxxxxxxxxxx>,
*       "Vincent Lefevre" <vincent@xxxxxxxxxx> wrote:
> 
> You need
> 
>   #include <stdlib.h>

No, you don't, because strtoul() doesn't exist, so no header file
defines its interface.  Including a header doesn't make a symbol
available at link time.  (At link time, it's either there or it isn't.)
It just helps the compiler check grammar, and the grammer checked fine.

Actually, it was misleading and a little peevish for me to use cc in my
previous example.  Sun's cc won't compile mutt, as it's non-ANSI.  But
for the same reason, neither will gcc compile the test code on the same
platform: it's still using the Sun system libraries.


> Moreover, perhaps linking
> with some library, such as -lansi (as suggested on the web),
> is needed.

There is no libansi on stock SunOS4.  There is no _strtoul in
/usr/lib/lib*.a on stock SunOS4.


> Anyway, even if it is really missing, this could be solve by
> a configure test, like this can be done for the non-standard
> strcasecmp and strncasecmp functions.

Sure, but then you need either to fail configure and say "get yourself
a strtoul() implementation", or you need a backup implementation
encased within "#ifdef NEED_STRTOUL" or something.  Why add this extra
weight when an alternate solution is just to use atoi() and while
(isdigit((foo)*p)) p++?  This basically is equivalent to inlining
your specially-defined my_strtoul(), but additionally applying it to
all platforms instead of just SunOS, meaning you don't need to have
confidence in a strtoul check, you don't have extra code to maintain,
and you don't do any harm.

I agree, using strtoul() is best if you're writing code for modern
platforms.  Mutt aims for portability to non-modern platforms, and I try
to support that so that Steve doesn't need to file a bug report after
commit. :)


I'll take Thomas Dickey's word that strtol() is reliably present -- I
wasn't sure how broadly-implemented it is, having seen strtoul() missing
so often.  Every platform I've used has strtol(), as far as I recall,
but I haven't seen everything.  So Vincent, if you want to submit a
patch to use strtol(), I won't argue it.

-- 
 -D.    dgc@xxxxxxxxxxxx        NSIT    University of Chicago