Hi Eric,
Again, I've stumbled across a behaviour of brackets in autoconf macros that
I don't understand.
If in file m4/include_next.m4 at line 210 I add the following code
-------------------------------------------------------------------------------
case "$host_os" in
mingw*)
dnl For the sake of native Windows compilers (excluding
gcc), treat
dnl backslash as a directory separator, like /. Actually,
these
dnl compilers use a double-backslash as directory separator,
inside the
dnl # line "filename"
dnl directives.
gl_absolute_header_sed='\#[/\\]]m4_defn([gl_HEADER_NAME])[#{
s#.*"\(.*[/\\]]m4_defn([gl_HEADER_NAME])[\)".*#\1#
s#^/[^/]#//&#
p
q
}'
;;
*)
gl_absolute_header_sed='\#/]m4_defn([gl_HEADER_NAME])[#{
s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
s#^/[^/]#//&#
p
q
}'
;;
esac
-------------------------------------------------------------------------------
then the generated configure file (in a testdir
$ ./gnulib-tool --create-testdir --dir=... --with-tests --single-configure
math
) will contain the lines
-------------------------------------------------------------------------------
case "$host_os" in
mingw*)
gl_absolute_header_sed='\#[/\\]math.h#{
s#.*"\(.*[/\\]math.h\)".*#\1#
s#^/[^/]#//&#
p
q
}'
;;
*)
gl_absolute_header_sed='\#/math.h#{
s#.*"\(.*/math.h\)".*#\1#
s#^/[^/]#//&#
p
q
}'
;;
esac
-------------------------------------------------------------------------------
which is OK. Note the brackets around /\\ have been preserved.
But when I rearrange the code like this:
-------------------------------------------------------------------------------
case "$host_os" in
mingw*)
dnl For the sake of native Windows compilers (excluding gcc),
dnl treat backslash as a directory separator, like /.
dnl Actually, these compilers use a double-backslash as
dnl directory separator, inside the
dnl # line "filename"
dnl directives.
gl_dirsep_regex='[/\\]'
;;
*)
gl_dirsep_regex='/'
;;
esac
gl_absolute_header_sed='\#'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[#{
s#.*"\(.*'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[\)".*#\1#
s#^/[^/]#//&#
p
q
}'
-------------------------------------------------------------------------------
then the configure file contains this:
-------------------------------------------------------------------------------
case "$host_os" in
mingw*)
gl_dirsep_regex='/\\'
;;
*)
gl_dirsep_regex='/'
;;
esac
gl_absolute_header_sed='\#'"${gl_dirsep_regex}"'math.h#{
s#.*"\(.*'"${gl_dirsep_regex}"'math.h\)".*#\1#
s#^/[^/]#//&#
p
q
}'
-------------------------------------------------------------------------------
Note that the brackets around /\\ have been removed. Why??
And the brackets in the s#^/[^/]#//&# line have not been removed. I don't
see a difference in quotation level between the gl_dirsep_regex definition
and the gl_absolute_header_sed definition.
I'm using autoconf-2.68 and m4-1.4.15.
Bruno
--
In memoriam Sergei Tretyakov <http://en.wikipedia.org/wiki/Sergei_Tretyakov>