PATCH: [perl #115808]: POSIX::setlocale returns bizarre value on failure

It turns out that this bug is caused by a more general one, covered by
[perl #118693].  But in the meantime, this commit fixes the problem for
setlocale(), and makes the code slightly cleaner besides.