svn commit: r301138 - head/usr.bin/sed
Pedro F. Giffuni
pfg at FreeBSD.org
Wed Jun 1 16:53:03 UTC 2016
Author: pfg
Date: Wed Jun 1 16:53:02 2016
New Revision: 301138
URL: https://svnweb.freebsd.org/changeset/base/301138
Log:
sed(1): Fix a mismatch and sync with the OpenBSD's commit.
This was causing some strange behaviour.
Reported by: olivier
Obtained from: OpenBSD (CVS rev. 1.28)
Modified:
head/usr.bin/sed/process.c
Modified: head/usr.bin/sed/process.c
==============================================================================
--- head/usr.bin/sed/process.c Wed Jun 1 16:45:08 2016 (r301137)
+++ head/usr.bin/sed/process.c Wed Jun 1 16:53:02 2016 (r301138)
@@ -394,7 +394,7 @@ substitute(struct s_command *cp)
linenum, fname, cp->u.s->maxbref);
}
}
- if (!regexec_e(re, s, 0, 0, 0, psl))
+ if (!regexec_e(re, ps, 0, 0, 0, psl))
return (0);
SS.len = 0; /* Clean substitute space. */
@@ -404,7 +404,7 @@ substitute(struct s_command *cp)
do {
/* Copy the leading retained string. */
- if (n <= 1 && match[0].rm_so - le)
+ if (n <= 1 && (match[0].rm_so > le))
cspace(&SS, s, match[0].rm_so - le, APPEND);
/* Skip zero-length matches right after other matches. */
@@ -425,8 +425,8 @@ substitute(struct s_command *cp)
}
/* Move past this match. */
- s += (match[0].rm_eo - le);
- slen -= (match[0].rm_eo - le);
+ s = ps + match[0].rm_eo;
+ slen = psl - match[0].rm_eo;
le = match[0].rm_eo;
/*
@@ -446,7 +446,8 @@ substitute(struct s_command *cp)
} else
lastempty = 0;
- } while (n >= 0 && slen >= 0 && regexec_e(re, ps, 0, 0, le, psl));
+ } while (n >= 0 && slen >= 0 &&
+ regexec_e(re, ps, REG_NOTBOL, 0, le, psl));
/* Did not find the requested number of matches. */
if (n > 1)
More information about the svn-src-head
mailing list