commit 906a6caa1367ca981ddc1c3fdf905bdd03fb39e2 parent aa718fd83ad84e357a1235b7bd037385dcdc23ff Author: Ivan Tham <pickfire@riseup.net> Date: Tue, 6 Sep 2016 21:36:05 +0800 Main goto loop to for loop Thanks to quinq http://lists.suckless.org/hackers/1609/12073.html Diffstat:
| M | spt.c | | | 13 | +++++-------- |
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/spt.c b/spt.c @@ -129,14 +129,11 @@ main(int argc, char *argv[]) if (signal(SIGUSR2, SIG_IGN) != SIG_IGN) signal(SIGUSR2, toggle); -run: - notify_send(timers[i].cmt); - - for (timecount = 0; timecount < timers[i].tmr; timecount += inc) - sleep(1); - - if (++i >= LEN(timers)) i = 0; /* i infinal loop */ - goto run; + for (i = 0; ; i = (i + 1) % LEN(timers)) { + notify_send(timers[i].cmt); + for (timecount = 0; timecount < timers[i].tmr; timecount += inc) + sleep(1); + } return 0; }