git: 770e04e65fbb - stable/14 - awk: revert upstream's attempt to disallow hex strings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 15 Apr 2024 23:02:05 UTC
The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=770e04e65fbbb8e8a21830fe043522907a1702c3 commit 770e04e65fbbb8e8a21830fe043522907a1702c3 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-04-15 22:59:28 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-04-15 22:59:28 +0000 awk: revert upstream's attempt to disallow hex strings Upstream one-true-awk decided to disallow hex strings as numbers. This is in line with awk's behavior prior to C99, and allowed by the POSIX standard. The standard, however, allows them to be treated as numbers because that's what the standard said in the 2001 through 2004 editions. Since 2001, the nawk in FreeBSD has treated them as numbers, so restore that behavior, allowed by prior standards, but not the latest POSIX standard. A number of scripts in the FreeBSD tree depend on this interpretation, including scripts to build the kernel which had mysteriously started failing for some people and not others. By re-allowing 0x hex numbers, this fixes those scripts and restores POLA. Upstream issue: https://github.com/onetrueawk/awk/issues/126 Sponsored by: Netflix Reviewed by: kevans MFC After: asap due to regression alrady merged to stable Differential Revision: https://reviews.freebsd.org/D31199 Note: This is re-done in stable/14 because the release notes say 15 and newer will have this restriction, implying stable/14 will not, but the OTA 2nd edition merge neglected to have this, breaking kernel.bin in arm*. (cherry picked from commit d4d252c49976de33d0a2926df733744d0b8d95fa) --- contrib/one-true-awk/lib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/one-true-awk/lib.c b/contrib/one-true-awk/lib.c index 0dac1f929cf2..e6fb99c744b5 100644 --- a/contrib/one-true-awk/lib.c +++ b/contrib/one-true-awk/lib.c @@ -886,9 +886,18 @@ bool is_valid_number(const char *s, bool trailing_stuff_ok, while (isspace((int) *s)) s++; +/* + * This test, while allowed by newer POSIX standards, represents a regression + * where hex strings were treated as numbers in nawk the whole time it has been + * in FreeBSD (since 2001). The POSIX 2001 through 2004 standards mandated this + * behavior and the current standard allows it. Deviate from upstream by restoring + * the prior FreeBSD behavior. + */ +#if 0 /* no hex floating point, sorry */ if (s[0] == '0' && tolower(s[1]) == 'x') return false; +#endif /* allow +nan, -nan, +inf, -inf, any other letter, no */ if (s[0] == '+' || s[0] == '-') {