Now hexchat doesn't abnormally terminal when started as root.

This fixes #589/#504.
Factored locale related code in main() to a new function.
Removed unnecessary call to check_prefs_dir() in load_config().
This function is called in save_config(), where it is actually needed.
Forget to put an empty line after a function definition
Restructured a fair bit of cfgfiles.c. Besides making the code cleaner this allows
for better error handling (in fact the error message of check_prefs_dir () whould
make hexchat abort).
Merge pull request #590 from orium/run-as-root-589-504

Now hexchat doesn't abnormally terminate when started as root.