Before doing compile_re() which needs a parameter to identify

whether we should ignore case, determine the flag by calling
compile_flags() first.  Also, make sure that we obtain an
initialized cmd->u.s buffer before processing further.  We
may want to refine this solution later, but for now, make
the changes in order to unbreak world build after a sed(1)
with rev. 1.29 of compile.c is installed.

Approved by:	re (hrs)
This commit is contained in:
Xin LI 2007-07-06 16:34:56 +00:00
parent 49d8ecb49e
commit 870945d830
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171284

View File

@ -318,19 +318,19 @@ semicolon: EATSPACE();
errx(1,
"%lu: %s: substitute pattern can not be delimited by newline or backslash",
linenum, fname);
if ((cmd->u.s = malloc(sizeof(struct s_subst))) == NULL)
if ((cmd->u.s = calloc(1, sizeof(struct s_subst))) == NULL)
err(1, "malloc");
p = compile_delimited(p, re);
if (p == NULL)
errx(1,
"%lu: %s: unterminated substitute pattern", linenum, fname);
--p;
p = compile_subst(p, cmd->u.s);
p = compile_flags(p, cmd->u.s);
if (*re == '\0')
cmd->u.s->re = NULL;
else
cmd->u.s->re = compile_re(re, cmd->u.s->icase);
--p;
p = compile_subst(p, cmd->u.s);
p = compile_flags(p, cmd->u.s);
EATSPACE();
if (*p == ';') {
p++;