[MPlayer-dev-eng] a patch to show Chinese characters correctly in terminal

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Apr 4 17:09:58 CEST 2010


On Sun, Apr 04, 2010 at 09:21:08PM +0900, Jehan Pagès wrote:
> On Sun, Apr 4, 2010 at 6:17 PM, Reimar Döffinger
> <Reimar.Doeffinger at gmx.de> wrote:
> > And disregard one part of the other reply: any and all uses of setlocale are and as
> > long as I can stop it will be banned from MPlayer, it is broken by design, particularly
> > if you want a chance to support multi-threading.
> 
> I didn't know that setlocale was not thread safe. There is no mention
> of this in the man.

It modifies global state and as such can't be thread safe.

> When you say it is broken by design, is there any
> other reason that the multi-threading (just to feed my knowledge)?

Well, the multi-threading issue is what makes it impossible to use
(well, at least without completely wrapping all uses of almost all
libc string functions).
Without it, it would only be a pain to use - it changes the way
printf works, which would break slave mode, it changes how scanf works,
breaking reading config files and not working at all with the command-line.
It changes how strcasecmp works, even if you only use ASCII strings (no,
I is not the upper case of i in TR_tr).
There are probably more issues I just forgot.

> And if you want to ban setlocale from mplayer, you should start now by the way:
> 
> $ grep setlocale */*
> osdep/getch2.c:    setlocale(LC_CTYPE, "");
> osdep/getch2.c:    setlocale(LC_CTYPE, "C");
> osdep/getch2-os2.c:    setlocale( LC_CTYPE, "");
> osdep/getch2-os2.c:    setlocale( LC_CTYPE, "C");

Ok, though that is at least only run at startup for that reason, we can assume
there are no threads involved yet so it is fixable.



More information about the MPlayer-dev-eng mailing list