oliverschmidt/cc65 — pull request #3 by greg-king5 (2013-05-02 00:52:45+00:00)
Title: Fixed two <ctype.h> functions.

My first conclusion about Eric's patch is half wrong. His "fix" actually made things worse (it gave wrong results for more characters). So, I created my own fix.

`isgraph(),` `isprint(),` and `ispunct()` are "negative" functions. They ask the question, "Is this character _not_ what I want?" Then, they negate the answer. The old code used a bit-wise operator to do that negation. It works for `isprint()` because that function tests only one bit in the `_ctype` table. It doesn't work for the other functions because they test several bits at the same time (the bit-wise operator negates all of those bits – including bits that aren't relevant for a particular character).

I replaced that operator with a boolean negation. A comparison operator sets the virtual "borrow" flag to a state that is the opposite of the accumulator (e.g., the flag becomes zero when the `A` register is _any_ non-zero value). A subtraction operator translates that borrow flag into an accumulator value that is the function's result.