snore

sleep with feedback
git clone git://git.bitsmanent.org/snore
Log | Files | Refs | README | LICENSE

commit ef935c718f90e230d0507a9a18c0af602521b795
parent 71d12c5947c0d4116dd038cbbccea458c2181497
Author: clamiax <smoppy@gmail.com>
Date:   Wed, 18 Apr 2018 16:15:49 +0200

Fix a bug when passing 0 as unique argument; closes #6.

Diffstat:
Msnore.c | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/snore.c b/snore.c @@ -108,16 +108,19 @@ main(int argc, char *argv[]) { if(argc == 2 && !strcmp("-v", argv[1])) die("snore-"VERSION"\n"); - for(i = 1; i < argc; ++i) { - tm = time_to_sec(argv[i]); - if(tm < 0) - die("%s: wrong time\n", argv[i]); - endtm += tm; - if(endtm >= UINT_MAX) - die("%s: time too large\n", argv[0]); - } - if(!endtm) + if(argc == 1) { endtm = symbols[LENGTH(symbols) - 1].mult; + } + else { + for(i = 1; i < argc; ++i) { + tm = time_to_sec(argv[i]); + if(tm < 0) + die("%s: wrong time\n", argv[i]); + endtm += tm; + if(endtm >= UINT_MAX) + die("%s: time too large\n", argv[0]); + } + } for(tm = 0; tm < endtm; tm += DELTA) { time_print(tm); /* ascending */ printf(" | ");