From: Ian Campbell Subject: Re: [PATCH 14/20] libxl: include and introduce CTYPE helper macro Date: Tue, 20 Mar 2012 12:12:10 +0000 Message-ID: <1332245530.9223.235.camel@zakaz.uk.xensource.com> References: <1331915215-10477-1-git-send-email-ian.jackson@eu.citrix.com> <1331915215-10477-15-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1331915215-10477-15-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Fri, 2012-03-16 at 16:26 +0000, Ian Jackson wrote: > Signed-off-by: Ian Jackson Shouldn't there be a handful of cleanups off the back of this? Huh, grep suggests only tools/libxl/xl_cmdimpl.c: if (!isdigit((uint8_t)p[i])) { which is not useful in the context of libxl_internal.h I have a feeling the others I was thinking of are in blktap or something Acked-by: Ian Campbell > --- > tools/libxl/libxl_internal.h | 20 ++++++++++++++++++++ > 1 files changed, 20 insertions(+), 0 deletions(-) > > diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h > index 8091ca2..69b6f74 100644 > --- a/tools/libxl/libxl_internal.h > +++ b/tools/libxl/libxl_internal.h > @@ -33,6 +33,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -1529,6 +1530,25 @@ static inline void libxl__ctx_unlock(libxl_ctx *ctx) { > } while(0) > > > +/* > + * int CTYPE(ISFOO, char c); > + * int CTYPE(toupper, char c); > + * int CTYPE(tolower, char c); > + * > + * This is necessary because passing a simple char to a ctype.h > + * is forbidden. ctype.h macros take ints derived from _unsigned_ chars. > + * > + * If you have a char which might be EOF then you should already have > + * it in an int representing an unsigned char, and you can use the > + * macros directly. This generally happens only with values > + * from fgetc et al. > + * > + * For any value known to be a character (eg, anything that came from > + * a char[]), use CTYPE. > + */ > +#define CTYPE(isfoo,c) (isfoo((unsigned char)(c))) > + > + > #endif > > /*