autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: document m4_foreach*/AC_FOREACH


From: Ralf Wildenhues
Subject: Re: document m4_foreach*/AC_FOREACH
Date: Thu, 16 Feb 2006 21:58:12 +0100
User-agent: Mutt/1.5.9i

Hi Eric,

* Eric Blake wrote on Thu, Feb 16, 2006 at 09:35:28PM CET:
> According to Ralf Wildenhues on 2/15/2006 5:22 PM:
> > +dnl Make sure we do not divide by zero:
> 
> You probably also ought to have tests:
> 
> m4_for([myvar], 1, 2, 0, [ myvar])
> m4_for([myvar], 1, 1, 0, [ myvar])
> m4_for([myvar], 2, 1, 0, [ myvar])
> 
> to test that an explicit step size of 0 properly triggers an
> m4_assert, distinct from a defaulted step size.

Yes, good idea.  Below is an additional patchlet for the first and third
case.  The second isn't m4_assert'ed at the moment: the body is expanded
once, with myvar set to 1.  Do you think that should be forbidden?  I'm
not sure that would be necessary.  My concerns were mostly with (almost)
endless loops and huge memory consumption, which may happen if the user
inadvertently messes up.

Thanks,
Ralf

--- tests/m4sugar.at    2006-02-16 21:51:04.000000000 +0100
+++ tests/m4sugar.at    2006-02-16 21:51:07.000000000 +0100
@@ -279,4 +279,28 @@
 script.4s:3: the top level
 autom4te: m4 failed with exit status: 1
 ]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert_push([0])m4_wrap([m4_divert_pop([0])[]])dnl
+m4_for([myvar], 1, 2, 0, [ myvar])
+]])
+
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:3: error: assert failed: 0 == 1
+script.4s:3: the top level
+autom4te: m4 failed with exit status: 1
+]])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_init
+m4_divert_push([0])m4_wrap([m4_divert_pop([0])[]])dnl
+m4_for([myvar], 2, 1, 0, [ myvar])
+]])
+
+AT_CHECK_M4SUGAR([], 1, [],
+[[script.4s:3: error: assert failed: 0 == -1
+script.4s:3: the top level
+autom4te: m4 failed with exit status: 1
+]])
 AT_CLEANUP




reply via email to

[Prev in Thread] Current Thread [Next in Thread]