This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs/fortran warnings (Was : possible spurious warning for isdigit)


   Date: Mon, 10 Nov 1997 13:31:41 -0500 (EST)
   From: Craig Burley <burley@gnu.org>

   However, I'll have to put this off at least until I can take
   enough time to figure out just how one is supposed to portably,
   efficiently, and standard-conformingly do things like
   `isalpha("foo"[0])' when the compiler encodes strings as `char *'.

Either
    isalpha ((unsigned char) ("foo"[0]))
or
    isalpha (((const unsigned char *) "foo")[0])

   That is, generally, I'm not sure offhand how to properly use
   these functions when the character has already been read
   via, say, getc(), validated as not being EOF, and copied into
   an element of a `char *'.  Simply casting the `char' back to
   `int' is plainly wrong, but maybe casting it to `unsigned char'
   isn't?

Right; just cast to unsigned char.  Some very very old compilers don't
support unsigned char, but that is presumably not a problem for the
code in question.  (For those compilers, you can safely `& 0xff').

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]