<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.7" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Day 16 of 60: I strongly dislike M4</title>
	<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/</link>
	<description>It'll all be over in 60 days</description>
	<pubDate>Thu, 28 Aug 2008 23:36:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.7</generator>

	<item>
		<title>by: Tref</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-1685</link>
		<pubDate>Fri, 29 Dec 2006 14:14:07 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-1685</guid>
					<description>If Sendmail is driving you insane, I'd strongly recommend Exim. It's an excellent MTA.</description>
		<content:encoded><![CDATA[<p>If Sendmail is driving you insane, I&#8217;d strongly recommend Exim. It&#8217;s an excellent MTA.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Try before you buy &#187; Blog Archive &#187; Day 19 of 60: M4 issues resolved, ministat updates</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-34</link>
		<pubDate>Fri, 28 Jul 2006 11:03:39 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-34</guid>
					<description>[...] The issues with M4 have been resolved. A colleague, Andre Lucas, took up the challenge and worked out a fix which he describes in detail. And ministat&#8217;s now looking much better. It&#8217;s grown some useful new options, a lot of documentation, and can now (optionally) generate plots in colour. Look below the fold for two example plots. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] The issues with M4 have been resolved. A colleague, Andre Lucas, took up the challenge and worked out a fix which he describes in detail. And ministat&#8217;s now looking much better. It&#8217;s grown some useful new options, a lot of documentation, and can now (optionally) generate plots in colour. Look below the fold for two example plots. [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: nik</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-33</link>
		<pubDate>Fri, 28 Jul 2006 10:09:38 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-33</guid>
					<description>Bingo.  Committed, with related changes, in &lt;a href="http://jc.ngo.org.uk/svnweb/jc/revision/?rev=1097" rel="nofollow"&gt;1097&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Bingo.  Committed, with related changes, in <a href="http://jc.ngo.org.uk/svnweb/jc/revision/?rev=1097" rel="nofollow">1097</a>.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andre</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-32</link>
		<pubDate>Thu, 27 Jul 2006 13:45:38 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-32</guid>
					<description>Grrr! Wordpress 'smart quotes' buggered it up this time. Sod it, read the patch!</description>
		<content:encoded><![CDATA[<p>Grrr! Wordpress &#8217;smart quotes&#8217; buggered it up this time. Sod it, read the patch!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andre</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-31</link>
		<pubDate>Thu, 27 Jul 2006 13:43:37 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-31</guid>
					<description>Ironically, my last post had a quoting error... (In the exposition, not the patch.) I used '&#60;' as a quote character, which generally doesn't work well in HTML. Doh.

In order to get [stuff `command` more stuff] in the output, I put [`stuff ``command`''' more stuff'] in the macro definition. Actually the output is [stuff `command`'' more stuff] but the [''] is effectively removed by the shell.</description>
		<content:encoded><![CDATA[<p>Ironically, my last post had a quoting error&#8230; (In the exposition, not the patch.) I used &#8216;&lt;&#8217; as a quote character, which generally doesn&#8217;t work well in HTML. Doh.</p>
<p>In order to get [stuff `command` more stuff] in the output, I put [`stuff &#8220;command`&#8221;&#8217; more stuff&#8217;] in the macro definition. Actually the output is [stuff `command`'&#8217; more stuff] but the ['&#8217;] is effectively removed by the shell.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andre</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-30</link>
		<pubDate>Thu, 27 Jul 2006 13:38:54 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-30</guid>
					<description>Ok, got this working reliably now. It's a high-9 on the ugly hackometer, but it seems to work fairly portably.

The problem with using changequote is that it only applies to the first run through m4. It appears that the block in question goes through m4 twice, and that's where the quoting headache comes from. 

Instead of using changequote([,]), I put in enough quotes to survive the multiple m4 runs, and use the fact that the string  (two single-quotes) is a null string in sh, in order to balance the m4-esque backtick-quote pairs. 

E.g. in order to get  in the output, I have   `stuff ``command`''' more stuff' in the macro. Actually, the output is , but since it's interpreted by /bin/sh, '' is effectively ignored. Ugly, but it works.

Patch against the original links.m4. There's another little fix in there, as discussed the '-' in front of mkdir shouldn't be there, it's a make construct and doesn't work in the middle of a compound sh command.

&lt;code&gt;&lt;br /&gt;
&#45;&#45;- devtools/M4/UNIX/links.m4.nik&#160;&#160;&#160;&#160;&#160;&#160; 2006-07-27 14:36:07.744667000 +0100&lt;br /&gt;
+++ devtools/M4/UNIX/links.m4&#160;&#160; 2006-07-27 14:36:36.849567000 +0100&lt;br /&gt;
@@ -20,16 +20,11 @@&lt;br /&gt;
 define(`bldMAKE_SOURCE_LINKS&#039;,&lt;br /&gt;
 `bldFOREACH(`bldMAKE_SOURCE_LINK(&#039;, $1)&#039;dnl&lt;br /&gt;
 )dnl&lt;br /&gt;
-dnl Change the quote definition temporarily so that we can use backticks&lt;br /&gt;
-dnl in the next bit of Makefile&lt;br /&gt;
-changequote([,])dnl&lt;br /&gt;
-define([bldMAKE_TARGET_LINKS],&lt;br /&gt;
-[&#160;&#160;&#160;&#160;&#160;&#160;for i in $2; do \&lt;br /&gt;
-&#160;&#160;&#160;&#160;&#160;&#160; -mkdir -p `dirname $$i`; \&lt;br /&gt;
+define(`bldMAKE_TARGET_LINKS&#039;,&lt;br /&gt;
+`&#160;&#160;&#160;&#160;&#160;&#160;for i in $2; do \&lt;br /&gt;
+&#160;&#160;&#160;&#160;&#160;&#160; mkdir -p &#96;`dirname $$i`&#039;&#039;&#039;; \&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rm -f $$i; \&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ln -s ${DESTDIR}$1 $$i; \&lt;br /&gt;
&#160;&#160;&#160;&#160; done&lt;br /&gt;
-])dnl&lt;br /&gt;
-dnl Change the quotes back&lt;br /&gt;
-changequote(`, &#039;)dnl&lt;br /&gt;
+&#039;)dnl&lt;br /&gt;
&#160;&lt;br /&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Ok, got this working reliably now. It&#8217;s a high-9 on the ugly hackometer, but it seems to work fairly portably.</p>
<p>The problem with using changequote is that it only applies to the first run through m4. It appears that the block in question goes through m4 twice, and that&#8217;s where the quoting headache comes from. </p>
<p>Instead of using changequote([,]), I put in enough quotes to survive the multiple m4 runs, and use the fact that the string  (two single-quotes) is a null string in sh, in order to balance the m4-esque backtick-quote pairs. </p>
<p>E.g. in order to get  in the output, I have   `stuff &#8220;command`&#8221;&#8217; more stuff&#8217; in the macro. Actually, the output is , but since it&#8217;s interpreted by /bin/sh, &#8216;&#8217; is effectively ignored. Ugly, but it works.</p>
<p>Patch against the original links.m4. There&#8217;s another little fix in there, as discussed the &#8216;-&#8217; in front of mkdir shouldn&#8217;t be there, it&#8217;s a make construct and doesn&#8217;t work in the middle of a compound sh command.</p>
<p><code><br />
&#45;&#45;- devtools/M4/UNIX/links.m4.nik&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2006-07-27 14:36:07.744667000 +0100<br />
+++ devtools/M4/UNIX/links.m4&nbsp;&nbsp; 2006-07-27 14:36:36.849567000 +0100<br />
@@ -20,16 +20,11 @@<br />
 define(`bldMAKE_SOURCE_LINKS&#039;,<br />
 `bldFOREACH(`bldMAKE_SOURCE_LINK(&#039;, $1)&#039;dnl<br />
 )dnl<br />
-dnl Change the quote definition temporarily so that we can use backticks<br />
-dnl in the next bit of Makefile<br />
-changequote([,])dnl<br />
-define([bldMAKE_TARGET_LINKS],<br />
-[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for i in $2; do \<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -mkdir -p `dirname $$i`; \<br />
+define(`bldMAKE_TARGET_LINKS&#039;,<br />
+`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for i in $2; do \<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mkdir -p &#96;`dirname $$i`&#039;&#039;&#039;; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rm -f $$i; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ln -s ${DESTDIR}$1 $$i; \<br />
&nbsp;&nbsp;&nbsp;&nbsp; done<br />
-])dnl<br />
-dnl Change the quotes back<br />
-changequote(`, &#039;)dnl<br />
+&#039;)dnl<br />
&nbsp;<br />
</code>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andre</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-29</link>
		<pubDate>Wed, 26 Jul 2006 11:38:48 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-29</guid>
					<description>Same patch, will need to xlate spaces to tabs.
&lt;code&gt;&lt;br /&gt;
&#45;&#45;- devtools/M4/UNIX/links.nik&#160;&#160;2006-07-26 12:33:13.423230000 +0100&lt;br /&gt;
+++ devtools/M4/UNIX/links.m4&#160;&#160; 2006-07-26 12:29:29.005179000 +0100&lt;br /&gt;
@@ -22,14 +22,14 @@&lt;br /&gt;
 )dnl&lt;br /&gt;
 dnl Change the quote definition temporarily so that we can use backticks&lt;br /&gt;
 dnl in the next bit of Makefile&lt;br /&gt;
-changequote(&#34;,&#34;)dnl&lt;br /&gt;
-define(&#34;bldMAKE_TARGET_LINKS&#34;,&lt;br /&gt;
-&#34;&#160;&#160;&#160;&#160;&#160;&#160;for i in $2; do \&lt;br /&gt;
+changequote([,])dnl&lt;br /&gt;
+define([bldMAKE_TARGET_LINKS],&lt;br /&gt;
+[&#160;&#160;&#160;&#160;&#160;&#160;for i in $2; do \&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;-mkdir -p `dirname $$i`; \&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;rm -f $$i; \&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ln -s ${DESTDIR}$1 $$i; \&lt;br /&gt;
-&#160;&#160;&#160;&#160;done&#34;&lt;br /&gt;
-)dnl&lt;br /&gt;
+&#160;&#160;&#160;&#160;done&lt;br /&gt;
+])dnl&lt;br /&gt;
 dnl Change the quotes back&lt;br /&gt;
 changequote(`, &#039;)dnl&lt;br /&gt;
&#160;&lt;br /&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Same patch, will need to xlate spaces to tabs.<br />
<code><br />
&#45;&#45;- devtools/M4/UNIX/links.nik&nbsp;&nbsp;2006-07-26 12:33:13.423230000 +0100<br />
+++ devtools/M4/UNIX/links.m4&nbsp;&nbsp; 2006-07-26 12:29:29.005179000 +0100<br />
@@ -22,14 +22,14 @@<br />
 )dnl<br />
 dnl Change the quote definition temporarily so that we can use backticks<br />
 dnl in the next bit of Makefile<br />
-changequote(&quot;,&quot;)dnl<br />
-define(&quot;bldMAKE_TARGET_LINKS&quot;,<br />
-&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for i in $2; do \<br />
+changequote([,])dnl<br />
+define([bldMAKE_TARGET_LINKS],<br />
+[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for i in $2; do \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-mkdir -p `dirname $$i`; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rm -f $$i; \<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ln -s ${DESTDIR}$1 $$i; \<br />
-&nbsp;&nbsp;&nbsp;&nbsp;done&quot;<br />
-)dnl<br />
+&nbsp;&nbsp;&nbsp;&nbsp;done<br />
+])dnl<br />
 dnl Change the quotes back<br />
 changequote(`, &#039;)dnl<br />
&nbsp;<br />
</code>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andre</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-28</link>
		<pubDate>Wed, 26 Jul 2006 11:37:41 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-28</guid>
					<description>Not sure why I used blockquote instead of code. Sigh.</description>
		<content:encoded><![CDATA[<p>Not sure why I used blockquote instead of code. Sigh.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andre</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-27</link>
		<pubDate>Wed, 26 Jul 2006 11:35:07 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-27</guid>
					<description>This compiled for me on Solaris 10 (gcc). I haven't tried it on Sun Studio yet.

&lt;blockquote&gt;
--- devtools/M4/UNIX/links.nik  2006-07-26 12:33:13.423230000 +0100
+++ devtools/M4/UNIX/links.m4   2006-07-26 12:29:29.005179000 +0100
@@ -22,14 +22,14 @@
 )dnl
 dnl Change the quote definition temporarily so that we can use backticks
 dnl in the next bit of Makefile
-changequote(",")dnl
-define("bldMAKE_TARGET_LINKS",
-"      for i in $2; do \
+changequote([,])dnl
+define([bldMAKE_TARGET_LINKS],
+[      for i in $2; do \
        -mkdir -p `dirname $$i`; \
        rm -f $$i; \
        ln -s ${DESTDIR}$1 $$i; \
-    done"
-)dnl
+    done
+])dnl
 dnl Change the quotes back
 changequote(`, ')dnl

&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>This compiled for me on Solaris 10 (gcc). I haven&#8217;t tried it on Sun Studio yet.</p>
<blockquote><p>
&#8212; devtools/M4/UNIX/links.nik  2006-07-26 12:33:13.423230000 +0100<br />
+++ devtools/M4/UNIX/links.m4   2006-07-26 12:29:29.005179000 +0100<br />
@@ -22,14 +22,14 @@<br />
 )dnl<br />
 dnl Change the quote definition temporarily so that we can use backticks<br />
 dnl in the next bit of Makefile<br />
-changequote(&#8221;,&#8221;)dnl<br />
-define(&#8221;bldMAKE_TARGET_LINKS&#8221;,<br />
-&#8221;      for i in $2; do \<br />
+changequote([,])dnl<br />
+define([bldMAKE_TARGET_LINKS],<br />
+[      for i in $2; do \<br />
        -mkdir -p `dirname $$i`; \<br />
        rm -f $$i; \<br />
        ln -s ${DESTDIR}$1 $$i; \<br />
-    done&#8221;<br />
-)dnl<br />
+    done<br />
+])dnl<br />
 dnl Change the quotes back<br />
 changequote(`, &#8216;)dnl</p>
</blockquote>
]]></content:encoded>
				</item>
	<item>
		<title>by: nik</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-26</link>
		<pubDate>Wed, 26 Jul 2006 10:57:14 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-26</guid>
					<description>You can, of course, ignore the backslashes in the previous comment.  Seems to be a bug in WordPress.</description>
		<content:encoded><![CDATA[<p>You can, of course, ignore the backslashes in the previous comment.  Seems to be a bug in WordPress.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: nik</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-25</link>
		<pubDate>Wed, 26 Jul 2006 10:54:35 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-25</guid>
					<description>I tried that yesterday.

With

&lt;code&gt;changequote(`, \&#039;)dnl&lt;/code&gt;

it gets further through the build process, but eventually fails when trying to make 

&lt;code&gt;&#46;../executable.m4:42 EOF in quote&lt;/code&gt;

Since the manpage for m4 says:

&lt;blockquote&gt;changequote  without  arguments restores the original values (that is,`\').&lt;/blockquote&gt;

I\'ve tried &lt;code&gt;changequote()&lt;/code&gt; and &lt;code&gt;changequote&lt;/code&gt; too, to no effect.  I\'ve even tried &lt;code&gt;changequote(\&#34;`\&#34;, \&#34;\&#039;\&#34;)&lt;/code&gt;.

Here\'s the current &lt;a href=\"http://jc.ngo.org.uk/~nik/links.m4\" rel=\"nofollow\" rel="nofollow"&gt;links.m4&lt;/a&gt; (which doesn\'t work).  If you can drop that in to &lt;code&gt;devtools/M4/UNIX/&lt;/code&gt;, and get &lt;code&gt;sh Build&lt;/code&gt; to work then I\'m interested in what you had to change.</description>
		<content:encoded><![CDATA[<p>I tried that yesterday.</p>
<p>With</p>
<p><code>changequote(`, \&#039;)dnl</code></p>
<p>it gets further through the build process, but eventually fails when trying to make </p>
<p><code>&#46;../executable.m4:42 EOF in quote</code></p>
<p>Since the manpage for m4 says:</p>
<blockquote><p>changequote  without  arguments restores the original values (that is,`\&#8217;).</p></blockquote>
<p>I\&#8217;ve tried <code>changequote()</code> and <code>changequote</code> too, to no effect.  I\&#8217;ve even tried <code>changequote(\&quot;`\&quot;, \&quot;\&#039;\&quot;)</code>.</p>
<p>Here\&#8217;s the current <a href=\"http://jc.ngo.org.uk/~nik/links.m4\" rel=\"nofollow\" rel="nofollow">links.m4</a> (which doesn\&#8217;t work).  If you can drop that in to <code>devtools/M4/UNIX/</code>, and get <code>sh Build</code> to work then I\&#8217;m interested in what you had to change.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andre Lucas</title>
		<link>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-24</link>
		<pubDate>Wed, 26 Jul 2006 10:31:13 +0000</pubDate>
		<guid>http://jc.ngo.org.uk/blog/2006/07/25/day-16-of-60-i-strongly-dislike-m4/#comment-24</guid>
					<description>changequote(,) doesn't reset the quotes, it turns off quoting. I think you want changequote(`,').

I put your macro in my site.config.m4, with cq.([,]) before and cq.(`,') at the end and it works fine. If I use cq.(,) at the end, it explodes spectacularly.

The reason it works standalone is because there's nothing else to quote, so turning quoting off doesn't cause a problem.</description>
		<content:encoded><![CDATA[<p>changequote(,) doesn&#8217;t reset the quotes, it turns off quoting. I think you want changequote(`,&#8217;).</p>
<p>I put your macro in my site.config.m4, with cq.([,]) before and cq.(`,&#8217;) at the end and it works fine. If I use cq.(,) at the end, it explodes spectacularly.</p>
<p>The reason it works standalone is because there&#8217;s nothing else to quote, so turning quoting off doesn&#8217;t cause a problem.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
