🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5640

Re: How to use toupper()

#5640
From: Doug Gwyn
Date: Fri, 20 Jan 1989 17:38
50 lines
2650 bytes
In article <23156@watmath.waterloo.edu> rbutterworth@watmath.waterloo.edu (Ray Butterworth) writes:
>If 'C' is any character that sign extends, the switch won't work.

In Standard C it will work for all 'C' in the required source
character set, which are required to have nonnegative values as
"chars", which match the character-constant integer values.

Sign extension of "chars" has ALWAYS been an issue for portable
C programming, and there is no way to fix that in the Standard
other than by outlawing signed implementation of "char", which
the Committee has repeatedly declined to do.

>Much of this was mentioned to the Committee.
>e.g. Letter P04 to the Second Public Review contained: ...

And letter L181 which was responded to in the third formal public
review repeated the point, which I summarized as:

	<ctype.h> macros should be made safe for "signed char"
	arguments.

The X3J11 response was:

	The Committee has voted against this idea.

	"char" arguments can always be cast to "unsigned char"
	type before calling a <ctype.h> function.  Indeed, since
	one cannot distinguish in classic signed "char"
	implementations between EOF (with value -1) and the
	8-bit char '377', whenever there might be a '377' value
	for a "char" the argument *must* be cast to an "unsigned
	char" for such implementations.

>+  ... there certainly can't be any existing code that depends on
>+  the described behavior.

But there is a LOT of code that does.  As you note, implementations
in environments with characters with high bits set are advised to
to implement plain "char" as if it were unsigned.

>Drop that requirement and say that they are only defined to work on
>values that can be returned by getchar().

What's the point?  getchar() can return ANY byte value, or EOF.  The
proposed Standard already requires that the argument to a ctype-
function be representable as an "unsigned char" or equal the value EOF.

You've tried at least twice now to convince X3J11 to change this part
of the specification, and you haven't convinced them.  Why carry on
about it here?
Technical Details
Message-ID: <9457@smoke.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!labrea!rutgers!cmcl2!adm!smoke!gwyn
References: <2537@xyzzy.UUCP> <189@becker.UUCP> <9256@smoke.BRL.MIL> <2792@xyzzy.UUCP> <23156@watmath.waterloo.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!labrea!rutgers!cmcl2!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn )
Newsgroups: comp.std.c
Subject: Re: How to use toupper()
Message-ID: <9457@smoke.BRL.MIL>
Date: 20 Jan 89 17:38:56 GMT
References: <2537@xyzzy.UUCP> <189@becker.UUCP> <9256@smoke.BRL.MIL> <2792@xyzzy.UUCP> <23156@watmath.waterloo.edu>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 50