Re: git: 8b197806dcdf - main - libsysdecode: Teach mktables to handle enums
Date: Thu, 19 Nov 2026 22:22:21 UTC
On 19 Nov 2026, at 21:39, Jessica Clarke <jrtc27@freebsd.org> wrote:
> On 19 Nov 2026, at 21:12, Jessica Clarke <jrtc27@freebsd.org> wrote:
>> On 6 Jul 2026, at 20:44, Dag-Erling Smørgrav <des@freebsd.org> wrote:
>>>
>>> The branch main has been updated by des:
>>>
>>> URL: https://cgit.FreeBSD.org/src/commit/?id=8b197806dcdff5673dd4f77a97bf46035d14db2a
>>>
>>> commit 8b197806dcdff5673dd4f77a97bf46035d14db2a
>>> Author: Dag-Erling Smørgrav <des@FreeBSD.org>
>>> AuthorDate: 2026-07-06 19:41:15 +0000
>>> Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
>>> CommitDate: 2026-07-06 19:41:15 +0000
>>>
>>> libsysdecode: Teach mktables to handle enums
>>>
>>> While here, clean up and simplify the existing code.
>>
>> This has completely broken mktables on macOS*. Please back it out
>> immediately, MFC it and get that into 15.2 so we can go back to a
>> known-good state and have time to properly diagnose and fix it.
>
> The cause is that \> is not POSIX, nor is it a universal extension.
>
> GNU sed supports \> and \b
> FreeBSD sed supports [[:>:]] and \>
> macOS sed supports [[:>:]]
>
> Note that, although we bootstrap FreeBSD sed, it still behaves like
> macOS sed, because it uses the system’s regex(3).
>
> I have no immediate solution I would feel comfortable deploying this
> close to 15.2’s release, so still believe a revert with a later re-land
> is the right course of action.
The more adventurous alternative would be something like:
diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables
index bb784c853e48..61dc089a42c4 100644
--- a/lib/libsysdecode/mktables
+++ b/lib/libsysdecode/mktables
@@ -64,7 +64,7 @@ _EOF_
sed -nE ${excl:+-e "/${excl}/d"} \
-e "/^#[[:space:]]*define[[:space:]]+${grep}/p" \
"${include_dir}/${file}" | \
- sed -Ee 's/.*define[[:space:]]+([^[:space:]]+)\>.*/TABLE_ENTRY(\1)/'
+ sed -Ee 's/.*define[[:space:]]+([_[:alpha:]][_[:alnum:]]*).*/TABLE_ENTRY(\1)/'
fi
cat <<_EOF_
TABLE_END
@@ -95,7 +95,7 @@ _EOF_
awk '/^(typedef[[:space:]]*)?enum([[:space:]].*)?\{/,
/^\}([[:space:]].*)?;/' |
# pick out the constants we want
- sed -Ene 's/^[[:space:]]*('"${grep}"')\>.*/TABLE_ENTRY(\1)/p'
+ sed -Ene 's/^[[:space:]]*('"${grep}"')([^_[:alnum:]].*|$)/TABLE_ENTRY(\1)/p'
fi
cat <<_EOF_
TABLE_END
Tested only that the build produces a plausible tables.h on macOS, but
I believe that in theory it only uses standard POSIX ERE features.
Jessica