tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: using the interfaces in ctype.h
>> Look closer. The object indexed inside the macro is _one past_ the
>> base of the array object being indexed; this is done specifically to
>> support EOF as an argument.
> Nope, that does not work, at least not if the parameter is an int
> variable,
No? In what sense does it not work? Remember that x[y] is equivalent
to *(x+y), except as regards operator precedence; in particular,
(x+1)[y] is equivalent to x[(y)+1].
>> Ideally, I'd say, ["save"] would mean "drop core when passed
>> anything out-of-range" (and I don't mean "drop core or access
>> something random, depending on the arg and how memory happens to be
>> laid out").
> And just how do you plan to do that with any traditional C
> implementation [...]
I don't. That's why I wrote of a substantial performance penalty: it
would involve a substantially more complicated implementation.
> A simple mask provides all of the safety one can hope for given the
> present implementation. :-)
Only if "safety" means "conflating invalid values with valid ones",
and, worse, either conflating EOF with some unsigned char or (almost)
doubling the size of the array.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents.montreal.qc.ca@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