[Toybox] [PATCH] Added wc -L longest line option

Oliver Webb aquahobbyist at proton.me
Sat Nov 4 09:51:57 PDT 2023


Heya, I added a -L[ongest line] option to wc

I thought that this option was considered and discarded since
it isn't that hard to implement and is a GNU extension. But grep-ing through
the list archives shows no mention of a -L option in relation to wc.

I added the -L option in the below patch, along with a couple of tests for it.
GNU wc -L doesn't count newlines, so it makes sense that toybox's one shouldn't.
the "(signed)" cast is so the output is never "-1"

Also, when I originally tried to implement this option, I appended it
to the end of the option string. Then -l started acting in the same way as -L.
Which made me take a look at generated/flags.h to check if options were being parsed
case-sensitively.

Then I realized that option strings are parsed into "FLAG_" macros backwards.
(End -> Start, First options get higher value flags)
Which from my searching isn't mentioned in lib/args.c, nor scripts/make.sh.

- Oliver Webb <aquahobbyist at proton.me>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-wc-L.patch
Type: text/x-patch
Size: 3274 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20231104/0a4b3149/attachment.bin>


More information about the Toybox mailing list