Download raw body.
sed: check length before append in substitute
Thoughts on this patch?
> On Aug 16, 2024, at 6:33 PM, Mohamed Akram <mohd.akram@live.com> wrote:
>
> This resolves the case where the pattern space is empty but does not
> start with a null character, which might occur after using the D
> command. This can be seen in the following sed program, which should
> print its input as-is:
>
> printf 'foo\n\n' | sed -e 's/^//p' -e '$!N' -e D
>
> --- src/usr.bin/sed/process.c.orig 2024-08-16 17:35:20
> +++ src/usr.bin/sed/process.c 2024-08-16 17:35:52
> @@ -387,14 +387,12 @@
> * and at the end of the line, terminate.
> */
> if (match[0].rm_so == match[0].rm_eo) {
> - if (*s == '\0' || *s == '\n')
> - slen = -1;
> - else
> - slen--;
> - if (*s != '\0') {
> + if (slen > 0) {
> cspace(&SS, s++, 1, APPEND);
> + slen--;
> le++;
> - }
> + } else
> + slen = -1;
> lastempty = 1;
> } else
> lastempty = 0;
>
sed: check length before append in substitute