Re: [hackers] [st][PATCH] arg.h: optimize & style

From: Laslo Hunhold <dev_AT_frign.de>
Date: Sun, 4 Jul 2021 12:34:54 +0200

On Sun, 4 Jul 2021 11:55:53 +0200
Hiltjo Posthuma <hiltjo_AT_codemadness.org> wrote:

Dear Hiltjo,

> Thanks, but I prefer the current style one.
>
> I'm not confident this patch doesn't modify any behaviour.
> For example I see the `i` variable was removed, but it is actually
> important to not modify argv as this causes issues on NetBSD and
> OpenBSD process listing (see commit
> a5a928bfc1dd049780a45e072cb4ee42de7219bf).
>
> This is just one example. Unless it fixes a bug I rather keep the
> current code.

the arg.h in st has some "low-hanging" fruits regarding improvements,
and I modified it accordingly in quark and farbfeld back in 2017 (see
[0]) to fix some issues.

One example is that in my modified form, you can actually access
EARGF()/ARGF() multiple times (instead of silently corrupting the
state), and it properly handles the case when argv is NULL (which is
allowed by POSIX). There was also a bit of
code-deduplication/refactoring with fewer local variables and abort()
was replaced with exit(1).

Of course and as the license permits, feel free to use it in st or
other projects as well, if you like. :)

With best regards

Laslo

[0]:https://git.suckless.org/quark/file/arg.h.html
Received on Sun Jul 04 2021 - 12:34:54 CEST

This archive was generated by hypermail 2.3.0 : Sun Jul 04 2021 - 13:12:31 CEST