From mkb@altair.mayn.de  Sat Mar 18 16:59:41 2000
Return-Path: <mkb@altair.mayn.de>
Received: from altair.mayn.de (altair.mayn.de [194.145.150.157])
	by hub.freebsd.org (Postfix) with ESMTP id 11B4D37B609
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 18 Mar 2000 16:59:35 -0800 (PST)
	(envelope-from mkb@altair.mayn.de)
Received: (from mkb@localhost)
	by altair.mayn.de (8.9.3/8.9.3) id BAA05378;
	Sun, 19 Mar 2000 01:59:03 +0100 (CET)
	(envelope-from mkb)
Message-Id: <200003190059.BAA05378@altair.mayn.de>
Date: Sun, 19 Mar 2000 01:59:03 +0100 (CET)
From: Matthias Buelow <mkb@altair.mayn.de>
Reply-To: mkb@altair.mayn.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: m4 changecom doesn't work as documented
X-Send-Pr-Version: 3.2

>Number:         17480
>Category:       bin
>Synopsis:       m4 changecom doesn't work as documented
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jmallett
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 18 17:00:01 PST 2000
>Closed-Date:    Sun Jun 16 20:56:57 PDT 2002
>Last-Modified:  Sun Jun 16 20:56:57 PDT 2002
>Originator:     Matthias Buelow
>Release:        FreeBSD 3.3-STABLE i386
>Organization:
nil
>Environment:

FreeBSD altair.mayn.de 3.3-STABLE FreeBSD 3.3-STABLE #4: Wed Mar  8 22:02:50 CET 2000     root@altair.mayn.de:/usr/src/sys/compile/ALTAIR  i386

>Description:

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.

>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.

>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.


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jmallett 
Responsible-Changed-By: jmallett 
Responsible-Changed-When: Wed Apr 24 20:50:44 PDT 2002 
Responsible-Changed-Why:  
Over to me, since I did the OpenBSD m4(1) import. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=17480 
State-Changed-From-To: open->patched 
State-Changed-By: jmallett 
State-Changed-When: Mon Jun 3 13:35:43 PDT 2002 
State-Changed-Why:  
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. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=17480 
State-Changed-From-To: patched->closed 
State-Changed-By: jmallett 
State-Changed-When: Sun Jun 16 20:56:34 PDT 2002 
State-Changed-Why:  
Traditional BSD behaviour will be documented. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=17480 
>Unformatted:
