From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 03C1F384D169; Fri, 24 Mar 2023 11:52:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03C1F384D169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679658732; bh=o/qVZKI6x530mkADBiqtrNB2iK/UOYqyiTbgLSdGpTU=; h=From:To:Subject:Date:From; b=b+7zR+ELo2c/AA13YgJi3ds1ewaDJTLeMFlkwlJ2KUkWLWGxJFeuygc1QtkRtobb8 sBTWOeSmeHAZifTv35g7mhX40XQdTw0+Mw51xrqL2oRu9jYW1sPtAw2TPz2alZoy2C +nEa7thNlsguPUaLM//eKTZs4MZ1QgKg3Ebtk5O0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: locales: set errno to ENOENT if locale is invalid X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 676796498defc0f26eb1c282c716785d20788b6f X-Git-Newrev: c53d0910e611bf4cf61f8f8cb44c6ce70d3e9a05 Message-Id: <20230324115212.03C1F384D169@sourceware.org> Date: Fri, 24 Mar 2023 11:52:12 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dc53d0910e61= 1bf4cf61f8f8cb44c6ce70d3e9a05 commit c53d0910e611bf4cf61f8f8cb44c6ce70d3e9a05 Author: Corinna Vinschen AuthorDate: Fri Mar 24 12:42:34 2023 +0100 Commit: Corinna Vinschen CommitDate: Fri Mar 24 12:50:59 2023 +0100 Cygwin: locales: set errno to ENOENT if locale is invalid =20 This allows newlocale to return with a valid errno if the locale is invalid. =20 Fixes: e95a7a795522 ("Cygwin: convert Windows locale handling from LCID= to ISO5646 strings") Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/nlsfuncs.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc index 808bf6a87320..a81dff3966d7 100644 --- a/winsup/cygwin/nlsfuncs.cc +++ b/winsup/cygwin/nlsfuncs.cc @@ -74,7 +74,10 @@ __get_rfc5646_from_locale (const char *name, wchar_t *wi= n_locale) if (!wcscmp (locale, L"ber")) wcscpy (locale, L"tzm"); if (ResolveLocaleName (locale, wlocale, ENCODING_LEN + 1) <=3D 0) - return -1; + { + set_errno (ENOENT); + return -1; + } wcpcpy (win_locale, wlocale); return 1; } @@ -114,7 +117,10 @@ __get_rfc5646_from_locale (const char *name, wchar_t *= win_locale) } if (!wlocale[0] && ResolveLocaleName (locale, wlocale, ENCODING_LEN + 1) <=3D 1) - return -1; + { + set_errno (ENOENT); + return -1; + } =20 /* Check for modifiers changing the script */ const wchar_t *iso15924_script[] =3D { L"Latn-", L"Cyrl-", L"Deva-", L"A= dlm-" };