On Fri, Apr 17, 2015 at 12:20 AM, Wolfgang Corcoran-Mathe
<first.lord.of.teal_AT_gmail.com> wrote:
> Hello,
>
> I have made an attempt at join(1). I hope it is worth a look.
>
> See NOTES for some points on which this implementation differs from
> other joins. The handling of -a | -v when used with -o is an issue.
>
> Comments are welcome. Please be brutal.
>
Hi, thanks for contributing!
To add to FRIGN's reply:
- Probably not an issue in this case, but I would avoid:
lp->fields = (struct field *) emalloc(INIT * sizeof(struct field));
and just use:
lp->fields = ereallocarray(NULL, INIT, sizeof(struct field));
See:
http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/calloc.3?query=reallocarray&arch=i386
- To makeline() you can add an argument of the line and use the
returned value from getline(). This way strlen is not needed.
getline() cannot return 0, so I guess the len - 1 is safe :)
- For the -1 and -2 flags POSIX says:
"
-1 field
Join on the fieldth field of file 1. Fields are decimal integers
starting with 1.
-2 field
Join on the fieldth field of file 2. Fields are decimal integers
starting with 1.
"
So:
jf[0] = estrtonum(EARGF(usage()), 0, MIN(LLONG_MAX, SIZE_MAX));
should be:
jf[0] = estrtonum(EARGF(usage()), 1, MIN(LLONG_MAX, SIZE_MAX));
- If you can add a man page for it too, that would be greaaat.
Kind regards,
Hiltjo
Received on Fri Apr 17 2015 - 11:33:52 CEST