Date: Fri, 06 Jul 2007 22:34:32 +0800 From: Xin LI <delphij@delphij.net> To: YAMAMOTO Shigeru <shigeru@iij.ad.jp> Cc: freebsd-current@freebsd.org, dogcube@gmail.com Subject: Re: buildworld error Message-ID: <468E52F8.2000501@delphij.net> In-Reply-To: <20070706.193428.212414018.shigeru@iij.ad.jp> References: <1183669505.10705.22.camel@patricia-laptop> <20070706.193428.212414018.shigeru@iij.ad.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------070805060302040409020809 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit YAMAMOTO Shigeru wrote: > Hi, all, > > I check a code to generate 'md2hl.c'. > I find 'sed' does not work right. > > I test following patterns. > % echo "abcdefg" | sed -e 's/abc/hij/g' > hijdefg > % echo "ABCDEFG" | sed -e 's/abc/hij/g' > hijDEFG > % echo "abcdefg" | sed -e 's/ABC/HIJ/g' > HIJdefg > % echo "ABCDEFG" | sed -e 's/ABC/HIJ/g' > HIJDEFG > > It seems me 'sed' always work with '/I'. > #'I' option is added at '2007/07/04 16:42:41'. > > Is it bug? I think so. Try attached patch. Cheers, --------------070805060302040409020809 Content-Type: text/x-patch; name="sed.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sed.diff" Index: compile.c =================================================================== RCS file: /home/ncvs/src/usr.bin/sed/compile.c,v retrieving revision 1.29 diff -u -p -r1.29 compile.c --- compile.c 4 Jul 2007 16:42:41 -0000 1.29 +++ compile.c 6 Jul 2007 07:00:47 -0000 @@ -318,19 +318,19 @@ nonsel: /* Now parse the command */ errx(1, "%lu: %s: substitute pattern can not be delimited by newline or backslash", linenum, fname); - if ((cmd->u.s = malloc(sizeof(struct s_subst))) == NULL) + if ((cmd->u.s = calloc(1, sizeof(struct s_subst))) == NULL) err(1, "malloc"); p = compile_delimited(p, re); if (p == NULL) errx(1, "%lu: %s: unterminated substitute pattern", linenum, fname); + --p; + p = compile_subst(p, cmd->u.s); + p = compile_flags(p, cmd->u.s); if (*re == '\0') cmd->u.s->re = NULL; else cmd->u.s->re = compile_re(re, cmd->u.s->icase); - --p; - p = compile_subst(p, cmd->u.s); - p = compile_flags(p, cmd->u.s); EATSPACE(); if (*p == ';') { p++; --------------070805060302040409020809--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?468E52F8.2000501>