]> git.draconx.ca Git - dxcommon.git/commitdiff
Fix underquoting issue in DX_DO.
authorNick Bowler <nbowler@draconx.ca>
Thu, 25 Jan 2018 00:29:52 +0000 (19:29 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 25 Jan 2018 04:45:47 +0000 (23:45 -0500)
The m4_map macro takes a "quoted list of argument descriptions ...
[which are] in turn a quoted list of quoted elements, suitable for
m4_apply."  This is not what actually is being passed in DX_DO,
which is underquoted resulting in various problems.

Add a test case to expose this issue, and switch DX_DO to use
m4_map_args which is a better fit.

Thanks to Eric Blake.

m4/utils.m4
tests/macros.at

index 0939e74eed4c648e453c57fdf3ba39c234262a17..32f3246cfc45fc9ab26897302e813ebdd1ad919c 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2015 Nick Bowler
+dnl Copyright © 2015, 2018 Nick Bowler
 dnl
 dnl Assorted helper macros
 dnl
 dnl
 dnl Assorted helper macros
 dnl
@@ -8,4 +8,4 @@ dnl There is NO WARRANTY, to the extent permitted by law.
 
 dnl DX_DO(arg, ...)
 dnl Expand each argument in sequence, inserting newlines between them.
 
 dnl DX_DO(arg, ...)
 dnl Expand each argument in sequence, inserting newlines between them.
-AC_DEFUN([DX_DO], [m4_do([$1], [m4_map([m4_newline], m4_cdr($@))])])
+AC_DEFUN([DX_DO], [m4_do([$1], [m4_map_args([m4_newline], m4_shift($@))])])
index a5c8c5d2e4d3e78b5e66b8edd556d197d11edeef..f3ada4563f5230decf9b9ee6e93c211076e229ce 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright © 2015 Nick Bowler
+dnl Copyright © 2014-2015, 2018 Nick Bowler
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
@@ -25,6 +25,7 @@ m4_define([TEST_CONFIGURE], [AT_CHECK([./configure $1], [0], [ignore])])
 dnl Verify that the DX_BASEDIR macro expands correctly during argument
 dnl collection.  Crucially, the output must not contain any other text.
 AT_SETUP([DX_BASEDIR during argument collection])
 dnl Verify that the DX_BASEDIR macro expands correctly during argument
 dnl collection.  Crucially, the output must not contain any other text.
 AT_SETUP([DX_BASEDIR during argument collection])
+AT_KEYWORDS([DX_BASEDIR macro])
 
 AT_DATA([test.in],
 [[@TEST@
 
 AT_DATA([test.in],
 [[@TEST@
@@ -45,6 +46,7 @@ AT_CLEANUP
 
 dnl Verify that DX_BASEDIR is correctly AC_SUBSTed
 AT_SETUP([DX_BASEDIR output substitution])
 
 dnl Verify that DX_BASEDIR is correctly AC_SUBSTed
 AT_SETUP([DX_BASEDIR output substitution])
+AT_KEYWORDS([DX_BASEDIR macro])
 
 AT_DATA([test.in],
 [[@DX_BASEDIR@
 
 AT_DATA([test.in],
 [[@DX_BASEDIR@
@@ -65,6 +67,7 @@ AT_CLEANUP
 
 dnl Verify that DX_BASEDIR is set correctly implicitly
 AT_SETUP([DX_BASEDIR implicit definition])
 
 dnl Verify that DX_BASEDIR is set correctly implicitly
 AT_SETUP([DX_BASEDIR implicit definition])
+AT_KEYWORDS([DX_BASEDIR macro])
 
 AT_DATA([test.in],
 [[@DX_BASEDIR@
 
 AT_DATA([test.in],
 [[@DX_BASEDIR@
@@ -80,6 +83,7 @@ TEST_CONFIGURE
 AT_CLEANUP
 
 AT_SETUP([DX_COMMAND_OUTPUT])
 AT_CLEANUP
 
 AT_SETUP([DX_COMMAND_OUTPUT])
+AT_KEYWORDS([DX_COMMAND_OUTPUT macro])
 
 AT_DATA([expout],
 [[   leading whitespace
 
 AT_DATA([expout],
 [[   leading whitespace
@@ -100,3 +104,24 @@ TEST_CONFIGURE
 AT_CHECK([cat test.out], [0], [expout])
 
 AT_CLEANUP
 AT_CHECK([cat test.out], [0], [expout])
 
 AT_CLEANUP
+
+AT_SETUP([DX_DO quoting])
+AT_KEYWORDS([DX_DO macro])
+
+TEST_CONFIGURE_AC(
+[[m4@&t@_define([FOO])
+:; { DX_DO([AS@&t@_ECHO_N(["[FOO]"])],
+           [AS@&t@_ECHO_N(["[FOO]"])],
+           [AS@&t@_ECHO(["[FOO]"])])
+} >test.out
+]])
+
+dnl TEST_CONFIGURE_AC(
+dnl [[DX_DO([AS@&t@_ECHO_N([hello,world])],[AS@&t@_ECHO_N([goodbye,world])])
+dnl ]])
+TEST_AUTORECONF
+TEST_CONFIGURE
+AT_CHECK([cat test.out], [0], [[FOOFOOFOO
+]])
+
+AT_CLEANUP