doesn't take numbers

Linas Vepstas linas@linas.org
Tue, 31 Jul 2001 15:53:06 -0500


On Tue, Jul 31, 2001 at 04:38:38PM -0400, James LewisMoss was heard to remark:
> 
> Is atoll happy on other platforms (Solaris being the example I'm aware
> gnucash is being used on)?

I presume so, but I can't say with authority.  five years ago, no, but 
these days, everybody has 64-bit cpus, so this stuff got added.

> What's surprising is that a redhat 7.x machine is buggy with sscanf.
> Just absurd.

I can't guess if this is in fact a gcc bug (redhat 7.0 shipped with a
funny gcc), or if its just hard to write a general parser (which is 
what sccanf needs to be).

Portability: e.g. on AIX, its %Ld not %lld for 64-bit ints; in that
sense, atoll is more 'portable'.  And, of course, if all else fails
one can always:

#ifdef NEED_ATOLL
long long atoll (const char *s)
{ long long x; sscanf ("%qd", &x); return x; /* or whatever */ }
#endif

Note the opposite direction #if NEED_WORKING_SSCANF is much much
harder to implement/port.

--linas


-- 
I'm very PUBLIC-MINDED, I'm helping a NIGERIAN get his $25,000,000 back!