Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Sep 2009 14:11:33 +0000 (UTC)
From:      Diomidis Spinellis <dds@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r197356 - in head: tools/regression/usr.bin/sed usr.bin/sed
Message-ID:  <200909201411.n8KEBXnn058929@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dds
Date: Sun Sep 20 14:11:33 2009
New Revision: 197356
URL: http://svn.freebsd.org/changeset/base/197356

Log:
  Allow [ to be used as a delimiter.
  
  Pointed by:	Marius Strobl
  Obtained from:	Apple

Modified:
  head/tools/regression/usr.bin/sed/multitest.t
  head/usr.bin/sed/compile.c

Modified: head/tools/regression/usr.bin/sed/multitest.t
==============================================================================
--- head/tools/regression/usr.bin/sed/multitest.t	Sun Sep 20 13:54:27 2009	(r197355)
+++ head/tools/regression/usr.bin/sed/multitest.t	Sun Sep 20 14:11:33 2009	(r197356)
@@ -432,6 +432,15 @@ u2/g' lines1
 	# POSIX does not say that this should work,
 	# but it does for GNU, BSD, and SunOS
 	mark '8.17' ; $SED -e 's/[/]/Q/' lines1
+
+	COMMENT='[ as an s delimiter and its escapes'
+	mark '8.18' ; $SED -e 's[_[X[' lines1
+	# This is a matter of interpretation
+	# POSIX 1003.1, 2004 says "Within the BRE and the replacement,
+	# the BRE delimiter itself can be used as a *literal* character
+	# if it is preceded by a backslash
+	mark '8.19' ; sed 's/l/[/' lines1 | $SED -e 's[\[.[X['
+	mark '8.20' ; sed 's/l/[/' lines1 | $SED -e 's[\[.[X\[['
 }
 
 test_error()

Modified: head/usr.bin/sed/compile.c
==============================================================================
--- head/usr.bin/sed/compile.c	Sun Sep 20 13:54:27 2009	(r197355)
+++ head/usr.bin/sed/compile.c	Sun Sep 20 14:11:33 2009	(r197356)
@@ -387,7 +387,7 @@ compile_delimited(char *p, char *d)
 		errx(1, "%lu: %s: newline can not be used as a string delimiter",
 				linenum, fname);
 	while (*p) {
-		if (*p == '[') {
+		if (*p == '[' && *p != c) {
 			if ((d = compile_ccl(&p, d)) == NULL)
 				errx(1, "%lu: %s: unbalanced brackets ([])", linenum, fname);
 			continue;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909201411.n8KEBXnn058929>