Update putword() to accept a FILE *

This commit is contained in:
sin 2015-04-21 17:40:57 +01:00
parent 504855ff96
commit c914a2feca
4 changed files with 9 additions and 9 deletions

2
echo.c
View File

@ -14,7 +14,7 @@ main(int argc, char *argv[])
} }
for (; *argv; argc--, argv++) for (; *argv; argc--, argv++)
putword(*argv); putword(stdout, *argv);
if (!nflag) if (!nflag)
putchar('\n'); putchar('\n');

View File

@ -4,13 +4,13 @@
#include "../util.h" #include "../util.h"
void void
putword(const char *s) putword(FILE *fp, const char *s)
{ {
static int first = 1; static int first = 1;
if (!first) if (!first)
putchar(' '); putchar(' ');
fputs(s, stdout); fputs(s, fp);
first = 0; first = 0;
} }

10
uname.c
View File

@ -44,15 +44,15 @@ main(int argc, char *argv[])
eprintf("uname:"); eprintf("uname:");
if (sflag || !(nflag || rflag || vflag || mflag)) if (sflag || !(nflag || rflag || vflag || mflag))
putword(u.sysname); putword(stdout, u.sysname);
if (nflag) if (nflag)
putword(u.nodename); putword(stdout, u.nodename);
if (rflag) if (rflag)
putword(u.release); putword(stdout, u.release);
if (vflag) if (vflag)
putword(u.version); putword(stdout, u.version);
if (mflag) if (mflag)
putword(u.machine); putword(stdout, u.machine);
putchar('\n'); putchar('\n');
return fshut(stdout, "<stdout>"); return fshut(stdout, "<stdout>");

2
util.h
View File

@ -68,7 +68,7 @@ void fnck(const char *, const char *, int (*)(const char *, const char *, int),
mode_t getumask(void); mode_t getumask(void);
char *humansize(double); char *humansize(double);
mode_t parsemode(const char *, mode_t, mode_t); mode_t parsemode(const char *, mode_t, mode_t);
void putword(const char *); void putword(FILE *, const char *);
#undef strtonum #undef strtonum
long long strtonum(const char *, long long, long long, const char **); long long strtonum(const char *, long long, long long, const char **);
long long enstrtonum(int, const char *, long long, long long); long long enstrtonum(int, const char *, long long, long long);