Skip to content

Commit

Permalink
Fix iteration over monitor list
Browse files Browse the repository at this point in the history
Ensure the code runs on the very last element of the list.

Closes #245
  • Loading branch information
LemonBoy committed Sep 10, 2023
1 parent 9ff4a7b commit cbe3940
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lemonbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,14 @@ parse (char *text)
case 'n': { // Named monitor.
const size_t name_len = block_end - (p + 1);
cur_mon = monhead;
while (cur_mon->next) {
while (cur_mon) {
if (cur_mon->name &&
!strncmp(cur_mon->name, p + 1, name_len))
!strncmp(cur_mon->name, p + 1, name_len) &&
cur_mon->name[name_len] == '\0')
break;
cur_mon = cur_mon->next;
}
if (!cur_mon) cur_mon = orig_mon;
p += 1 + name_len;
} break;
case '0' ... '9': // Numbered monitor.
Expand Down

1 comment on commit cbe3940

@ColeBardin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Please sign in to comment.