IEEE Std 1003.1, 2004 Edition states:

"The escape sequence '\n' shall match a <newline> embedded in
the pattern space."

It is unclear whether this also applies to a \n embedded in a
character class.  Disable the existing handling of \n in a character
class following Mac OS X, GNU sed version 4.1.5 with --posix, and
SunOS 5.10 /usr/bin/sed.

Pointed by:	Marius Strobl
Obtained from:	Mac OS X
This commit is contained in:
Diomidis Spinellis 2009-09-20 15:47:31 +00:00
parent 76570d0a99
commit ac8f32ce62
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=197362
4 changed files with 7 additions and 2 deletions

View File

@ -449,6 +449,9 @@ u2/g' lines1
mark '8.21'
echo 'a\b(c' |
$SED 'y%ABCDEFGHIJKLMNOPQRSTUVWXYZ, /\\()"%abcdefghijklmnopqrstuvwxyz,------%'
COMMENT='\n in a character class and a BRE'
mark '8.22' ; (echo 1; echo 2) | $SED -n '1{;N;s/[\n]/X/;p;}'
mark '8.23' ; (echo 1; echo 2) | $SED -n '1{;N;s/\n/X/;p;}'
}
test_error()

View File

@ -0,0 +1,2 @@
1
2

View File

@ -0,0 +1 @@
1X2

View File

@ -432,8 +432,7 @@ compile_ccl(char **sp, char *t)
for (c = *s; (*t = *s) != ']' || c != d; s++, t++)
if ((c = *s) == '\0')
return NULL;
} else if (*s == '\\' && s[1] == 'n')
*t = '\n', s++;
}
return (*s == ']') ? *sp = ++s, ++t : NULL;
}