-/* $OpenBSD: compile.c,v 1.42 2017/08/01 18:05:53 martijn Exp $ */
+/* $OpenBSD: compile.c,v 1.43 2017/12/08 18:41:59 martijn Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
pledge_rpath = 1;
p++;
EATSPACE();
+ if (*p == '\0')
+ error(COMPILE, "filename expected");
cmd->t = duptoeol(p, "read command", NULL);
break;
case BRANCH: /* b t */
{
int gn; /* True if we have seen g or n */
long l;
- char wfile[PATH_MAX], *q, *eq;
s->n = 1; /* Default */
s->p = 0;
continue;
case 'w':
p++;
-#ifdef HISTORIC_PRACTICE
- if (*p != ' ') {
- warning("space missing before w wfile");
- return (p);
- }
-#endif
EATSPACE();
- q = wfile;
- eq = wfile + sizeof(wfile) - 1;
- while (*p) {
- if (*p == '\n')
- break;
- if (q >= eq)
- error(COMPILE, "wfile too long");
- *q++ = *p++;
- }
- *q = '\0';
- if (q == wfile)
- error(COMPILE, "no wfile specified");
- s->wfile = strdup(wfile);
+ if (*p == '\0')
+ error(COMPILE, "filename expected");
+ s->wfile = duptoeol(p, "s command w flag", NULL);
+ *p = '\0';
if (aflag)
pledge_wpath = 1;
- else if ((s->wfd = open(wfile,
+ else if ((s->wfd = open(s->wfile,
O_WRONLY|O_APPEND|O_CREAT|O_TRUNC,
DEFFILEMODE)) == -1)
- error(FATAL, "%s: %s", wfile, strerror(errno));
+ error(FATAL, "%s: %s", s->wfile, strerror(errno));
return (p);
default:
error(COMPILE,
-.\" $OpenBSD: sed.1,v 1.51 2017/12/07 09:52:26 martijn Exp $
+.\" $OpenBSD: sed.1,v 1.52 2017/12/08 18:41:59 martijn Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)sed.1 8.2 (Berkeley) 12/30/93
.\"
-.Dd $Mdocdate: December 7 2017 $
+.Dd $Mdocdate: December 8 2017 $
.Dt SED 1
.Os
.Sh NAME
flag to the
.Ic s
function,
-take an optional
+take a
.Ar file
parameter,
which should be separated from the function or flag by whitespace.