From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11025 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: a bug in bindtextdomain() and strip '.UTF-8' Date: Sat, 11 Feb 2017 18:59:38 -0500 Message-ID: <20170211235938.GC1520@brightrain.aerifal.cx> References: <20170129140747.GJ1533@brightrain.aerifal.cx> <20170129155507.GK1533@brightrain.aerifal.cx> <20170129163329.GL1533@brightrain.aerifal.cx> <20170208143147.GY1533@brightrain.aerifal.cx> <20170211023610.GA1520@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1486857602 14962 195.159.176.226 (12 Feb 2017 00:00:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 12 Feb 2017 00:00:02 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11040-gllmg-musl=m.gmane.org@lists.openwall.com Sun Feb 12 00:59:54 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 1ccha5-00037g-7M for gllmg-musl@m.gmane.org; Sun, 12 Feb 2017 00:59:53 +0100 Original-Received: (qmail 11991 invoked by uid 550); 11 Feb 2017 23:59:52 -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 11973 invoked from network); 11 Feb 2017 23:59:51 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11025 Archived-At: On Sat, Feb 11, 2017 at 02:00:56PM +0800, He X wrote: > fresh patch :) > 1. It's easier that just stopping at dot, and i think this should be > commented in the wiki or somewhere. > 2. I read your first part of reply for 20mins, but im not sure; If i > understand right, you mean, let the __locale_map* and strcut binding* be > the id-card for msgcat list instead of the long name string, not only > faster, but also more easy to construct pathname string. Yes. The values needed for the "id-card" (key) for the lookup are: 1. loc->cat[category] 2. category 3. The struct binding * active for domainname; gettextdir should be replaced with a function to lookup the binding rather than just returning the dir name. These three pointer/integer values uniquely determine the pathname(s) to try, and thus the mapped translation file to use. > But there's some > questions: > + I removed name from msgcat, i can't find its use there, is it safe? I think that's fine. > + gettextdir() is replaced by a new loop, since i need the pointer of > struct binding not only the dirname, but then, gettextdir() is only called > by bindtextdomain(), is there a need to keep it? Or we have a better way to > get the pointer of struct binding? It could be replaced with a function calle getdomainbinding that returns the struct binding * for the domain argument. Then the caller can use the returned pointer to lookup an existing mapped msgcat, or read out the ->dirname member if it needs to construct a path to map a new one. > + you said msgcat's indexed by ( struct __locale_map *, struct binding *, > category ), but i found lm(locale_map) is located by category, so if > category is different, then we can't get the same lm, so we can just > compare lm, right? If LC_TIME and LC_MESSAGES are both the same locale, then loc->cat[LC_TIME] and loc->cat[LC_MESSAGES] will both be the same pointer. Thus category also needs to be kept for the lookup (and path expansion). Does this help? I'll review the patch code separately. Rich