Cache old LC_CTYPE locale for restoring it later.

Cache old LC_CTYPE locale before setting it to "C", so
we can use it to restore LC_CTYPE instead of asking
setlocale() to scan the environment variables.
Use C locale for LC_CTYPE around one more regcomp().
I probably wouldn't remember all this next time, so writing it down.