From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11160 Path: news.gmane.org!.POSTED!not-for-mail From: He X Newsgroups: gmane.linux.lib.musl.general Subject: Re: [setlocale]: return only one copy if all six parts of locale are same Date: Sat, 18 Mar 2017 23:00:52 +0800 Message-ID: References: <20170318123335.GO1693@brightrain.aerifal.cx> <20170318143954.GP1693@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f40304361d60ab4510054b02902b X-Trace: blaine.gmane.org 1489849287 27980 195.159.176.226 (18 Mar 2017 15:01:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Mar 2017 15:01:27 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11175-gllmg-musl=m.gmane.org@lists.openwall.com Sat Mar 18 16:01:22 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1cpFr6-0006do-B2 for gllmg-musl@m.gmane.org; Sat, 18 Mar 2017 16:01:20 +0100 Original-Received: (qmail 14020 invoked by uid 550); 18 Mar 2017 15:01:25 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14002 invoked from network); 18 Mar 2017 15:01:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=pkb+9M4d/47ElA2MbJEOlM7c8YaoaqOlatzw0Lu0oh0=; b=Vsa+NOShRZ4BF6j5EQuFo4s/MrPhKyrdHrWx2Zuft7Y6/JpytrTjGfIvgQTTU/e6LW b/gHj9WtmIIQBFocNuOoPgSrLxiIMYLzRskXcWgMpqcls5vgkMLjrxjVFUqStnNljq5j P+sMH7cKOG1xPfan+iyGbpE6rtYgIuGwwoY7EoJSV/7zaN57wZUHbhxLw2oUh7BxYuBU MHASOIRSkC3apzqQhK6sjlqX20RZ8GYHS01MmlgwYQ07lRj0cPlKpXaT8frAExcO1hzR PP3o9FcCKtg/BHx75TAiupQX2lTqv9gakr9d8qXGEnuc4A4VyNLJhnzxNoTSGmQlT8cX cI7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=pkb+9M4d/47ElA2MbJEOlM7c8YaoaqOlatzw0Lu0oh0=; b=EnJ33YrXit3CV1UFEXFB+gqzzlonioYKzyHo1PKGVEpCXossBJOjG6Ac9YNx4i+e+2 GdXhfqyEJ8vIQJoW8nUrbrGTln6QljPalPdxy5yVsRxoftb7cIcm2ryyGFU9DrXw9QiE pYARs2x6d5q8DHUN5usgwQ2eVe9oAIJQ2KNA7/zVGAfykT3wQfM2FWEWbQ2CNf6kl3nl bIXGcZOAJRxTcueZaTs2HW22rX8StzlzLEhrh6T9VKG70khCeS0H4O3/devG3DT+N/aS guQ69M+SZovRrQJmPOm91OyclF/eTKNgKx1I7L5aO/U0EGj09ZRNB7Mr3ah+rjg7SBZv WlXA== X-Gm-Message-State: AFeK/H0s3DwWvkrz4ZB2RfvEwc1h2XOqqF8htznA6bG40INxYMTUza5hJ6vGyHYALzNFjpP3YHv5zpEX512KIQ== X-Received: by 10.176.23.111 with SMTP id k47mr1389724uaf.54.1489849272712; Sat, 18 Mar 2017 08:01:12 -0700 (PDT) In-Reply-To: <20170318143954.GP1693@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:11160 Archived-At: --f40304361d60ab4510054b02902b Content-Type: text/plain; charset=UTF-8 Wow, tested. Thx for improvements. Learnt a lots from recent patches related to locale. Sincerely thank you, rich :) xhe 2017-03-18 22:39 GMT+08:00 Rich Felker : > On Sat, Mar 18, 2017 at 09:48:41PM +0800, He X wrote: > > oops, i missed UNLOCK(lock). > > > > [...] > > >> > > >> I think the results of this patch can be achieved much more simply. > > >> Just compare lm pointers (rather than string contents) for equality at > > >> each iteration in the current loop, counting how many were equal to > > >> libc.global_locale.cat[0]. If that number equals LC_ALL, return > > >> libc.global_locale.cat[0]->name (or "C" if the lm is null) rather > than > > >> buf. > > >> > > >> Rich > > >> > > > > > > > > By simpler I meant something like the attached. > > Rich > --f40304361d60ab4510054b02902b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Wow, tested. Thx for improvements. Learnt a lots from rece= nt patches related to locale.
Sincerely thank you, rich :)
xhe

2017-03-18 22:39 GMT+08:00 Rich Felker <dalias@libc.org>:
On Sat, Mar 18, 2017 at 09:48:41PM= +0800, He X wrote:
> oops, i missed UNLOCK(lock).
>
> [...]
> >>
> >> I think the results of this patch can be achieved much more s= imply.
> >> Just compare lm pointers (rather than string contents) for eq= uality at
> >> each iteration in the current loop, counting how many were eq= ual to
> >> libc.global_locale.cat[0]. If that number equals LC_A= LL, return
> >> libc.global_locale.cat[0]->name (or "C&q= uot; if the lm is null) rather than
> >> buf.
> >>
> >> Rich
> >>
> >
> >

By simpler I meant something like the attached.

Rich

--f40304361d60ab4510054b02902b--