This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: isblank patch
Why not make isblank a self expanding macro and an inline or extern function
?
static inline isblank(int c) { return c == ' ' || c == '\t'; }
#define isblank(c) ((isblank)(c))
This way isblank is a macro whose presence can be correctly detected with
#ifdef
Thinking twice about this, I think isblank should be locale specific per
C99:
7.4.1.3 The isblank function
Synopsis
1 #include <ctype.h>
int isblank(int c);
Description
2 The isblank function tests for any character that is a standard blank
character or is one
of a locale-specific set of characters for which isspace is true and that is
used to
separate words within a line of text. The standard blank characters are the
following:
space (' '), and horizontal tab ('\t'). In the "C" locale, isblank returns
true only
for the standard blank characters.
What a bloody shame!
Chqrlie.
----- Original Message -----
From: "Howland Craig D (Craig)" <howland@LGSInnovations.com>
To: <newlib@sourceware.org>
Sent: Tuesday, October 14, 2008 6:29 PM
Subject: isblank patch
A couple of minor touchups for the isblank() function. ctype.h has it
listed as being non-ANSI, but it is. Additionally, isblank.c claimed
that it was a macro yet ctype.h does not have a macro for it. The
attached patch moves the prototype in ctype.h so that it is there for
ANSI
and makes appropriate cleanups to the comments in isblank.c. The patch
file also includes a ChangeLog entry.
(I decided not to create an isblank macro because it would have been
messy to make a good one. There are some to be found that do this:
#define isblank(c) ((c) == ' ' || (c) == '\t')
This form has the problem of evaluating the argument twice, which is
undesirable. I did not use the method presently in ctype.h for toupper
and tolower because they are only defined for GCC and would not
always be applicable, making a comment about it being a macro in the
man page subject to error.)
Craig Howland