0226c05105
1) argc style 2) safeguard argv-loop as already seen in echo(1) with argc-decrement.
32 lines
402 B
C
32 lines
402 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <stdio.h>
|
|
|
|
#include "util.h"
|
|
|
|
static void
|
|
usage(void)
|
|
{
|
|
eprintf("usage: %s [-n] [string ...]\n", argv0);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
int nflag = 0;
|
|
|
|
ARGBEGIN {
|
|
case 'n':
|
|
nflag = 1;
|
|
break;
|
|
default:
|
|
usage();
|
|
} ARGEND;
|
|
|
|
for (; argc > 0; argc--, argv++)
|
|
putword(*argv);
|
|
if (!nflag)
|
|
putchar('\n');
|
|
|
|
return 0;
|
|
}
|