>>>>> Maciej Sieczka <[EMAIL PROTECTED]> writes:
[...]
>> I could change it to use strtol(), which sets errno to ERANGE on
>> overflow.
It may be better to check `*tailptr', like:
int
p_arg_long (const char *s, long *vp)
{
char *t;
long v;
if ((v = strtol (s, &t, 0)),
t == s || *t != '\0') {
/* . */
return -1;
}
if (vp != 0) *vp = v;
/* . */
return 0;
}
...
if (p_arg_long (str, &val) != 0) {
/* not a long integer */
}
Though `errno' may be used for finer diagnostics.
> Would that make r.mapcalc accept integers bigger than int32?
The sizes of the C types generally depend on the platform, but
for x86-based platforms I'm familiar with, sizeof (long) is 32.
It may make sense to use `long long' and strtoll () where
available.
[...]
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev