Mark libc ctype functions as pure where applicable.

Same as the pull for #285 

Except removed the mathlib bits, leaving the ctype/wctype functions in place.