From 9cb225d99b1042bd7281c24ac4d1d8ea4b7f7665 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Wed, 16 Jan 2008 17:23:17 +0000 Subject: 20080116-1729 --- appl/cmd/sed.b | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'appl/cmd/sed.b') diff --git a/appl/cmd/sed.b b/appl/cmd/sed.b index 30bfbd22..59c7c7b7 100644 --- a/appl/cmd/sed.b +++ b/appl/cmd/sed.b @@ -558,7 +558,7 @@ trans(ch: int) : string '\\' => return "\\\\"; * => - return sys->sprint("\\u%4x", ch); + return sys->sprint("\\u%.4ux", ch); } } @@ -789,6 +789,7 @@ substitute(c: ref Sedcom.S, s: string) : (bool, string) sflag = true; start := 0; + # Beware of infinite loops: 's/$/i/g', 's/a/aa/g', 's/^/a/g' do { se := (start, len s); if ((m := regex->executese(c.re, s, se, true, true)) == nil) @@ -816,7 +817,9 @@ substitute(c: ref Sedcom.S, s: string) : (bool, string) } } s = s[0:l] + rep + s[r:]; - start++; + start = l + len rep; + if(r == l) + start++; } while (c.gfl); return (true, s); } -- cgit v1.2.3