Re: join(1): use getline instead of fgetln

2018-07-18 Thread Todd C. Miller
On Wed, 18 Jul 2018 19:07:21 +0200, Ingo Schwarze wrote: > I think it's more elegant to just break; when getline() returns -1, > you already have the free() at the end: > > if ((len = getline(, , F->fp)) == -1) > break; > > But you get to choose the colour of the bikeshed, OK

Re: join(1): use getline instead of fgetln

2018-07-18 Thread Ingo Schwarze
Hi Todd, Todd C. Miller wrote on Tue, Jul 17, 2018 at 01:38:14PM -0600: > On Tue, 17 Jul 2018 13:21:31 -0600, "Todd C. Miller" wrote: >> It probably makes more sense to do the newline check (and decrement >> len if one is present) before newsize is computed. Then you would >> need to

Re: join(1): use getline instead of fgetln

2018-07-17 Thread Lauri Tirkkonen
On Tue, Jul 17 2018 13:38:14 -0600, Todd C. Miller wrote: > On Tue, 17 Jul 2018 13:21:31 -0600, "Todd C. Miller" wrote: > > > It probably makes more sense to do the newline check (and decrement > > len if one is present) before newsize is computed. Then you would > > need to unconditionally

Re: join(1): use getline instead of fgetln

2018-07-17 Thread Lauri Tirkkonen
On Tue, Jul 17 2018 13:21:31 -0600, Todd C. Miller wrote: > > @@ -360,17 +364,15 @@ slurpit(INPUT *F) > > lp->linealloc = newsize; > > } > > F->setusedc++; > > - memmove(lp->line, bp, len); > > + memmove(lp->line, line, len); > >

Re: join(1): use getline instead of fgetln

2018-07-17 Thread Todd C. Miller
On Tue, 17 Jul 2018 13:21:31 -0600, "Todd C. Miller" wrote: > It probably makes more sense to do the newline check (and decrement > len if one is present) before newsize is computed. Then you would > need to unconditionally NUL-terminate lp->line. Perhaps something like this. - todd Index:

Re: join(1): use getline instead of fgetln

2018-07-17 Thread Todd C. Miller
On Tue, 17 Jul 2018 19:39:16 +0300, Lauri Tirkkonen wrote: > while porting join(1) to Unleashed OS (which does not have fgetln(3)) I > came up with the following. Since the fgetln man page advises against > using it, I thought OpenBSD might want this diff too. Looks good. One minor comment

join(1): use getline instead of fgetln

2018-07-17 Thread Lauri Tirkkonen
Hi, while porting join(1) to Unleashed OS (which does not have fgetln(3)) I came up with the following. Since the fgetln man page advises against using it, I thought OpenBSD might want this diff too. diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c index 3049a423196..ac62cf83cd1 100644 ---