sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit ad9a9dd3e10629f82c89dcdbf2070f4efb23738f
parent bf3210b6de544f86aefd6df97ea1cbb40fbfec78
Author: FRIGN <dev@frign.de>
Date:   Sat Feb 28 21:11:10 +0100

Audit yes(1)

Oh well, time to simplify the loop.
Also, change the comment on unreachable code to something more clear.

Diffstat:
yes.c | 14+++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/yes.c b/yes.c @@ -19,14 +19,10 @@ main(int argc, char *argv[]) usage(); } ARGEND; - if (argc == 0) { - for (;;) - puts("y"); - } else { - for (i = 0; ; i++, i %= argc) { - printf("%s", argv[i]); - putchar(i == argc - 1 ? '\n' : ' '); - } + for (i = 0; ; i++, i %= argc ? argc : 1) { + fputs(argc ? argv[i] : "y", stdout); + putchar((!argc || i == argc - 1) ? '\n' : ' '); } - return 1; /* should not reach */ + + return 1; /* not reached */ }