Page MenuHomeFreeBSD

usr.bin/m4: Improve compatibility with GNU m4.
Needs ReviewPublic

Authored by jkoshy on Feb 7 2025, 6:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 22, 7:05 AM
Unknown Object (File)
Sun, Mar 2, 5:47 PM
Unknown Object (File)
Sat, Mar 1, 7:35 PM
Unknown Object (File)
Feb 21 2025, 3:28 PM
Unknown Object (File)
Feb 13 2025, 9:23 AM
Unknown Object (File)
Feb 12 2025, 8:46 PM
Unknown Object (File)
Feb 11 2025, 9:22 PM
Subscribers

Details

Reviewers
imp
gnn
emaste
Summary

Do not expand bare a "shift" keyword that is not immediately followed by
an open parenthesis.

POSIX leaves undefined the behavior of a "shift" keyword that is NOT
immediately followed by an open-parenthesis. GNU m4 conveniently passes
through such uses unexpanded:

GM4: "shift" -> "shift"       # A bare "shift" keyword is not expanded.

Prior to this change FreeBSD's M4 would expand a bare "shift" in its
input to the empty string:

Previous FBM4: "shift" -> ""	# A bare "shift" keyword is expanded.

which, while technically compatible with POSIX, made FreeBSD M4 harder
to use with plain English text.

After this change the behavior of FreeBSD M4 should match that of
GNU M4:

FBM4: "shift" -> "shift"     # A bare keyword is not expanded.

Normal macro invocations (e.g., "shift($*)") continue to work as before.

Reference: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/m4.html

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 62302
Build 59186: arc lint + arc unit

Event Timeline

jkoshy requested review of this revision.Feb 7 2025, 6:18 PM

Any sendmail configs affected?

In D48892#1115051, @imp wrote:

Any sendmail configs affected?

Not that I can see - those files aren't using the bare "shift" keyword.

Normal macro invocations (e.g., "shift($*)") continue to work as before.