From b2ede86e69a566d860de6a8287834e8b93eb5d38 Mon Sep 17 00:00:00 2001 From: randomuser Date: Fri, 11 Jun 2021 00:49:03 -0500 Subject: [PATCH] settings struct now only uses seconds --- progs/timer.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/progs/timer.c b/progs/timer.c index be7bd23..78bf949 100644 --- a/progs/timer.c +++ b/progs/timer.c @@ -12,7 +12,6 @@ struct settings { int d:1; /* count down/up (1/0) */ int b:1; /* ascii bel when done */ int f:1; /* display hours */ - int m; /* minutes */ int s; /* seconds */ } s = { .e = 0, @@ -20,13 +19,12 @@ struct settings { .d = 0, .b = 0, .f = 0, - .m = 0, .s = 0 }; int timerissettings(struct timer *t) { if(t->s == 0) return 0; - if(s.m * 60 + s.s == t->s) return 1; + if(s.s == t->s) return 1; return 0; } @@ -42,7 +40,7 @@ void timerloop() { struct timer *t = timerinit(); if(s.d) { t->u = timerdec; - t->s = s.s + (s.m * 60); + t->s = s.s; t->c = timerzero; } else { t->u = timerinc; @@ -88,8 +86,8 @@ int main(int argc, char **argv) { break; case 'd': s.d = 1; break; case 'b': s.b = 1; break; case 'f': s.f = 1; - break; case 'm': s.m = atoi(optarg); - break; case 's': s.s = atoi(optarg); + break; case 'm': s.s = s.s + (atoi(optarg) * 60); + break; case 's': s.s = s.s + atoi(optarg); break; case '?': return 1; break; default: abort(); }