Date: Wed, 1 Jun 2016 16:53:02 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301138 - head/usr.bin/sed Message-ID: <201606011653.u51Gr2IP040664@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606011653.u51Gr2IP040664>