tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: once again, some discussion about <ctype.h> interfaces....
> Also, is sizeof() defined when handed an expression, rather than a
> variable, or type?
Yes. It returns the size of the expression's type.
> That is: isupper(c&0xFF) is perfectly valid, but I am not sure
> sizeof(c&0xFF) means anything.
It does. It returns sizeof(int), at least assuming c is of a type that
turns into int under the integer promotion rules (char is an example of
such a type).
> If you're of my vintage [...] then [...]
> if (isascii(c) && isupper(c)) c = tolower(c);
> Unfortunately, needing to do that has been obsolete for a long time
> now, so unless your legacy code is very legacy indeed, it probably
> doesn't do any of that.
Yes...but the restriction of the domain to "unsigned char plus EOF"
came in at the same time, so either it's traditional code (which tests
the argument first) or now-standard code (which mustn't pass plain
char); there is no need to support the hybrid style which doesn't test
but passes plain char. Such code is broken under either paradigm.
I see no need to change anything here. The warnings are valuable and
correct under the current standard paradigm; for building legacy code,
just turn off the warning in question; the code will be as correct (or
incorrect) as it always was.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index