From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Morten Welinder <mwelinder@gmail.com>, git@vger.kernel.org
Subject: Re: Usage of isspace and friends
Date: Thu, 13 Oct 2005 08:04:17 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0510130756550.15297@g5.osdl.org> (raw)
In-Reply-To: <7vachd6hdx.fsf@assigned-by-dhcp.cox.net>
On Wed, 12 Oct 2005, Junio C Hamano wrote:
>
> Huh? isspace is "int isspace(int)". Presumably standard
> integral promotion rules applies here whether char is signed or
> unsigned, doesn't it?
No.
The input range for the "isxxxxx()" macros is the same as the range for
the "[f]getc[h]()" family: unsigned char + EOF (the latter usually being
-1).
So Morten is right - if you have a "char *", it should not be dereferenced
and used directly, although I think glibc does the right thing (and, in
fact, I can't understand why the standards haven't been updated to do the
right thing: it's _not_ that hard. In fact, it should be trivial apart
from the special case of "255" that looks undistinguishable from EOF in
signed char representation).
I'm almost goign to suggest that we do our own ctype.h, just to get the
sane semantics: we want locale-independence, _and_ we want the right
signed behaviour. Plus we only use a very small subset of ctype.h anyway
(isspace, isalpha, isdigit and isalnum).
Linus
next prev parent reply other threads:[~2005-10-13 15:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-12 1:40 Usage of isspace and friends Morten Welinder
2005-10-13 6:49 ` Junio C Hamano
2005-10-13 8:29 ` Antti-Juhani Kaijanaho
2005-10-13 13:27 ` H. Peter Anvin
2005-10-13 15:44 ` Junio C Hamano
2005-10-13 15:04 ` Linus Torvalds [this message]
2005-10-13 15:45 ` H. Peter Anvin
2005-10-13 15:56 ` Linus Torvalds
2005-10-13 16:07 ` H. Peter Anvin
2005-10-13 15:46 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0510130756550.15297@g5.osdl.org \
--to=torvalds@osdl.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=mwelinder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).