Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Apr 2004 19:40:10 -0500
From:      Sean Kelly <smkelly@FreeBSD.org>
To:        arch@freebsd.org
Subject:   m4 modifications?
Message-ID:  <20040426004010.GA31337@edgemaster.zombie.org>

next in thread | raw e-mail | index | archive | help
I am currently dealing with a PR (bin/60914). This PR addresses several
shortcomings and flaws in our m4 implementation, including:
 * The bitwise operators not behaving like bitwise operators
 * Improper operator precdence
 * Weak error messages
 * Short-circuit evaluation

The last item in that list is the one which is the one I am fishing
for opinions and insight on. In our current m4, there is no short-circuit
evaluation of expressions:

     $ echo "eval(1 || (1/0))" | m4
     m4: division by zero in eval.

The PR submitter's patch changes our m4 to properly(?) evaluate this to 1,
obeying short-circuit evaluation. The problem is that it is unclear to me
whether this is the way it should be done.

No other m4 implementation that I can find does short-circuit evaluation,
including GNU, HP-UX's, and Solaris. According to SUSv3:

    All of the C-language operators shall be supported, except for:                
    []       ->       ++       --       (type)                                     
    unary *  sizeof   .        ?:       unary &                                    
    and all assignment operators. Precedence and associativity shall               
    be as in the ISO C standard.                                                   

Does that imply that short-circuit evaluation should be done? If so,
should we do it even though nobody else seems to? If it is vague, should
we do it?

My experience with m4 is somewhat limited, and this is not an area where
I can speak authoritatively.

-- 
Sean Kelly          | PGP KeyID: D2E5E296
smkelly@FreeBSD.org | http://www.sean-kelly.org/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040426004010.GA31337>