From owner-svn-src-stable-8@FreeBSD.ORG Fri May 21 19:44:23 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64FC71065678; Fri, 21 May 2010 19:44:23 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 516D98FC1A; Fri, 21 May 2010 19:44:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o4LJiNJr018605; Fri, 21 May 2010 19:44:23 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4LJiNhX018603; Fri, 21 May 2010 19:44:23 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201005211944.o4LJiNhX018603@svn.freebsd.org> From: Marius Strobl Date: Fri, 21 May 2010 19:44:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208402 - in stable/8: tools/regression/usr.bin/sed tools/regression/usr.bin/sed/regress.multitest.out usr.bin/sed X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2010 19:44:23 -0000 Author: marius Date: Fri May 21 19:44:23 2010 New Revision: 208402 URL: http://svn.freebsd.org/changeset/base/208402 Log: MFC: r197361 Follow POSIX (IEEE Std 1003.1, 2004 Edition) in the implementation of the y (translate) command. "If a backslash character is immediately followed by a backslash character in string1 or string2, the two backslash characters shall be counted as a single literal backslash character" Pointed by: Marius Strobl Obtained from: Mac OS X Added: stable/8/tools/regression/usr.bin/sed/regress.multitest.out/8.21 - copied unchanged from r197361, head/tools/regression/usr.bin/sed/regress.multitest.out/8.21 Modified: stable/8/tools/regression/usr.bin/sed/multitest.t stable/8/usr.bin/sed/compile.c Directory Properties: stable/8/tools/regression/usr.bin/sed/ (props changed) stable/8/usr.bin/sed/ (props changed) Modified: stable/8/tools/regression/usr.bin/sed/multitest.t ============================================================================== --- stable/8/tools/regression/usr.bin/sed/multitest.t Fri May 21 19:40:27 2010 (r208401) +++ stable/8/tools/regression/usr.bin/sed/multitest.t Fri May 21 19:44:23 2010 (r208402) @@ -445,6 +445,10 @@ u2/g' lines1 # set specification (both with --posix and without). mark '8.19' ; sed 's/l/[/' lines1 | $SED -e 's[\[.[X[' mark '8.20' ; sed 's/l/[/' lines1 | $SED -e 's[\[.[X\[[' + COMMENT='\ in y command' + mark '8.21' + echo 'a\b(c' | + $SED 'y%ABCDEFGHIJKLMNOPQRSTUVWXYZ, /\\()"%abcdefghijklmnopqrstuvwxyz,------%' } test_error() Copied: stable/8/tools/regression/usr.bin/sed/regress.multitest.out/8.21 (from r197361, head/tools/regression/usr.bin/sed/regress.multitest.out/8.21) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/usr.bin/sed/regress.multitest.out/8.21 Fri May 21 19:44:23 2010 (r208402, copy of r197361, head/tools/regression/usr.bin/sed/regress.multitest.out/8.21) @@ -0,0 +1 @@ +a-b-c Modified: stable/8/usr.bin/sed/compile.c ============================================================================== --- stable/8/usr.bin/sed/compile.c Fri May 21 19:40:27 2010 (r208401) +++ stable/8/usr.bin/sed/compile.c Fri May 21 19:44:23 2010 (r208402) @@ -66,7 +66,7 @@ static struct labhash { static char *compile_addr(char *, struct s_addr *); static char *compile_ccl(char **, char *); -static char *compile_delimited(char *, char *); +static char *compile_delimited(char *, char *, int); static char *compile_flags(char *, struct s_subst *); static regex_t *compile_re(char *, int); static char *compile_subst(char *, struct s_subst *); @@ -320,7 +320,7 @@ nonsel: /* Now parse the command */ linenum, fname); if ((cmd->u.s = calloc(1, sizeof(struct s_subst))) == NULL) err(1, "malloc"); - p = compile_delimited(p, re); + p = compile_delimited(p, re, 0); if (p == NULL) errx(1, "%lu: %s: unterminated substitute pattern", linenum, fname); @@ -373,7 +373,7 @@ nonsel: /* Now parse the command */ * with the processed string. */ static char * -compile_delimited(char *p, char *d) +compile_delimited(char *p, char *d, int is_tr) { char c; @@ -399,9 +399,12 @@ compile_delimited(char *p, char *d) *d++ = '\n'; p += 2; continue; - } else if (*p == '\\' && p[1] == '\\') - *d++ = *p++; - else if (*p == c) { + } else if (*p == '\\' && p[1] == '\\') { + if (is_tr) + p++; + else + *d++ = *p++; + } else if (*p == c) { *d = '\0'; return (p + 1); } @@ -654,11 +657,11 @@ compile_tr(char *p, struct s_tr **py) errx(1, "%lu: %s: transform pattern can not be delimited by newline or backslash", linenum, fname); - p = compile_delimited(p, old); + p = compile_delimited(p, old, 1); if (p == NULL) errx(1, "%lu: %s: unterminated transform source string", linenum, fname); - p = compile_delimited(p - 1, new); + p = compile_delimited(p - 1, new, 1); if (p == NULL) errx(1, "%lu: %s: unterminated transform target string", linenum, fname); @@ -781,7 +784,7 @@ compile_addr(char *p, struct s_addr *a) ++p; /* FALLTHROUGH */ case '/': /* Context address */ - p = compile_delimited(p, re); + p = compile_delimited(p, re, 0); if (p == NULL) errx(1, "%lu: %s: unterminated regular expression", linenum, fname); /* Check for case insensitive regexp flag */