| Summary: | m4 changecom doesn't work as documented | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Matthias Buelow <mkb> |
| Component: | bin | Assignee: | Juli Mallett <jmallett> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 3.3-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
Responsible Changed From-To: freebsd-bugs->jmallett Over to me, since I did the OpenBSD m4(1) import. State Changed From-To: open->patched In CURRENT using OpenBSD's m4(1) we can use a "GNU" mode which supports changecom as you mention, however the behaviour of BSD traditionally seems to have been different from how it was documented, but possibly intended. In any case, it is more than likely that some users of m4 rely on BSD m4(1) to reset to the default comment characters in the case of changecom with no arguments. I've committed clarification to the manual page, and when/if OpenBSD m4(1) is MFC'd, this will appear in STABLE. State Changed From-To: patched->closed Traditional BSD behaviour will be documented. |
The m4 program is a general purpose macro processor. Its "changecom" command allows the user to change the comment-start and end sequences. Quote from the manpage: changecom Change the start and end comment sequences. The default is the pound sign `#' and the newline character. With no arguments comments are turned off. The maximum length for a comment marker is five characters. which doesn't work at all in the m4 shipped with FreeBSD. System V m4 and Gnu m4 work that way, though. An example (the first line of a pair is always typed, the second is what m4 prints to stdout): $ m4 changecom # dnl asdf # dnl asdf as you can see the comment chars are still effective although according to the manpage there should be no comments at all now and the output should be # dnl asdf # A quick look at the code showed that changecom without arguments actually resets the comment chars to their compile-time defaults. Setting comment characters to more than one char isn't possible either (I don't know who wrote the manpage but certainly not the person who did the implementation): changecom(`/*', `*/') /* dnl adsf */ /* which is also wrong, it should display /* dnl asdf */ /* dnl asdf */ The problem above is that m4 actually only takes the first character of the comment string. Fix: I'm quite busy and can't cough up a patch currently. As a workaround, you can install Gnu m4 from the ports collection. How-To-Repeat: See above. Look at m4's eval.c dochc() function and you'll see that it was never intended to do what the manpage says. However, since the behaviour described by the manpage seems to be the case with "other" m4s (as found on System V, Digital Unix and with Gnu m4) I suggest implementing the missing functionality. Maybe a general code inspection will reveal some other "missing" things.