Date: Tue, 28 Jun 2016 03:11:07 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r302244 - stable/10/usr.bin/sed Message-ID: <201606280311.u5S3B7ET049737@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Tue Jun 28 03:11:07 2016 New Revision: 302244 URL: https://svnweb.freebsd.org/changeset/base/302244 Log: MFC r301138: sed(1): convert sed to use REG_STARTEND more explicitly. This is a followup to previous r302228, which only merged the incomplete r300684 causing a regression. Reported by: mi PR: 209387 Taken from: openbsd-tech (Martijn van Duren) Modified: stable/10/usr.bin/sed/process.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/sed/process.c ============================================================================== --- stable/10/usr.bin/sed/process.c Tue Jun 28 00:37:34 2016 (r302243) +++ stable/10/usr.bin/sed/process.c Tue Jun 28 03:11:07 2016 (r302244) @@ -384,7 +384,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. */ @@ -394,7 +394,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. */ @@ -415,8 +415,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; /* @@ -436,7 +436,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?201606280311.u5S3B7ET049737>