Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Use read and fwrite rather than fgets and print...
details: https://anonhg.NetBSD.org/src/rev/41362c5ce85f
branches: trunk
changeset: 333158:41362c5ce85f
user: sjg <sjg%NetBSD.org@localhost>
date: Mon Oct 20 23:22:57 2014 +0000
description:
Use read and fwrite rather than fgets and printf when reading filemon data.
diffstat:
usr.bin/make/meta.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diffs (40 lines):
diff -r cbe232c28012 -r 41362c5ce85f usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Mon Oct 20 23:21:11 2014 +0000
+++ b/usr.bin/make/meta.c Mon Oct 20 23:22:57 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.34 2014/10/18 08:33:30 snj Exp $ */
+/* $NetBSD: meta.c,v 1.35 2014/10/20 23:22:57 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -155,8 +155,8 @@
static void
filemon_read(FILE *mfp, int fd)
{
- FILE *fp;
char buf[BUFSIZ];
+ int n;
/* Check if we're not writing to a meta data file.*/
if (mfp == NULL) {
@@ -166,17 +166,14 @@
}
/* rewind */
(void)lseek(fd, (off_t)0, SEEK_SET);
- if ((fp = fdopen(fd, "r")) == NULL)
- err(1, "Could not read build monitor file '%d'", fd);
fprintf(mfp, "-- filemon acquired metadata --\n");
- while (fgets(buf, sizeof(buf), fp)) {
- fprintf(mfp, "%s", buf);
+ while ((n = read(fd, buf, sizeof(buf))) > 0) {
+ fwrite(buf, 1, n, mfp);
}
fflush(mfp);
- clearerr(fp);
- fclose(fp);
+ close(fd);
}
#endif
Home |
Main Index |
Thread Index |
Old Index