scanf(3) patch for C99-conformant FP parsing
Garance A Drosihn
drosih at rpi.edu
Tue Jun 24 12:27:33 PDT 2003
At 10:57 PM +0400 6/24/03, Andrey Chernov wrote:
>On Tue, Jun 24, 2003, Garance A Drosihn wrote:
>> #define isdigitch(Anychar) isdigit(((int) Anychar) & 255)
>> #define isupperch(Anychar) isupper(((int) Anychar) & 255)
>> #define isxdigitch(Anychar) isdigit(((int) Anychar) & 255)
>> #define tolowerch(Anychar) tolower(((int) Anychar) & 255)
>Just (unsigned char) cast produce better code and more readable.
>In any case & 255 alone will be enough without needs to convert
>to (int) first.
Yeah, I actually have two or three different versions of the
macros, depending on what I was thinking at the time. The above
lines are from a file I just happened to have open while reading
today's email. It wouldn't surprise me too much if they include
a bit of overkill.
In any case, my main suggestion is having is*ch() macros, and
using them whenever dealing with byte-values. I often see
code that uses one of the is*() routines with a parameter that
is 'char *'. It's an easy mistake to make, and it can introduce
subtle bugs when porting code.
Garance Alistair Drosehn = gad at gilead.netel.rpi.edu
Senior Systems Programmer or gad at freebsd.org
Rensselaer Polytechnic Institute or drosih at rpi.edu
More information about the freebsd-standards