diff options
| -rw-r--r-- | appl/cmd/sed.b | 7 | ||||
| -rw-r--r-- | dis/sed.dis | bin | 13113 -> 13134 bytes |
2 files changed, 5 insertions, 2 deletions
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); } diff --git a/dis/sed.dis b/dis/sed.dis Binary files differindex 744a7be4..6e42daba 100644 --- a/dis/sed.dis +++ b/dis/sed.dis |
