[MPlayer-dev-eng] Re: [PATCH] one input key more commands
Diego Biurrun
diego at biurrun.de
Sun Apr 1 12:33:10 CEST 2007
On Sun, Apr 01, 2007 at 11:48:59AM +0200, Ötvös Attila wrote:
> 2007. április 1. 01.00 dátummal Alban Bedel ezt írta:
>
> --- input/input.c (revision 22870)
> +++ input/input.c (working copy)
> @@ -898,6 +909,31 @@
>
> +static mp_cmd_bind_section_t*
> +mp_input_get_bind_section(char *section) {
> + mp_cmd_bind_section_t* bind_section = cmd_binds_section;
> +
> + if (section==NULL) section="default";
> + while (bind_section) {
> + if(strcmp(section,bind_section->section)==0) {
> + return bind_section;
> + }
> + if(bind_section->next==NULL) break;
> + bind_section=bind_section->next;
> + }
> + if(bind_section) {
> + bind_section->next=malloc(sizeof(mp_cmd_bind_section_t));
> + bind_section=bind_section->next;
> + } else {
> + cmd_binds_section=malloc(sizeof(mp_cmd_bind_section_t));
> + bind_section=cmd_binds_section;
> + }
> + bind_section->cmd_binds=NULL;
> + bind_section->section=strdup(section);
> + bind_section->next=NULL;
> + return bind_section;
> +}
Your idea of indentation is .. peculiar to say the least.
> @@ -905,6 +941,8 @@
>
> if(cmd_binds)
> cmd = mp_input_find_bind_for_key(cmd_binds,n,keys);
> + if(cmd_binds_default && cmd == NULL)
> + cmd = mp_input_find_bind_for_key(cmd_binds_default,n,keys);
same here
> @@ -1378,31 +1416,46 @@
> void
> mp_input_bind_keys(int keys[MP_MAX_KEY_DOWN+1], char* cmd) {
> int i = 0,j;
> mp_cmd_bind_t* bind = NULL;
> + mp_cmd_bind_section_t* bind_section = NULL;
> + char *section=NULL, *p;
and here
> + if(*cmd=='{' && (p=strchr(cmd,'}'))) {
> + *p=0;
> + section=++cmd;
> + cmd=++p;
> + // Jump beginning space
> + for( ; cmd[0] != '\0' && strchr(SPACE_CHAR,cmd[0]) != NULL ; cmd++)
> + /* NOTHING */;
> + }
> + bind_section=mp_input_get_bind_section(section);
> +
> + if(bind_section->cmd_binds) {
> + for(i = 0; bind_section->cmd_binds[i].cmd != NULL ; i++) {
> + for(j = 0 ; bind_section->cmd_binds[i].input[j] == keys[j] && keys[j] != 0 ; j++)
> /* NOTHING */;
> - if(keys[j] == 0 && cmd_binds[i].input[j] == 0 ) {
> - bind = &cmd_binds[i];
> + if(keys[j] == 0 && bind_section->cmd_binds[i].input[j] == 0 ) {
> + bind = &bind_section->cmd_binds[i];
dito
> @@ -1584,9 +1633,30 @@
> }
> mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrWhyHere);
> close(fd);
> + mp_input_set_section(NULL);
> return 0;
see above
[...]
I don't understand this, don't you think (proper) indentation makes code
more readable? Do you follow any sort of guidelines for indentation?
Do you roll dice to decide how many spaces to put at the beginning of
each line?
Diego
More information about the MPlayer-dev-eng
mailing list