@@ -1,5 +1,5 @@
/* $OpenBSD: extern.h,v 1.49 2009/10/14 17:19:47 sthen Exp $ */
-/* $NetBSD: extern.h,v 1.19 2016/01/16 18:30:57 christos Exp $ */
+/* $NetBSD: extern.h,v 1.19.18.1 2020/07/07 10:40:46 martin Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -146,7 +146,7 @@
/* trace.c */
extern unsigned int trace_flags;
#define TRACE_ALL 512
-extern void trace_file(const char *);
+extern int trace_file(const char *);
extern size_t trace(const char **, int, struct input_file *);
extern void finish_trace(size_t);
extern void set_trace_flags(const char *);
@@ -1,4 +1,4 @@
-.\" $NetBSD: m4.1,v 1.27 2016/01/17 11:24:28 wiz Exp $
+.\" $NetBSD: m4.1,v 1.27.18.1 2020/07/07 10:40:46 martin Exp $
.\" @(#) $OpenBSD: m4.1,v 1.56 2009/10/14 17:19:47 sthen Exp $
.\"
.\" Copyright (c) 1989, 1993
@@ -31,7 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 16, 2015
+.Dd June 25, 2020
.Dt M4 1
.Os
.Sh NAME
@@ -46,7 +46,6 @@
.Sm on
.Oc
.Op Fl d Ar flags
-.Op Fl e Ar filename
.Op Fl F Ar filename
.Op Fl I Ar dirname
.Op Fl L Ar number
@@ -138,8 +137,6 @@
Warnings make
.Nm
exit.
-.It Fl e , Fl Fl error-output Ar filename
-Redirect error output to filename.
.It Fl F , Fl Fl freeze-state Ar filename
Save the input state to
.Ar filename .
@@ -166,7 +163,7 @@
.It Fl L , Fl Fl nesting-limit
Set the nesting limit in macro expansions.
This is unimplemented and unlimited.
-.It Fl o Ar filename
+.It Fl o , Fl Fl error-output Ar filename
Send trace output to
.Ar filename .
.It Fl P , Fl Fl prefix-builtins
@@ -1,5 +1,5 @@
/* $OpenBSD: main.c,v 1.77 2009/10/14 17:19:47 sthen Exp $ */
-/* $NetBSD: main.c,v 1.48 2019/03/26 16:41:06 christos Exp $ */
+/* $NetBSD: main.c,v 1.48.2.1 2020/07/07 10:40:46 martin Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
#include "nbtool_config.h"
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.48 2019/03/26 16:41:06 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.48.2.1 2020/07/07 10:40:46 martin Exp $");
#include <assert.h>
#include <signal.h>
#include <getopt.h>
@@ -196,7 +196,7 @@
struct option longopts[] = {
{ "debug", optional_argument, 0, 'd' },
{ "define", required_argument, 0, 'D' },
- { "error-output", required_argument, 0, 'e' },
+ { "error-output", required_argument, 0, 'o' }, /* sic */
{ "fatal-warnings", no_argument, 0, 'E' },
{ "freeze-state", required_argument, 0, 'F' },
{ "gnu", no_argument, 0, 'g' },
@@ -227,8 +227,8 @@
{
int c;
int n;
+ int error;
char *p;
- FILE *sfp;
setprogname(argv[0]);
@@ -246,7 +246,7 @@
outfile = NULL;
resizedivs(MAXOUT);
- while ((c = getopt_long(argc, argv, "D:d:e:EF:GgI:iL:o:PR:Qst:U:v",
+ while ((c = getopt_long(argc, argv, "D:d:EF:GgI:iL:o:PR:Qst:U:v",
longopts, NULL)) != -1)
switch(c) {
case 'D': /* define something..*/
@@ -263,18 +263,6 @@
case 'E':
fatal_warnings++;
break;
- case 'e':
- /*
- * 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;
#ifndef REAL_FREEZE
@@ -299,7 +287,9 @@
nesting_limit = atoi(optarg);
break;
case 'o':
- trace_file(optarg);
+ error = trace_file(optarg);
+ if (error)
+ warn("%s", optarg);
break;
case 'P':
prefix_builtins = 1;
@@ -1,4 +1,4 @@
-/* $NetBSD: trace.c,v 1.8 2012/03/20 20:34:58 matt Exp $ */
+/* $NetBSD: trace.c,v 1.8.34.1 2020/07/07 10:40:46 martin Exp $ */
/* $OpenBSD: trace.c,v 1.15 2006/03/24 08:03:44 espie Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
@@ -28,7 +28,7 @@
#include "nbtool_config.h"
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: trace.c,v 1.8 2012/03/20 20:34:58 matt Exp $");
+__RCSID("$NetBSD: trace.c,v 1.8.34.1 2020/07/07 10:40:46 martin Exp $");
#include <sys/types.h>
#include <err.h>
@@ -59,15 +59,27 @@
unsigned int trace_flags = TRACE_QUOTE | TRACE_EXPANSION;
-void
+int
trace_file(const char *name)
{
+ FILE *newfp;
+ if (name == NULL)
+ newfp = stderr;
+#if 0 /* not yet */
+ else if (*name == '\0')
+ newfp = NULL;
+#endif
+ else {
+ newfp = fopen(name, "a");
+ if (newfp == NULL)
+ return -1;
+ }
+
if (traceout && traceout != stderr)
fclose(traceout);
- traceout = fopen(name, "w");
- if (!traceout)
- err(1, "can't open %s", name);
+ traceout = newfp;
+ return 0;
}
static unsigned int