[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] iscntrl(EOF)



Guido Flohr <gufl0000@stud.uni-sb.de> writes:

|> On Tue, Mar 07, 2000 at 04:44:30PM +0100, Andreas Schwab wrote:
|> > |> If so I would have to surrender and arrange for EOF not being a control
|> > |> character whereas 255 (UCHAR_MAX) would be one.  But I don't like that
|> > |> because a construct like
|> > |> 
|> > |> 	if (iscntrl (c))
|> > |> 		cast_it ();
|> > |> 
|> > |> would fail then for c == EOF.
|> > 
|> > What does UCHAR_MAX have to do with EOF?  They are distinct values.
|> 
|> Sure, they are, but in <ctype.h>:
|> 
|> #define iscntrl(c) (_ctype[(unsigned char) (c)] & _CTc)

This is just broken.

|> If UCHAR_MAX (255) and EOF (-1) should produce different results I have to
|> use a macro that evaluates its arguments twice (at least for non-gcc
|> compilers).
|> 
|> Hm, maybe it is cleverer to allow negative subscripts into the _ctype
|> array instead and remove the cast to unsigned char.

Use c+1.

Andreas.

-- 
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg