[PATCH] build: Avoid length() GNU awk extension

Mike Frysinger vapier@gentoo.org
Wed Mar 9 09:10:17 GMT 2022


On 09 Mar 2022 03:54, Mike Frysinger wrote:
> On 09 Mar 2022 08:31, Sebastian Huber wrote:
> > Other awk implementations such as mawk do not support the length() function.
> 
> those awk implementations are not POSIX compliant.  length() is
> *not* a GNU extension.  you can see it clearly defined in POSIX:
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_13

sorry, i quoted length() as used to count bytes in a string, not elements
in an array.  POSIX doesn't support that.  i would still argue that, while
gawk supports it, it isn't a GNU extension.  bwk supported it back in 2002,
and gawk didn't implement it until ~2005.

> that said, mawk does support length(), and has since at least 2008 in
> the 1.3.3 release.  i stopped looking back further in the history.

the original mawk has been dead for over a decade.  i hope you're not trying
to use such vintage tools.  Thomas E. Dickey picked up maintenance and has
produced a series of fixes & improvements, and every distro i'm aware of is
using his fork.
https://invisible-island.net/mawk/

i mention this because he implemented length() to count array elements back
in 2012.  so if you still haven't updated to a version that supports that,
you should really get on top of that.

all that said, the patch you propose is a simple alternative that is POSIX
compliant, so i'm fine with it too.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20220309/a4c3b0a5/attachment.sig>


More information about the Newlib mailing list