Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 05 Apr 2016 22:19:04 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 208554] usr.bin/sed :sed functions 'i' and 'a' discard leading white space
Message-ID:  <bug-208554-8-9FccVevFRT@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-208554-8@https.bugs.freebsd.org/bugzilla/>
References:  <bug-208554-8@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D208554

Bryan Drewery <bdrewery@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bdrewery@FreeBSD.org

--- Comment #1 from Bryan Drewery <bdrewery@FreeBSD.org> ---

I think this makes sense as otherwise you cannot control whitespace in the
line you are adding.  Reading opengroup there's no mention of eating
whitespace on these commands either.

*However*, we've had this particular behavior forever, since at least r1591.

The removal in NetBSD follows it accidentally being added back in 2014.
The real removal came in 2004:

> commit 39dd7ae9eebb61b8b83c15e441faa17593a5ec8d
> Author: matt <matt>
> Date:   Wed Nov 17 22:17:54 2004 +0000
>
>     When adding text due to an a, c, or i command, don't eat the space(s)=
 at
>     the beginning of the lines since the addition is supposed to be "verb=
atim".
>     Fix a comment for compile_text indicating it's also used for the 'c' =
command.
>
> diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
> index 4ae0e53..4a185de 100644
> --- a/usr.bin/sed/compile.c
> +++ b/usr.bin/sed/compile.c
> @@ -1,4 +1,4 @@
> -/*	$NetBSD: compile.c,v 1.30 2004/07/09 23:43:07 enami Exp $	*/
> +/*	$NetBSD: compile.c,v 1.31 2004/11/17 22:17:54 matt Exp $	*/
>=20=20
>  /*-
>   * Copyright (c) 1992, 1993
> @@ -72,7 +72,7 @@
>  #if 0
>  static char sccsid[] =3D "@(#)compile.c	8.2 (Berkeley) 4/28/95";
>  #else
> -__RCSID("$NetBSD: compile.c,v 1.30 2004/07/09 23:43:07 enami Exp $");
> +__RCSID("$NetBSD: compile.c,v 1.31 2004/11/17 22:17:54 matt Exp $");
>  #endif
>  #endif /* not lint */
>=20=20
> @@ -666,7 +666,7 @@ compile_tr(char *p, char **transtab)
>  }
>=20=20
>  /*
> - * Compile the text following an a or i command.
> + * Compile the text following an a, c, or i command.
>   */
>  static char *
>  compile_text(void)
> @@ -681,7 +681,6 @@ compile_text(void)
>  	while (cu_fgets(lbuf, sizeof(lbuf))) {
>  		op =3D s =3D text + size;
>  		p =3D lbuf;
> -		EATSPACE();
>  		for (; *p; p++) {
>  			if (*p =3D=3D '\\')
>  				p++;


I support removing it, especially since GNU and NetBSD do so as well and
it gives more control to the user.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-208554-8-9FccVevFRT>