Date: Tue, 24 Jun 2003 15:27:29 -0400 From: Garance A Drosihn <drosih@rpi.edu> To: Andrey Chernov <ache@nagual.pp.ru> Cc: das@freebsd.org Subject: Re: scanf(3) patch for C99-conformant FP parsing Message-ID: <p0521063fbb1e50e913fe@[128.113.24.47]> In-Reply-To: <20030624185704.GB92022@nagual.pp.ru> References: <20030624114418.GA58305@HAL9000.homeunix.com> <20030624124233.GA83552@nagual.pp.ru> <p0521063ebb1e4c770918@[128.113.24.47]> <20030624185704.GB92022@nagual.pp.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
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@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p0521063fbb1e50e913fe>