[Toybox] awk (was: strlower() bug)

Ray Gardner raygard at gmail.com
Tue May 14 19:36:08 PDT 2024


On Fri, May 10, 2024 at 1:38 PM Rob Landley <rob at landley.net> wrote:
>
> On 5/8/24 16:27, Ray Gardner wrote:
>> BTW I was a bit surprised that mentioning my awk for toybox got no reaction.
>
> Oh I'm interested, but somebody (probably you) mentioned they were looking into
> it before, and I'll wait to see some code first. :)
>
> (The problem with asking to see code early is pending/git.c isn't useful and
> that's as far as the original developer had time/energy for, and I haven't
> personally opened that can of worms yet. The problem with waiting until it's
> done is pending/bc.c was several times larger than I expected and I'm uncertain
> if I even want to personally open that can of worms.)
>
> That said, if you're actively working on it and wanted to do a brief design
> infodump here, consider it solicited. :)

I've worked on it a lot. See

    https://www.raygard.net/awkdoc/

    https://github.com/raygard/wak/blob/main/toybox/awk.c

    https://github.com/raygard/wak/blob/main/toybox_awk_test/awk.test

Yes, it's larger than busybox awk. I believe it's also got fewer bugs
and performs better.

It works. Drop it in toys/pending or (if you're feeling rad) in
toys/posix. Let me know if anything does not work.

See the comments in https://github.com/raygard/wak/issues/7 -- it's in
use by at least a couple people in its "standalone" version outside of
toybox. Also see https://github.com/raygard/wak/issues/2 -- this guy
did the Advent of Code in awk, and my awk works on it.

For more fun, get
https://github.com/patsie75/awk-mandelbrot/raw/master/mandelbrot.awk

and run: toybox awk -v profile=2 -f mandelbrot.awk

It may take a while but it will finish at frame 400. Try other profile
values (1 through 8). busybox awk doesn't work at all. All other awks
(gawk, Kernighan's awk, mawk, goawk) give similar output but no two
awks make identical output.

Regarding bc.c being several times larger than expected: bc is a
programming language with functions and control structures and
arbitrary precision math and interactive mode. Not sure it can be
written much smaller. But my awk is smaller than toybox bc.c in
(non-comment nonblank) LOC.

Ray

> P.S. Also, my old Austin house finally went on the market last weekend and we

P.S. I hope the house thing is going OK for you.


More information about the Toybox mailing list