sed(1): add LEGACY_BSDSED_COMPAT compile-time flag.

In r297602, which included a __FreeBSD_version bump to 1100105, we changed
sed 'i' and 'a' from discarding whitespaces to conform with what GNU and
sysvish sed do.

There are arguments in favor of keeping the old behavior but the new
behavior is also useful for migration purposes. It seems important to at
least consider the case of developers depending on the previous behavior,
so add a CFLAG to enable the old behaviour.

PR:		213474
MFC after:	5 days
This commit is contained in:
Pedro F. Giffuni 2016-11-04 20:49:59 +00:00
parent aba6e41495
commit b780b03cbe
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=308314

View file

@ -746,6 +746,9 @@ compile_text(void)
while (cu_fgets(lbuf, sizeof(lbuf), NULL) != NULL) {
op = s = text + size;
p = lbuf;
#ifdef LEGACY_BSDSED_COMPAT
EATSPACE();
#endif
for (esc_nl = 0; *p != '\0'; p++) {
if (*p == '\\' && p[1] != '\0' && *++p == '\n')
esc_nl = 1;