mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-20 05:33:47 -04:00
main: improve handling of setlocale(3) return value
There's no need to call setlocale() twice, since the first call returns the same value as the second. We also handle a NULL return value explicitly and show a distinct error message for that case, since it typically indicates a misconfigured locale and not just a non-UTF8 locale.
This commit is contained in:
parent
3e04c4e4f4
commit
0e5e68d82e
1 changed files with 6 additions and 2 deletions
8
main.c
8
main.c
|
|
@ -417,8 +417,12 @@ main(int argc, char *const *argv)
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
const char *locale = setlocale(LC_CTYPE, "");
|
||||||
LOG_INFO("locale: %s", setlocale(LC_CTYPE, NULL));
|
if (locale == NULL) {
|
||||||
|
LOG_ERR("setlocale() failed");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
LOG_INFO("locale: %s", locale);
|
||||||
if (!locale_is_utf8()) {
|
if (!locale_is_utf8()) {
|
||||||
LOG_ERR("locale is not UTF-8");
|
LOG_ERR("locale is not UTF-8");
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue