From: Christian Heller Date: Mon, 25 Nov 2013 01:03:43 +0000 (+0100) Subject: sorted_winttogle_and_activate() now sufficiently tolerates toggle_order_and_activate... X-Git-Tag: tce~915 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/te"st.html?a=commitdiff_plain;h=52f02f0f8614afa7d4776e90d955eff9c3659f80;p=plomrogue sorted_winttogle_and_activate() now sufficiently tolerates toggle_order_and_activate files that go beyond there intended length. --- diff --git a/config/windows/toggle_order_and_active b/config/windows/toggle_order_and_active index f188d83..2ae7c2c 100644 --- a/config/windows/toggle_order_and_active +++ b/config/windows/toggle_order_and_active @@ -1,2 +1,2 @@ kmicl -m \ No newline at end of file +m diff --git a/src/readwrite.h b/src/readwrite.h index 01a6f38..6f7bce3 100644 --- a/src/readwrite.h +++ b/src/readwrite.h @@ -33,8 +33,8 @@ extern void try_fclose_unlink_rename(FILE * file, char * p1, char * p2, char * f); /* Wrapper: Call textfile_sizes() from function called "f" to get max line - * length of "file", exit via exit_err() with trouble_msg()-generated error - * message on failure. + * length (includes newline char) of "file", exit via exit_err() with + * exit_trouble() on failure. */ extern uint16_t get_linemax(FILE * file, char * f); diff --git a/src/wincontrol.c b/src/wincontrol.c index bbb4c5c..6fb9acb 100644 --- a/src/wincontrol.c +++ b/src/wincontrol.c @@ -391,7 +391,6 @@ extern void sorted_wintoggle_and_activate() char * path = "config/windows/toggle_order_and_active"; FILE * file = try_fopen(path, "r", f_name); uint16_t linemax = get_linemax(file, f_name); - char win_order[linemax + 1]; try_fgets(win_order, linemax + 1, file, f_name); @@ -401,7 +400,7 @@ extern void sorted_wintoggle_and_activate() try_fclose(file, f_name); uint8_t i = 0; - for (; i < linemax - 1; i++) + for (; i < strlen(win_order) - 1; i++) { if (NULL == strchr(world.winconf_ids, win_order[i])) {