[MPlayer-dev-eng] [PATCH] Support locale under Windows console

Zuxy Meng zuxy.meng at gmail.com
Thu Mar 1 11:10:21 CET 2007


Hi,

2007/3/1, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> Hello,
> On Thu, Mar 01, 2007 at 12:39:20PM +0800, Zuxy Meng wrote:
> > -
> > +#include <stdio.h>
> >  #include <windows.h>
> >  #include "keycodes.h"
> >  #include "input/input.h"
> >
> >  int mp_input_win32_slave_cmd_func(int fd,char* dest,int size){
> >    DWORD retval;
> > -  HANDLE stdin = GetStdHandle(STD_INPUT_HANDLE);
> > -  if(!PeekNamedPipe(stdin, NULL, size, &retval, NULL, NULL) || !retval){
> > +  HANDLE hd_stdin = GetStdHandle(STD_INPUT_HANDLE);
> > +  if(!PeekNamedPipe(hd_stdin, NULL, size, &retval, NULL, NULL) || !retval){
>
>
> just put the stdio.h include into the USE_ICONV ifdef below. That's not
> too beautiful but not more ugly than this...

The purpose to include <stdio.h> was to avoid warnings about
undeclared "snprintf": just don't want to introduce more warnings in
the new code. However, "printf" had been used in old code, too; so
after I did what you suggested, there were still warnings. So we can
either:
1. Ignore the warning and don't bother <stdio.h> at all.
2. Rename stdin....

>
> > +#ifdef USE_ICONV
> > +char* get_term_charset()
> > +{
> > +    static char codepage[10];
> > +    const struct {
>
> IMO make it static, not that the compiler thinks of copying it to the
> stack. Actually, I personally would prefer it if you moved it outside
> the function, makes a slightly more "cleaned up" impression to me.

OK. I'll update the patch.
>
> > +    if (cpno >= cp_alias[0].cp) {
> > +        unsigned cur_cp, i = 0;
> > +        while ((cur_cp = cp_alias[i].cp)) {
> > +            if (cpno == cur_cp) {
> > +                return cp_alias[i].alias;
> > +            }
> > +            i++;
> > +        }
> > +    }
>
> The "if" seems like a pointless speed optimization to me, and requires
> the list to start with the element with the lowest number, which I dont
> like either. Why not just something like
> for (i = 0; cp_alias[i].cp; i++)
>  if (cp_alias[i].cp == cpno) return cp_alias[i].alias;

OK. I'll update the patch.

-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6



More information about the MPlayer-dev-eng mailing list