bin/59883: divert cannot be renamed in FreeBSD m4 [with patch]
Craig Boston
craig at olyun.gank.org
Tue Apr 27 22:00:40 PDT 2004
The following reply was made to PR bin/59883; it has been noted by GNATS.
From: Craig Boston <craig at olyun.gank.org>
To: freebsd-gnats-submit at FreeBSD.org, bremner at unb.ca
Cc:
Subject: Re: bin/59883: divert cannot be renamed in FreeBSD m4 [with patch]
Date: Tue, 27 Apr 2004 23:50:34 -0500
--Boundary-00=_agzjAbC17iIIQlN
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi,
I've recently run into the same problem with our m4 -- defn() appears to not
work correctly with builtins, so they cannot be copied/renamed at all.
The problem seems to be the result of a commit from about 2 years (!) ago.
Guess nobody uses BSD m4 very much :)
http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/m4/main.c?rev=1.14&content-type=text/x-cvsweb-markup
p->defn = null;
was changed to
p->defn = xstrdup(null);
as part of a GCC3 const/WARNS sweep. null is apparently a pointer to a
somewhat "magic" empty string. The problem happens in dodefn() in eval.c
when this is checked:
if (p->defn != null) {
[ do stuff for macros ]
} else ... {
[ do stuff for builtins ]
}
p->defn is no longer == to null for builtins, but rather a copy of it. I
changed it to instead check p->type to see if it's a macro or not and that
seems to fix it. Also checked the OpenBSD CVS and it looks like they fixed
the problem there with a very similar (though more extensive) approach. A
quick grep/once-over of the code didn't turn up any more (ab)use of pointers
to "null" that would be affected by this.
Patch is both inline (tabs mangled I'm sure) and attached -- I don't remember
if gnats accepts MIME attachments :-/
--- eval.c.orig Tue Apr 27 23:33:03 2004
+++ eval.c Tue Apr 27 23:33:57 2004
@@ -617,7 +617,7 @@
const char *real;
if ((p = lookup(name)) != nil) {
- if (p->defn != null) {
+ if ((p->type & TYPEMASK) == MACRTYPE) {
pbstr(rquote);
pbstr(p->defn);
pbstr(lquote);
--Boundary-00=_agzjAbC17iIIQlN
Content-Type: text/plain;
charset="us-ascii";
name="bsd.m4.defn.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="bsd.m4.defn.patch"
--- eval.c.orig Tue Apr 27 23:33:03 2004
+++ eval.c Tue Apr 27 23:33:57 2004
@@ -617,7 +617,7 @@
const char *real;
if ((p = lookup(name)) != nil) {
- if (p->defn != null) {
+ if ((p->type & TYPEMASK) == MACRTYPE) {
pbstr(rquote);
pbstr(p->defn);
pbstr(lquote);
--Boundary-00=_agzjAbC17iIIQlN--
More information about the freebsd-bugs
mailing list