Kalle Olavi Niemitalo <[EMAIL PROTECTED]> wrote Sat, Jan 26, 2008:
> So if the overflow check is necessary, it should be corrected.
> If overflows can be assumed to wrap (C does not guarantee that),
> then I think the following is correct and the simplest solution:
>
> 
>       for (; pos < length && isdigit(string[pos]); pos++) {
>                 off_t newint = integer * 10 + string[pos] - '0';
> 
>                 if (newint / 10 != integer)
>                         return 0; /* overflow */
>                 integer = newint;
>         }
> 
> OTOH, if overflows instead trap or saturate, then this won't work.

I think the dectection is necessary and I like your correction.

-- 
Jonas Fonseca
_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to