Improve consistency of the substitution command further.
authorschwarze <schwarze@openbsd.org>
Tue, 14 Aug 2018 18:10:09 +0000 (18:10 +0000)
committerschwarze <schwarze@openbsd.org>
Tue, 14 Aug 2018 18:10:09 +0000 (18:10 +0000)
commit2f0eb8851647c12b1b04d1751f109ee5a544a02f
treeb61860a2683e60400cda58db9bcf31ca0cdd85c3
parentfcb1ddc764b80b71cf03d455c3f375cfb6cdf909
Improve consistency of the substitution command further.

When the opening square bracket ('[') is abused as the delimiter, the regular
expression contains a bracket expression, and the bracket expression contains
another opening square bracket (sick! - i mean, sic!), then do not require
escaping that innermost bracket and treat a preceding backslash as a literal
backslash character, in accordance with POSIX:

   $ printf 'x[x\\x\n' | sed 's[\[[][R[g'
  xRx\x
   $ printf 'x[x\\x\n' | sed 's[\[\[][R[g'
  xRxRx

While here, also make the implementation more readable and insert
some comments.

Joint work with martijn@ (started during g2k18) and OK martijn@.
usr.bin/sed/compile.c