On Sat, Jul 27, 2019 at 2:20 PM Rob Landley <[email protected]> wrote: > > On 7/26/19 4:32 PM, enh via Toybox wrote: > > You didn't include a test and I didn't know what you were trying to fix, so it > took me a while to figure out that (long) instead of (unsigned long) was the > actual _bug_, and the rest of the patch is unrelated. (I was going "l<0" is > _supposed_ to be a signed test?)
(the commit message included the objdump output with -S, so the source lines in question were shown right there. but, yeah, rather than just explain in the commit message that i've made two unrelated changes i should send two separate patches...) > As for cleanups, I'm once again leaning towards an xgetline() and xgetdelim() > that just always allocate: > > char *xgetline(FILE *fp, int *optional_len); > char *xgetdelim(FILE *fp, char delim, int *optional_len); certainly for the case where you're keeping each line anyway, i think that makes sense. i haven't really looked to see how many getline() uses in toybox benefit from the "reuse the existing allocation" behavior. > So the "I don't care what the length is, just gimme a line" use would be: > > char *s = xgetline(stdin, 0); > > And then s = NULL means end of input (check errno if you care _why_, we can > zero > errno before calling getdelim() so it's always 0 when nothing bad happened). > > And that can be a wrapper around xgetdelim_raw() that doesn't remove the > > > Rob > > P.S. I need to give a talk at ELC on August 22, and I want toysh reasonably > working by then, which means cutting a release shortly before the conference. > (Ok, shortly before the talk. I know me.) I've been head down trying to get > that > to work by deadline, but a release generally has more than one thing in it. :) > > P.P.S. After that, I have to wander back into $DAYJOB land and not having time > for toybox again for a while. Blame capitalism. I'm very grateful to my > patreon > supporters, but it doesn't pay my health insurance, let alone mortgage... _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
