On Mon, May 11, 2020 at 07:35:43AM +0200, Richard Ipsum wrote: > Hi, > > This patch makes paste treat '\0' in the delim list as an empty string > instead of a null character as per POSIX[1]. > > before: > > % echo -e 'hello\nworld' | ./paste -s -d '\0' - | od -b > 0000000 150 145 154 154 157 000 167 157 162 154 144 012 > 0000014 > > after: > > % echo -e 'hello\nworld' | ./paste -s -d '\0' - | od -b > 0000000 150 145 154 154 157 167 157 162 154 144 012 > 0000013 > > Thanks, > Richard > > [1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/paste.html > > diff --git usr.bin/paste/paste.c usr.bin/paste/paste.c > index 77c9f328755..68ed12898a4 100644 > --- usr.bin/paste/paste.c > +++ usr.bin/paste/paste.c > @@ -193,7 +193,7 @@ sequential(char **argv) > while ((len = getline(&line, &linesize, fp)) != -1) { > if (line[len - 1] == '\n') > line[len - 1] = '\0'; > - if (cnt >= 0) > + if (cnt >= 0 && delim[cnt] != '\0') > putchar(delim[cnt]); > if (++cnt == delimcnt) > cnt = 0;
Any reason this didn't get merged? Thanks, Richard
