[MPlayer-dev-eng] [PATCH] Support locale under Windows console
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Mar 1 10:51:05 CET 2007
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...
> +#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.
> + 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;
Greetings,
Reimar Döffinger
More information about the MPlayer-dev-eng
mailing list