> > OK - I'm feeling particularly stupid now: how does masking > a byte with 0xFF help? Is it that isdigit() thinks it gets an > int, or... > > I'm missing something key here, obviously... > > C doesn't define whether a "char" is signed or unsigned, so > masking makes sure that you don't pass in a negative number, > and also keeps the value within the range supported by the > ctype functions (-1 to 255 in most cases - -1 because that is > the "EOF" character...)
OK - so it is just sign-extension in the promotion to int that we are dealing with then, that makes sense... E.g. if the char in *str is 0x83 say, and is promoted to int, we have to assume (for safety) that it will be sign extended to 0xF..F83, so we mask it with 0xFF to ensure the actual int value is the same as the original char value. Fair enough, seems like a Good Thing To Do. (Though possibly redundant in this case? Are there char values that would sign extend for which isidigit() holds true?) SELEX Galileo Ltd Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL A company registered in England & Wales. Company no. 02426132 ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ******************************************************************** _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
