On Sun, Jul 24, 2016 at 8:17 PM, Wolfgang Corcoran-Mathe <[email protected]> wrote: > Sorry, this last patch is simpleminded. > > Given the following text and substitution, what should happen? > > 'glorious' > > s/G*/P/g > > sbase sed(1) gives us 'PgPlPoPrPiPoPuPsP' (matching every null > string), while GNU ed(1) gives an error. The above patch does > not throw an error, but rather performs the first substitution > and stops. > > Is there a case in which a global substitution for a regex that > matches the null string is useful? Should we produce output like > 'PgPlPoPrPiPoPuPsP' (which is almost certainly unwanted garbage) > or assume that such an expression is a mistake? > > Regards, > > -- > wcm >
The sed behavior is based on other sed implementations. I think I based it on GNU sed and busybox sed test cases that make sure to increment the position in the string by one after each 0 length match. Whereas GNU has problems with consistency, I think sbase should not. Whether that means changing ed or sed, I think they should give the same result. That being said I still think sed is in desperate need of a (probably complete) rewrite in order to handle null bytes (i.e. don't use libc string functions). -emg
