Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/error Use rewind() instead of freopen()'ing the same...
details: https://anonhg.NetBSD.org/src/rev/04ea1b19a904
branches: trunk
changeset: 345485:04ea1b19a904
user: dholland <dholland%NetBSD.org@localhost>
date: Mon May 30 16:26:34 2016 +0000
description:
Use rewind() instead of freopen()'ing the same file for no reason. Also,
close the file when done instead of dropping it on the floor. Obsoletes
PR 50579.
diffstat:
usr.bin/error/filter.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diffs (41 lines):
diff -r aad062b4ae6e -r 04ea1b19a904 usr.bin/error/filter.c
--- a/usr.bin/error/filter.c Mon May 30 14:52:06 2016 +0000
+++ b/usr.bin/error/filter.c Mon May 30 16:26:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: filter.c,v 1.16 2015/08/09 09:49:25 shm Exp $ */
+/* $NetBSD: filter.c,v 1.17 2016/05/30 16:26:34 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)filter.c 8.1 (Berkeley) 6/6/93";
#endif
-__RCSID("$NetBSD: filter.c,v 1.16 2015/08/09 09:49:25 shm Exp $");
+__RCSID("$NetBSD: filter.c,v 1.17 2016/05/30 16:26:34 dholland Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -108,20 +108,14 @@
fgets(inbuffer, sizeof(inbuffer)-1, fyle) != NULL; nignored++)
continue;
names_ignored = Calloc(nignored+1, sizeof (char *));
- if (freopen(filename, "r", fyle) == NULL) {
-#ifdef FULLDEBUG
- fprintf(stderr, "%s: Failure to open \"%s\" for second read.\n",
- processname, filename);
-#endif
- nignored = 0;
- return;
- }
+ rewind(fyle);
for (i=0; i < nignored &&
(fgets (inbuffer, sizeof(inbuffer)-1, fyle) != NULL); i++) {
names_ignored[i] = strdup(inbuffer);
(void)substitute(names_ignored[i], '\n', '\0');
}
qsort(names_ignored, nignored, sizeof *names_ignored, lexsort);
+ fclose(fyle);
#ifdef FULLDEBUG
printf("Names to ignore follow.\n");
for (i=0; i < nignored; i++) {
Home |
Main Index |
Thread Index |
Old Index