Whilst we bootstrap our own sed when building on non-FreeBSD, it uses
the system regex(3) implementation, and so inherits its extensions, not
our own. Our implementation and glibc's both include this extension to
POSIX, but macOS's does not, and so even with our bootstrap sed we
cannot use the \> extension when built and run on macOS.
Unfortunately, there is no alternative form we can use; whilst macOS
implements :>: as an extension that provides this same feature, and
so do we, the regex(3) implementation in glibc does not, and the only
alternative glibc offers is \b, which neither us nor macOS implement.
We could make the form used conditional on the OS, but that starts to
get messy once other Linux libcs enter the picture, which in theory we
somewhat support.
Rewrite both uses to avoid the need for \>. For gen_table, use a pattern
to match the identifier that is precisely the (non-extended) C99
identifier pattern, and therefore by virtue of longer submatches being
preferred left-to-right will capture the entire identifier before the .*
matches anything, with no need to check for a boundary. However, for
gen_table_enum, the input pattern (${grep}) can be more specific, so we
should check for a word boundary, which we can do by explicitly matching
on a non-identifier character (or the end of the line).
With and without this patch applied to releng/15.2 at time of writing,
building on both FreeBSD 15.1 and Ubuntu 22.04, make tinderbox produces
identical tables.h files across all four possible such configurations;
specifically:
find $MAKEOBJDIRPREFIX -path '*/libsysdecode/tables.h' -exec md5sum {} + | LC_ALL=C sortis identical for the four OS * patched configurations. Additionally, make
tinderbox for the same patched tree on macOS 27.2.1 (noting the unpatched tree
doesn't build) also identical produces identical tables.h files to these four
configurations.
Fixes: 8b197806dcdf ("libsysdecode: Teach mktables to handle enums")
MFC after: 1 day