Ethereal-dev: Re: [ethereal-dev] How to distinguish between signed and unsigned ints

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxx>
Date: Fri, 28 Jul 2000 15:13:43 -0700 (PDT)
> At 02:37 PM 7/28/00 -0500, Gilbert Ramirez wrote:
> WRT display filters, the man page refers to some fields being signed ints
> and some unsigned ints.
> 
> How does the user write an unsigned int vs a signed int?

The user doesn't, and shouldn't have to.  They should be able to write
the number and have it be interpreted correctly by the filter parser,
based on what type of value the int is being compared with; the code to
parse the filter expression should, if necessary, use "strtol()" vs. 
"strtoul()" when parsing the token for the number, based on whether the
other operand is a signed or unsigned field.

Right now, though, the number is always stored in the expression tree as
a "guint32", so we just call "strtoul()"; I suspect this means that
order comparisons on signed integers don't work correctly in display
filters (equality comparisons might work if sign extension of sub-32-bit
quantities is done on both values or is not done on both values).