Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/m4 Behave like gnu m4; when the error output file ca...
details: https://anonhg.NetBSD.org/src/rev/e34baaed6128
branches: trunk
changeset: 997787:e34baaed6128
user: christos <christos%NetBSD.org@localhost>
date: Tue Mar 26 15:00:34 2019 +0000
description:
Behave like gnu m4; when the error output file cannot be opened, just warn
and keep going.
diffstat:
usr.bin/m4/main.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diffs (47 lines):
diff -r 0bd42724ddba -r e34baaed6128 usr.bin/m4/main.c
--- a/usr.bin/m4/main.c Tue Mar 26 14:55:02 2019 +0000
+++ b/usr.bin/m4/main.c Tue Mar 26 15:00:34 2019 +0000
@@ -1,5 +1,5 @@
/* $OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $ */
-/* $NetBSD: main.c,v 1.46 2016/01/23 14:24:43 christos Exp $ */
+/* $NetBSD: main.c,v 1.47 2019/03/26 15:00:34 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
#include "nbtool_config.h"
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.46 2016/01/23 14:24:43 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.47 2019/03/26 15:00:34 christos Exp $");
#include <assert.h>
#include <signal.h>
#include <getopt.h>
@@ -228,6 +228,7 @@
int c;
int n;
char *p;
+ FILE *sfp;
setprogname(argv[0]);
@@ -263,9 +264,16 @@
fatal_warnings++;
break;
case 'e':
- if (freopen(optarg, "w+", stderr) == NULL)
- err(EXIT_FAILURE, "Can't redirect errors to `%s'",
- optarg);
+ /*
+ * Don't use freopen here because if it fails
+ * we lose stderr, instead trash it.
+ */
+ if ((sfp = fopen(optarg, "w+")) == NULL) {
+ warn("Can't redirect errors to `%s'", optarg);
+ break;
+ }
+ fclose(stderr);
+ memcpy(stderr, sfp, sizeof(*sfp));
break;
case 'F':
freeze = optarg;
Home |
Main Index |
Thread Index |
Old Index