fix code to work with gcc, move init_locales() outside of util.