Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 30 Dec 2015 11:56:33 +0100
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: Patches: Timezone in %c and POT file

Hi all,

Now I have subscribed, so CC'ing me is no longer necessary.

Today I worked on two things: Firstly, I put the timezone into
strftime's %c output. The reason is that glibc's strftime() does the
same. That means, that an application dev currently can't depend on
either behavior (so strftime("%c %Z") will give me the timezone twice on
glibc, but only once on musl, and my app won't be able to tell without
inspecting the resulting string).

No biggie, changing that one is easy. Of course, a heated argument can
be had over whether or not we want it one way or the other. And it'll
come down to personal taste, because as far as I'm aware, POSIX isn't
mandating anything about this.

Then I noticed, that for quite some time now, musl has been supporting
.mo files, but no infrastructure is in place for them (i.e. no POT file
nor any PO file is shipped). I tried searching around for POT or PO
file, but I couldn't find any. So I added a handwritten POT file and a
German PO file (I'm not proficient enough in any languages besides
English and German to want to create that file for any other languages.
And an English PO file would be kind of redundant.)

I filled the POT file with all the strings I could find, that would ever
be plugged into __lctrans(). That gives me strerror(), strsignal(),
gai_strerror(), hstrerror(), and __getopt_msg() strings.

Unfortunately this design is running into some problems: At the moment
several strings are empty in the C locale (which is fine), but they
could translate to something else in some other locale (nl_langinfo()'s
ERA* and THOUSEP come to mind). Some strings in the C locale are the
exact same and might translate to something else in some language (the
long and short forms of "May" for instance). I think glibc solves that
problem with another file format for libc's locales, which is a headache
I don't want to think about this year anymore.

The second patch might be applicable to musl without the first by
accident: I left the format for ERA_D_T_FMT untouched, so looking up the
unchanged D_T_FMT would give that as a result. (Though I did translate
ERA_D_T_FMT.)

To make it clear to people who don't like locale: I changed nothing
about the build system. Locale MOs still aren't built and installed
automatically. That wouldn't even be possible without mandating a
default value for MUSL_LOCPATH.

However, I tried it out (installed it somewhere, put that location into
MUSL_LOCPATH and called strftime("%c")) and that seems to work. If we
got this far, then that means the file is found and can be mapped and
the lookup works. So the only thing that might be broken now is bad
translations or typos in the PO file. (Well, or anything unforseen, as
usual.)

Also, as usual, criticisms and comments are welcome.

Ciao,
Markus

View attachment "0001-Add-timezone-to-strftime-s-c.patch" of type "text/x-diff" (834 bytes)

View attachment "0002-Add-musl-PO-template-and-German-PO-file.patch" of type "text/x-diff" (22365 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.