m4: Sync with FreeBSD.

This improves compat with GNU m4 and brings the code closer to NetBSD
and OpenBSD.

Obtained-from:  FreeBSD
Add regression tests for m4.

Obtained-from:  FreeBSD