mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Re: a bug in bindtextdomain() and strip '.UTF-8'
Date: Sat, 11 Feb 2017 18:59:38 -0500	[thread overview]
Message-ID: <20170211235938.GC1520@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAPG2z08yePs-6pqHcoBbMfWRPyXunuT-2Ge_JDWH8E5Y+_0wtw@mail.gmail.com>

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


  reply	other threads:[~2017-02-11 23:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 11:25 He X
2017-01-29  4:52 ` He X
2017-01-29 13:39   ` Szabolcs Nagy
2017-01-29 14:07     ` Rich Felker
2017-01-29 14:48       ` He X
2017-01-29 15:55         ` Rich Felker
2017-01-29 16:14           ` He X
2017-01-29 16:33             ` Rich Felker
2017-02-08 10:13               ` He X
2017-02-08 14:31                 ` Rich Felker
2017-02-09  9:49                   ` He X
2017-02-11  2:36                     ` Rich Felker
2017-02-11  6:00                       ` He X
2017-02-11 23:59                         ` Rich Felker [this message]
2017-02-12  2:34                         ` Rich Felker
2017-02-12  6:56                           ` He X
2017-02-12  7:11                             ` He X
2017-02-13 17:08                             ` Rich Felker
2017-02-13  8:01                           ` He X
2017-02-13 13:28                             ` Rich Felker
2017-02-13 14:06                               ` He X
2017-02-13 17:12                                 ` Rich Felker
2017-03-04  8:02                                   ` He X
2017-03-17 19:27                                     ` Rich Felker
2017-03-17 19:37                                       ` Rich Felker
2017-03-18  7:34                                         ` He X
2017-03-18 12:28                                           ` Rich Felker
2017-03-18 13:50                                             ` He X
2017-02-13 14:12                               ` He X
2017-02-13 17:13                                 ` Rich Felker
2017-01-29 16:37         ` Rich Felker
2017-01-30  0:37           ` He X
2017-01-30 14:17           ` He X
2017-01-29 16:40         ` Szabolcs Nagy
2017-01-29 16:49           ` Rich Felker
2017-01-30 12:36             ` He X
2017-01-30 13:05               ` Szabolcs Nagy
2017-01-30  1:32           ` He X

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170211235938.GC1520@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).