From b4705bbaa72a663f9d6e387cc248be6ae919d8af Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Tue, 13 Apr 2010 20:41:41 +0200 Subject: [PATCH 1/2] Conf: Fix button section bug --- src/config.c | 19 ++++++++++--------- src/parse/parse.c | 16 ++++++++-------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/config.c b/src/config.c index 905ca08..17d71b8 100644 --- a/src/config.c +++ b/src/config.c @@ -291,7 +291,7 @@ conf_client_section(void) free(mouse); /* Multi button part */ - button = fetch_section(sec[0], "button"); + button = fetch_section(titlebar[0], "button"); for(n = 0; button[n]; n++); @@ -487,7 +487,7 @@ conf_tag_section(void) for(i = 0; i < sc; ++i) tags[i] = emalloc(n + 2, sizeof(Tag)); - for(i = (n-1); i >= 0; i--) + for(i = (n - 1); i >= 0; i--) { j = fetch_opt(tag[i], "-1", "screen")[0].num; @@ -566,7 +566,7 @@ void conf_menu_section(void) { char *tmp2; - int i, j, n; + int i, j, aj, n; struct conf_sec **menu, **set_menu, **item; menu = fetch_section(NULL, "menu"); @@ -611,13 +611,14 @@ conf_menu_section(void) if((conf.menu[i].nitem = n)) { conf.menu[i].item = emalloc(conf.menu[i].nitem, sizeof(MenuItem)); - for(j = 0; j < conf.menu[i].nitem; ++j) + for(j = 0; j < n; ++j) { - conf.menu[i].item[j].name = fetch_opt(item[j], "item_wname", "name")[0].str; - conf.menu[i].item[j].func = name_to_func(fetch_opt(item[j], "", "func")[0].str, func_list); - conf.menu[i].item[j].cmd = fetch_opt(item[j], "", "cmd")[0].str; - conf.menu[i].item[j].check = name_to_func(fetch_opt(item[j], "", "check")[0].str, func_list); - conf.menu[i].item[j].submenu = fetch_opt(item[j], "", "submenu")[0].str; + aj = (n - 1) - j; + conf.menu[i].item[aj].name = fetch_opt(item[j], "item_wname", "name")[0].str; + conf.menu[i].item[aj].func = name_to_func(fetch_opt(item[j], "", "func")[0].str, func_list); + conf.menu[i].item[aj].cmd = fetch_opt(item[j], "", "cmd")[0].str; + conf.menu[i].item[aj].check = name_to_func(fetch_opt(item[j], "", "check")[0].str, func_list); + conf.menu[i].item[aj].submenu = fetch_opt(item[j], "", "submenu")[0].str; } } free(item); diff --git a/src/parse/parse.c b/src/parse/parse.c index 5695293..1237667 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -225,7 +225,7 @@ get_conf(const char *name) SLIST_INSERT_HEAD(&config, s, entry); break; default: - errx(1, "%s:%d: near '%s', config out of any section", + errx(1, "%s:%lu: near '%s', config out of any section", file.name, curk->line, curw->name); break; } @@ -246,7 +246,7 @@ get_section(void) pop_keyword(); if (curk->type != WORD) - errx(1, "%s:%d: near '%s', missing section name", + errx(1, "%s:%lu: near '%s', missing section name", file.name, curk->line, curw->name); pop_keyword(); @@ -264,7 +264,7 @@ get_section(void) case SEC_END: break; default: - errx(1, "%s:%d: near '%s', syntax error", + errx(1, "%s:%lu: near '%s', syntax error", file.name, curk->line, curw->name); break; } @@ -272,11 +272,11 @@ get_section(void) pop_keyword(); if (curk->type != WORD) - errx(1, "%s:%d: near '%s', missing end-section name", + errx(1, "%s:%lu: near '%s', missing end-section name", file.name, curk->line, curw->name); if (strcmp(curw->name, s->name)) - errx(1, "%s:%d: near '%s', non-closed section '%s'", + errx(1, "%s:%lu: near '%s', non-closed section '%s'", file.name, curk->line, curw->name, s->name); pop_stack(); @@ -297,7 +297,7 @@ get_option(void) pop_keyword(); if (curk->type != EQUAL) - errx(1, "%s:%d: near '%s', missing '=' here", + errx(1, "%s:%lu: near '%s', missing '=' here", file.name, curk->line, curw->name); pop_keyword(); @@ -312,7 +312,7 @@ get_option(void) pop_keyword(); while (curk->type != LIST_END) { if (curk->type != WORD) - errx(1, "%s:%d: near '%s', declaration into a list", + errx(1, "%s:%lu: near '%s', declaration into a list", file.name, curk->line, curw->name); o->val[j++] = strdup(curw->name); pop_stack(); @@ -321,7 +321,7 @@ get_option(void) o->val[j] = NULL; break; default: - errx(1, "%s:%d: near '%s', syntax error", + errx(1, "%s:%lu: near '%s', syntax error", file.name, curk->line, curw->name); break; } From 9a38a64ceddbaa09f0f9468c3053043248a0b265 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Tue, 13 Apr 2010 20:49:42 +0200 Subject: [PATCH 2/2] Conf: Fix multi mouse section of titlebar --- src/config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 17d71b8..11d2b9c 100644 --- a/src/config.c +++ b/src/config.c @@ -281,13 +281,14 @@ conf_client_section(void) mouse = fetch_section(titlebar[0], "mouse"); - for(n = 0; sec[n]; n++); + for(n = 0; mouse[n]; n++); if((conf.titlebar.nmouse = n) > 0) { conf.titlebar.mouse = emalloc(conf.titlebar.nmouse, sizeof(MouseBinding)); mouse_section(conf.titlebar.mouse, n, mouse); } + free(mouse); /* Multi button part */