Re: [Lit.] Buffer overruns
From: Bryan Olson (nameless_at_nowhere.org)
Date: 01/26/05
- Next message: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- Previous message: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- In reply to: infobahn: "Re: [Lit.] Buffer overruns"
- Next in thread: Douglas A. Gwyn: "Re: [Lit.] Buffer overruns"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 26 Jan 2005 22:15:32 GMT
infobahn wrote:
> 7.4 (ctype.h)
>
> The header <ctype.h> declares several functions useful for classifying
> and mapping characters.166) In all cases the argument is an int, the
> value of which shall be representable as an unsigned char or shall
> equal the value of the macro EOF. If the argument has any other value,
> the behavior is undefined.
I stand corrected. I had been going by Harbison and Steele's
/C, A Reference Manual/, know to C programmers as "H&S". H&S
apparently has this wrong. It states:
All of the facilities described here operate properly on all
values representable as type char or type unsigned char, and
also for the value EOF, but are undefined for all other
integer values unless the individual description states
otherwise.
[Samuel P. Harbison and Guy L. Steele, Jr., /C: A Reference
Manual/, Fifth Edition, Prentice-Hall, 2002; Chapter 12,
"Character Processing", page 335.]
Thus I thought a char argument to toupper (which is descibed in
chapter 12) was fine. Harbison and Steele go on to say:
Warning: Some non-Standard implementations of C let the type
char be signed and also support a type unsigned char, yet
the character-handling facilities fail to operate properly
on all values representable by type unsigned char.
That lead me to believe type char was slightly preferable to
type unsigned char.
I just checked the H&S errata, and the issue is not yet noted. I
sent it in.
I bow to your superior knowledge of the C standard. As for my
opinion of C, I'm yet again aghast at how awful it is.
-- --Bryan
- Next message: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- Previous message: Mok-Kong Shen: "Re: [Lit.] Buffer overruns"
- In reply to: infobahn: "Re: [Lit.] Buffer overruns"
- Next in thread: Douglas A. Gwyn: "Re: [Lit.] Buffer overruns"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|