newlocale: set errno to ENOENT if __loadlocale fails

__loadlocale never sets errno, but newlocale is supposed to
return ENOENT if the locale isn't valid.

Fixes: aefd8b5b51 ("Implement newlocale, freelocale, duplocale, uselocale")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-03-24 10:51:31 +01:00
parent 87ab6c7b26
commit 606373e7d2
1 changed files with 4 additions and 1 deletions

View File

@ -171,7 +171,10 @@ _newlocale_r (struct _reent *p, int category_mask, const char *locale,
continue;
/* Otherwise load locale data. */
else if (!__loadlocale (&tmp_locale, i, new_categories[i]))
goto error;
{
p->_errno = ENOENT;
goto error;
}
}
}
/* Allocate new locale_t. */