Re: boolean annoyance



Dňa Štvrtok 09 Február 2006 01:52 Logan Capaldo napísal:
On Feb 8, 2006, at 7:41 PM, Claudio Jeker wrote:
This is not correct. strtol(3) does not return 0 in case of an
error. It
sets errno to ERANGE and returns LONG_MAX or LONG_MIN.

RETURN VALUES
The strtol(), strtoll(), strtoimax() and strtoq() functions
return the
result of the conversion, unless the value would underflow or
overflow.
***If no conversion could be performed, 0 is returned and the
global vari-
able errno is set to EINVAL.*** If an overflow or underflow
occurs, errno
is set to ERANGE and the function return value is clamped
according to
the following table.


This made me smile and laugh and giggle. And also hover my hand on the button
that controls the "Do not feed the troll" sign, but I'm still more amused
than annoyed.

Rule 1 of trolling: Never, ever be blatantly wrong about anything.

David Vallner


.



Relevant Pages

  • Re: Confused about fscanf( "%i" ) for > INT_MAX
    ... "The strtol, strtoll, strtoul, and strtoull functions", reads: ... resulting from the conversion is negated." ... and the value of the macro ERANGE is stored in errno. ...
    (comp.lang.c.moderated)
  • Re: detabbing again
    ... If no conversion could be performed, zero is returned. ... stored in errno. ... strtoll is but not strtol. ...
    (comp.lang.c)
  • Re: string validation for int and long (strisint, strislong)
    ... You should allow the caller to preserve the prior errno if ... strtol succeeds... ... if (errno) return 0; ... Testing for a decimal number, without conversion, can be done ...
    (comp.lang.c)
  • Re: boolean annoyance
    ... sets errno to ERANGE and returns LONG_MAX or LONG_MIN. ... The strtol(), strtoll, strtoimaxand strtoqfunctions return the ... result of the conversion, unless the value would underflow or overflow. ...
    (comp.lang.ruby)
  • Re: Finding a word inside a string
    ... The conversion fails, and errno is set to erange. ... The assignment of either of these values to an int will ...
    (comp.lang.c)