Tty characters 'undefined' value revisited

wen-king at cit-vlsi.UUCP wen-king at cit-vlsi.UUCP
Fri Feb 6 06:03:59 AEST 1987


In article <152 at quacky.mips.UUCP> dce at quacky.UUCP (David Elliott) writes:
>
>Basically,
>the problem is that the 4.3BSD documentation says that a value of -1
>means 'undefined', but our compilers generate unsigned characters.
>
>The general concensus of the responses I got is that the ttychars
>structure should be changed so that all of the members are shorts or
>ints instead of chars.
>
>Can anyone think of a reason NOT to do this? Are there places where
>these values are expected to be chars, and will broken by this change?

I remember vaguely that you were having problems comparing chars to
the constant -1.  The comparison:

    char c;
    c = -1;
    if(c == -1) ...

tests true on one some but false on others.  That is to be expected
because C does not specify how chars are to be casted to ints.
What you can do is to do the comparison like this:

    char c;
    c = -1;
    if(c == (char) -1) ...

This should test true on all machines.



More information about the Comp.unix.wizards mailing list